Android 11 makes using Google Photos uncomfortable, but there may be a fix

We have no way of knowing how many devices on the market run Android 11, as Google no longer publishes distribution statistics, but there are probably tens of millions now that companies like Xiaomi and Samsung have had time to push the update for many of their models. If your device runs Android 11 and you use Google Photos, you may have encountered a somewhat irritating change in the way the app handles image deletion and restoration. Instead of simply selecting the images and videos you want to delete, clicking the trash can icon and then tapping the “move to trash” button, you will now have to tap an extra prompt to give Google Photos permission to delete or restore your files.

For those who take a lot of photos and videos, it can be annoying to have to grant Google Photos permission to delete or restore a file. And as pointed out by AndroidPolice, tapping an extra button is not the only problem you may have to deal with. If you use Google Photos on another device and want to edit or delete a file sent from your Android 11 phone, the app may ask you to review “out of sync changes”. This can quickly become annoying if Google Photos keeps asking you to review the changes you just made on another platform.

The extra step to delete or restore a file was not required on Android 10, but is now required on Android 11 due to the application of scoped storage. Before scoped storage, access to the entire external storage directory was managed by a single permission, making it difficult for you to limit which applications can access your private documents, images or videos. With scoped storage implemented, Android limits how much access an application can have to sensitive files without the user’s explicit consent. You can find more details on scoped storage in this article or look at the Google chart below for a summary of the changes.

Android 11 scoped storage summary

While they were busy restricting access to storage on Android 11, Google was also improving existing APIs to improve the user experience. For example, applications targeting Android 11 can use the MediaStore API to destroy a file instead of deleting it. However, to move a file to the trash, the application must ask the user to grant it write access. Since most of the images and videos you add to Google Photos on your phone came from a different app – like the stock camera app – Photos needs to ask for permission before moving a file to the trash. However, Google Photos does not ask for permission to remove files if you are using a Pixel smartphone with Android 11 installed. However, he asks for permission on basically all other devices running Android 11, including most Samsung, Xiaomi, OnePlus and ASUS devices. What gives?

The reason is that the system gallery application is not subject to scoped storage restrictions. This means that the stock gallery application can open, edit or delete images and videos without explicit permission. Google Photos is preset as the system gallery app on Pixel phones, but most OEMs preset their own gallery app. In addition, there is no user-facing setting to change the system gallery application, not even on the Android “default applications” screen. However, there are is a hidden way to change the system gallery application, but there is a big warning: only one system app can be defined as the system gallery app. That means only phones that already has Google Photos pre-installed as a system application you can take advantage of this trick.

Few phones meet this criteria, but based on our tests, we can confirm this works on most OnePlus and some ASUS phones. This method did not work on any of the Samsung phones we tested it on, nor did it work on a Xiaomi Mi 10 Pro. If you have root access or are running a custom ROM, this method may work on your device after systematizing the Google Photos app, but we only test this method on stock devices.

How (maybe) to make Google Photos the system gallery app

Credits go to Kieron Quinn (Quinny899 on the XDA Forums) for sharing this trick!

The first thing you need to do is install ADB on your PC. We have an updated guide on how to do this here. After configuring the ADB, enter the following command:

adb shell cmd role add-role-holder android.app.role.SYSTEM_GALLERY com.google.android.apps.photos

If you don’t see an error, it probably worked! You can check if it worked quickly by taking a photo and then trying to delete it in Google Photos. Alternatively, you can run the following command:

adb shell dumpsys role

… And make sure that the “holder” of “android.app.role.SYSTEM_GALLERY” is “com.google.android.apps.photos” (the Google Photos package name).

If your output matches the text highlighted in the red rectangle, it worked.

What does this command do?

Android 10 added a new API called “Roles“. When an application has a certain role, access to certain permissions is automatically granted. For example, the SYSTEM_GALLERY function automatically grants an application “full read and write access to all image and video files on external storage, including access to location metadata”. The SYSTEM_GALLERY function can only be granted to system applications, and its default holder is defined by the Android configuration value “config_systemGallery”. As we explained earlier, most OEMs default to this value for the package name corresponding to their own gallery application. This value cannot be changed without modifying the structure or installing an overlay, both of which require root access.

However is possible to add another application as holder of the SYSTEM_GALLERY role, but if that application is also a system application. This is possible on many OnePlus and some ASUS phones because these OEMs apparently pre-installed Google Photos at the system level, not at the user level. For this reason, the Google Photos app is eligible to have the SYSTEM_GALLERY role and we take advantage of Android’s hidden RoleManager shell interface to grant it access to permissions that normally cannot be granted. If you try to grant the SYSTEM_GALLERY role to an application that does not belong to the system, you will see the following error in the logcat:

E RoleControllerServiceImpl: Package does not qualify for the role, package: com.google.android.apps.photos, role: android.app.role.SYSTEM_GALLERY

Unfortunately, we have not found a way around this limitation, but if we do, we will share our method with the community. Obviously, we would prefer that Google simply make the SYSTEM_GALLERY function user-definable, rather than limiting itself to the choice of the OEM.

Source