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:

  1. 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

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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:

  1. PackageManagerService scans and identifies overlay packages during installation.

  2. OverlayManagerService maintains the state of these overlays.

  3. When an app requests a resource, ResourcesManagerService creates a Resources object.

  4. ResourcesImpl, used by the Resources object, consults AssetManager for resource loading.

  5. AssetManager uses idmap files (managed by IdmapManager) to efficiently apply overlays.

  6. 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