UnifiedNlp icon indicating copy to clipboard operation
UnifiedNlp copied to clipboard

Unable to install on Android 9 (LineageOS 16)

Open sirtoobii opened this issue 5 years ago • 14 comments

The described method in the readme (copying the apk to /priv-app) does not work anymore on Android 9 due the permission-whitelist enforcing ASOP docs. As a result of this, your phone won't boot if you just copy the apk to priv-app! As far as I understand, the issue should be solvable by creating a matching priv-app-permission.xml file in /etc/permissions.

I'm willing to contribute the required changes to the readme - however since I'm pretty unfamiliar with the android stack a need a bit more information:

  • What would be the package name(s) and their required permissions
  • Is there any kind of signature stuff involved?

sirtoobii avatar Dec 11 '19 10:12 sirtoobii

For anybody who found themselves here after following the README instructions and discovering their device no longer boots correctly (-.-"), here is how to unbrick it again (using TWRP):

  1. Boot into Recovery.
  2. Select "Mount".
  3. Tick the box "System", make sure "Mount system partition read-only" is disabled.
  4. Don't touch any of the buttons below. Your system is already mounted by ticking the box.
  5. Go back to the main menu, select "Advanced", "File Manager".
  6. Navigate to /system/priv-app.
  7. Select NetworkLocation.apk, then "Delete".
  8. Go back to the main menu, select "Reboot", "System".

Leaving this here as "just delete the file again" is obvious, but how to mount the right thing was not for me.

SOwOphie avatar Dec 15 '19 21:12 SOwOphie

I've used Stanley to extract the manifest of NetworkLocation.apk. It lists the app's name and permissions.

<?xml version="1.0" encoding="UTF-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="20187" android:versionName="1.6.8" package="com.google.android.gms" platformBuildVersionCode="24" platformBuildVersionName="7.0">
  <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="24"/>
  <permission android:label="@id/0x7F070020" android:name="org.microg.permission.FORCE_COARSE_LOCATION" android:protectionLevel="1" android:permissionGroup="android.permission-group.LOCATION" android:description="@id/0x7F07001F"/>
  <uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER"/>
  <uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES"/>
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
  <uses-permission android:name="org.microg.permission.FORCE_COARSE_LOCATION"/>
  <uses-permission android:name="com.android.settings.INJECT_SETTINGS"/>
  <application android:label="@id/0x7F07001D" android:icon="@id/0x7F030000" android:allowBackup="true">
    <activity android:label="@id/0x7F07001D" android:icon="@id/0x7F030001" android:name="org.microg.nlp.ui.SettingsLauncherActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
    <uses-library android:name="com.android.location.provider"/>
    <service android:name="org.microg.nlp.location.LocationServiceV1" android:permission="android.permission.ACCESS_COARSE_LOCATION" android:exported="true">
      <intent-filter>
        <action android:name="com.android.location.service.NetworkLocationProvider"/>
        <action android:name="com.google.android.location.NetworkLocationProvider"/>
      </intent-filter>
      <meta-data android:name="serviceVersion" android:value="1"/>
      <meta-data android:name="version" android:value="1"/>
    </service>
    <service android:name="org.microg.nlp.location.LocationServiceV2" android:permission="android.permission.ACCESS_COARSE_LOCATION" android:exported="true">
      <intent-filter>
        <action android:name="com.android.location.service.v3.NetworkLocationProvider"/>
        <action android:name="com.android.location.service.v2.NetworkLocationProvider"/>
      </intent-filter>
      <meta-data android:name="serviceVersion" android:value="2"/>
      <meta-data android:name="serviceIsMultiuser" android:value="false"/>
    </service>
    <service android:name="org.microg.nlp.geocode.GeocodeServiceV1" android:exported="true">
      <intent-filter>
        <action android:name="com.android.location.service.GeocodeProvider"/>
        <action android:name="com.google.android.location.GeocodeProvider"/>
      </intent-filter>
      <meta-data android:name="serviceVersion" android:value="2"/>
      <meta-data android:name="serviceIsMultiuser" android:value="false"/>
    </service>
    <service android:name="org.microg.nlp.ui.SettingInjectorService">
      <intent-filter>
        <action android:name="android.location.SettingInjectorService"/>
      </intent-filter>
      <meta-data android:name="android.location.SettingInjectorService" android:resource="@id/0x7F060001"/>
    </service>
    <activity android:theme="@id/0x7F090138" android:label="@id/0x7F07001E" android:icon="@id/0x7F030001" android:name="org.microg.nlp.ui.SettingsActivity"/>
    <receiver android:name="org.microg.nlp.PackageReceiver">
      <intent-filter>
        <action android:name="android.intent.action.PACKAGE_CHANGED"/>
        <action android:name="android.intent.action.PACKAGE_UPGRADED"/>
        <action android:name="android.intent.action.PACKAGE_REMOVED"/>
        <action android:name="android.intent.action.PACKAGE_REPLACED"/>
        <action android:name="android.intent.action.PACKAGE_RESTARTED"/>
        <data android:scheme="package"/>
      </intent-filter>
    </receiver>
    <meta-data android:name="org.microg.nlp.API_VERSION" android:value="@id/0x7F070057"/>
    <activity android:theme="@id/0x01030010" android:name="org.microg.nlp.api.MPermissionHelperActivity" android:exported="true"/>
  </application>
</manifest>

Stanley also shows the certificate used to sign the .apk:

(NOGAPPS Project)
O=NOGAPPS Project,C=DE
SHA-1:10321BD893F69AF97F7573AAFE9DE1DC0901F3A1

SOwOphie avatar Dec 18 '19 09:12 SOwOphie

I build a magisk module and work correctly. The permission file I use: privapp-permissions-unifiednlp.txt

pedrxd avatar Feb 03 '20 13:02 pedrxd

@pedrxd Thank you for your input. However, If you install UnifiedNlp as location provider without the "gms-core" there is no need to spoof the signature (as far as I understand) and therefore the permissions should be something like <package="org.microg.*">

sirtoobii avatar Feb 04 '20 14:02 sirtoobii

Yes, that was strange for me. But I check the name that unifiedNLP package have and was the same as the google one. So when i made the permission file I use the same. Probably I use the wrong apk when installing unifiedNLP.

pedrxd avatar Feb 04 '20 17:02 pedrxd

Ah ok. I'll check it on Thursday and update this comment accordingly.

sirtoobii avatar Feb 04 '20 17:02 sirtoobii

As of today it seems not to be possible to install standalone Unified NLP with Lineage OS 16? Or is there some workaround?

bboyDmT avatar May 09 '20 13:05 bboyDmT

Copy this apk to /system/priv-app/UnifiedNLP/ and this permission file to /system/etc/permissions/ (remember use the .xml extension) . Working for me without Gapps.

pedrxd avatar May 09 '20 16:05 pedrxd

So I tried these two files and did adb push NetworkLocation.apk /system/priv-app/UnifiedNLP/NetwortkLocation.apk and adb push privapp-permissions-unifiednlp.txt /system/etc/permissions/privapp-permissions-unifiednlp.txt and my phone won't boot. Do I have to rename them some specific way?

Edit: Renamed the apk to UnifiedNLP.apk and the permission file to privapp-permissions-unifiednlp.xml. Now its booting again.

k4ps avatar May 10 '20 07:05 k4ps

The name of the .apk is irrelevant, but the permissions file needs to be a .xml. Can confirm it also works for me.

SOwOphie avatar May 10 '20 08:05 SOwOphie

Thank you! Can confirm working with .xml.

No magisk microG module was needed (which broke all gsf dependant apps).

Is it possible to update the description, it seems like legit workaround?

Tested on LG G4, Lineage OS 16.0, Android 9. System without GApps.

bboyDmT avatar May 10 '20 10:05 bboyDmT

Can anybody explain how to use it with gapps?

TontyTon avatar Jun 07 '20 20:06 TontyTon

@TontyTon As far as I understand this implementation this is not possible since this is a replacement of a Google Play Services component.

sirtoobii avatar Jun 08 '20 05:06 sirtoobii

@sirtoobii I was talking about this (org.microg.nlp) -

UnifiedNlp.apk – for Android WITH Gapps

TontyTon avatar Jun 08 '20 20:06 TontyTon