Android 11 makes Google Photos annoying to use, but there may be a solution

We have no way of knowing how many devices are running Android 11, as Google no longer publishes distribution statistics, but there are probably tens of millions that companies like Xiaomi and Samsung have had time to post the update to many of their models. If your device is running Android 11 and you are using Google Photos, chances are you have experienced a rather annoying change with the way the app handles image removal and recovery. Instead of simply selecting the images and videos you want to delete, tapping the trash can icon and then tapping the “Move to Trash” button, now you need to tap through an additional guide to get Google Photos permission to delete or recover your files.

For those of you who take a lot of photos and videos, it can be annoying to give Google Photos permission to delete or recover a file. And as indicated by AndroidPolice, tapping an extra button is not the only problem you are dealing with. If you use Google Photos on another device and want to edit or trash a file you uploaded from your Android 11 phone, the app may ask you to check for ‘out-of-sync changes’. It can quickly become annoying if Google Photos keeps asking you to review changes you just made to another platform.

The extra step of deleting or recovering a file was not necessary in Android 10 but is now required in Android 11 due to the application of Scoped Storage. Before Scoped Storage, access to the entire external storage directory is managed with a single permission, making it difficult to restrict which apps have access to your private documents, images, or videos. With Scoped Storage in place, Android restricts the amount of access to an app to sensitive files without the express permission of the user. You can find more information about Scoped Storage in this article or check out the image from Google below for a summary of the changes.

Android 11 Store Summary

While restricting storage access in Android 11, Google has also improved existing APIs to enhance the user experience. For example, apps targeting Android 11 could use the MediaStore API to trash a file rather than delete it. However, to move a file to the Trash, the app must request the user to grant written access. Since most of the images and videos you add from Google to your Google Photos phone are from another app, such as the stock camera app, photos need permission before they can move a file to or from the Trash. However, Google Photos does not require permission to trash files when using a Pixel phone with Android 11 installed. However, it requires permission for basically every other device running Android 11, including most Samsung, Xiaomi, OnePlus, and ASUS devices. What gives?

The reason for this is that the system gallery app is not subject to Scoped Storage restrictions. This means that the stock gallery app can open, edit or delete images and videos without express permission. Google Photos is pre-set as the system gallery app on Pixel phones, but most OEMs set up their own gallery app instead. Furthermore, there is no setting that the user faces to change the system gallery app, not even on Android’s “default apps” screen. However, there are is a hidden way to change the system gallery app, but there is one big reservation: only a system application can be set as the system gallery app. It just means calling Google Photos already installed as a system application can use this trick.

Not many phones meet this criterion, but they do based on our testing, we can confirm it works on most OnePlus and some ASUS phones. This method does not work on any of the Samsung phones we tested it on, nor does it work on a Xiaomi Mi 10 Pro. If you have root access or use a custom ROM, this method may work on your device after installing the Google Photos app, but we’ve only tested this method on stock devices.

How to make Google Photos (maybe) 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 computer. We have an updated guide on how to do this here. Once you have the ADB setting, enter the following command:

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

If you see no error, it probably worked! You can quickly verify that it worked by taking a photo and then trying to delete it in Google Photos. Alternatively, you can perform the following command:

adb shell dumpsys role

… And check if the “container” of “android.app.role.SYSTEM_GALLERY” is “com.google.android.apps.photos” (the package name of Google Photos).

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

What does this assignment do?

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

However, it is is possible to add an app other than the holder of the SYSTEM_GALLERY role, but only if that app is also a system application. This is possible on many OnePlus and some ASUS phones, because these OEMs seem to have installed Google Photos at the system level rather than the user level. Therefore, the Google Photos app can take on the role of SYSTEM_GALLERY and we use the hidden RoleManager tracking interface of Android to grant access to the rights that would not normally be granted. If you try to assign the SYSTEM_GALLERY role to a non-system app, you see the following error in 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 to circumvent this limitation, but if we do, we will share our method with the community. Of course, we prefer that Google make the role SYSTEM_GALLERY easily user-definable, rather than limited to the choice of OEM.

Source