<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Android 12: Turning off revocation of permissions of unused apps</title>
	<atom:link href="http://billauer.se/blog/2022/09/android-12-opt-out-hibernation/feed/" rel="self" type="application/rss+xml" />
	<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/</link>
	<description>Anything I found worthy to write down.</description>
	<lastBuildDate>Thu, 26 Mar 2026 13:15:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>By: Serge</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1850</link>
		<dc:creator>Serge</dc:creator>
		<pubDate>Tue, 19 Aug 2025 19:22:39 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1850</guid>
		<description>You can add this script to autostart, and every time phone reboot it will disable REVOKE_PERMISSIONS_IF_UNUSED for every installed user packages.

PID=`cut -d &quot; &quot; -f 4 /proc/self/stat` ; renice -n 19 $PID ; ionice -c 3 -p $PID ; chrt -i 0 -p $PID ; for i in `pm list users &#124; awk -F&#039;[{:]&#039; &#039;/UserInfo/ {print $2}&#039;` ; do echo $i ; pm list packages -i --user $i &#124; awk -F &#039;[: ]+&#039; &#039;!/installer=null/ {print $2}&#039; &#124; xargs -P 100 -n1 -r sh -c &#039;cmd appops set &quot;$1&quot; AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore&#039; &#039;&#039; ; done ; cmd appops write-settings</description>
		<content:encoded><![CDATA[<p>You can add this script to autostart, and every time phone reboot it will disable REVOKE_PERMISSIONS_IF_UNUSED for every installed user packages.</p>
<p>PID=`cut -d &#8221; &#8221; -f 4 /proc/self/stat` ; renice -n 19 $PID ; ionice -c 3 -p $PID ; chrt -i 0 -p $PID ; for i in `pm list users | awk -F&#8217;[{:]&#8216; &#8216;/UserInfo/ {print $2}&#8217;` ; do echo $i ; pm list packages -i &#8211;user $i | awk -F &#8216;[: ]+&#8217; &#8216;!/installer=null/ {print $2}&#8217; | xargs -P 100 -n1 -r sh -c &#8216;cmd appops set &#8220;$1&#8243; AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore&#8217; &#8221; ; done ; cmd appops write-settings</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Molly</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1835</link>
		<dc:creator>Molly</dc:creator>
		<pubDate>Sat, 26 Apr 2025 06:49:17 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1835</guid>
		<description>Better, use this URL - no smart quote replacement, etc.: https://pastebin.com/drYvgBw0</description>
		<content:encoded><![CDATA[<p>Better, use this URL &#8211; no smart quote replacement, etc.: <a href="https://pastebin.com/drYvgBw0" rel="nofollow">https://pastebin.com/drYvgBw0</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Molly</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1834</link>
		<dc:creator>Molly</dc:creator>
		<pubDate>Sat, 26 Apr 2025 06:46:13 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1834</guid>
		<description># You try this at your own risk, offered with no warranty, etc. but to my current knowledge does not make your computer turn into a duck.

# MAY TOGGLE THE FEATURE OFF SYSTEM-WIDE:

# adb shell device_config put app_hibernation app_hibernation_enabled false
# adb shell device_config set_sync_disabled_for_tests persistent
# adb shell settings put global auto_revoke_permissions_if_unused 0

# TOGGLES &#039;MANAGE APP IF UNUSED&#039; OPTION OFF FOR EVERY APP:
# (PowerShell)

$packages = adb shell &quot;pm list packages -3&quot; &#124; ForEach-Object { $_.Trim() }
foreach ($pkg in $packages) {
    if ($pkg -match &quot;package:(.+)&quot;) {
        $packageName = $Matches[1]
        adb shell &quot;appops set $packageName AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore&quot;
    }
}

# RESTORATION OF LOST PRIVILEGES - CAUTION: THIS PROGRAMATICALLY GIVES AN APP EVERY PRIVILEGE IT IS ASKING FOR:
# (also PowerShell)

# Function to get an app&#039;s requested permissions
function Get-AppPermissions {
    param (
        [string]$packageName
    )

    # Get the runtime permissions for the app - focus on permissions with granted=false
    $permissions = adb shell dumpsys package $packageName &#124;
                  Select-String -Pattern &quot;android\.permission\.[A-Z_]+:.*granted=(false&#124;true)&quot; -AllMatches &#124;
                  ForEach-Object { $_.Matches } &#124;
                  ForEach-Object {
                      if ($_.Value -match &quot;(android\.permission\.[A-Z_]+)&quot;) {
                          $Matches[1]
                      }
                  } &#124;
                  Sort-Object -Unique

    return $permissions
}

# List of permissions to exclude (non-changeable or not relevant for granting)
$excludedPermissions = @(
    &quot;android.permission.FOREGROUND_SERVICE&quot;,
    &quot;android.permission.INTERNET&quot;,
    &quot;android.permission.ACCESS_NETWORK_STATE&quot;,
    &quot;android.permission.WAKE_LOCK&quot;,
    &quot;android.permission.RECEIVE_BOOT_COMPLETED&quot;,
    &quot;android.permission.VIBRATE&quot;,
    &quot;android.permission.BLUETOOTH&quot;,
    &quot;android.permission.READ_APP_BADGE&quot;
)

# Get all third-party packages
$packages = adb shell &quot;pm list packages -3&quot; &#124; ForEach-Object {
    if ($_ -match &quot;package:(.+)&quot;) {
        $Matches[1]
    }
}

$successCount = 0
$failCount = 0

# For each package, get its permissions and try to grant them
foreach ($package in $packages) {
    Write-Host &quot;Processing package: $package&quot; -ForegroundColor Cyan

    # Get permissions for this package
    $permissions = Get-AppPermissions -packageName $package

    if ($permissions.Count -eq 0) {
        Write-Host &quot;  No permissions found for $package&quot; -ForegroundColor Yellow
        continue
    }

    # Filter out excluded permissions
    $filteredPermissions = $permissions &#124; Where-Object { $excludedPermissions -notcontains $_ }

    Write-Host &quot;  Found $($filteredPermissions.Count) grantable permissions&quot;

    # Try to grant each permission
    foreach ($permission in $filteredPermissions) {
        # Try to grant the permission, but don&#039;t display errors
        $result = adb shell &quot;pm grant $package $permission 2&gt;&amp;1&quot;

        # Check if the grant was successful
        if ($result -match &quot;Exception&quot;) {
            # Do nothing for failures - they&#039;re too common and noisy
            $failCount++
        } else {
            Write-Host &quot;  Granted: $permission&quot; -ForegroundColor Green
            $successCount++
        }
    }

    # Set AUTO_REVOKE_PERMISSIONS_IF_UNUSED to ignore
    adb shell &quot;appops set $package AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore&quot; &#124; Out-Null
}

Write-Host &quot;`nPermissions Summary:&quot; -ForegroundColor Cyan
Write-Host &quot;  Successfully granted: $successCount&quot; -ForegroundColor Green
Write-Host &quot;  Failed to grant: $failCount&quot; -ForegroundColor Yellow
Write-Host &quot;All packages processed.&quot; -ForegroundColor Cyan</description>
		<content:encoded><![CDATA[<p># You try this at your own risk, offered with no warranty, etc. but to my current knowledge does not make your computer turn into a duck.</p>
<p># MAY TOGGLE THE FEATURE OFF SYSTEM-WIDE:</p>
<p># adb shell device_config put app_hibernation app_hibernation_enabled false<br />
# adb shell device_config set_sync_disabled_for_tests persistent<br />
# adb shell settings put global auto_revoke_permissions_if_unused 0</p>
<p># TOGGLES &#8216;MANAGE APP IF UNUSED&#8217; OPTION OFF FOR EVERY APP:<br />
# (PowerShell)</p>
<p>$packages = adb shell &#8220;pm list packages -3&#8243; | ForEach-Object { $_.Trim() }<br />
foreach ($pkg in $packages) {<br />
    if ($pkg -match &#8220;package:(.+)&#8221;) {<br />
        $packageName = $Matches[1]<br />
        adb shell &#8220;appops set $packageName AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore&#8221;<br />
    }<br />
}</p>
<p># RESTORATION OF LOST PRIVILEGES &#8211; CAUTION: THIS PROGRAMATICALLY GIVES AN APP EVERY PRIVILEGE IT IS ASKING FOR:<br />
# (also PowerShell)</p>
<p># Function to get an app&#8217;s requested permissions<br />
function Get-AppPermissions {<br />
    param (<br />
        [string]$packageName<br />
    )</p>
<p>    # Get the runtime permissions for the app &#8211; focus on permissions with granted=false<br />
    $permissions = adb shell dumpsys package $packageName |<br />
                  Select-String -Pattern &#8220;android\.permission\.[A-Z_]+:.*granted=(false|true)&#8221; -AllMatches |<br />
                  ForEach-Object { $_.Matches } |<br />
                  ForEach-Object {<br />
                      if ($_.Value -match &#8220;(android\.permission\.[A-Z_]+)&#8221;) {<br />
                          $Matches[1]<br />
                      }<br />
                  } |<br />
                  Sort-Object -Unique</p>
<p>    return $permissions<br />
}</p>
<p># List of permissions to exclude (non-changeable or not relevant for granting)<br />
$excludedPermissions = @(<br />
    &#8220;android.permission.FOREGROUND_SERVICE&#8221;,<br />
    &#8220;android.permission.INTERNET&#8221;,<br />
    &#8220;android.permission.ACCESS_NETWORK_STATE&#8221;,<br />
    &#8220;android.permission.WAKE_LOCK&#8221;,<br />
    &#8220;android.permission.RECEIVE_BOOT_COMPLETED&#8221;,<br />
    &#8220;android.permission.VIBRATE&#8221;,<br />
    &#8220;android.permission.BLUETOOTH&#8221;,<br />
    &#8220;android.permission.READ_APP_BADGE&#8221;<br />
)</p>
<p># Get all third-party packages<br />
$packages = adb shell &#8220;pm list packages -3&#8243; | ForEach-Object {<br />
    if ($_ -match &#8220;package:(.+)&#8221;) {<br />
        $Matches[1]<br />
    }<br />
}</p>
<p>$successCount = 0<br />
$failCount = 0</p>
<p># For each package, get its permissions and try to grant them<br />
foreach ($package in $packages) {<br />
    Write-Host &#8220;Processing package: $package&#8221; -ForegroundColor Cyan</p>
<p>    # Get permissions for this package<br />
    $permissions = Get-AppPermissions -packageName $package</p>
<p>    if ($permissions.Count -eq 0) {<br />
        Write-Host &#8221;  No permissions found for $package&#8221; -ForegroundColor Yellow<br />
        continue<br />
    }</p>
<p>    # Filter out excluded permissions<br />
    $filteredPermissions = $permissions | Where-Object { $excludedPermissions -notcontains $_ }</p>
<p>    Write-Host &#8221;  Found $($filteredPermissions.Count) grantable permissions&#8221;</p>
<p>    # Try to grant each permission<br />
    foreach ($permission in $filteredPermissions) {<br />
        # Try to grant the permission, but don&#8217;t display errors<br />
        $result = adb shell &#8220;pm grant $package $permission 2&gt;&amp;1&#8243;</p>
<p>        # Check if the grant was successful<br />
        if ($result -match &#8220;Exception&#8221;) {<br />
            # Do nothing for failures &#8211; they&#8217;re too common and noisy<br />
            $failCount++<br />
        } else {<br />
            Write-Host &#8221;  Granted: $permission&#8221; -ForegroundColor Green<br />
            $successCount++<br />
        }<br />
    }</p>
<p>    # Set AUTO_REVOKE_PERMISSIONS_IF_UNUSED to ignore<br />
    adb shell &#8220;appops set $package AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore&#8221; | Out-Null<br />
}</p>
<p>Write-Host &#8220;`nPermissions Summary:&#8221; -ForegroundColor Cyan<br />
Write-Host &#8221;  Successfully granted: $successCount&#8221; -ForegroundColor Green<br />
Write-Host &#8221;  Failed to grant: $failCount&#8221; -ForegroundColor Yellow<br />
Write-Host &#8220;All packages processed.&#8221; -ForegroundColor Cyan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sudhakar</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1794</link>
		<dc:creator>sudhakar</dc:creator>
		<pubDate>Sun, 04 Aug 2024 06:13:54 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1794</guid>
		<description>playing silent mp3 instead of sleep (termux).</description>
		<content:encoded><![CDATA[<p>playing silent mp3 instead of sleep (termux).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Androidguy</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1752</link>
		<dc:creator>Androidguy</dc:creator>
		<pubDate>Fri, 05 Jan 2024 18:19:51 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1752</guid>
		<description>Hi does Android have a macro program that could set a cron-like job that would go into each app and set the correct permission say once a day at 3:00 a.m. for example?  This is sort of cheesy but you wouldn&#039;t have to go into a hundred apps or update new apps this way. Also have any enhancements been added after Android 12 to fix this issue universally?  Also does rooting the phone give any more control over annoying stuff like this?</description>
		<content:encoded><![CDATA[<p>Hi does Android have a macro program that could set a cron-like job that would go into each app and set the correct permission say once a day at 3:00 a.m. for example?  This is sort of cheesy but you wouldn&#8217;t have to go into a hundred apps or update new apps this way. Also have any enhancements been added after Android 12 to fix this issue universally?  Also does rooting the phone give any more control over annoying stuff like this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Pruss</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1721</link>
		<dc:creator>Alexander Pruss</dc:creator>
		<pubDate>Sun, 10 Sep 2023 21:51:48 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1721</guid>
		<description>Two more ideas (in root shell):

pm disable  com.google.android.permissioncontroller/com.android.permissioncontroller.permission.service.AutoRevokeService

pm disable com.google.android.permissioncontroller/com.android.permissioncontroller.permission.service.AutoRevokeOnBootReceiver

&lt;strong&gt;(Webmaster note: The commands are not fully visible as displayed. Copy-Paste the entire comment into an editor in order to see the complete commands). &lt;/strong&gt;</description>
		<content:encoded><![CDATA[<p>Two more ideas (in root shell):</p>
<p>pm disable  com.google.android.permissioncontroller/com.android.permissioncontroller.permission.service.AutoRevokeService</p>
<p>pm disable com.google.android.permissioncontroller/com.android.permissioncontroller.permission.service.AutoRevokeOnBootReceiver</p>
<p><strong>(Webmaster note: The commands are not fully visible as displayed. Copy-Paste the entire comment into an editor in order to see the complete commands). </strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Pruss</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1720</link>
		<dc:creator>Alexander Pruss</dc:creator>
		<pubDate>Sun, 10 Sep 2023 21:34:49 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1720</guid>
		<description>According to https://developer.android.com/topic/performance/app-hibernation , jobscheduler job id #2 for com.google.android.permissioncontroller may controls this.

So perhaps canceling job id #2 will work? Alas, it turns back on on every reboot. I am experimenting with having tasker run  
cmd jobscheduler cancel com.google.android.permissioncontroller 2 
on every boot, in a root shell. I fear that the job may still run before tasker cancels it.</description>
		<content:encoded><![CDATA[<p>According to <a href="https://developer.android.com/topic/performance/app-hibernation" rel="nofollow">https://developer.android.com/topic/performance/app-hibernation</a> , jobscheduler job id #2 for com.google.android.permissioncontroller may controls this.</p>
<p>So perhaps canceling job id #2 will work? Alas, it turns back on on every reboot. I am experimenting with having tasker run<br />
cmd jobscheduler cancel com.google.android.permissioncontroller 2<br />
on every boot, in a root shell. I fear that the job may still run before tasker cancels it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eli</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1677</link>
		<dc:creator>eli</dc:creator>
		<pubDate>Sat, 06 May 2023 02:31:02 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1677</guid>
		<description>Thanks for that. I&#039;ve added a note in the post mentioning this comment.

I haven&#039;t tried this myself (yet?). I can however confirm that appops knows about AUTO_REVOKE_PERMISSIONS_IF_UNUSED as an OP on my phone.

I&#039;ll add a couple of links on this matter: https://automationchronicles.com/set-permissions-via-adb-and-appops-command/ and https://developer.android.com/reference/android/app/AppOpsManager

For general knowledge, the list of AppOps can found as the RUNTIME_AND_APPOP_PERMISSIONS_OPS array on https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/AppOpsManager.java

It would have been much nicer to change the default permission for this OP to &quot;ignore&quot; (which means disallow). That would be a catch-all solution for this problem. Not sure if this is possible, though.</description>
		<content:encoded><![CDATA[<p>Thanks for that. I&#8217;ve added a note in the post mentioning this comment.</p>
<p>I haven&#8217;t tried this myself (yet?). I can however confirm that appops knows about AUTO_REVOKE_PERMISSIONS_IF_UNUSED as an OP on my phone.</p>
<p>I&#8217;ll add a couple of links on this matter: <a href="https://automationchronicles.com/set-permissions-via-adb-and-appops-command/" rel="nofollow">https://automationchronicles.com/set-permissions-via-adb-and-appops-command/</a> and <a href="https://developer.android.com/reference/android/app/AppOpsManager" rel="nofollow">https://developer.android.com/reference/android/app/AppOpsManager</a></p>
<p>For general knowledge, the list of AppOps can found as the RUNTIME_AND_APPOP_PERMISSIONS_OPS array on <a href="https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/AppOpsManager.java" rel="nofollow">https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/AppOpsManager.java</a></p>
<p>It would have been much nicer to change the default permission for this OP to &#8220;ignore&#8221; (which means disallow). That would be a catch-all solution for this problem. Not sure if this is possible, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gene Cash</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1676</link>
		<dc:creator>Gene Cash</dc:creator>
		<pubDate>Fri, 05 May 2023 15:29:30 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1676</guid>
		<description>FYI, you might need to do &quot;appops write-settings&quot; afterwards to &quot;immediately write pending changes to storage&quot; - these settings changes do show up in the app info settings, but it doesn&#039;t seem to hurt.</description>
		<content:encoded><![CDATA[<p>FYI, you might need to do &#8220;appops write-settings&#8221; afterwards to &#8220;immediately write pending changes to storage&#8221; &#8211; these settings changes do show up in the app info settings, but it doesn&#8217;t seem to hurt.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gene Cash</title>
		<link>https://billauer.se/blog/2022/09/android-12-opt-out-hibernation/comment-page-1/#comment-1675</link>
		<dc:creator>Gene Cash</dc:creator>
		<pubDate>Fri, 05 May 2023 15:24:12 +0000</pubDate>
		<guid isPermaLink="false">https://billauer.se/blog/?p=6725#comment-1675</guid>
		<description>Sorry... I should not post too early in the morning.

I dug a bit more and discovered the &quot;appops&quot; command. The invocation we&#039;re interested in is:
appops set 10259 AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore

&quot;AUTO_REVOKE_PERMISSIONS_IF_UNUSED&quot; is the &quot;hibernation&quot; operation and we can do &quot;ignore&quot; or &quot;allow&quot; - note that it&#039;s case-sensitive.

It&#039;s a bit strange, as it operates differently depending if you give it a UID or a package name, and &quot;appops set org.genecash.garagedor AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore&quot; does not do what you want it to do.

I&#039;ve used the following to set all &quot;third-party&quot; (i.e. apps I&#039;ve installed personally) to not hibernate:
for uid in `pm list packages -U -3 &#124; awk &#039;{ print $3}&#039; FS=:` ; do appops set $uid AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore ; done</description>
		<content:encoded><![CDATA[<p>Sorry&#8230; I should not post too early in the morning.</p>
<p>I dug a bit more and discovered the &#8220;appops&#8221; command. The invocation we&#8217;re interested in is:<br />
appops set 10259 AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore</p>
<p>&#8220;AUTO_REVOKE_PERMISSIONS_IF_UNUSED&#8221; is the &#8220;hibernation&#8221; operation and we can do &#8220;ignore&#8221; or &#8220;allow&#8221; &#8211; note that it&#8217;s case-sensitive.</p>
<p>It&#8217;s a bit strange, as it operates differently depending if you give it a UID or a package name, and &#8220;appops set org.genecash.garagedor AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore&#8221; does not do what you want it to do.</p>
<p>I&#8217;ve used the following to set all &#8220;third-party&#8221; (i.e. apps I&#8217;ve installed personally) to not hibernate:<br />
for uid in `pm list packages -U -3 | awk &#8216;{ print $3}&#8217; FS=:` ; do appops set $uid AUTO_REVOKE_PERMISSIONS_IF_UNUSED ignore ; done</p>
]]></content:encoded>
	</item>
</channel>
</rss>
