在 Android 模拟器 API 24 Nougat 中更改 SimCountryIso

Changing the SimCountryIso in Android Emulator API 24 Nougat

到目前为止,我们一直在使用这种方法 How do I change the Mobile Country Code (MCC) in the Android Emulator? 来更改 sim 国家/地区值。由于我们 运行 我们的模拟设备 API 24,模拟器保持默认的美国国家代码。

这就是我们在 gradle 中 运行 的方式:

tasks.withType(Test) {
    systemProperties = System.getProperties()
    systemProperty "buildDir", "${buildDir}"
    systemProperty "file.encoding", "UTF8"

    beforeTest {
        logger.info "restoring android emulator SIM country to AT"
        exec {
            commandLine "bash", "-c", "source ~/.bash_profile && adb -e shell setprop gsm.sim.operator.iso-country at
            ignoreExitValue true
        }
    }
}

对我来说,当我 运行 在 AVD 版本 24+ 上以 root 用户身份执行此命令时它有效:

adb shell su root setprop gsm.sim.operator.iso-country at