RRO classes in AOSP
The handling of Runtime Resource Overlays (RROs) in AOSP (Android Open Source Project) is distributed across several classes and services. Let's break down the key components:
OverlayManagerService (OMS): This is the core service responsible for managing overlays in Android. Location:
frameworks/base/services/core/java/com/android/server/om/OverlayManagerService.java
Key responsibilities:Maintaining the state of all overlays
Handling enable/disable requests for overlays
Managing overlay priorities
ResourcesManagerService: This service works in conjunction with OMS to handle resource loading and overlay application. Location:
frameworks/base/core/java/android/app/ResourcesManager.java
Key responsibilities:Creating and caching Resources objects
Applying overlays when creating Resources objects
AssetManager: This class is responsible for loading resources and applying overlays at a lower level. Location:
frameworks/base/core/java/android/content/res/AssetManager.java
Key responsibilities:Loading resources from APKs and overlay packages
Applying idmap files for efficient overlay lookup
IdmapManager: This class handles the creation and management of idmap files, which are crucial for efficient overlay lookup. Location:
frameworks/base/cmds/idmap2/idmap2d/IdmapManager.cpp
Key responsibilities:Creating idmap files when overlays are installed or updated
Managing the lifecycle of idmap files
OverlayConfig: This class handles the configuration of overlays, including reading overlay-related properties from device configuration. Location:
frameworks/base/core/java/android/content/om/OverlayConfig.java
Key responsibilities:Reading and parsing overlay configuration
Providing configuration information to OMS
PackageManagerService: While not directly handling overlays, this service plays a crucial role in scanning and registering overlay packages. Location:
frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
Key responsibilities:Scanning installed packages and identifying overlays
Notifying OMS about new or updated overlay packages
ResourcesImpl: This class is responsible for the actual resource loading and is where much of the overlay application logic resides. Location:
frameworks/base/core/java/android/content/res/ResourcesImpl.java
Key responsibilities:Loading resources
Applying overlays during resource lookup
Here's a simplified flow of how these components interact:
PackageManagerService scans and identifies overlay packages during installation.
OverlayManagerService maintains the state of these overlays.
When an app requests a resource, ResourcesManagerService creates a Resources object.
ResourcesImpl, used by the Resources object, consults AssetManager for resource loading.
AssetManager uses idmap files (managed by IdmapManager) to efficiently apply overlays.
The resulting overlaid resource is returned to the app.
This system allows for efficient and flexible application of overlays while maintaining performance and stability.
Last updated