3

I removed too much system apps last time and I reinstalled Google Play Services (GmsService) from .apk file from backup.

However, its component com.google.android.gms.persistent needs permission OBSERVE_GRANT_REVOKE_PERMISSIONS and there is no way to add it using adb grant command because it's a special permission.

Without this permission it's constantly restarting and this causes high CPU usage and battery drain.

Logcat:

12-01 11:59:37.352 26458 26458 E DeviceDoctorHandler: FATAL EXCEPTION: main
12-01 11:59:37.352 26458 26458 E DeviceDoctorHandler: Process: com.google.android.gms.persistent, PID: 26458
12-01 11:59:37.352 26458 26458 E DeviceDoctorHandler: java.lang.RuntimeException: Unable to create application co.g.App: java.lang.SecurityException: addOnPermissionsChangeListener: Neither user 10009 nor current process has android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS.

What I tried is to edit /data/system/packages.xml file and add permission manually:

<item name="android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS" granted="true" flags="0" />

However, packages.xml is restored after reboot and manual changes are lost.

How to add this permission or how to reinstall GmsService with all required permissions?

5
  • 2
    You need to install GMS as privileged system apps. Then add android.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS to /system/etc/permissions/privapp-permissions.xml. Dec 5, 2021 at 8:32
  • Isn't that the answer to the question, even if it's short?
    – Izzy
    Dec 5, 2021 at 12:13
  • @IrfanLatif, no such file on my device (Android 6.0.1) Dec 5, 2021 at 23:52
  • Sorry I didn't see the Android 6 tag. It was added in Android 8. Related documentation: source.android.com/devices/tech/config/perms-allowlist. Before that, IIRC, every privileged app was granted the requested permissions with the signature|privileged protection level. Dec 6, 2021 at 10:28
  • @IrfanLatif I followed these tutorials from command line: forum.xda-developers.com/t/… forum.xda-developers.com/t/… But if we had the app installed previously, then we must fix paths in /data/system/packages.xml and remove (or back-up under another name) /data/system/packages.xml.mbak to prevent overwriting changes in packages.xml. Now I will observe... Dec 6, 2021 at 15:29

0

You must log in to answer this question.