Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not grand SMS and BACKGROUND_LOCATION Permission on Android 11 #1440

Closed
theScrabi opened this issue Apr 8, 2021 · 14 comments
Closed

Can not grand SMS and BACKGROUND_LOCATION Permission on Android 11 #1440

theScrabi opened this issue Apr 8, 2021 · 14 comments
Labels

Comments

@theScrabi
Copy link

Describe the bug
Trying to grand the permissions for

  • android.permission.ACCESS_BACKGROUND_LOCATION
  • android.permission.RECEIVE_SMS
    Is not possible.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Permission settings for GMS Core
  2. Click on SMS permission
  3. Click on "grand"
  4. Go back
  5. See permissin is still not granded

Expected behavior
Permission is granded

Screenshots/Logs

asdf.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.

@theScrabi theScrabi added the bug label Apr 8, 2021
@0purple
Copy link

0purple commented Apr 11, 2021

Same on Android10

@Azureit
Copy link

Azureit commented Apr 15, 2021

I reverted to android 10 based rom because of this.
But if I'm not mistaken, if we don't install as a priv-app it will allow to grant all permissions, but then some apps will tell com.google.android.gms is not installed.

@0purple
Copy link

0purple commented Apr 16, 2021

Installed it as priv-app, still can`t grant these permissions

@Azureit
Copy link

Azureit commented Apr 16, 2021

Installed it as priv-app, still can`t grant these permissions

I said the opposite, if you don't install as a priv-app.

@stainlesspot
Copy link

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.

@0purple
Copy link

0purple commented Apr 26, 2021

Will try it in few days, this should be in wiki too :)

@Azureit
Copy link

Azureit commented Apr 26, 2021

I have microg working with android 11 without any workarounds.
Using https://github.com/FriendlyNeighborhoodShane/MinMicroG
I build a fresh NoGoolag package:

./update.sh
./build.sh nogoolag

I flashed MinMicroG-NoGoolag-2.9-20210426095739.zip with TWRP, and microg is working correctly.

EDIT: Can the problem be related to the installing method, TWRP vs Magisk module?

@theScrabi
Copy link
Author

theScrabi commented May 2, 2021

@stainlesspot Yes this did the job for my installation to :). Thank you.

@pwn0r
Copy link

pwn0r commented May 25, 2021

I have microg working with android 11 without any workarounds.
Using https://github.com/FriendlyNeighborhoodShane/MinMicroG
I build a fresh NoGoolag package:

I'm using the latest available update package -- MinMicroG-NoGoolag-UPDATELY-20210515002736.zip and I have the same problem.

This zip was installed from TWRP, but with magisk already installed. This used to work in Lineage17.1 but does not work in LOS 18.1. In order to get location providers working I had to install (as user level apps) the core app and all the location providers as well. I.e. the problem seems to be related to microg (and providers) being in a magisk module? Can it be fixed on a magisk level perhaps? I'm currently using magisk v23.0.

@Fs00
Copy link
Contributor

Fs00 commented Aug 20, 2021

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_SMS and ACCESS_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 the APPLY_RESTRICTION flag which means that they are not whitelisted).

So the key takeaways are:

  • this is not really a microG bug but a quirk in how Android handles certain permissions
  • can be easily worked around by installing/updating microG manually, as others have already discovered
  • is present on Android 10 and higher (PackageManager APIs to interact with permission whitelists have been added in API 29, and I also encountered this issue on Android 10)

Also, the whitelisting alone was not enough to be able to grant ACCESS_BACKGROUND_LOCATION permission 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.

@evermind-zz
Copy link

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.xml from twrp recovery.

--- /data/system/users/0/runtime-permissions.xml	2021-11-05 12:21:18.972951060 +0100
+++ /data/system/users/0/runtime-permissions.xml	2021-11-05 12:07:34.578981494 +0100
@@ -409,13 +409,13 @@
   <pkg name="com.google.android.gms">
     <item name="android.permission.ACCESS_FINE_LOCATION" granted="true" flags="300" />
     <item name="android.permission.FAKE_PACKAGE_SIGNATURE" granted="true" flags="0" />
-    <item name="android.permission.RECEIVE_SMS" granted="false" flags="300" />
+    <item name="android.permission.RECEIVE_SMS" granted="true" flags="3320" />
     <item name="android.permission.READ_EXTERNAL_STORAGE" granted="true" flags="4300" />
     <item name="android.permission.ACCESS_COARSE_LOCATION" granted="true" flags="300" />
     <item name="android.permission.READ_PHONE_STATE" granted="true" flags="300" />
     <item name="android.permission.GET_ACCOUNTS" granted="true" flags="300" />
     <item name="android.permission.WRITE_EXTERNAL_STORAGE" granted="true" flags="4300" />
-    <item name="android.permission.ACCESS_BACKGROUND_LOCATION" granted="false" flags="300" />
+    <item name="android.permission.ACCESS_BACKGROUND_LOCATION" granted="true" flags="3020" />
   </pkg>
   <pkg name="com.sec.spp.push">
     <item name="android.permission.READ_EXTERNAL_STORAGE" granted="false" flags="2180" />

@ale5000-git
Copy link
Member

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.

@CircuitSerialKiller
Copy link

CircuitSerialKiller commented Jun 18, 2024

Thank you @evermind-zz!!! I was struggling with this issue and nothing happening when clicking on "Permission to access location in the background" in microG, along with resulting location issues.

For anyone else experiencing this issue (Android 11+ ?), search for com.google.android.gms in my root text editor in
/data/misc_de/%USERNUMBER%/apexdata/com.android.permission/runtime-permissions.xml

In this section, change the line that has ACCESS_BACKGROUND_LOCATION so that granted="true" and flags="3020".
Reboot
Problem solved!

For awareness, please like or comment if you experienced this issue and this helped.

@ale5000-git
Copy link
Member

ale5000-git commented Jun 18, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants