Auto Revoke Permissions settings panel missing on some apps (Android 11 API/System)

Viewed 1206

I'm trying to whitelist some of my enterprise apps to avoid the auto-reset of runtime permissions, because they are background applications and users do not interact very often with them.

But it seems (https://issuetracker.google.com/issues/170968725) that a new manifest attribute " autoRevokePermissions " isn't working (anymore or for now, I don't know because its new on API lvl 30 BUT its also not working AND bypassed by system...).

So I'm trying to ask user permisison for this action, like explained here : https://developer.android.com/guide/topics/permissions/overview#auto-reset-permissions-unused-apps

My problem is, on some of the apps, this section of settings is totally gone. No switch or information when I dive to permissions settings. I install them from Android Studio I've updated targetSdkVersion on all, the configurations seems similar...

Does anyone know why I encounter this issue ?

Is there a third way to put this new setting off ? I'm trying with packageManager.setAutoRevokeWhitelisted but java.lang.SecurityException: Caller must either hold android.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS or be the installer on record ... and don't know how to do those)

Thx for the possibles answers, clues or bypasses^^

(and really sorry for bad english ;)

2 Answers

I've got an official answer from Google developpers Team :

"The toggle is disabled for some apps that perform a background service, including device admin apps Whenever the toggle is hidden/disabled the app is already exempted from auto revoke"

Source : https://issuetracker.google.com/issues/172325509

My problem is finally solved by itself !

Please try these steps:

1.setAutoRevokeWhitelisted:

PackageManager pm = getPackageManager();
pm.setAutoRevokeWhitelisted(getPackageName(), true);
boolean result = pm.isAutoRevokeWhitelisted(); // result should be true

2.in AndroidManifest.xml:

<uses-permission android:name="android.permission.WHITELIST_AUTO_REVOKE_PERMISSIONS" />

3.sign your app with platform key (see example), use in build.gradle app:

signingConfigs {
        sign_platform {
            keyPassword 'android'
            storeFile file('platform.keystore')
            storePassword 'android'
            keyAlias 'platform'
        }
}

defaultConfig {
   signingConfig signingConfigs.sign_platform
}
Related