首页 > 解决方案 > 未向应用程序提供运营商特权

问题描述

我正在开发一个应该获得 Carrier Privileges 的应用程序。我们有一张 eSIM 卡,它已经有一个 SHA-1 和一个密钥库的指纹,用于对写入它的应用程序进行签名,但应用程序无法获得权限。

为了获得访问权限,应用程序是否应该调用任何东西?

我有扩展 CarrierService 的服务正在运行,但它似乎根本没有调用 onLoadConfig 方法。

标签: android

解决方案


我相信这里的文档是不正确的。它说使用:

<service android:name=".SampleCarrierConfigService"
android:label="@string/service_name"
android:permission="android.permission.BIND_CARRIER_SERVICES">
      <intent-filter>
      <action android:name="android.service.carrier.ConfigService"/></intent-filter>
</service>

但我认为你需要<action android:name="android.service.carrier.CarrierService"/>改用。

至少当我们使用文档版本时,我们的 onLoadConfig 不会被调用,而当我们使用 android.service.carrier.ConfigService 时,我们确实会收到回调。

您可以做的另一件事是在您的应用程序中调用类似这样的东西(只是在常规活动中,而不是在服务中):

    val telephonyManager =
        context?.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
    val haspriv = telephonyManager.hasCarrierPrivileges()
    Log.d(TAG, "priv: $haspriv")

如果 telephonyManager.hasCarrierPrivileges() 返回 true,您就知道签名检查是正确的。这与服务无关;您可以拥有一个具有运营商权限的应用程序,而无需实现 android.service.carrier.ConfigService。(我不知道你为什么要这样做,但这是可能的。)


推荐阅读