[Xperia Z2 Q&A, Help & Troubleshooting] ticktock666:
Background information:

Ever since Android Nougat roms came out, google started using the sim card to set the WiFi region code on the device, and for some countries, this completely breaks the WiFi functionality, some details about the subject here : WiFi_regional_problem_on_Android.

This was possible to fix on Nougat by following this tutorial : WiFi Country Problem Solving for AOSP, MIUI & others , but when Oreo roms started coming out, they we odexed out of the box, which meant to actually apply this fix you needed to deodex the rom and then apply the fix, a bit of headache.

Once Xposed became available for Nougat & Oreo, an xposed module was created that fixed the issue and allowed us to use WiFi normally : Wifi region fix

Recently, Pie based roms started showing up for the Z2, and with them came back the same WiFi issue, and while there's a sort of working Xposed solution, EDxposed, it works through magisk and atm does not support resources hooking, which means the xposed module can't work it's magic.

Solutions and Status:

I've been trying to find a fix for this, and I have followed various guides on the internet, but they don't seem to work.

First of all I've deodexed the /framewrok folder using TOAD (The open-source Android Deodexer), then have followed these suggested fixes.

Method 01 (Failed)

WiFi Country Problem Solving for AOSP, MIUI & others

Method 02 (Failed)

WiFi region fix for android N & O

These 2 methods required modifying the telephony-common.jar file

Method 03 (Failed)

wifi country code fix requires root

This method modifies the wifi-services.jar , which is the same way the xposed module works, so I'm hoping to focus on it, another method that uses the same method is on another forum, but basically offers the same directions MIUI wifi region fix

My problem with these 2 methods is the config files they show seem to use ".registers" command, while the files to modify for our Z2 use the ".locals" command, and from what I can see both define the number of variables we can use inside the ".method" with a slight difference, for example a ".registers 3" will allow you to use 4 total variables, like v0, v1, p0, p1, while ".locals 3" will allow you to use 4 of each variable, like v0, v1, v2, v3 and p0, p1, p2, p3. This is my personal observation, since I wasn't able to find any specific info on this matter using google.

Update: it seems this is related to how I was decompiling the jar file, if I used apktool with the -d switch, I get the files using the ".locals" version, but if I decompile using "BatchApkTool" i get the files using the ".registers" version, although making changes and recompiling/decompiling reflects the results in different ".registers" & ".locals" changes.

But there's still another difference, in those guides they show :

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

const-string[COLOR="Blue"]/jumbo[/COLOR] v2, "WifiService"

and the fix is to add another line after that :

const-string[COLOR="blue"]/jumbo[/COLOR] v6, "US"

I'm not sure what is the /jumbo thing is, but it doesn't exist in our version of that file, in the Z2 file we have:

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

.line 2174
const-string v0, "WifiService"

and my change was:

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

.line 2174
const-string v0, "WifiService"

const-string v3, "US"

flashed the resulting file, but it's still not working, I really feel I'm close but still somehow doing something wrong, so any insights/guidance/help would be Very Much appreciated.

Update:

Working with wifi-service.jar didn't give any results, tried multiple modifications but once WiFi was gone, that was it, even airplane mode didn't allow me to see any networks, so I went back to work on telephony-common.jar , and there seems to be some progress.

Right now, if I use the modified version, put the phone in airplane mode and reboot, I'll have WiFi working as long as the phone remains in airplane mode, once airplane mode is disabled and the phone detects the sim, WiFi will stop working until I activate airplane mode again AND reboot.

I'll do more testing tomorrow, that's it for tonight.