[HTC Sensation] HTCZ715E:
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):

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:

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":

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:

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:

.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:

.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:

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!