GmsCore: Can not grand SMS and BACKGROUND_LOCATION Permission on Android 11
Describe the bug Trying to grand the permissions for
android.permission.ACCESS_BACKGROUND_LOCATIONandroid.permission.RECEIVE_SMSIs not possible.
To Reproduce Steps to reproduce the behavior:
- Go to Permission settings for GMS Core
- Click on SMS permission
- Click on “grand”
- Go back
- See permissin is still not granded
Expected behavior Permission is granded
Screenshots/Logs
https://user-images.githubusercontent.com/1891273/114101423-02a13d00-98c6-11eb-9b20-72b85464c5f9.mp4
Sysdump for package
...
runtime permissions:
android.permission.ACCESS_FINE_LOCATION: granted=true, flags=[ USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]
android.permission.RECEIVE_SMS: granted=false, flags=[ USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED|APPLY_RESTRICTION]
android.permission.READ_EXTERNAL_STORAGE: granted=true, flags=[ USER_SET|USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED|APPLY_RESTRICTION]
android.permission.ACCESS_COARSE_LOCATION: granted=true, flags=[ USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]
android.permission.READ_PHONE_STATE: granted=true, flags=[ USER_SET|USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]
android.permission.GET_ACCOUNTS: granted=true, flags=[ USER_SET|USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED]
android.permission.WRITE_EXTERNAL_STORAGE: granted=true, flags=[ USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED|APPLY_RESTRICTION]
android.permission.ACCESS_BACKGROUND_LOCATION: granted=false, flags=[ USER_SENSITIVE_WHEN_GRANTED|USER_SENSITIVE_WHEN_DENIED|APPLY_RESTRICTION]
...
/data/system/user/0/runtime-permissions.xml:
...
<pkg name="com.google.android.gms">
<item name="android.permission.ACCESS_FINE_LOCATION" granted="true" flags="330"/>
<item name="android.permission.RECEIVE_SMS" granted="true" flags="3b20"/>
<item name="android.permission.READ_EXTERNAL_STORAGE" granted="true" flags="3b20"/>
<item name="android.permission.ACCESS_COARSE_LOCATION" granted="true" flags="330"/>
<item name="android.permission.READ_PHONE_STATE" granted="true" flags="320"/>
<item name="android.permission.GET_ACCOUNTS" granted="true" flags="320"/>
<item name="android.permission.WRITE_EXTERNAL_STORAGE" granted="true" flags="3b20"/>
<item name="android.permission.ACCESS_BACKGROUND_LOCATION" granted="true" flags="3b30"/>
</pkg>
...
System Android Version:11 Custom ROM: LineageOS 18.1
Additional context
Maybe my system is just F*** up. I tried to upgrade from LineageOS 17.1 with a Riru based MicroG installation to a lineag.microg.org based setup. This might cause trouble apparently.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (3 by maintainers)
You can also take a look at #1280
As my comment there suggests, you can work around this issue by installing GmsCore twice - first as a priv-app and then from the .apk as an user app update.
Hello everyone! I’ve been investigating this issue in detail lately, and I believe I have found the cause. I want to share with you what I have discovered.
RECEIVE_SMSandACCESS_BACKGROUND_LOCATION- the two permissions giving troubles - are considered “hard restricted” permissions from Android 10 onwards, which means that they cannot be granted by the user unless explicitly marked as whitelisted for that specific app by the system. The system package installer marks all restricted permissions as whitelisted by default when you install an APK manually, which is why installing or updating microG manually solves the issue. Therefore, if you happen to install microG by simply copying the APK into /system/priv-app (or using a Magisk module), this whitelisting doesn’t happen and therefore causes the inability to grant the permission (in the sysdump above, you can see that those permissions have theAPPLY_RESTRICTIONflag which means that they are not whitelisted).So the key takeaways are:
Also, the whitelisting alone was not enough to be able to grant
ACCESS_BACKGROUND_LOCATIONpermission for me: I had to enable location inside device settings, then go back to microG Self-Check and check background location permission. I don’t know why.I got it fixed following xda microG GmsCore - lightweight free software clone of Google Play Services post. Basically I changed granted and flags attribute in
/data/system/users/0/runtime-permissions.xmlfrom twrp recovery.Same on Android10
There isn’t any need to complicate things like this.
For installers, they just need to add
whitelisted="true"(where needed) in default-permissions xml files (most installers already do this).For users that have the problem they can simply reinstall the app:
adb shell "pm install -r -g /system/priv-app/GmsCore/GmsCore.apk"This is more like an install issue rather than microG issue so I will close it. Those that still have issues can open another ticket.
@stainlesspot Yes this did the job for my installation to 😃. Thank you.
I said the opposite, if you don’t install as a priv-app.