[GUIDE] WiFi Country Problem Solving for AOSP, MIUI & others

Search This thread

Abdulla_91

Senior Member
Jul 4, 2012
88
14
Damascus
wifi goes sleep even setting policy to "Always On"

@HTCZ715E
First of all your patch amazing solved my problem :)
I am on viper s 5.0.1
but i have a little problem you might notice it ... when phone screen is of wifi goes to sleep !. I can see this clearly through windows app called connectify(wich make laptop as hot spot) ! i see my phone wifi disconnect from it ! until i wakeup the phone it reconnect again ! other phones/ tablets still connect :/
I searched for solution .. I found same issue in one X forum and they give a solution with recompiling setting.apk modification on some lines in the following link ... am sorry i don't know how to do it myself :(
http://xdaforums.com/showpost.php?p=26412094&postcount=336
please can you do this for our senny ! we never had this issue with viper 3.1.4 and your patch is the only&best solution for our sensation
 

moonmoon8

Member
Feb 13, 2007
48
7
Not Working for new ROMs

WiFi COUNRTY PROBLEM solving

Hello!
We, who did buy phones from other countries using internet shopping,
instead of joy face the problem of WiFi-service functioning.
WiFi scan not works or shows network; but there is written NOT IN RANGE..

Problem resides in new WifiCountryCode, which phone recieves from our SIM-card.
But this new WifiCountryCode is not known for internal WiFi-program,
so it does not know which WiFi rules use.

During 2 mounth of tries I found following 3 ways to solve:

1. ARHD7.3 ROM has not THIS WiFi problem! Bravo!
(sorry, didn't check previous versions).

2. program WiFi Fix by Fardjad.
This program updates WiFi Country Code on boot and afterwards.
For most ICS roms it works good, for AOSP roms less good.
Requires: before SHUTDOWN or REBOOT WiFi should be turned off.
Slightly annoying.
On AOSP roms first WiFi TURN ON stucks;
needs 1-2 minutes to TURN OFF stucked WiFi and then second TURN ON works.
Greatly annoying!

Current version is WiFix Manager V1.32;
Author promised to solve this problem.

3. in AOSP CM10.1, before starting WiFi, goto
System settings > WiFi > Advanced > WiFi region code >>
and if here is nothing selected (your country not in list), press United States (or Europe?),
then get back from this Advanced menu and only now TURN ON WiFi.
Wifi scan now should work.
...Until next restart....
also before SHUTDOWN or REBOOT you should turn off WiFi to prevent stuck on start..

(this setting is not available in SuperXE 4.2.2 build_6)


********************************************
Buttt.. seems I found solve before WiFix author, YESS!
How this happened:

greatly annoyed, I learned about USB-debugging and Logcats and ApkTool.
here is lines from Logcat (XX replaces new country code):

Code:
D/MccTable( 636): updateMccMncConfiguration: mcc=..., mnc=..
D/MccTable( 636): locale set to null_XX
D/MccTable( 636): WIFI_COUNTRY_CODE set to XX
I/WifiService( 445): WifiService trying to set country code to XX with persist set to true

Where is this MccTable? not found such file..
Web search gives me this:

https://android.googlesource.com/pl.../com/android/internal/telephony/MccTable.java

this IS source, where is written updateMccMncConfiguration code from line 169 to 208.
and actually we need to disable these lines:

Code:
189            if (mcc != 0) {
190                setTimezoneFromMccIfNeeded(context, mcc);
191                setLocaleFromMccIfNeeded(context, mcc);
192                setWifiCountryCodeFromMcc(context, mcc);
193            }

Because Timezone you can setup in settings > Date& Time
and LOCAL parameters are set in most roms in file "/system/build.prop":

Code:
 ro.product.locale.language=en
 ro.product.locale.region=US

(if not, make it..)

Alternate "mild" edition:
you can disable only line setWifiCountryCodeFromMcc(context, mcc);
and live rest 2 updater lines.

now let me guess, this program code should be inside of some JAR file..
exactly in "/system/framework/telephony-common.jar"

I did decompile this file with ApkTool:
Code:
 apktool d telephony-common.jar

it made output as folder "telephony-common.jar.out" and there is file:
"telephony-common.jar.out/smali/com/android/internal/telephony/MccTable.smali"
and inside are above mentioned lines:

Code:
   .line 189
    if-eqz v2, :cond_0

    .line 190
    invoke-static {p0, v2}, Lcom/android/internal/telephony/MccTable;->setTimezoneFromMccIfNeeded(Landroid/content/Context;I)V

    .line 191
    invoke-static {p0, v2}, Lcom/android/internal/telephony/MccTable;->setLocaleFromMccIfNeeded(Landroid/content/Context;I)V

    .line 192
    invoke-static {p0, v2}, Lcom/android/internal/telephony/MccTable;->setWifiCountryCodeFromMcc(Landroid/content/Context;I)V

    .line 195
    :cond_0


lets gently change line 189:

Code:
    .line 189
    goto :cond_0

so program will jump over unwanted updates!
now recompile back "telephony-common.jar" with command:
Code:
 apktool b -f -d telephony-common.jar.out

and in folder "telephony-common.jar.out/dist" you will find it out.
from original file do copy of directory "META-INF" in new file with any archive manager.

now we should put "telephony-common.jar" in phone.
for this we need:
ROOT access,
with ES_file_manager >Tools >Root Explorer >Mount R/W > mount /system RW,
replace telephony-common.jar and set proper file attributes (-rw-r--r-),
mount /system R
and afterwards do REBOOT.
on new BOOT there will be "Android updates" files ...

AND WiFi problems HAVE GONE!!
Now you even can do SHUTDOWN or REBOOT with TURNED ON WiFi
AND WiFi will connect before SIM card joins GSM network!!!


Tools used:
ADB
JDK
ApkTool
ES file manager
Notepad+ or Edit+

Credits to:
[TOOL/GUIDE GB/ICS/JB] Decompile/Recompile apk | jar | sign + Basic editing xml/smali

in attachments I put:
google_src_code,
patched_MccTable.smali


*************
For SuperXE 4.2.2 build_6 (MD5=2DBDDB534A7CA6DE627EF75FCE3E7CF0)
more steps reqiured.
SuperXE has other "telephony-common.jar" MD5=C8917C386BA7FD24A0203058BFDC17F5,
so we again perform above steps for patch;
See attached file "SUXE_patched_telephony-common.jar"

now we should replace "telephony-common.jar" in phone.

with ES_file_manager >Tools >Root Explorer >Mount R/W > mount /system RW,
replace telephony-common.jar and set proper file attributes (-rw-r--r-),

Extra step 1
click on "/system/build.prop" and open in ES Note Editor;
seek line
ro.product.locale.region=GB
and change GB to US; confirm OK for save file.
mount /system R

Extra step 2
because of first boots, in Settings database is written our country code,
which should be US.
for this: install "Sqlite Editor", run, grant ROOT access. after program finds
& lists databases, look for & open "Settings Storage" > settings.db > global:
find "wifi_country_code", select it and press menu button > Edit Record;
change value to US and press "save"

if this step is too hard for you, from "wipe data, cache, dalvik"... but many
other stuff will be erased..

Now do REBOOT.
on new BOOT there will be "Android updates" files ...

*************
for VIPERS roms you should patch framework2.jar

then

Extra step 1
click on "/system/build.prop" and open in ES Note Editor;
add line
ro.product.locale.region=US
confirm OK for save file.

Extra step 2
because of first boots, in Settings database is written our country code,
which should be US.
for this: install "Sqlite Editor", run, grant ROOT access. after program finds
& lists databases, look for & open "Settings Storage" > settings.db > global:
find "wifi_country_code", select it and press menu button > Edit Record;
change value to US and press "save"

if this step is too hard for you, from "wipe data, cache, dalvik"... but many
other stuff will be erased..

Now do REBOOT.


*************
attached file CM1012_20130806_telephony-common.jar for AOSP CM10.1.2 albinoman887,
which has original telephony-common.jar file with MD5=90521F154A0E37302496D88DA879EA75

*************
attached file CM102_20131028_telephony-common.jar for AOSP CM10.2 albinoman887

*************
attached file CM11_20131119_Albinoman887_telephony-common.jar for AOSP CM11 albinoman887
"mild" patch!

*************
in MIUIandroid framework.jar should be patched; code line is 188;
also copy from old to new archive file preloaded-classes

attached file for MIUIandroid 3.10.25
attached file for MIUIandroid 3.11.15, use this also up to MIUIandroid 3.12.27

*************
attached file Inspiration_v1.0.1_framework2.jar for Inspiration v1.0.1
which has original framework2.jar file with MD5=8f67ad19fe72513489972cbfd76f244c

*************
attached file Elegancia_Sense_4.1_v7.5.0_framework2.jar for Elegancia Sense 4.1 v7.5.0
which has original framework2.jar file with MD5=a9b34b25201d592f41677c94039b520d

*************
attached file CM10_bruce_20130914_framework.jar for CM10 bruce 20130914,

*************
attached file VIPERS1.6.3_framework2.jar for VIPERS 1.6.3,
which has original framework2.jar file with MD5=3d16f3818e0ce6b7fe201f9188408491

*************
attached file ViperS2-0-0_framework2.jar for ViperS 2.0.0,
which has original framework2.jar file with MD5=c7bd6fa8a2f0fd210f21fd223089d094

*************
attached file ViperS5-0-0_framework2.jar for ViperS 5.0.0

*************
attached pack ViperS5-1-0

*************
android1234567 accepts this patch already
http://xdaforums.com/showthread.php?t=2320657


HTCZ715E!


Tried on New JellyBean Roms and not working for ASIA Region
Can you guide some more about this issue?
WiFix, wificodes, etc all are temporary
need permanent fix
 
  • Like
Reactions: Kinan9011

dramon

Senior Member
Aug 14, 2011
62
6
It works, thank you!
I have a HTC first and I modified it as per your post.

Now with wifi switched on and rebooting the wifi works.

But when you toggle wifi off and on it stops working. Also it doesn't work when you reboot when wifi is off.

Any suggestions?
 

irfan99

Member
Apr 18, 2007
19
0
hi

Sir i dont have skills to edit this file please can you do that for me please
 

Attachments

  • framework2.jar
    2.1 MB · Views: 4

m.m.m

Senior Member
Oct 22, 2011
146
18
26
Tehran
first of all, thanks for spending your time on compiling and decompiling for each file,
but build.prop for the vipers 5.1.0 is corrupted and causes bootloops so had to change the build.prop with kernel tuner personally.
 

compulife

Member
Jan 29, 2006
42
4
Wifi in Syria

Hi friends,
My current rom is :

[ROM] CyanogenMod 11.0 | Android 4.4.2 KitKat [KANG] [Jan-15]

how can I get the telephony-common.jar file for it?

Pls help,

Thanks
 

StyxCrosser

Senior Member
Feb 4, 2012
51
14
41
Tehran

Attachments

  • shantur-3.4K-CM11-telephony-common.jar
    575.4 KB · Views: 10

francesco totti

Senior Member
Jul 14, 2013
300
48
Hi I cant find this line in MccTable.smali in android kitkat !! has it changed??
.line 189
if-eqz v2, :cond_0
someone please help!!
 

nelmaster_vc

Senior Member
Jan 24, 2008
204
32
Villa Clara
Please can you help me again whith this file is from Phoenix ROM S4 KK 4.4.2

I hope you can help again

Thanks !!!
 

Attachments

  • telephony-common.jar
    922.7 KB · Views: 4

codlovergb

Member
Oct 12, 2013
24
1
am following the steps (my rom is viper 5.1.0) and get a bootloop (stuck on htc logo)
wipping cach and factory reset from recovery ... and the same problem

any solutions please ?
 

Abdulla_91

Senior Member
Jul 4, 2012
88
14
Damascus
Thanks for reply Abdulla,
Can u tell me how to fix the country code problem in this file,

Thanks

Bro you have Viper5.1.0.zip right ?! and you downloaded this "patch " http://xdaforums.com/attachment.php?attachmentid=2582728&d=1392565753
only you have to do is to extract the files from the ViperSC2_5-1-0_patch.zip to newfolder using winrar ... then open Viper5.1.0.zip
1- first copy framwork2 form extracted folder and go to /system/framwork in Viper5.1.0.zip and past it here ! it well ask for replace press accept .
2- first copy build.prob form extracted folder and go to /system in Viper5.1.0.zip and past it here ! it well ask for replace press accept

finally copy this modified rom "Viper5.1.0.zip " to sd card and install it ... the normal way ... the wifi well work

---------- Post added at 10:09 AM ---------- Previous post was at 10:02 AM ----------

am following the steps (my rom is viper 5.1.0) and get a bootloop (stuck on htc logo)
wipping cach and factory reset from recovery ... and the same problem

any solutions please ?

replace the files with rom zip ... then install it

---------- Post added at 10:14 AM ---------- Previous post was at 10:09 AM ----------

Thanks for reply Abdulla,
Can u tell me how to fix the country code problem in this file,

Thanks

u can do it by installing app called country code from the market ! u can find it in 4shared.com
 

codlovergb

Member
Oct 12, 2013
24
1
Bro you have Viper5.1.0.zip right ?! and you downloaded this "patch " http://xdaforums.com/attachment.php?attachmentid=2582728&d=1392565753
only you have to do is to extract the files from the ViperSC2_5-1-0_patch.zip to newfolder using winrar ... then open Viper5.1.0.zip
1- first copy framwork2 form extracted folder and go to /system/framwork in Viper5.1.0.zip and past it here ! it well ask for replace press accept .
2- first copy build.prob form extracted folder and go to /system in Viper5.1.0.zip and past it here ! it well ask for replace press accept

finally copy this modified rom "Viper5.1.0.zip " to sd card and install it ... the normal way ... the wifi well work

---------- Post added at 10:09 AM ---------- Previous post was at 10:02 AM ----------



replace the files with rom zip ... then install it


thanks bro ... but i just flashed test2.zip ( http://xdaforums.com/showpost.php?p=50830257&postcount=7) after installing the rom and the wifi working 100% :)
 
Last edited:

saldymhmd

Senior Member
Oct 17, 2011
941
581
30
Bekasi (Indonesia)
Can you please update patch for CM11 Albinoman? Patch on OP is outdated, I've got com,android.phone force close. Then I follow the tutorials, manually patched the telephony-common.jar on latest Albino's build April 24....Voilaaaa! It woking, can I share the file here?
 

karo222

Senior Member
Oct 13, 2011
391
43
33
Please patch this

Please patch this file for me
I don't know how to patch framework.jar
Htc Destre Rom
 

Attachments

  • peuq_framework.jar
    4.1 MB · Views: 3

Top Liked Posts

  • There are no posts matching your filters.
  • 56
    WiFi COUNRTY PROBLEM solving

    Hello!
    We, who did buy phones from other countries using internet shopping,
    instead of joy face the problem of WiFi-service functioning.
    WiFi scan not works or shows network; but there is written NOT IN RANGE..

    Problem resides in new WifiCountryCode, which phone recieves from our SIM-card.
    But this new WifiCountryCode is not known for internal WiFi-program,
    so it does not know which WiFi rules use.

    During 2 mounth of tries I found following 3 ways to solve:

    1. ARHD7.3 ROM has not THIS WiFi problem! Bravo!
    (sorry, didn't check previous versions).

    2. program WiFi Fix by Fardjad.
    This program updates WiFi Country Code on boot and afterwards.
    For most ICS roms it works good, for AOSP roms less good.
    Requires: before SHUTDOWN or REBOOT WiFi should be turned off.
    Slightly annoying.
    On AOSP roms first WiFi TURN ON stucks;
    needs 1-2 minutes to TURN OFF stucked WiFi and then second TURN ON works.
    Greatly annoying!

    Current version is WiFix Manager V1.32;
    Author promised to solve this problem.

    3. in AOSP CM10.1, before starting WiFi, goto
    System settings > WiFi > Advanced > WiFi region code >>
    and if here is nothing selected (your country not in list), press United States (or Europe?),
    then get back from this Advanced menu and only now TURN ON WiFi.
    Wifi scan now should work.
    ...Until next restart....
    also before SHUTDOWN or REBOOT you should turn off WiFi to prevent stuck on start..

    (this setting is not available in SuperXE 4.2.2 build_6)


    ********************************************
    Buttt.. seems I found solve before WiFix author, YESS!
    How this happened:

    greatly annoyed, I learned about USB-debugging and Logcats and ApkTool.
    here is lines from Logcat (XX replaces new country code):

    Code:
    D/MccTable( 636): updateMccMncConfiguration: mcc=..., mnc=..
    D/MccTable( 636): locale set to null_XX
    D/MccTable( 636): WIFI_COUNTRY_CODE set to XX
    I/WifiService( 445): WifiService trying to set country code to XX with persist set to true

    Where is this MccTable? not found such file..
    Web search gives me this:

    https://android.googlesource.com/pl.../com/android/internal/telephony/MccTable.java

    this IS source, where is written updateMccMncConfiguration code from line 169 to 208.
    and actually we need to disable these lines:

    Code:
    189            if (mcc != 0) {
    190                setTimezoneFromMccIfNeeded(context, mcc);
    191                setLocaleFromMccIfNeeded(context, mcc);
    192                setWifiCountryCodeFromMcc(context, mcc);
    193            }

    Because Timezone you can setup in settings > Date& Time
    and LOCAL parameters are set in most roms in file "/system/build.prop":

    Code:
     ro.product.locale.language=en
     ro.product.locale.region=US

    (if not, make it..)

    Alternate "mild" edition:
    you can disable only line setWifiCountryCodeFromMcc(context, mcc);
    and live rest 2 updater lines.

    now let me guess, this program code should be inside of some JAR file..
    exactly in "/system/framework/telephony-common.jar"

    I did decompile this file with ApkTool:
    Code:
     apktool d telephony-common.jar

    it made output as folder "telephony-common.jar.out" and there is file:
    "telephony-common.jar.out/smali/com/android/internal/telephony/MccTable.smali"
    and inside are above mentioned lines:

    Code:
       .line 189
        if-eqz v2, :cond_0
    
        .line 190
        invoke-static {p0, v2}, Lcom/android/internal/telephony/MccTable;->setTimezoneFromMccIfNeeded(Landroid/content/Context;I)V
    
        .line 191
        invoke-static {p0, v2}, Lcom/android/internal/telephony/MccTable;->setLocaleFromMccIfNeeded(Landroid/content/Context;I)V
    
        .line 192
        invoke-static {p0, v2}, Lcom/android/internal/telephony/MccTable;->setWifiCountryCodeFromMcc(Landroid/content/Context;I)V
    
        .line 195
        :cond_0


    lets gently change line 189:

    Code:
        .line 189
        goto :cond_0

    in newer android, there is also second call to setWifiCountryCodeFromMcc, so comment out it also.

    so program will jump over unwanted updates!
    now recompile back "telephony-common.jar" with command:
    Code:
     apktool b -f -d telephony-common.jar.out

    and in folder "telephony-common.jar.out/dist" you will find it out.
    from original file do copy of directory "META-INF" in new file with any archive manager.

    now we should put "telephony-common.jar" in phone.
    for this we need:
    ROOT access,
    with ES_file_manager >Tools >Root Explorer >Mount R/W > mount /system RW,
    replace telephony-common.jar and set proper file attributes (-rw-r--r-),
    mount /system R
    and afterwards do REBOOT.
    on new BOOT there will be "Android updates" files ...

    AND WiFi problems HAVE GONE!!
    Now you even can do SHUTDOWN or REBOOT with TURNED ON WiFi
    AND WiFi will connect before SIM card joins GSM network!!!


    Tools used:
    ADB
    JDK
    ApkTool
    ES file manager
    Notepad+ or Edit+

    Credits to:
    [TOOL/GUIDE GB/ICS/JB] Decompile/Recompile apk | jar | sign + Basic editing xml/smali

    in attachments I put:
    google_src_code,
    patched_MccTable.smali


    *************
    For SuperXE 4.2.2 build_6 (MD5=2DBDDB534A7CA6DE627EF75FCE3E7CF0)
    more steps reqiured.
    SuperXE has other "telephony-common.jar" MD5=C8917C386BA7FD24A0203058BFDC17F5,
    so we again perform above steps for patch;
    See attached file "SUXE_patched_telephony-common.jar"

    now we should replace "telephony-common.jar" in phone.

    with ES_file_manager >Tools >Root Explorer >Mount R/W > mount /system RW,
    replace telephony-common.jar and set proper file attributes (-rw-r--r-),

    Extra step 1
    click on "/system/build.prop" and open in ES Note Editor;
    seek line
    ro.product.locale.region=GB
    and change GB to US; confirm OK for save file.
    mount /system R

    Extra step 2
    because of first boots, in Settings database is written our country code,
    which should be US.
    for this: install "Sqlite Editor", run, grant ROOT access. after program finds
    & lists databases, look for & open "Settings Storage" > settings.db > global:
    find "wifi_country_code", select it and press menu button > Edit Record;
    change value to US and press "save"

    if this step is too hard for you, from "wipe data, cache, dalvik"... but many
    other stuff will be erased..

    Now do REBOOT.
    on new BOOT there will be "Android updates" files ...

    *************
    for VIPERS roms you should patch framework2.jar

    then

    Extra step 1
    click on "/system/build.prop" and open in ES Note Editor;
    add line
    ro.product.locale.region=US
    confirm OK for save file.

    Extra step 2
    because of first boots, in Settings database is written our country code,
    which should be US.
    for this: install "Sqlite Editor", run, grant ROOT access. after program finds
    & lists databases, look for & open "Settings Storage" > settings.db > global:
    find "wifi_country_code", select it and press menu button > Edit Record;
    change value to US and press "save"

    if this step is too hard for you, from "wipe data, cache, dalvik"... but many
    other stuff will be erased..

    Now do REBOOT.


    *************
    attached file CM1012_20130806_telephony-common.jar for AOSP CM10.1.2 albinoman887,
    which has original telephony-common.jar file with MD5=90521F154A0E37302496D88DA879EA75

    *************
    attached file CM102_20131028_telephony-common.jar for AOSP CM10.2 albinoman887

    *************
    attached file CM11_20131119_Albinoman887_telephony-common.jar for AOSP CM11 albinoman887
    "mild" patch!

    *************
    in MIUIandroid framework.jar should be patched; code line is 188;
    also copy from old to new archive file preloaded-classes

    attached file for MIUIandroid 3.10.25
    attached file for MIUIandroid 3.11.15, use this also up to MIUIandroid 3.12.27

    *************
    attached file Inspiration_v1.0.1_framework2.jar for Inspiration v1.0.1
    which has original framework2.jar file with MD5=8f67ad19fe72513489972cbfd76f244c

    *************
    attached file Elegancia_Sense_4.1_v7.5.0_framework2.jar for Elegancia Sense 4.1 v7.5.0
    which has original framework2.jar file with MD5=a9b34b25201d592f41677c94039b520d

    *************
    attached file CM10_bruce_20130914_framework.jar for CM10 bruce 20130914,

    *************
    attached file VIPERS1.6.3_framework2.jar for VIPERS 1.6.3,
    which has original framework2.jar file with MD5=3d16f3818e0ce6b7fe201f9188408491

    *************
    attached file ViperS2-0-0_framework2.jar for ViperS 2.0.0,
    which has original framework2.jar file with MD5=c7bd6fa8a2f0fd210f21fd223089d094

    *************
    attached file ViperS5-0-0_framework2.jar for ViperS 5.0.0

    *************
    attached pack ViperS5-1-0

    *************
    attached pack ViperS5-2-0

    *************
    android1234567 accepts this patch already
    http://xdaforums.com/showthread.php?t=2320657

    *************
    CyanogenMod12 by ivanich 20150118
    attached pack CyanogenMod12_by_ivanich_20150118_telephony-common.jar
    after replacement go to settings > Backup & reset > Factory data reset and RESET PHONE

    *************
    seems, many people done patch in their sources:
    https://github.com/search?utf8=✓&q=setWifiCountryCodeFromMcc&type=Code&ref=searchresults

    HTCZ715E!
    16
    some tips:
    yep, good tip:
    on first installation of ROM, start it without SIM-card.

    in attachments some patched files per users requests.

    added for [ROM][N1] Evervolv Kitkat 4.4
    added for [ROM]Cyanogenmod 11 | kernel 3.4 | dominos_liberty
    added for [ROM] [4.4.2] [8.Feb 2014] CyanogenMod 11.0 | KitKANG | PRE-ALPHA | v0.5 for HTC Desire
    4
    didnt work on xperia S OpenSEMC 4.4
    tried to patch "telephony-common.jar" but it cause a system fail to start
    here is the orginal file can you help me ??


    attachments are in 2nd post.
    push all thanks buttons :p
    3
    update

    updated attachment for CM10.2 20130829
    3
    added attachment for miuiandroid 3.11.1; MIUI now is JB4.2,
    so file for patch and replace is telephony-common.jar

    also I did new kind patch - "mild" edition; as I described in 1st post;