Android R new Api isAutoRevokeWhitelisted始终为false,即使打开/关闭手动权限重置

问题描述

因此,在Android R上,如果应用未使用操作系统,则用户现在可以选择允许操作系统撤销给定的权限。此新设置将在应用设置的权限部分提供(请检查屏幕截图以供参考),默认情况下,根据当前的Beta行为,该功能处于关闭状态

https://developer.android.com/preview/privacy/permissions#auto-reset

enter image description here

添加了一个api来跟踪当前您的应用是否在给定的白名单中

https://developer.android.com/reference/android/content/pm/PackageManager#isAutoRevokeWhitelisted()。我试过测试,但是即使打开或关闭设置,api始终返回false。想知道是否还有其他人遇到过这个问题。

我检查了日志,并看到了一些日志,这使我感到即使将其选项打开后,它实际上并没有添加到白名单中

2020-08-14 03:04:26.002 7005-7047/? I/AppPermissionGroupsViewModel: sessionId 5928824040472035289 setting auto revoke enabled to true forcom.abc.xyz UserHandle{0}
2020-08-14 03:04:26.007 864-3020/? D/audio_hw_primary: enable_snd_device: snd_device(2: speaker)
2020-08-14 03:04:26.007 7005-7283/? W/AutoRevokePermissions: Error carrier privileged status for com.abc.xyz: -1
2020-08-14 03:04:26.007 864-3020/? D/audio_route: Apply path: speaker
2020-08-14 03:04:26.007 7005-7283/? I/AutoRevokePermissions: Parsed teamfood setting value: null
2020-08-14 03:04:26.007 7005-7283/? I/chatty: uid=10187(com.google.android.permissioncontroller) pool-2-thread-7 identical 1 line
2020-08-14 03:04:26.007 7005-7283/? I/AutoRevokePermissions: Parsed teamfood setting value: null

解决方法

您可能已将targetSDK设置为29,我也遇到了不正确的API工作。但是,如果我将targetSDK设置为30,它将恢复正常。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...