我正在开发一项功能,在安装 Sim 并且应用程序获得运营商权限后,我需要为我们的订阅更新一些 CarrierConfig。现在应用程序成功获得了 Carrier 权限,但不知何故 CarrierService 没有被执行。 onLoadConfig 方法都没有被调用。
下面是我的服务
class SampleCarrierConfigService : CarrierService() {
override fun onLoadConfig(id: CarrierIdentifier?): PersistableBundle {
val config = PersistableBundle()
config.putBoolean(
CarrierConfigManager.KEY_CARRIER_VOLTE_AVAILABLE_BOOL, true
)
config.putBoolean(
CarrierConfigManager.KEY_CARRIER_VOLTE_TTY_SUPPORTED_BOOL, false
)
config.putInt(CarrierConfigManager.KEY_VOLTE_REPLACEMENT_RAT_INT, 6)
// Check CarrierIdentifier and add more config if needed…
return config
}
companion object {
private const val TAG = "SampleCarrierConfig"
}
init {
Log.d(TAG, "Service created")
}
}
这是我在 list 中注册它的方式
<service
android:name=".SampleCarrierConfigService"
android:label="carrier_config_service"
android:permission="android.permission.BIND_CARRIER_SERVICES">
<intent-filter>
<action android:name="android.service.carrier.CarrierService" />
</intent-filter>
<meta-data
android:name="android.service.carrier.LONG_LIVED_BINDING"
android:value="true" />
</service>
最佳答案
这是特权权限。
您可以引用下面的代码。
https://android.googlesource.com/platform/packages/apps/CarrierConfig/+/refs/heads/master/Android.bp
android_app { 名称:“运营商配置”, srcs: ["src/**/*.java"], platform_apis:是的, 证书:“平台”, system_ext_specific: true, 特权:真实, 必需:["privapp_whitelist_com.android.carrierconfig"], 优化:{ proguard_flags_files:[“proguard.flags”], }, aaptflags: ["--keep-raw-values"],
关于android - 即使在获得运营商特权后也不会调用 CarrierService.onLoadConfig,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71531727/