skip to Main Content

Since Android 11, there has been a system feature where it resets app permissions after a certain amount of time has passed and you haven’t used the app.

I know you can turn it off on most apps, by the user itself like the screenshot below :

auto revoke by user

and also it seems to turn back on when there are app or system updates.

How can I disable this function in my app by code or sth else?

2

Answers


  1. Well, I doubt there is an easy way.
    If your app is a device policy controller, it will not be set to hibernation (System exemptions from hibernation) or, if your app is a default handler for messages, phone, browser etc.

    What you can do, is to ask the user to disable auto revoke for your app. But you might have to do that after updates as well, if the system resets this privilege on your app (so your problem won’t be solved).

    The permissions you request in your app manifest (android:required="true") should never be revoked. But of course you cannot request every kind of permission that way. Some need to be requested explicitly.

    Apps using background services are whitelisted automatically as stated here. So you can declare a background service, if this is appropriate for you. But if there is nothing to be done, I could imagine, that the system removes your app from whitelist. (I didn’t test all of it)

    If you see this post you can also try

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

    and this in your manifest:

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

    But I actually doubt it works.

    Login or Signup to reply.
  2. i found article for your subject. It’s says,

    "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"

    Link to the article

    You can examine this if you want. I hope it helps you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search