[TUT][N,O] WIFI region code Fix for RR , Carbon(Roms based on it) and cypherOS

Search This thread

raminta

Senior Member
Jul 30, 2012
860
319
shiraz
Xiaomi Mi 8
Xiaomi Poco F3
Hello Guy today I want to teach you how to fix WiFi region code problem on Nought and Oreo roms

FIX FOR NOUGHT ROMS AND OREO ROMS(ONLY FOR BUILDS BEFORE 19/1/2018)(NOT FOR cypherOS)
If you are on builds after 19/1/2018 or cypherOS go down ; there is a way with xposed to fix the problem
reqierments :

1. knowing how decompile .jar files (you can use This tool)
2. notepad ++(for editing some files)
3. "telephony-common.jar" from rom (you can find it in "system -> framwork)
4. framwork-res.apk of rom (you can find it in "system -> framwork)(the process may work without it)
** if you see this mark on TUT it means "if you use the tool that is on first requierments"

Steps :

1. install the "framework-res.apk" for apktool (** copy it to "in" folder of tool
then choose " 1 " and choose the "framwork-res.apk" of rom)

2. decompile the "telephony-common.jar" file and go the folder of the decompiled file (** copy the file to "in" folder open the tool and choose " 2 " then choose the "telephony-common.jar" and continue the process to complete decompile and then you can find the folder of decompiled file in "out" folder)

3. After you go to the folder of decompiled file go to " smail -> com -> android -> internal -> telephony " then search for " MccTable " and open it with "notepad ++"

4. on " notepad ++ " search for " setWifiCountryCode " and you will find three lines with it

go to first line

under it you will see " .locals 5 " change it to " .locals 13 "
( as you can see in picture )
first line
Screenshot_12_.png


then go to second line

go a little upper and found (here is .line 199)(but the line number may change duo to rom)
and change the line below of it to
( as you can see in picture )
second line
Screenshot_13_.png

there is no need to touch the third line

5. save the file and close " notepad ++ "

6. now recompile the file (** choose " 3 " to recompile the file and choose "telephony-common.jar" and then press NUM "4" option (Recompile, Sign And Then Zipalign)and continue the process to complete recompile )
6.1 ( ** you can find the file on " done " folder)

7. after the recompile completed copy the file to your phone

8. on your phone replace old " telephony-common.jar " with the new one and set permissions and reboot phone

P.S. after the reboot the phone may not boot at the first time (dont worry) just force shutdown your phone ( by press and holding "power button" and "volume up" and phone will vibrate 3 times ) then turn on your phone again
and you will see the problem of region code is gone :good:

FIX FOR all Nought and OREO BUILDS (LOS & RR & CARBON & CYPHER OS)
first of all thanks to @ali6944 for finding this xposed modules

you just need xposed for it and install this modules then active it and reboot your phone and problem is gone :good:
 
Last edited:

Dr.TheMaster

Senior Member
Mar 16, 2014
368
128
Damascus
OnePlus 3
OnePlus 7 Pro
I have done exactly what you did with the same tool, but only in step 6 when recompiling, I am getting four options :
Recompile "telephony-common.jar"
1 - Only Recompile
2 - Recompile And Then Sign
3 - Recompile And Then Zipalign
4 - Recompile, Sign And Then Zipalign

I chose the first one and I got the file in "done" folder but in zip format like this telephony-common.zip
I changed the extension to .jar and copied it to phone, replaced the old one and gave permissions, powered off the device (force shut down) and turned it on but I didn't get a working WIFI, I am on RR 5.8.5 BTW, thanks for the help.. hope you can reply soon..
 

raminta

Senior Member
Jul 30, 2012
860
319
shiraz
Xiaomi Mi 8
Xiaomi Poco F3
I have done exactly what you did with the same tool, but only in step 6 when recompiling, I am getting four options :
Recompile "telephony-common.jar"
1 - Only Recompile
2 - Recompile And Then Sign
3 - Recompile And Then Zipalign
4 - Recompile, Sign And Then Zipalign

I chose the first one and I got the file in "done" folder but in zip format like this telephony-common.zip
I changed the extension to .jar and copied it to phone, replaced the old one and gave permissions, powered off the device (force shut down) and turned it on but I didn't get a working WIFI, I am on RR 5.8.5 BTW, thanks for the help.. hope you can reply soon..
yes you are right i have forgot to say anything about that four option
i choose " 4 " ( Recompile, Sign And Then Zipalign )
and i dont know why it was in zip format
and another thing is i did this for carbon rom which has no option to change wifi region code i dont know if it works on RR
BTW try again with the NUM 4 option and if it didnt worked send the telephony-common.jar file to me to see what can i do
 

Dr.TheMaster

Senior Member
Mar 16, 2014
368
128
Damascus
OnePlus 3
OnePlus 7 Pro
I got it working for RR using this..

yes you are right i have forgot to say anything about that four option
i choose " 4 " ( Recompile, Sign And Then Zipalign )
and i dont know why it was in zip format
and another thing is i did this for carbon rom which has no option to change wifi region code i dont know if it works on RR
BTW try again with the NUM 4 option and if it didnt worked send the telephony-common.jar file to me to see what can i do

After doing exactly as you showed, but instead of recompiling using this tool I recompiled the file using the APKTOOK that was installed previously on my computer using this command (after opening CMD in the out folder)
Code:
apktool b -f -d telephony-common.jar
after that I copied the output file from the dist folder (telephony-common.jar\dist) and replaced it with permissions and it worked perfectly (RR 5.8.5), thanks for helping and keep it up for more tutorials :highfive:
 
  • Like
Reactions: raminta

jjanggukin

New member
Jan 23, 2018
2
0
Newest Carbon rom build has 410byte dummy version of telephony-common.jar, this fix cannot be enabled.
 
Last edited:

ali6944

Senior Member

rocker00

Senior Member
Jun 23, 2012
513
511
It's because the rom is not deodexed, I've spent a lot of time searching for a way to deodex and found out that android 8.1 moved to .vdex instead of .odex so there isn't yet a way to deodex to apply this fix, you can learn more about this here: https://github.com/JesusFreke/smali/issues/498

For linux you can use this: https://github.com/anestisb/vdexExtractor
for windows: https://github.com/Furniel/Apk-Changer
i successfully deodexed the whole framework but there's something wrong!
if you removed oat and arm folders then flashed the deodexed framework you will enjoy with the lovely bootloop, if you flashed without removing oat and arm folders it's fine but not effects for any modded jars!! so basically the deodexed framework is useless!!
here is the file which you need already deodexed and patched and if you find anyway to get it working please let me know because i miss some mods since the latest build :D
 

Attachments

  • fix.zip
    1.1 MB · Views: 139
Last edited:

ali6944

Senior Member
For linux you can use this: https://github.com/anestisb/vdexExtractor
for windows: https://github.com/Furniel/Apk-Changer
i successfully deodexed the whole framework but there's something wrong!
if you removed oat and arm folders then flashed the deodexed framework you will enjoy with the lovely bootloop, if you flashed without removing oat and arm folders it's fine but not effects for any modded jars!! so basically the deodexed framework is useless!!
here is the file which you need already deodexed and patched and if you find anyway to get it working please let me know because i miss some mods since the latest build :D

Nice work, will keep on the case, can't stand being on an obsolete build forever!
 

ali6944

Senior Member
Latest build of Lineage and CypherOS is the same, so that's might be the new style and i think it's better if we can find a solution for that rather than using old builds!

You are absolutely right, also it's a universal thing with all the new 8.1 roms, even the Pixel phone OTAs have it so a lot of effort is being but into this right now, I'll keep trying, I'm even using the latest build of carbon right now, it's a bit inconvenient having to reboot the phone every time you disconnect from WiFi, but this motivates me to try even further!
 

rocker00

Senior Member
Jun 23, 2012
513
511
@rocker00 can you try installing vdex extractor, you can find it compiled and ready here:
https://www.dropbox.com/s/cbqs5e8nwy...actor.exe?dl=0
it didn't want to install on my PC for some reason, if you can get it working try using it on boot-telephony-common.vdex from framwork/arm and see what comes up

This is not an app to install, it's like command line, also it doesn't make any sense to try this because the tool i mentioned for windows also based on vdexextractor, it's just implemented for windows.
now am confused more and more, i flash deodexed patched services.jar (aka superuser mod) and it worked! then i tried to remove services.vdex from oat/arm and it worked also!! so why it worked with or without .vdex from oat/arm and the other mods based on arm folder doesn't work and if you removed boot-......vdex for any jar you will have bootloop!!
 
Last edited:

ali6944

Senior Member
This is not an app to install, it's like command line, also it doesn't make any sense to try this because the tool i mentioned for windows also based on vdexextractor, it's just implemented for windows.
now am confused more and more, i flash deodexed patched services.jar (aka superuser mod) and it worked! then i tried to remove services.vdex from oat/arm and it worked also!! so why it worked with or without .vdex from oat/arm and the other mods based on arm folder doesn't work and if you removed boot-......vdex for any jar you will have bootloop!!

here is a thread that i found helpful: https://xdaforums.com/pixel-xl/help/successfully-deodex-stock-oreo-systemui-t3685034/page3

It seems like even the gods of deodexing are having the same issues, you can deodex pretty much anything including services.jar, but you can't touch any other framework file without causing a bootloop, if i got the conclusion right then i think we need to wait for jesusfreake to update smali and backsmali to support vdex
 

rocker00

Senior Member
Jun 23, 2012
513
511
here is a thread that i found helpful: https://xdaforums.com/pixel-xl/help/successfully-deodex-stock-oreo-systemui-t3685034/page3

It seems like even the gods of deodexing are having the same issues, you can deodex pretty much anything including services.jar, but you can't touch any other framework file without causing a bootloop, if i got the conclusion right then i think we need to wait for jesusfreake to update smali and backsmali to support vdex

Yeah, the latest post in the thread you mentioned exactly the same issue i have, looks like we are out of luck now!
 

ali6944

Senior Member
I can't believe I forgot about this, but while I was looking for a fix for nougat months ago I found this xposed module that fixes the issue, but since I got WiFi working before that, I totally forgot about it, I just tried it with the latest Carbon rom and it works! Can't believe it was right there for so long
Here it is http://repo.xposed.info/module/android.wifiregionalfix
 

raminta

Senior Member
Jul 30, 2012
860
319
shiraz
Xiaomi Mi 8
Xiaomi Poco F3
  • Like
Reactions: ali6944

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Hello Guy today I want to teach you how to fix WiFi region code problem on Nought and Oreo roms

    FIX FOR NOUGHT ROMS AND OREO ROMS(ONLY FOR BUILDS BEFORE 19/1/2018)(NOT FOR cypherOS)
    If you are on builds after 19/1/2018 or cypherOS go down ; there is a way with xposed to fix the problem
    reqierments :

    1. knowing how decompile .jar files (you can use This tool)
    2. notepad ++(for editing some files)
    3. "telephony-common.jar" from rom (you can find it in "system -> framwork)
    4. framwork-res.apk of rom (you can find it in "system -> framwork)(the process may work without it)
    ** if you see this mark on TUT it means "if you use the tool that is on first requierments"

    Steps :

    1. install the "framework-res.apk" for apktool (** copy it to "in" folder of tool
    then choose " 1 " and choose the "framwork-res.apk" of rom)

    2. decompile the "telephony-common.jar" file and go the folder of the decompiled file (** copy the file to "in" folder open the tool and choose " 2 " then choose the "telephony-common.jar" and continue the process to complete decompile and then you can find the folder of decompiled file in "out" folder)

    3. After you go to the folder of decompiled file go to " smail -> com -> android -> internal -> telephony " then search for " MccTable " and open it with "notepad ++"

    4. on " notepad ++ " search for " setWifiCountryCode " and you will find three lines with it

    go to first line

    under it you will see " .locals 5 " change it to " .locals 13 "
    ( as you can see in picture )
    first line
    Screenshot_12_.png


    then go to second line

    go a little upper and found (here is .line 199)(but the line number may change duo to rom)
    and change the line below of it to
    ( as you can see in picture )
    second line
    Screenshot_13_.png

    there is no need to touch the third line

    5. save the file and close " notepad ++ "

    6. now recompile the file (** choose " 3 " to recompile the file and choose "telephony-common.jar" and then press NUM "4" option (Recompile, Sign And Then Zipalign)and continue the process to complete recompile )
    6.1 ( ** you can find the file on " done " folder)

    7. after the recompile completed copy the file to your phone

    8. on your phone replace old " telephony-common.jar " with the new one and set permissions and reboot phone

    P.S. after the reboot the phone may not boot at the first time (dont worry) just force shutdown your phone ( by press and holding "power button" and "volume up" and phone will vibrate 3 times ) then turn on your phone again
    and you will see the problem of region code is gone :good:

    FIX FOR all Nought and OREO BUILDS (LOS & RR & CARBON & CYPHER OS)
    first of all thanks to @ali6944 for finding this xposed modules

    you just need xposed for it and install this modules then active it and reboot your phone and problem is gone :good:
    2
    I can't believe I forgot about this, but while I was looking for a fix for nougat months ago I found this xposed module that fixes the issue, but since I got WiFi working before that, I totally forgot about it, I just tried it with the latest Carbon rom and it works! Can't believe it was right there for so long
    Here it is http://repo.xposed.info/module/android.wifiregionalfix
    2
    for editing we need apk tool or batch apk tool or mt manager. We decompile framework.jar and look for a method in smali along the path android / net / wifi / WifiManager.smali
    and we are looking for a method

    .method public setCountryCode(Ljava/lang/String;Z)V

    then we add one register or locale, if you had ".registers5" then you need to change it to ".registers6", if it was ".locals1", then you need to change it to ".locals2". I think this is all clear

    Now consider the transition variables for the correct application of the constant

    Consider a piece of code in order to understand how to add a constant

    :try_start_2
    iget-object v1, p0, Landroid/net/wifi/WifiManager;->mService:Landroid/net/wifi/IWifiManager;

    invoke-interface {v1, p1, p2}, Landroid/net/wifi/IWifiManager;->setCountryCode(Ljava/lang/String;Z)V
    :try_end_7
    .catch Landroid/os/RemoteException; {:try_start_2 .. :try_end_7} :catch_8


    in my case, the variables start with "v1"; you can have it differently, for example, with "v0". That is, the added constant I will have with "v2", that is, you need to add one meaning for the new constant that looks like "const-string v2,"US""

    and put the constant "const-string v2,"US"" between the ".line 1729" (this value will most likely be different for you) and ": try_start_2 " (your value may differ)

    then replace "p1" in a piece of code

    invoke-interface {v1, p1, p2}

    to the value "v2" (this is the value of our new constant)

    Below you can see how it was and how it became. After all the manipulations, you need to recompile framework.jar

    As it was

    .method public setCountryCode(Ljava/lang/String;Z)V
    .registers 5
    .param p1, "country" # Ljava/lang/String;
    .param p2, "persist" # Z

    .prologue
    .line 1729

    :try_start_2
    iget-object v1, p0, Landroid/net/wifi/WifiManager;->mService:Landroid/net/wifi/IWifiManager;

    invoke-interface {v1, p1, p2}, Landroid/net/wifi/IWifiManager;->setCountryCode(Ljava/lang/String;Z)V
    :try_end_7
    .catch Landroid/os/RemoteException; {:try_start_2 .. :try_end_7} :catch_8

    .line 1733
    return-void

    .line 1730
    :catch_8
    move-exception v0

    .line 1731
    .local v0, "e":Landroid/os/RemoteException;
    invoke-virtual {v0}, Landroid/os/RemoteException;->rethrowFromSystemServer()Ljava/lang/RuntimeException;

    move-result-object v1

    throw v1
    .end method

    As it became

    .method public setCountryCode(Ljava/lang/String;Z)V
    .registers 6
    .param p1, "country" # Ljava/lang/String;
    .param p2, "persist" # Z

    .prologue
    .line 1729
    const-string v2, "US"

    :try_start_2
    iget-object v1, p0, Landroid/net/wifi/WifiManager;->mService:Landroid/net/wifi/IWifiManager;

    invoke-interface {v1, v2, p2}, Landroid/net/wifi/IWifiManager;->setCountryCode(Ljava/lang/String;Z)V
    :try_end_7
    .catch Landroid/os/RemoteException; {:try_start_2 .. :try_end_7} :catch_8

    .line 1733
    return-void

    .line 1730
    :catch_8
    move-exception v0

    .line 1731
    .local v0, "e":Landroid/os/RemoteException;
    invoke-virtual {v0}, Landroid/os/RemoteException;->rethrowFromSystemServer()Ljava/lang/RuntimeException;

    move-result-object v1

    throw v1
    .end method

    you may need to replace "p1" with "v1" or "v0" (which is starting in variables) in the following blocks "move-exception p1", "invoke-virtual {p1}", "move-result-object p1", "throw p1".

    I hope this instruction will help
    2
    Hey there, can you please explain more? What exact modifications did you make, or a link to the 4pda post with the fix?
    Is this a fix for the WiFi region issue, or just for the 5ghz WiFi to work?
    @Old._.Boy did you manage to apply this fix? I'm trying to look into it too
    Today I will write a brief instruction