[MOD][GUIDE] Disable Google Location consent dialog when enabling network location

Search This thread

nopainwithme

Member
Jul 14, 2013
33
13
Hi, i find so annoying having to always tap "agree" when enabling Network location checkbox (i automatically enable it with a task together with GPS, when i need it) so I managed to obtain the same result of this Xposed module http://xdaforums.com/xposed/modules/mod-disable-google-location-consent-t2449926, modifing directly the involved file system/app/NetworkLocation.apk of my JB 4.2.2 AOKP based rom (as in AOKP, CM roms you can't install Xposed Framework). tested 3 days on my JB 4.2.2 and using the app "Location test" from Google Play store. I'm sharing my knowledge.
---Always: test it yourself, at your own risk. I don't know if there are memory leaks (don't know exactly what they are :D but read about them ) or something else like unpredictable crashes. I'm not a developer and i just make small changes to smali code usually---

Instructions:

I took some hints from the source code of this Module and made changes to NetworkLocation.apk (thanks to the authors)

I used the tool dex2jar (https://code.google.com/p/dex2jar/downloads/list) (i find it useful for editing system apks).
Extract it in a folder.
It contains some batch files, you drag and drop files/folders into them and they make their work.
You can also use Apktool, if you prefer (be sure that the file decompiles without errors).

First of all: open NetworkLocation.apk taken from your rom and extract classes.dex (use 7-zip)
Drag and drop classes.dex into d2j-dex2jar.bat, a .jar file will be created. Then drag and drop the created .jar file into d2j-jar2jasmin.bat, a new jasmin folder will be created. Now open this folder and go to com-google-android-location and find 2 files: ConfirmAlertActivity.j and NetworkLocationProvider.j
These jasmin (.j) files are similar to .smali files,
Open them as text and edit as below (be sure to find and edit the correct pieces of code)(edit only the green numbers) :

A) ConfirmAlertActivity.j

1)

(.....)

iconst_1 (instead of iconst_0)
putfield com/google/android/location/ConfirmAlertActivity/mAgreed Z
(.....)

[smali code for those who are using apktool:

const/4 v0, 0x1

iput-boolean v0, p0, Lcom/google/android/location/ConfirmAlertActivity;->mAgreed:Z ]


2)

(.....)
L0:
iconst_1 (instead of iconst_0)
istore 3
goto L1
.limit locals 4

(.....)

[corresponding smali code:

.line 67
:cond_0
const/4 v0, 0x1 ]

B) NetworkLocationProvider.j


(....)
L0:
aload 0
iconst_1 (instead of iconst_0)
invokespecial com/google/android/location/NetworkLocationProvider/setUserConfirmedPreference(Z)V
return

(....)


[in smali:

.line 206
:cond_2

const/4 vX, 0x1 (where X is a number not used elesewhere in the method, for example: v10, v11, ...)

invoke-direct {p0, v6}, Lcom/google/android/location/NetworkLocationProvider;->setUserConfirmedPreference(Z)V ]


Finished!
Now do the inverse process: drag and drop the modified jasmin folder into d2j-jasmin2jar.bat, then the new .jar file into jar2dex.bat.
You will obtain a new classes-jar-blablabla-jasmin.dex file. Rename it classes.dex and use it to replace the classes.dex in the original NetworkLocation.apk (use 7-zip to open the.apk, Winrar might give problems).
Now you have your new NetworkLocation.apk without location consent dialog (automatically agreed). When you replace the old .apk, be sure that the new one has the same permissions of the old one.

I'm attaching the modified NetworkLocation.apk (version 1.1.10) of my android version: Rootbox JellyBean 4.2.2
These instructions won't work with Kitkat but should work at least with android 4.3.
Hope this is useful to someone that can't install this Xposed Module but want the same result!
 

Attachments

  • NetworkLocation.apk
    268.2 KB · Views: 239

tdunham

Inactive Recognized Contributor
Jun 21, 2008
13,686
36,465
TampaBay
Would you mind adding the .method headers where the 3 edits are located?
Or please provide stock apk so that I may diff the changes.
The code I am trying to adapt this to is for 4.4.2 and it is very different.
Tnx - TD
 

budbay

Senior Member
Jul 6, 2014
163
48
Any more info on how to do this on 4.4, the thread was deleted.

Sent from my One X using XDA Free mobile app
 

budbay

Senior Member
Jul 6, 2014
163
48
Thanks for the info. I am trying to reapply to HTC one x but I don't think I have the GmsCore.apk. I guess I'll keep searching.

Edit- I actually found PrebuiltGmsCore.apk that might be the equivalent

Sent from my One X using XDA Free mobile app
 
Last edited:

edjanx

Senior Member
Nov 5, 2008
79
16
Scranton
Disable Google Location consent on Lollipop

Nevermind, I figured it out. Here is the guide I did for 4.4.2 TW for the Galaxy S5.

Has there been any method for those of us on the Galaxy S 5 lollipop 5.0? I did download an Xposed module, but it didn't work since it was only for 4.2.2. Thanks!

Ed Janx
 

tdunham

Inactive Recognized Contributor
Jun 21, 2008
13,686
36,465
TampaBay
Has there been any method for those of us on the Galaxy S 5 lollipop 5.0? I did download an Xposed module, but it didn't work since it was only for 4.2.2. Thanks!

Ed Janx
Not that I know of. You could try the method in my guides thread for kitkat but I haven't even bothered since then since I think its a google play services edit and that updates now and then which means you'd have to keep doing the hack everytime it takes an update.
 

edjanx

Senior Member
Nov 5, 2008
79
16
Scranton
Nevermind, I figured it out. Here is the guide I did for 4.4.2 TW for the Galaxy S5.
http://xdaforums.com/showthread.php?t=2798995

Not that I know of. You could try the method in my guides thread for kitkat but I haven't even bothered since then since I think its a google play services edit and that updates now and then which means you'd have to keep doing the hack everytime it takes an update.

Thanks for the info tdunham, as it helps to understand the mechanics behind it. It sounds like this could be an ideal Xposed module, especially if it could detect the play services update, then 're-disable' the warning.

Ed Janx
 

Top Liked Posts