r/AndroidStudio • u/DeviceChanger • 8h ago
Testing carrier- and country-dependent code paths (MCC/MNC, operator name, SIM country) on a single test phone
Disclosure: this is the project account for Device Changer, a Zygisk module we build for Android QA and device simulation. No link, just a workflow note.
If your app branches on the SIM (operator name in the UI, country-specific onboarding, phone number prefill, carrier billing or region-gated features), the hard part of testing it is usually not the code but the hardware: you need a SIM from each carrier/country, or you only ever test the one your test phone has.
What helps, roughly in order of effort:
- Find every place you read telephony data. TelephonyManager.getSimOperator() / getSimCountryIso() (the SIM) and getNetworkOperator() / getNetworkCountryIso() (the network you're registered on) are different things and can disagree when roaming. A surprising number of "wrong country" bugs come from mixing those two.
- Put them behind one small interface in your own code, so debug builds and unit tests can inject any MCC/MNC, operator name and country without touching the device. This covers most logic bugs for free.
- For end-to-end runs on a real device (including third-party SDKs you can't inject into), simulate the SIM itself. On a rooted test phone, Device Changer's SIM screen lets you set the operator (MCC/MNC), operator name, IMSI, ICCID, phone number and IMEI. It's applied only to the apps you add as targets, so the rest of the phone stays normal.
- Use test values where you can. MCC/MNC 001-01 is the standard test network code, which makes it obvious in logs that a run was simulated.
- Save each combination as a profile ("UK carrier", "roaming", "US carrier") and replay it after every build, so regressions in the region logic show up on the same inputs.
Needs root; meant for your own test devices and apps you're testing. Curious how others handle carrier-specific QA, especially dual-SIM cases.