Remove All Ads from XDA

UnifiedNLP with GApps Patch

131 posts
Thanks Meter: 32
By M.A.K, Senior Member on 5th March 2017, 08:53 PM
Post Reply Email Thread
This package contains a few windows batch files to help you get UnifiedNLP working with (or without) Google Play Services on your phone. Extract it anywhere and run the batch files as needed. Everything required is included in the download but you will need root ADB capabilities. Learn more about ADB here:

For the record, I use this on Nougat. More specifically, LineageOS 14.1 so I can't say how it will work or what is necessary on other versions or roms.

Included Batch Files
To use these scripts your phone needs to be connected to your computer.
Install.bat - Install apks and addon.d updater script
Patch.bat - Patch framework-res.apk
DisableGoogle.bat - Disable Google location services and permissions
EnableGoogle.bat - Enable Google location services and permissions
Restore.bat - Delete apks, restore stock framework, enable services and permissions
GetDiff.bat - Create new patch file.

UnifiedNlp is a network location provider that can be used instead of the Google network location service that's included in Google Play Services. The version used here is the GApps version that can be used along side Google Play Services.

Installing the Apps
Run Install.bat
UnifiedNLP has to be installed as a system app. This script installs it in /system/app along with some backends. It also installs an addon.d script so it will survive system updates if your rom supports it. Once installed, you can find the app in your app drawer. See the thread on XDA to help set it up.

Patching the Framework
Run Patch.bat
To use a location provider, it's package name has to be included in the "config_locationProviderPackageNames". This script patches framework-res.apk to include the UnifiedNLP package name. I've created a thread on the LOS subreddit asking for this to be included by default but until then we'll have to patch each update.

If patching fails run GetDiff.bat to create a new patch file:
When prompted, open arrays.patched.xml in your text editor (Notepad++ recommended)
Find 'config_locationProviderPackageNames' section
Add a new item 'org.microg.nlp'
Save and continue
Run Patch.bat again

Disabling Googles Location Service
Run DisableGoogle.bat
When you enable network location in settings you also enable Google's location service. There's no simple way to enable one without the other... Bit of a monopoly and totally wrong if you ask me, but that's the way it is. So we have to disable a couple of Google services to get UnifiedNLP working.

So now we should have UnifiedNLP working but we still have Google Play Services stalking us and constantly checking our location. This is what gives us all those NLP related wakelocks. To prevent this we just have to revoke coarse/fine location permissions for Google Play Services. DisableGoogle.bat also does this.

Needless to say, if you try this you do so at your own risk. I take no responsibility for anything.
It's always a good idea to make a full backup before doing anything like this to your phone.


Everything required is included in the download but if you'd like to download full versions or find out more, checkout the links.
The Following 6 Users Say Thank You to M.A.K For This Useful Post: [ View ] Gift M.A.K Ad-Free
5th March 2017, 08:53 PM |#2  
OP Senior Member
Thanks Meter: 32
6th March 2017, 07:04 PM |#3  
OP Senior Member
Thanks Meter: 32
Download updated: There was a very silly error in Patch.bat.
28th March 2017, 01:50 PM |#4  
Senior Member
Flag Portland, OR
Thanks Meter: 233
I'm just posting to say that my ROM won't boot after applying this patch. Fortunately, I had a backup. I'm running Resurrection Remix on a Note 4 (N910T), which is v7.1.1 and based on a mix of LineageOS and Emotion/Emotroid (the latter is AOSP). I followed the instructions to the tee. I already had adb and fastboot installed. The patch did succeed. I also tried clearing cache and dalvik cache in TWRP, but still couldn't boot. I do have GApps installed. What could have gone wrong?

The Following User Says Thank You to AnonVendetta For This Useful Post: [ View ] Gift AnonVendetta Ad-Free
2nd April 2017, 01:10 PM |#5  
OP Senior Member
Thanks Meter: 32
Hmm... Not sure why it wouldn't work for you. I can only guess that the framework didn't re-compile properly or it wasn't pushed to system properly.

One thing you could try is boot to twrp, mount system and run patch.bat from there.
3rd April 2017, 03:11 PM |#6  
Junior Member
Flag Tübingen
Thanks Meter: 3
No GCN push
Hey, thank you very much for your effort! I have used your Windows Batch files in an editor to translate the process to Linux. Everything works flawlessly on my LG G4 with Lineage 14.1!
Without GCM, which is sadly a dealbreaker. It seems to need permission for " android.permission.ACCESS_FINE_LOCATION", the other three adb lines in your DisableGoogle.bat can be executed and GCM still works.
So I ask: What do I lose in privacy in not revoking permission for the line above?
3rd April 2017, 06:05 PM |#7  
OP Senior Member
Thanks Meter: 32
If location permissions are allowed then google play services will keep accessing network/gps to keep track of your location. This causes all those nlp wakelocks. I did find however that using UnifiedNLP like this caused significantly less wakelocks than using the google location services. So if that's how you need it then go for it.

BTW, what's GCN push?
3rd April 2017, 06:17 PM |#8  
Junior Member
Flag Tübingen
Thanks Meter: 3
Sorry, I meant GCM, Google Cloud Messaging (not Notification).
The main question would be if Google still collects and tracks Wi-Fis, cell towers etc. when I don't revoke this permission. If so, the whole enterprise to get the Mozilla Location Provider to work would be rather pointless. No push notifications for Signal, Tweetings etc. is sadly not acceptable for me.
3rd April 2017, 06:33 PM |#9  
OP Senior Member
Thanks Meter: 32
Ah, I can't comment on GCM as I've never used it but third party app's I use push ok. But that being said, you use GCM so that's what you need to work.

The whole point of this really is to stop google from stalking you (whether for privacy, battery or both). So yeah, I'd have to agree that using this and allowing those google location permissions would be pretty pointless.
The Following User Says Thank You to M.A.K For This Useful Post: [ View ] Gift M.A.K Ad-Free
10th April 2017, 10:00 AM |#10  
Senior Member
Flag Evansville
Thanks Meter: 57
Donate to Me
Works great on my op3t thanks a million
10th April 2017, 02:20 PM |#11  
sohamsen's Avatar
Senior Member
Flag Kolkata
Thanks Meter: 1,265
microG's built in unified nlp and this are same?
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes