Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the Mobile Country Code (MCC) in the Android Emulator?

My Android application needs to react differently to different Mobile Country Codes.

It seems like it is hardcoded to mcc310 (US). I can read this value from TelephonyManager.getSimCountryIso() or by using a resource folder like res/values-mcc123/ but how do I set this value in the emulator?

like image 956
neu242 Avatar asked Apr 14 '10 13:04

neu242


People also ask

What is MCC in APN settings?

This part of the APN is optional. The MCC is the mobile country code and the MNC is the mobile network code which together uniquely identify a mobile network operator.

How do I change my SIM country code?

Click the Settings tab. Under Default Country Code, select a country code. Click Save.

What is MCC in SIM?

MCC is a mobile code consisting of three digits used to identify GSM networks. MCC is also used along with the International Mobile Subscriber Identity (IMSI) to identify the region from which mobile subscriber belongs. The first digit of the MCC specifies the geographical correlation of the GSM service provider.


2 Answers

To change what TelephonyManager.getSimCountryIso() returns, simply execute

adb shell setprop gsm.sim.operator.iso-country no

and it now returns no (Norway).

If you want to change what TelephonyManager.getSimOperator() returns (MCC+MNC) then execute

adb shell setprop gsm.sim.operator.numeric 24201

and you have changed MCC to 242 (Norway) and MNC to 01 (Telenor).

To see which other properties you can change then execute

adb shell getprop

This is verified to work on both AVD and Genymotion. However, this does not change these properties persistently.

like image 87
Espen Riskedal Avatar answered Oct 09 '22 02:10

Espen Riskedal


I have observed that value for this properties varies in some API level. I have tried to address this issue.

You can use following command to change the value on API 26:

  1. adb shell
  2. su
  3. setprop gsm.operator.numeric 280701

Note: Some emulators require restart.

On some emulators the property can be different name

You can find the property name as follows:

  1. adb shell
  2. getprop

It will give you data similar to following:

...
[dalvik.vm.lockprof.threshold]: [500]
[dalvik.vm.stack-trace-file]: [/data/anr/traces.txt]
[dalvik.vm.usejit]: [true]
[dalvik.vm.usejitprofiles]: [true]
[debug.atrace.tags.enableflags]: [0]
[debug.force_rtl]: [0]
[dev.bootcomplete]: [1]
[drm.service.enabled]: [true]
[gsm.current.phone-type]: [1]
[gsm.defaultpdpcontext.active]: [true]
[gsm.network.type]: [LTE]
[gsm.nitz.time]: [1524141151210]
[gsm.operator.alpha]: [Android]
[gsm.operator.iso-country]: [us]
[gsm.operator.isroaming]: [false]
[gsm.operator.numeric]: [310260]
[gsm.sim.operator.alpha]: [Android]
[gsm.sim.operator.iso-country]: [us]
[gsm.sim.operator.numeric]: [310260]
[gsm.sim.state]: [READY]
[gsm.version.baseband]: [1.0.0.0]
[gsm.version.ril-impl]: [android reference-ril 1.0]
[hwservicemanager.ready]: [true]
[init.svc.adbd]: [running]
[init.svc.audio-hal-2-0]: [running]
[init.svc.audioserver]: [running]
[init.svc.bootanim]: [stopped]
[init.svc.camera-provider-2-4]: [running]
[init.svc.cameraserver]: [running]
...

Search for numeric by copying the output in text file. Get the property name and use setprop <property name> <new MCC MNC>

You can also use getProp to verify whether the value has been changed.

like image 39
Sagar Avatar answered Oct 09 '22 02:10

Sagar