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

后端 未结 6 468
隐瞒了意图╮
隐瞒了意图╮ 2020-12-25 08:18

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

It seems like it is hardcoded to mcc310 (US). I can read thi

6条回答
  •  一向
    一向 (楼主)
    2020-12-25 09:12

    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

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

提交回复
热议问题