Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP HTCZ715E

18th July 2013, 12:18 PM   |  #1  
OP Senior Member
Thanks Meter: 144
 
181 posts
Join Date:Joined: Jun 2013
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/pla.../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

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

*************
android1234567 accepts this patch already
http://forum.xda-developers.com/show....php?t=2320657


HTCZ715E!
Last edited by HTCZ715E; 21st May 2014 at 09:45 PM. Reason: update
The Following 43 Users Say Thank You to HTCZ715E For This Useful Post: [ View ]
18th July 2013, 12:18 PM   |  #2  
OP Senior Member
Thanks Meter: 144
 
181 posts
Join Date:Joined: Jun 2013
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
Last edited by HTCZ715E; 10th February 2014 at 06:15 PM. Reason: added attachments
The Following 13 Users Say Thank You to HTCZ715E For This Useful Post: [ View ]
18th July 2013, 02:49 PM   |  #3  
BuXuRa's Avatar
Senior Member
Flag Tbilisi
Thanks Meter: 32
 
292 posts
Join Date:Joined: Oct 2011
More
thanks for share working for me !

Sent from my HTC Sensation using xda premium
19th July 2013, 09:11 AM   |  #4  
mohammad0089's Avatar
Member
Thanks Meter: 0
 
47 posts
Join Date:Joined: Aug 2012
More
Angry question
The explained steps are too much; so as I realized we just need to replace the attached files with the original ones; right?
19th July 2013, 12:43 PM   |  #5  
OP Senior Member
Thanks Meter: 144
 
181 posts
Join Date:Joined: Jun 2013
Angry
Quote:
Originally Posted by mohammad0089

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

So you want replace MY ATTACHMENTS with original ones??? : : : ) ) )
19th July 2013, 07:30 PM   |  #6  
mohammad0089's Avatar
Member
Thanks Meter: 0
 
47 posts
Join Date:Joined: Aug 2012
More
Smile
Quote:
Originally Posted by HTCZ715E

So you want replace MY ATTACHMENTS with original ones??? : : : ) ) )

yes if i can; i have the same problem which you mentioned; so can i replace them in all cyanogen mod roms?:
20th July 2013, 01:46 PM   |  #7  
OP Senior Member
Thanks Meter: 144
 
181 posts
Join Date:Joined: Jun 2013
Quote:
Originally Posted by mohammad0089

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 by HTCZ715E; 22nd July 2013 at 09:16 AM.
21st July 2013, 07:56 PM   |  #8  
OP Senior Member
Thanks Meter: 144
 
181 posts
Join Date:Joined: Jun 2013
patch for CM10.1.2 update
patch for CM10.1.2 update.
look in first post
The Following User Says Thank You to HTCZ715E For This Useful Post: [ View ]
21st July 2013, 10:04 PM   |  #9  
mamarda's Avatar
Senior Member
Flag Tbiisi
Thanks Meter: 12
 
106 posts
Join Date:Joined: Jun 2009
More
what about sense 4 ROMs? I have same issues on all Sense 4 roms
21st July 2013, 10:10 PM   |  #10  
Member
Thanks Meter: 4
 
87 posts
Join Date:Joined: Jan 2010
Fix works perfectly for albinoman887's CM10.1 ROM ! Thanks a ton!

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes