• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

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

Search This thread

HTCZ715E

Senior Member
Jun 23, 2013
233
186
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://forum.xda-developers.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!
 

Attachments

  • SUXE_patched_telephony-common.jar
    482.1 KB · Views: 545
  • WiFiSolveFiles.zip
    50.5 KB · Views: 3,806
  • CM1012_20130806_telephony-common.jar
    513.5 KB · Views: 442
  • Elegancia_Sense_4.1_v7.5.0_framework2.jar
    859.7 KB · Views: 148
  • Inspiration_v1.0.1_framework2.jar
    1.2 MB · Views: 109
  • VIPERS1.6.3_framework2.jar
    873.4 KB · Views: 109
  • CM10_bruce_20130914_framework.jar
    4.2 MB · Views: 201
  • ViperS2-0-0_framework2.jar
    1.2 MB · Views: 125
  • CM102_20131028_telephony-common.jar
    583.4 KB · Views: 434
  • miuiandroid_pyramid_3.10.25_framework.jar
    3.7 MB · Views: 250
  • CM11_20131119_Albinoman887_telephony-common.jar
    544.2 KB · Views: 571
  • miuiandroid_pyramid_3.11.15_telephony-common.jar
    460.1 KB · Views: 271
  • ViperS5-0-0_framework2.jar
    1.9 MB · Views: 691
  • ViperSC2_5-1-0_patch.zip
    1.9 MB · Views: 926
  • ViperSC2_5-2-0_patch.zip
    1.9 MB · Views: 552
  • CyanogenMod12_by_ivanich_20150118_telephony-common.jar
    750.8 KB · Views: 663
Last edited:

HTCZ715E

Senior Member
Jun 23, 2013
233
186
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
 

Attachments

  • RSKTEAMORIOLAXperiaZ_framework.jar
    4.2 MB · Views: 27
  • XperiaS_OpenSEMC_4.4_telephony-common.jar
    553.1 KB · Views: 59
  • Pixeldroid_JB_4-2-2_V3_htc_desire_telephony-common.jar
    485.8 KB · Views: 24
  • HTC_Google_Nexus_One_evervolv_kitkat_4.4.2_(passion)_telephony-common.jar
    546.6 KB · Views: 67
  • CM11K34_dominos_liberty_telephony-common.jar
    526 KB · Views: 70
  • cm-11-kitkang-20140208-v0.5_slim-telephony-common.jar
    526.6 KB · Views: 87
Last edited:

mohammad0089

Member
Aug 17, 2012
47
0
question

The explained steps are too much; so as I realized we just need to replace the attached files with the original ones; right?
 

HTCZ715E

Senior Member
Jun 23, 2013
233
186
so can i replace them in all cyanogen mod roms?:

patched_AOSP_telephony-common.jar file is for AOSP CM10.1
original file MD5=30BBC2690C8A08A4C5D977BC27D42885

SUXE_patched_telephony-common.jar file is for SuperXE 4.2.2 build 6
original file MD5=C8917C386BA7FD24A0203058BFDC17F5,

CM10-1-20130720_telephony-common.jar for AOSP CM10.1.2, which has original
telephony-common.jar file with MD5=00c7d16ae721ef64dfc1bbf2aee4bf92

one of this file you should copy on sdcard, rename as telephony-common.jar,
then with RootExplorer, replace original file in /system/framework

if original file is same, you can replace.
if not, upload it here.
 
Last edited:

Chikko

Senior Member
Sep 3, 2007
367
28
Nepi(VT), Italy
I'm sorry sir but i didn't understand... I've just to replace attached files or i edit first them?
Wifi solve is a flashable file for any rom?

Inviato dal mio HTC Sensation
 

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://forum.xda-developers.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;