An average Android user installs 50+ apps on their devices (the number increases as the RAM-tier of devices increases). However, a significant number of these apps go unused by the user for a long period of time.
App hibernation hibernates apps that the user does not use for a few months, similar to permission auto-revocation. This force-stops the app and puts it into a state where we optimize for storage rather than performance. Permission auto-revoke is also bundled with this state and they share the same exemption setting in Settings. A force stopped app doesn't run jobs or alerts in the background and isn't able to send push notifications. When the user uses the app again, the app exits hibernation and jobs/alerts/notifications run again as usual. Any jobs/alerts/notifications that were scheduled before the app went into hibernation need to be re-scheduled.
OEMs modifying the platform may conflict with the app hibernation implementation. For example
- Modifying the app usage definition or introducing ways of waking up an app that aren’t in AOSP may interrupt app hibernation’s accuracy
- An OEM’s proprietary restriction mechanism similar to app hibernation may perform a similar purpose. While both can exist, there may be some overlap.
CDD outlines a new set of requirements for changes that are based on app usage, similar to the existing 3.5.1 requirement. App hibernation follows these requirements.
The framework code lives in:
- repo: platform/frameworks/base
- directory: services/core/java/com/android/server/apphibernation
The policy logic lives in:
- repo: platform/packages/modules/Permission
- directory: PermissionController/src/com/android/permissioncontroller/hibernation
The App Hibernation system service optimizes a user’s infrequently used apps for storage and prevents those apps from running in the background. To achieve these results, when we hibernate an app, we specifically:
- Auto-revoke permissions
- Force-Stop the app
- Delete the ODEX and VDEX files
- Delete the app cache
Our goal is to implement hibernation as a reversible action so that the app is still available to the user via Launcher and other surfaces with app data intact. Upon launching the app, we will restore it back from the force-stop state and continue with the ODEX and VDEX file creation as usual.
The planned design centers around two main parts:
- determining when a package should hibernate
- optimizing the hibernating package
A new system service,
AppHibernationService, and a job service,
PermissionController is the glue that controls the overall decision
making and logic.
Determining when a package should hibernate is primarily powered by
UsageStatsService and managed by
PermissionController. This policy logic lives in
allow us to dynamically update via Mainline. In addition, we plan on adding
a new signal, component usage, to capture usage of the package’s components
(for example, services, content providers) as a new
Optimizing a package is where all the actual savings/optimizations
AppHibernationService communicates with various parts of the system
to stop the package, delete cache data, delete ART artifacts, and so on. Permission
revocation is directly initiated from
AppHibernationJobService to retain
auto-revoke functionality on Android 11 and
The user is provided with both information and controls over which apps can be hibernated.
Similar to auto-revoke, the user gets a notification about which apps are hibernated and has the option to go to the Settings directly from the notification to either open the app and bring it out of hibernation or delete the unused app if required.
We continue to support the developer's intent of asking the user for an exemption from hibernation via the existing permissions auto-revoke exemption intent.
Hibernation-specific features are available starting Android 12. These feature could not function on earlier versions since the platform components (such as. the new system service) are not present. Auto-revoke continues to function as implemented currently for the earlier OS versions.
Starting Android 12, to ensure backward compatibility, a hibernation toggle is added on the app's page under Apps & notifications in Settings while keeping the original auto-revoke toggle within the Permissions sub-menu. This toggle controls the overall App Hibernation system exemption for the app.
Since some of the implementation is part of modular system component, partners are discouraged from modifying the feature. Partners can instead implement similar features/functionality as long as they follow the CDD requirements.
App hibernation should default to ON for all apps targeting Android 11 or above. This is the same as permissions auto-revoke. While the setting itself may be ON, the app hibernation implementation may differ between apps targeting Android 11 versus Android 11 (namely, app hibernation only works for apps targeting Android 11 whereas it is essentially just auto-revoke for apps targeting Android 11.
Additionally, OEMs may be implementing a similar feature. However, those features are targeted on a much shorter timescale for battery optimizations which can be OEM specific. Any similar app restriction features developed by OEMs can co-exist with the App Hibernation system as long as they meet the existing criteria defined in CDD.
App hibernation has CTS and unit tests to ensure it is working correctly.