com.android.providers.test,android P非systemuid应用如何通过反射调用hide接口——系统修改方案...

高通8909平台,项目需要集成GMS。开机后,SetupWizard一直报错,查看log发现是调用了系统的hide方法,显示Accessing hidden method进而报错java.lang.NoSuchMethodException。

百度找到了一篇入门贴:

https://blog.csdn.net/firedancer0089/article/details/82969969

然后找了一篇科普贴:

https://developer.android.com/distribute/best-practices/develop/restrictions-non-sdk-interfaces

官方科普贴有临时调试方案:

Android 9 (API level 28)

To enable access, use the following adb commands:

adb shell settings put global hidden_api_policy_pre_p_apps 1

adb shell settings put global hidden_api_policy_p_apps 1

To reset the API enforcement policy to the default settings, use the following commands:

adb shell settings delete global hidden_api_policy_pre_p_apps

adb shell settings delete global hidden_api_policy_p_apps

You can set the integer in the API enforcement policy to one of the following values:

0: Disable all detection of non-SDK interfaces. Using this setting disables all log messages for non-SDK interface usage and prevents you from testing your app using the StrictMode API. This setting is not recommended.

1: Enable access to all non-SDK interfaces, but print log messages with warnings for any non-SDK interface usage. Using this setting also allows you to test your app using the StrictMode API.

2: Disallow usage of non-SDK interfaces that belong to either the blacklist or the greylist and are restricted for your target API level.

设置0之后,重启设备可以解决我的问题,之后就找靠谱的解决方案。

可以从官方文档看到,除了临时调试方案,还有黑名单、灰名单和白名单,但是没有写如何修改。

重点来了,仅针对QC平台,我修改的文件:

frameworks/base/data/etc/hiddenapi-package-whitelist.xml

只需要加上应用包名即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值