android - 未向应用程序提供运营商特权
问题描述
我正在开发一个应该获得 Carrier Privileges 的应用程序。我们有一张 eSIM 卡,它已经有一个 SHA-1 和一个密钥库的指纹,用于对写入它的应用程序进行签名,但应用程序无法获得权限。
为了获得访问权限,应用程序是否应该调用任何东西?
我有扩展 CarrierService 的服务正在运行,但它似乎根本没有调用 onLoadConfig 方法。
解决方案
我相信这里的文档是不正确的。它说使用:
<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。(我不知道你为什么要这样做,但这是可能的。)
推荐阅读
- python - 需要在作者评论部分设置 current.username
- python - 过滤包含步行轨迹的数据集中的噪声
- sql - 在一个字段上连接两个表包含另一个字段
- javascript - forEach 循环中的 Promise
- python - 使用 2 格式 Python 更改类型列
- laravel - 在 laravel 中查询获取关系数据
- python - 在 Scrapy 中导入项目时的相对错误
- apache - 如何在内部代理上设置 apache HTTP 到 HTTPS 重定向?
- istio - 无法使用拒绝所有 GlobalNetworkPolicy 通过 Istio 连接到 EKS 上的应用程序
- c# - 如何在 Xamarin 中的模型中绑定列表对象