[Xiaomi Mi Max 3 Questions & Answers] virtualreptile:
bypass is done with catches

this post is more informational rather than something to be done. i don't guarantee anything on this post and you take whole responsibility for anything happens when you do something with this information. which includes legal problems, because using these can circumvent some restrictions.

bypassing is done, however it does have some catches. hotspot may go to unwanted channels and todays settings do not have manual channel selection. i tried this on another machine as well but other machine is always wifi country code "00" (global), both before and after edit. most likely it means wifi drivers and/or wifi hardware does not support country code, only global "00". other machines is huawei p10lite was-lx1, which is based on mediatek chipset.

crucial information is, wifi-service gets country code either from sim-card or operator codes. other settings usually won't matter.

i tested mi max 3 with aosip, https://xdaforums.com/mi-max-3/development/aosip-t3933754

command "iw reg get" gives information

https://bitbucket.org/JesusFreke/smali/downloads/

use smali and baksmali, some version. i used 2.4.0

!! remember to backup original file

get wifi-service.jar from device, probably /system/frame/wifi-service.jar

(do these in own directory to avoid a mess)

unzip jar file

(default goes to directory "out") (some cases odexing is required)

java -Xms1g -jar baksmali-2.4.jar d -d framework/arm64 classes.dex

find file WifiServiceImpl.smali , most likely out/com/android/server/wifi/WifiServiceImpl.smali

modify file

from this (probably varies heavily)
~~~~
.method public setCountryCode(Ljava/lang/String;)V
.registers 5

.line 2213
const-string v0, "WifiService"

new-instance v1, Ljava/lang/StringBuilder;

invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

const-string v2, "WifiService trying to set country code to "

invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v1

invoke-static {v0, v1}, Landroid/util/Slog;->i(Ljava/lang/String;Ljava/lang/String;)I

.line 2214
invoke-direct {p0}, Lcom/android/server/wifi/WifiServiceImpl;->enforceConnectivityInternalPermission()V

.line 2215
iget-object v0, p0, Lcom/android/server/wifi/WifiServiceImpl;->mLog:Lcom/android/server/wifi/WifiLog;

const-string v1, "setCountryCode uid=%"

invoke-interface {v0, v1}, Lcom/android/server/wifi/WifiLog;->info(Ljava/lang/String;)Lcom/android/server/wifi/WifiLog$LogMessage;

move-result-object v0

invoke-static {}, Landroid/os/Binder;->getCallingUid()I

move-result v1

int-to-long v1, v1

invoke-interface {v0, v1, v2}, Lcom/android/server/wifi/WifiLog$LogMessage;->c(J)Lcom/android/server/wifi/WifiLog$LogMessage;

move-result-object v0

invoke-interface {v0}, Lcom/android/server/wifi/WifiLog$LogMessage;->flush()V

.line 2216
invoke-static {}, Landroid/os/Binder;->clearCallingIdentity()J

move-result-wide v0

.line 2217
iget-object v2, p0, Lcom/android/server/wifi/WifiServiceImpl;->mCountryCode:Lcom/android/server/wifi/WifiCountryCode;

invoke-virtual {v2, p1}, Lcom/android/server/wifi/WifiCountryCode;->setCountryCode(Ljava/lang/String;)Z

.line 2218
invoke-static {v0, v1}, Landroid/os/Binder;->restoreCallingIdentity(J)V

.line 2219
return-void
.end method
~~~~
to this
~~~~
.method public setCountryCode(Ljava/lang/String;)V
.registers 6

.line 2213
const-string v0, "WifiService"

const-string v3, "US"

new-instance v1, Ljava/lang/StringBuilder;

invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

const-string v2, "WifiService trying to set country code to "

invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v1

invoke-static {v0, v1}, Landroid/util/Slog;->i(Ljava/lang/String;Ljava/lang/String;)I

.line 2214
invoke-direct {p0}, Lcom/android/server/wifi/WifiServiceImpl;->enforceConnectivityInternalPermission()V

.line 2215
iget-object v0, p0, Lcom/android/server/wifi/WifiServiceImpl;->mLog:Lcom/android/server/wifi/WifiLog;

const-string v1, "setCountryCode uid=%"

invoke-interface {v0, v1}, Lcom/android/server/wifi/WifiLog;->info(Ljava/lang/String;)Lcom/android/server/wifi/WifiLog$LogMessage;

move-result-object v0

invoke-static {}, Landroid/os/Binder;->getCallingUid()I

move-result v1

int-to-long v1, v1

invoke-interface {v0, v1, v2}, Lcom/android/server/wifi/WifiLog$LogMessage;->c(J)Lcom/android/server/wifi/WifiLog$LogMessage;

move-result-object v0

invoke-interface {v0}, Lcom/android/server/wifi/WifiLog$LogMessage;->flush()V

.line 2216
invoke-static {}, Landroid/os/Binder;->clearCallingIdentity()J

move-result-wide v0

.line 2217
iget-object v2, p0, Lcom/android/server/wifi/WifiServiceImpl;->mCountryCode:Lcom/android/server/wifi/WifiCountryCode;

invoke-virtual {v2, v3}, Lcom/android/server/wifi/WifiCountryCode;->setCountryCode(Ljava/lang/String;)Z

.line 2218
invoke-static {v0, v1}, Landroid/os/Binder;->restoreCallingIdentity(J)V

.line 2219
return-void
.end method
~~~~

point is to add one register, that is used instead temporary ones. register has string "US" or other country.

repack

mv classes.dex classes.dex.original-backup

java -Xms1g -jar smali-2.4.0.jar a -o classes.dex out

jar -cvf wifi-service.jar classes.dex

transfer file back to device. did you remember backup just in case!

information is based on https://xdaforums.com/pixel/themes/mod-wifi-country-code-fix-root-required-t3558044