📜 ⬆️ ⬇️

Google Photos can not delete files from the SD card

Many Android users are faced with an annoying problem associated with accessing applications to the SD card. One of these applications is Google Photos. Once everything was fine. But in Android 4.4 Google introduced a new system configuration, which prohibits applications from writing to the sd card. It’s extremely inconvenient to delete images through the gallery and then delete them in google photos again.

For myself, I solved the problem of rutting the device and correcting the configuration. Details on the video:


')
But for ordinary users, everything should work without root. About how to implement this, I propose to discuss in this article. I invite representatives of Google, Android developers and all interested in habrakat.

Some users have been deprived of functionality without warning. I have seen user comments with the following situation. Previously, they stored photos on the sd card and used google photo without any problems. Then the phone manufacturer offered to make an OTA update (up to 4.4 or higher), to which users agreed. But they could not even think that they would lose their functionality. Now google photo cannot delete snapshots, and in order to relieve the process of managing snapshots, we have to store them in the internal memory, which in itself is painful.

What is the matter here


Google has long wanted to prohibit unhindered access to applications to the sd card. This is explained by the fact that when you delete an application, the system cannot find out which files belong to the application, thus the sd card is cluttered. And in Android 4.4 google introduced such a thing as SAF (Storage Access Framework). They prohibited applications from changing anything on the sd card, with the exception of the application’s personal directory. And if the application asks, it gives the right to read (but not write) everything on the sd card.

Quote from here :
Just to sum up, here are the options 3rd-party apps have on KitKat:
An app without any permissions:
Automatic backup and automatic storage
With WRITE_EXTERNAL_STORAGE, they also have:
Read the file storage on the primary (built-in) storage
Read (not write) SD card storage

That is, for applications that are not pre-installed on the phone, and in my case google photo was not pre-installed, there is no official way to manage files at all! Google, I do not understand how you could do that. Do not finish a feature - complete it. But why in consumer devices to introduce something that does not work yet?

What to do in this situation?


As I said above, I have already solved the problem for myself by correcting the system configuration (I need root). What about "simple" users who haven't heard about root? I have a few ideas on how to solve this problem. Some of them are suitable only for Google, and some may be able to implement the community. So what are the options?

Option "Personal Directory"


Google should make it work as far as possible. It is clear that they can not advise to rant the device. But what about the private directory /storage/extSdCard/Android/data/com.google.android.apps.photos? What are they storing there? Most likely there is not a basket, because the files being deleted into the basket are located in /data/user/0/com.google.android.apps.photos/files/trash_files. I don’t know, it’s not customary in Android to store user data in such directories. Just offering a working version.

Those. If the application sees that it works on Android 4.4 and does not have access rights, then display a message like “No access. We suggest in the settings of your system camera to set the save to the directory /storage/extSdCard/Android/data/com.google.android.apps.photos/DCIM. Keep in mind that when you delete google photos, all pictures will be deleted. " The application is now ignoring this directory. If you put a snapshot into it, the catalog will not appear in the selection list for synchronization.

Most likely this is a dead option, since the camera must be systemic (otherwise it will not be able to write to someone else's directory on the sd card), and the system camera will most likely not be able to select the directory to save (on S4 it does not know exactly).

Option "Not a bug, but a feature"


But it turns out the developers have found a loophole , all the same allowing applications to manipulate files. I myself checked: I restored the original platform.xml (in which there is no write access to the sd card), rebooted, installed the total commander, and ... Uninstalling works! And even the code is.

Here the decision is for Google, maybe this decision is unacceptable for them. But as for me, there is nothing wrong with taking advantage of the bug as a feature, because they have to make everything work.

Option "Everything is bad, but you upgrade"


The article says that not all devices will work such a hack. There's nothing left but to just show the message that there is no access. The truth in it, you can hint that it would help the root, or the transition to another version of Android, and the older one also comes down.

Option "Bookmark"


I also had an idea that Google could update their google services (and this is a system application) so that it could be accessed by a non-system google photos application with a request to delete a file. And you will not need root. Will google go for it?

Solution for more recent versions of Android


In Android 5.0, google has improved SAF, and now applications can ask the user to provide write access to specific directories.

Quote from here :
Access to secondary shared storage devices
In this case, we’ve introduced APIs that make it possible for SD cards.

We’ve heard that we’ve added that we’ve added it to the ACTION_OPEN_DOCUMENT_TREE intent. AppsProvider document, including by the device, is supported by the device. There is no way for any additional user interaction. Just like the other document intents, apps can persist this access across reboots.

This gives apps accessibility. You can choose your SD card; the choice is theirs.

But even on Android 5 google photo does not use this feature, but simply reports that it does not have access. I believe that before synchronizing a directory, an application must first request write access to it via SAF so that snapshots can be deleted . This can be done directly from the same activity where you select with the switch which directories you want to synchronize (Settings - Startup and Sync - Select folders). Google, why aren't you doing this?

Summarize


This is how the application behaves now:
The user pressed the trash can
Is there direct access to write to the sd card?
Yes - delete the picture.
No - print the message that there is no access.

It should be:
The user pressed the trash can
Is there direct access / through a loophole to write to the sd card?
Yes - delete the picture.
No - then
- We are working on Android 5.0+?
- Yes — request access to the directory via SAF and delete the snapshot.
- No - (i.e. most likely it is 4.4. But it can be a specially modified 4.3-, configured as in 4.4) then:
- - Display a message: “No access, but root or Android version will help you” or “Configure the system camera to save pictures in /storage/extSdCard/Android/data/com.google.android.apps.photos/DCIM”, or “Update google servies, we will give access to the record through them” at the discretion of google.

Looking for developers


If there are representatives of google here, pass the information to the developers. Because this topic has been discussed for a long time, but Google does not correct the situation.

And for habrayusers who know how to develop on Android, I want to ask a question. Is it possible to change the application as I said, but on my own, without waiting for google? I know about the digital signature discrepancy, but in our case it does not matter. After all, all this is needed only if the application is not a system. And if it is not a system one, then you can remove it and then install it with a different signature. I saw a modified application instead of youtube - OGYouTube. Perhaps this is just what I describe.

Fill out this form if you had / have a problem described.

Poll results
Number of replies: 101 (at the time of September 20, 2016):










On this I think I did my job. Now google go. Or community.

Source: https://habr.com/ru/post/311238/


All Articles