UnifiedNLP with GApps Patch

AnonVendetta

Senior Member
Apr 29, 2016
851
319
63
Portland, OR
@Julien Faure: No i'm not aware of any ROM that only supports UnifiedNlp.

Try with signature verification patch only, see if ROM boots. Then try UnifiedNlp patch after that.

If it doesnt work, you can send me the zip that Smali Patcher produces, i can try to patch it. I'll also need a copy of your /system/framework/ directory, just compress it into a zip file.
 

Julien Faure

Member
Jan 28, 2021
18
0
1
@Julien Faure: No i'm not aware of any ROM that only supports UnifiedNlp.

Try with signature verification patch only, see if ROM boots. Then try UnifiedNlp patch after that.

If it doesnt work, you can send me the zip that Smali Patcher produces, i can try to patch it. I'll also need a copy of your /system/framework/ directory, just compress it into a zip file.
@AnonVendetta: I'm afraid I did not explain properly what I'm looking for. I'm not looking for a ROM that only supports UnifiedNlp but for a ROM that supports UnifiedNlp (as a location provider) in addition of supporting microG (as a Play Services replacement and thus as a location provider). In short, a ROM that does not require the OP's patch! 🙂

Finally thanks for the helping hand proposal, I will get back here once I will have get a chance to try the Smali patcher patch.
 

AnonVendetta

Senior Member
Apr 29, 2016
851
319
63
Portland, OR
@AnonVendetta: I'm afraid I did not explain properly what I'm looking for. I'm not looking for a ROM that only supports UnifiedNlp but for a ROM that supports UnifiedNlp (as a location provider) in addition of supporting microG (as a Play Services replacement and thus as a location provider). In short, a ROM that does not require the OP's patch! 🙂

Finally thanks for the helping hand proposal, I will get back here once I will have get a chance to try the Smali patcher patch.
Then it sounds like MicroG is what you want, it has UnifiedNlp built into it.

Some things you need to know:
1. MicroG needs a signature spoofing patch or it wont work (which isnt the same thing as signature verification, that's an internal Android security mechanism). Spoofing is needed so that MicroG can pretend to be Google Play Services
2. UnifiedNlp *MIGHT* need the patch outlined in this topic, but it depends on the ROM. Most stock ROMs will need this patch for UnifiedNlp to work properly. If it's based on AOSP/LOS/CM/etc, then usually not. Install the MicroG APK and see if the "system supports location provider" box is checked. If it isn't, then you need this patch (or as an alternative, one of the Xposed modules, "XposedUnifiedNlp"/"XposedGmsCoreUnifiedNlp").
3. From my tests, this patch usually wont work unless Android's signature verification is disabled. I could be wrong here, but i never managed to get any ROM to boot with this patch applied, unless signature verification is disabled
4. If you intend on installing GApps, then you can use UnifiedNlp alongside it, without MicroG. If you're going to use MicroG, then UnifiedNlp is included, but you might still need this patch
 

Julien Faure

Member
Jan 28, 2021
18
0
1
@AnonVendetta : I will come back here later for a more detailed answer (especially regarding microG) but thought I managed to apply the "signature verification" patch, as soon as a apply the second (UnifiedNLP) patch the device is bootlooping. You proposed to "patch the patch": which version of my /system/framework directory do you need? The stock one or the one with the modifications coming from Smali Patcher? Thks!
 

AnonVendetta

Senior Member
Apr 29, 2016
851
319
63
Portland, OR
@Julien Faure: Actually, i dont need the directory at all. The signature verification patch changes services.jar. The UnifiedNlp patch changes a different file, called framework-res.apk. That should be all i need.

But, are you sure verification is actually disabled? Assuming the patch succeeded, you replaced services.jar, and followed my other instructions, then are you able to boot?
 

Julien Faure

Member
Jan 28, 2021
18
0
1
Yup sure I followed your instructions : w/o the framework-res.apk change but with all the changes corresponding to the zip generated by Smali Patcher I'm able to boot. Is there a way to check that signature verification is actually disabled?

Which framework-res.apk do you need? The one before or after the org.microg.nlp patch?
 

AnonVendetta

Senior Member
Apr 29, 2016
851
319
63
Portland, OR
@Julien Faure: i'm actually not aware of any reliable way to know that the patch actually worked. The root version of YouTube Vanced requires it to be disabled, that might be a way to test.

If any of the steps we do end up requiring root access, then I suggest you use the LOS su addon, which you can get from the official LOS website. There is also an uninstaller zip that you can flash to cleanly unroot.

But for now, let's just assume it worked. Send me the original, unpatched framework-res.apk. No rush though, sincr it will be another 10+ hours before i can try patching it.
 

Julien Faure

Member
Jan 28, 2021
18
0
1
@Julien Faure: i'm actually not aware of any reliable way to know that the patch actually worked. The root version of YouTube Vanced requires it to be disabled, that might be a way to test.

If any of the steps we do end up requiring root access, then I suggest you use the LOS su addon, which you can get from the official LOS website. There is also an uninstaller zip that you can flash to cleanly unroot.

But for now, let's just assume it worked. Send me the original, unpatched framework-res.apk. No rush though, sincr it will be another 10+ hours before i can try patching it.
Ok thanks a lot again. Please find attached the original framework-res.apk (compressed as a zip) as well as the Smali-patched services.jar
 

Attachments

AnonVendetta

Senior Member
Apr 29, 2016
851
319
63
Portland, OR
I didnt need the services.jar. I can decompile framework-res.apk with APKTool, no problem. No issues editing the right file to add UnifiedNlp as a location provider. But when I try to recompile, just errors, like "could not exec", "error code 1",etc. I've tried with APKTool on Windows, Linux, and Android. I've also tried recompiling with AAPT v1 and AAPT v2. If I could get it to recompile, then we could move forward.

I've never worked with rebuilding Oreo system APKs before, I did my previous work on Marshmallow and Nougat, and it worked.

If you can get it to rebuild, try resigning with the original signature.

APKTool -c option/parameter

By default APKTool will *NOT* resign APKs after compiling them, Android wont accept unsigned APKs without deep system modifications.

And also try resigning with a plain old test key signature.
 

Julien Faure

Member
Jan 28, 2021
18
0
1
I didnt need the services.jar. I can decompile framework-res.apk with APKTool, no problem. No issues editing the right file to add UnifiedNlp as a location provider. But when I try to recompile, just errors, like "could not exec", "error code 1",etc. I've tried with APKTool on Windows, Linux, and Android. I've also tried recompiling with AAPT v1 and AAPT v2. If I could get it to recompile, then we could move forward.

I've never worked with rebuilding Oreo system APKs before, I did my previous work on Marshmallow and Nougat, and it worked.

If you can get it to rebuild, try resigning with the original signature.

APKTool -c option/parameter

By default APKTool will *NOT* resign APKs after compiling them, Android wont accept unsigned APKs without deep system modifications.

And also try resigning with a plain old test key signature.
Hi @AnonVendetta (and again, thanks for the follow-up),

I also get those errors on my first attempts running the OP's patch. To fix them, I updated the Patch.bat script so that to use my own (up-to-date) installation of Java as well as a more recent version of APKTool (but not the last one as it was crashing). Please find attached my modified script (renamed as txt to be allowed to upload it).

Unfortunately is seems this script is already resigning the APK with the original signature since the (re) compiling step is doing this :

java -jar tools/apktool_2.4.1.jar b -c work/framework-res -o work/framework-res.patched.apk
 

Attachments

AnonVendetta

Senior Member
Apr 29, 2016
851
319
63
Portland, OR
@Julien Faure: I didnt even use the script to do the patch. Literally all the script does is decompile, edit a file, recompile. Except in your case, the recompiling isnt so easy.

Since the script is already recompiling with original signature, then let it do that. Try the patch one more time with your modded script. If still not working, try using ZipSigner/APKSigner apps to sign the APK with a test key.
 

Julien Faure

Member
Jan 28, 2021
18
0
1
@AnonVendetta: what do you mean by " Try the patch one more time"? Should I restart from scratch that is to say : reinstall the ROM, patch services.jar with Smali Patcher, patch framework-res.apk with my modded script?

What are you expecting from this? The same causes should lead to the same effects shouln't they?
 
Last edited:

Julien Faure

Member
Jan 28, 2021
18
0
1
@AnonVendetta: FYI, I tried to applied the same patch to a Pie ROM (AOSiP). I had some difficulties at the recompile step but managed to overcome them. However, once pushed the patched framework-res.apk led to quite the same result as with LOS: instead of a bootloop, I got a device stuck on the boot animation. I will try to deactivate signature verification of this ROM to see what happens and I will report here.
 

Julien Faure

Member
Jan 28, 2021
18
0
1
@AnonVendetta: Victory! \o/ This time I managed to boot with the modified framework-res.apk once signature verification got deactivated. *BUT*, doing so, I realized that in my first sttempt (on LOS) I did *NOT* set the permissions on the patched apk to 644. Could that be what was preventing me from booting?

[EDIT]: !!! WARNING !!! I recently realized that I did another mistake that allowed me to boot but which put the device in an unclean state. Please see my clarification below.
 
Last edited:

AnonVendetta

Senior Member
Apr 29, 2016
851
319
63
Portland, OR
Possibly, yes, very likely. To make sure the permissions on these files are set correctly, do this:

Boot into TWRP
Start terminal in TWRP

Type the following commands:

chmod 0644 /system/framework/framework-res.apk

chmod 0644 /system/framework/services.jar

chown 0:0 /system/framework/framework-res.apk

chown 0:0 /system/framework/services.jar

Wipe cache and dakvik cache, reboot.

Install MicroG, see if the "system supports location provider" box is checked. If not, then the UnifiedNlp patch isnt done correctly, or something is interfering (most likely Google Play Services, or another system app that is location related, like com.qualcomm.location). A proprietary location provider like Qualcomm's iZat technology, would be another possible cause.

If you are going to use MicroG, be sure to do its' signature spoofing patch first. The easiest way to do is is with Smali Patcher (PC required), or an on-device solution like NanoDroid Patcher. This patch isnt needed if your ROM already has spoofing support built in.

As a final step, once you've installed MicroG, reboot, and check that "UnifiedNlp is registered in system" is checked. For Oreo and Pie, MicroG needs to be installed as system app for location provider stuff to work 100%
 

AnonVendetta

Senior Member
Apr 29, 2016
851
319
63
Portland, OR
Here is a link to 2 zips i created that you can use to install MicroG/Play Store as system apps:


If you're going to use official Play Store with MicroG, then:

Flash MicroG zip, delete the /system/priv-app/Phonesky folder. Then flash the PS zip. If not using PS, then you should leave this folder.
 

Julien Faure

Member
Jan 28, 2021
18
0
1
@AnonVendetta: first, thanks again for your help. Now... I feel stupid. The boot problems I had with the OP's patch were indeed due to the framework-res.apk file permissions :rolleyes: The second patch (disabling signature verification) is in fact useless (at least as long as apktool is supporting the "-c" command switch).

So in short, provided one manages to recompile the framework-res.apk file and sets its permissions to 0644, the OP's patch *is working*. I tested on Oreo (Unofficial LOS 15.1) and Pie (Official AOSiP 9.0). I plan to test on Q once I will have found a decent Google-free A10 ROM for the 5x: if I'm successful I will report here again.


[EDIT]: I was even more stupid than I thought 😭. Indeed when I copied the patched framework-res.apk, I *kept* the original one in place (renaming it framework-res.stock.apk). Without this original apk file, the device is *not* booting. Given that I was not sure that signature verification was actually deactivated, the correct conclusion of what I did is: the OP's patch may or may not be working and the way I made my tests was totally unclean. Sorry guys!

Sidenote: I don't get why the usage of UNLP as a location provider is not supported *by default* by recent ROMs... I mean, it's only a matter of adding "org.microg.nlp" in a list of xml items. Sigspoof is not even required...

Finally, regarding microG: if possible, I would like to avoid it and stay with UNLP + GApps. I will come back on this in details in our private conversation.
 
Last edited:

Julien Faure

Member
Jan 28, 2021
18
0
1
@AnonVendetta: that was too many successes in a row... The patch is not *fully* functional on Q. Indeed, since the begnning, my validations tests are the following :

#0: check that everything is ticked in the UNLP Self-Test.
#1: check that Google Maps IS NOT able to get a location.
#2: check that OsmAnd IS able to get a location.
#3: check the HereWeGo IS able to get a location.

On Q, #2 is failing. Besides, as opposed to what I observed on Oreo, despite the revokations and deactivations made by the DisableGoogle bat file of the OP, Google Play Services is still reported as having access to the location in the UI. I suspect an android (not file this time) permission issue but I don't know where to start: any help would be much appreciated.

PS: I did not forget that I have to answer the private conversation you started but I did not get the time to do it yet.
 
Last edited:

Julien Faure

Member
Jan 28, 2021
18
0
1
@AnonVendetta: that was too many successes in a row... The patch is not *fully* functional on Q. Indeed, since the beginning, my validations tests are the following :

#0: check that everything is ticked in the UNLP Self-Test.
#1: check that Google Maps IS NOT able to get a location.
#2: check that OsmAnd IS able to get a location.
#3: check the HereWeGo IS able to get a location.

On Q, #2 is failing. Besides, as opposed to what I observed on Oreo, despite the revokations and deactivations made by the DisableGoogle bat file of the OP, Google Play Services is still reported as having access to the location in the UI. I suspect an android (not file this time) permission issue but I don't know where to start: any help would be much appreciated.

PS: I did not forget that I have to answer the private conversation you started but I did not get the time to do it yet.
The failure was *not* due to the OP's patch. The failure is more or less due to the additional layer of complexity that Q brought wrt permissions. To bypass this Q-specific issue, the cleanest way to proceed is to install UNLP (manually or thanks to an OPA zip) *before* the first boot of the installed ROM (or, alternatively, to make a data wipe after the installation of UNLP) so that its associated user permissions (especially access to background location) gets properly generated by the permission manager.
 
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone