How can I programmatically change the country & network of an Android phone's SIM without root access? I'm using this code to retrieve information:
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
System.out.println(tm.getSimCountryIso()); // prints 'us', but I want it to be 'fr'
System.out.println(tm.getNetworkCountryIso()); // prints 'us, but I want it to be 'fr'
As my SIM card is from the USA, both of the outputs are us
. How can I programmatically make the output be fr
(France) for example?
Basically, I want to trick my smartphone into thinking its SIM's country & network is France, for example.
Something like this would be perfect but it doesn't exist:
tm.setSimCountryIso('fr')
tm.setNetworkCountryIso('fr')
What you are asking for is not possible without root.
As already stated in the comments, it is not physically possible to change the ICCID of the SIM unless it is a special writable SIM.
As for the call to getSimCountryIso
and getNetworkCountryIso()
those are system API's.
Without root, there is no way to interfere with their operation.
Android is built with several layers of security including restricting app access based on user privileges, enforcing SELinux on by default, verity checks as part of verified boot and more.
If you do have root on device, you can create an Xposed framework module that can hook these functions and overwrite their return value.
If you are curious, the table used to translate ICCID info into a two letter country name is hardcoded here. In case that link does not open right - it starts on line 316.
So changing that would require recompiling one of the core JARs of the OS.
Also note, that depending on your real purpose, altering the result of these two functions may not work at all.
For example, if you want to create a Google account from the phone for a different country, changing the SIM will not help, since Google will still look at your IP address, regardless of how you are connected to the internet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With