AOSP UI Customization: Runtime Resource Overlay

In this article, we will explore RRO and its significance within the Android Open Source Project (AOSP).

Narendra Harny
Make Android
4 min readNov 29, 2023

--

Photo by Steven Lewis on Unsplash

Android suggests a way of customization and flexibility for device manufacturers and developers using one of the key features that allow UI modification on top of existing Android Applications and Framework UI as an extension which is the Runtime Resource Overlay (RRO) system.

What is Runtime Resource Overlay?

Runtime Resource Overlay, usually shortened as RRO, is a technique in Android AOSP that permits developers and device manufacturers to construct dynamic modifications to the resources of an Android application at runtime. These resources contain components like XML layouts, drawables (icons, images), styles, and more, which all together illustrate the user interface and appearance of any Android Application.

The RRO technique is a defined standard way to customize the UI component of an application without doing modifications to the original resources associated with it. We can say the original resources of an application can be overlapped with the provided resources by RRO.

Resources!!

All UI components like those mentioned above all XMLs, Layout, Strings, Colors, Styles, Theme, images, icons(drawable) and everything present in the “res” section in the Android application and framework source are considered as “Can be Customized” know as resources for RRO.

How RRO works?

The below flow of the diagram shows how the RRO APK and Original Application APK will be placed into to system. The “Idmap” file will be generated and placed into the system which contains all the resource mapping tables for both packages and the most suitable resourced ID will be picked to reflect the the UI design for the visible UI component on the Android device.

RRO Internal work mechanism

Mechanism:
RRO is implemented using a mechanism comprehended as “Resource Overlay Packages” (ROPs). Individual ROP is a separate APK (Android Package) file that contains resources to be overlaid at runtime. These resources can enclose layouts, images, animations, values (e.g., strings, dimensions), or any other resource which the application uses as part of user interface creation.

Structure:
An ROP includes a directory structure that reflects the resource structure of the app it overlays. For example, if we want to modify the design of a specific activity, you would position an altered layout XML file in the ROP with the same path as the actual layout in the app.

Prioritization:
RROs have a priority order, which specifies the order in which they are applicable. When considerable overlays are available for an app, the system uses them in order of priority, with the higher-priority overlays taking precedence.

Resource Matching:
When an app asks for a resource (e.g., a layout file), the system first inspects for overlays that correspond to the package and resource name. If a matching overlay is found with a higher priority(sometimes optional) than others, its resource will utilized instead of the original.

Dynamic Theming:
RRO allows for dynamic theming of apps without altering their source code, meaning it can change an app’s look and feel by applying different overlays.

Important files in AOSP to Implement RRO

User Interface which required to be Overlaid!! following resources to be added as part of the source whether it is Android Applications or AOSP Source.

RRO components!!

Why RROs?

Before implementing RROs, we should know the limitations of RROs!!!

You can not use Runtime resource overlay on Java Source to customize the functionality.

  1. The idea behind RROs is to avoid modifying the existing resources and customize the UI.
  2. RRO concepts say, to place the overlaying resources in one place and overlaid resources in different places in AOSP sources and can replace them with original resources.
  3. This flexibility of RROs avoiding the modification in actual resources certainly benefits device manufacturers for leisurely future updates.

Thanks for Reading! If this article was helpful. Please hit the clap!

Follow on medium https://medium.com/@narendra147h

Connect on Linked In: linkedin.com/in/narendraharny

Please Follow & subscribe to Make Android Publication by Narendra K H for prompt updates on Android platform-related blogs.

Thank you!

--

--

Narendra Harny
Make Android

Connect on https://medium.com/make-android | Write On, Android AOSP & Applications | Python | DevOps | Java | C++ | Kotlin | Shell | Linux | Android Auto | IVI