Update 2021-04-12: I’ve added a compatibility section going over some current issues regarding installing UnifiedNLP on certain devices that have a qualcomm location services blob.
Overview
UnifiedNLP is a part of the microG project intended to replace the proprietary Google location services with an open-source alternative. These services essentially make it so your device’s location can be calculated from cellular towers and Wi-Fi networks, otherwise your device will use GPS which make take longer and use more battery. This isn’t required when using OpenGApps (as this uses Google’s location services) or microG (which has UnifiedNLP baked in).
Compatibility
Some devices have a QC Location
proprietary blob which prevents the installation of UnifiedNLP. In order to properly verify which devices still have this blob, I got a list of these devices by cloning the repositories for all LineageOS devices on GitHub and searching them to see if they had the blob. This is a 20 GiB download and took about 40 minutes.
for num in $(seq 23); do curl -s "https://api.github.com/users/LineageOS/repos?page=${num}&per_page=100" | grep \"clone_url\" | awk '{print $2}' | sed -e 's/"//g' -e 's/,//g' | grep "android_device_" | xargs -n1 git clone; done
grep -R "<bool name=\"config_enableNetworkLocationOverlay\" translatable=\"false\">false</bool>" . 2>/dev/null
As of 2021-04-12, these are the devices that have the QC location blob:
- Asus ROG Phone 2 (I001D)
- Asus Zenfone 5Z (Z01R)
- Asus Zenfone 6 (I01WD)
- Motorola Moto Z Play (addison)
- Xiaomi Redmi Note 8/8T (gingko)
Unfortunately for the time being the work around is a little complex, involving modifying a system APK and resigning it yourself (for security purposes). Those steps are provided here by Aqq123.
The other solution is getting the blob removed from the official builds of LineageOS, which has already been done for various other devices. There is currently an open issue for gingko on getting this blob removed, and no currently open issues for the other devices.
Installing UnifiedNLP
Here is how to install UnifiedNLP on LineageOS 16.0 and 17.1 without GApps.
I’ve tested this out on my OnePlus 3 running LineageOS 17.1, as well as my OnePlus 5T running LineageOS 16.0. I have not tested this on A/B devices, so be warned if you have an A/B device. This will also persist across LineageOS updates.
This will require a computer with a working version of ADB (Android Debugging Bridge). I did this using Linux, though the commands should translate to Windows and MacOS.
-
Enable ABD and ADB root
This will enable us to install UnifiedNLP without having to root our entire device, and is built into Android. This is also not permanent, and only accessible when using ADB.
Enable ADB by going to
Settings > About phone
and tap onBuild number
5 times. From here go toSettings > System > Advanced > Developer options
and checkAndroid debugging
.ADB root can be enabled at
Settings > System > Advanced > Developer options > Rooted debugging
. -
Connect device to computer running ADB and authorize it
After plugging in the phone and running
adb devices
, the adb server should start and there should be a popup on the device asking to authorize the computer for use with ADB. After agreeing, ensure that the device shows up and doesn’t say ‘unauthorized’ next to it.$ adb devices List of devices attached ffffffff device
-
Download the latest version of UnifiedNLP to your computer here
-
Create a file called
privapp-permissions-unifiednlp.xml
and add this to it<?xml version="1.0" encoding="utf-8"?> <permissions> <privapp-permissions package="com.google.android.gms"> <permission name="android.permission.INSTALL_LOCATION_PROVIDER"/> <permission name="android.permission.ACCESS_FINE_LOCATION"/> <permission name="android.permission.ACCESS_COARSE_LOCATION"/> <permission name="android.permission.ACCESS_COARSE_UPDATES"/> </privapp-permissions> </permissions>
-
Create another file called
50-UnifiedNLP.sh
and add this to it. This is the script that will allow UnifiedNLP to survive LineageOS updates#!/sbin/sh # # /system/addon.d/50-UnifiedNLP.sh # . /tmp/backuptool.functions list_files() { cat <<EOF priv-app/UnifiedNLP/NetworkLocation.apk etc/permissions/privapp-permissions-unifiednlp.xml EOF } case "$1" in backup) list_files | while read FILE DUMMY; do backup_file $S/$FILE done ;; restore) list_files | while read FILE REPLACEMENT; do R="" [ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT" [ -f "$C/$S/$FILE" ] && restore_file $S/$FILE $R done ;; esac
-
Start ADB with root and remount to make the file system read/write. Be careful as running adb root and abd remount can be dangerous if not used properly.
adb root adb remount
-
Push the files to device, assuming the files are in the same directory as the current shell
adb push NetworkLocation.apk /system/priv-app/UnifiedNLP/NetworkLocation.apk adb push privapp-permissions-unifiednlp.xml /system/etc/permissions/privapp-permissions-unifiednlp.xml adb push 50-UnifiedNLP.sh /system/addon.d adb shell chmod 755 /system/addon.d/50-UnifiedNLP.sh
-
Unroot and restart your device
adb unroot adb reboot
Enabling UnifiedNLP
Great! You’ve now successfully installed UnifiedNLP. Now here are the steps on how to set it up.
-
Check the UnifiedNLP settings
Settings > Location > Advanced > UnifiedNLP Settings
, or alternatively there should be a new app icon in your app drawer/home screen.Click on
Self-Check
and enablePermission to access approximate location ...
(if this is unable to be checked off, proceed ahead regardless).Make sure
UnifiedNlp is registered in system
is checked.Location backend(s) set up
is only checked after enabling location backends. -
Install location backends from F-Droid
Some examples:
There are several more listed here:
-
Enable backends in UnifiedNLP Settings
Settings > Location > Advanced > UnifiedNLP Settings
Click
Configure location backends
and check off the services you want to use. -
Test out a map program to see if it works (such as OsmAnd~)
-
Disable ADB and ADB root, both in Developer options
And that’s it! You have now installed UnifiedNLP. If you find UnifiedNLP (and by extension microG) useful, please consider donating to its continued development here!
Uninstalling UnifiedNLP
If for some reason it’s not working correctly, or you’re just not happy with it, here are the steps to uninstall UnifiedNLP.
-
Enable ABD and ADB root (same as above) and connect your phone to a computer with a working version of ADB
Make sure it’s connected by running
$ adb devices List of devices attached ffffffff device
-
Start ADB with root and remount
adb root adb remount
-
Remove the installed files
Make sure to type the command exactly as shown below as changes made here are permanent.
adb shell rm /system/priv-app/UnifiedNLP/NetworkLocation.apk adb shell rm /system/etc/permissions/privapp-permissions-unifiednlp.xml adb shell rm /system/addon.d/50-UnifiedNLP.sh
-
Unroot and restart your device
adb unroot adb reboot
-
Uninstall location backends
Then you’re all set. UnifiedNLP is now successfully removed from your phone.
Source:
- https://github.com/microg/UnifiedNlp/issues/181
- Cover image is a combination of the LineageOS logo and the UnifiedNLP logo. It is licensed under CC-BY-SA-4.0.