[Android Apps and Games] anarki@butterblume:
Since Android 6, a location provider has to be a priviledged app and thus, its apk has be be pushed to /system/priv-app.

For any priveledged app on the other hand, any permission it requests has to be well defined in a xml file within /etc/permissions. Otherwise, the OS will stay in a boot loop and continuously recheck the permissions.

The thing is, we get the new microg-releases via f-droid, but f-droid will install it als non-priviledged app. That's why you'll see location updates on the location modules page of gms-core, but no other app can receive it. E.g. Osmand will output "no network location provider found" in the system log.

You'll notice the difference when granting gms-core its permissions on the self-check page: If Android asks you to grant the selected permission after you clicked it, it means gms-core is running as non-priviledged.

If it is priviledged, you'll just have to check the checkboxes without getting asked by the OS.

To get gms-core running as a priviledged app,

- connect via adb root and remount

- make a directory /system/privapp/microg (naming is unrevelant)

- push a gms-core release to that folder, e.g. com.google.android.gms-204714034.apk

- set the correct file permissions: chmod 644 <file.apk> (this is important, since files with 777 or 600 are ignored)

For the sake of better understanding, reboot. You will be stuck in a boot loop because of missing permissions. This is intended. Find that permissions by

- connecting via adb root and remounting

- executing adb logcat | grep android.permission

- leave that terminal open

Now, in your terminal, watch out for the "permission not in whitelist" messages. You'll get the exact names of missing permissions, e.g.

Privileged permission android.permission.INSTALL_LOCATION_PROVIDER for package com.google.android.gms (/system/priv-app/com.google.android.gms) not in privapp-permissions whitelist

Now, create a xml file granting gms-core the permissions in question by

- opening another terminal

- touch /etc/permissions/privapp-permissions-microg.xml (filename doesn't matter)

- edit that file via vim or nano and paste the following:

<permissions>
<privapp-permissions package="com.google.android.gms">
<permission name="android.permission.READ_PHONE_STATE"/>
<permission name="android.permission.READ_CONTACTS"/>
<permission name="android.permission.WRITE_CONTACTS"/>
<permission name="android.permission.GET_ACCOUNTS"/>
<permission name="android.permission.ACCESS_FINE_LOCATION"/>
<permission name="android.permission.ACCESS_COARSE_LOCATION"/>
<permission name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
<permission name="org.microg.permission.FORCE_COARSE_LOCATION"/>
<permission name="android.permission.INSTALL_LOCATION_PROVIDER"/>
<permission name="android.permission.RECEIVE_SMS"/>
<permission name="android.permission.READ_EXTERNAL_STORAGE"/>
<permission name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<permission name="android.permission.CHANGE_DEVICE_IDLE_TEMP_WHITELIST"/>
<permission name="android.permission.UPDATE_APP_OPS_STATS"/>
</privapp-permissions>
</permissions>

Last but not least

- set the correct file permissions: chmod 644 <file.xml>

No reboot required: Android will immediately continue starting.

These permissions were taken from Nanodroid because that was easier that grepping through the logs: https://github.com/Nanolx/NanoDroid...tc/default-permissions/microg-permissions.xml

Now, if there is any permission issue in the future, fire up the above logcat command, find the missing permission and add it to the xml file.

Addendum

For me that works using LineageOS 17.1 and 18.1 (thank you @derf elot and @modpunk ) with the latest gms-core releases. I prefer Local GSM Location by deveee as a network location provider. Find it on f-droid.

The only downside is you can't update gms-core via f-droid. But you can enable the "include incompatible versions" option in the f-droid client to receive update notifications. If you then let the f-droid client download the update (and do checksum and pgp verifications), you can install it manually via root terminal:

mv /data/data/org.fdroid.fdroid/cache/apks/f-droid.org--1/com.google.android.gms<new_version>.apk /system/priv-app/microg/

chmod 644 /system/priv-app/microg/com.google.android.gms<new_version>.apk

rm /system/priv-app/microg/com.google.android.gms<old_version>.apk

restart

The upside is you wont't have to waint until a new Nanodroid bundle or Magisk module is released. You can update gms-core by yourself anytime.