How to change mobile phone code (MCC) in Android emulator?

My Android application should respond differently to different codes of mobile countries.

It seems to be tightly attached to mcc310 (US) . I can read this value from TelephonyManager.getSimCountryIso() or using the resource folder, for example res/values-mcc123/ , but how to set this value in the emulator?

+14
android android-emulator mobile-country-code mcc
source share
7 answers

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

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

and now it returns no (Norway).

If you want to change what TelephonyManager.getSimOperator() (MCC + MNC) returns, do

 adb shell setprop gsm.sim.operator.numeric 24201 

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

To find out what other properties you can change, do

 adb shell getprop 

This has been tested to work with both AVD and Genymotion. However, this does not change these properties persistently.

+12
source share

I noticed that the value for these properties varies depending on the API level. I tried to solve this problem.

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

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

Note. Some emulators require a reboot.

On some emulators, the property may have a different name.

You can find the property name as follows:

  1. adb shell
  2. getprop

This will give you data like the 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 a text file. Get property name and use setprop <property name> <new MCC MNC>

You can also use getProp to check if a value has been changed.

+2
source share

Changing the MCC + MNC in the emulator can only be done using ADB. To change the MCC + MNC in the emulator, connect to the ADB, do the following

 adb -s 127.0.0.1:53001 shell 

Then enter the country code. 23801 - Danish coutry code.

 setprop persist.<name of the emulator>.mccmnc 23801 

For the Droid4X emulator, this is

 setprop persist.droid4x.mccmnc 23801 

Reboot the emulator.

+1
source share

In the emulator: go to Settings-> Wired and Network-> Mobile network-> Names of access points. Try changing the MCC value in the APN set, and then try the code.

0
source share

Be aware that relying on MCC is not always right in every country. Digicell, for example, uses one MCC + MNC in several countries. Also understand that the whole idea of โ€‹โ€‹MCC is quite ridiculous in terms of network. It doesnโ€™t matter at all whether you are in Germany or the Netherlands if you are on T-Mobile with an AT & T phone both times.

0
source share

It seems that it is not possible to change the MCC / MNC using the settings on the Android emulator, every time this is done, the pre-configured "T-Mobile" APN will disappear from the list and the network connection will be lost. I even had an emulator that rebooted spontaneously after the change.

The software method also does not work, APN will disappear immediately after:

 root@generic _x86:/ # content update --uri content://telephony/carriers/ --bind name:s:'TheAPN' --bind apn:s:apn.operator.net --bind numeric:i:12345 --bind user:s: --bind password:s: --bind server:s: --bind proxy:s: --bind mmsproxy:s: --bind mmsc:s: --bind type:s: --bind mcc:i:123 --bind mnc:i:45 --bind current:i:1 --where _id=1 

This could hack the emulator in the same ways that allow you to change the MSISDN or IMEI .

0
source share

I do not want to change anything, I only register MCC ... in a file and send it to a PC. WIFI seems impossible; then it will be by mail.

0
source share

All Articles