An Android project that exposes only one devicename can still need two different power_profile.xml files, because the battery parameters for the two variants do not match. The existing implementation uses Missi's RRO overlay mechanism. That mechanism is tied to devicename: one devicename can only map to one power_profile.xml. Changing Missi's Java code is not an option under the current constraints, so the switching logic was moved to the vendor side. The trigger for choosing an overlay is a system property.

Two overlay APKs

The two overlays are packaged as separate APKs, for example:

  • xxx_1_overlay.apk
  • xxx_2_overlay.apk

The key resource is res/xml/power_profile.xml; each APK contains different power parameters.

project/
├── overlays/
│   ├── xxx_1/
│   │   ├── AndroidManifest.xml
│   │   └── res/
│   │       └── xml/
│   │           └── power_profile.xml
│   ├── xxx_2/
│       ├── AndroidManifest.xml
│       └── res/
│           └── xml/
│               └── power_profile.xml

First AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.spring_1_overlay">
    <application
        android:hasCode="false" />
    <overlay
        android:targetPackage="android"
        android:priority="1"
        android:requiredSystemPropertyName="ro.power.profile"
        android:requiredSystemPropertyValue="xxx" />
</manifest>

Second AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.spring_1_overlay">
    <application
        android:hasCode="false" />
    <overlay
        android:targetPackage="android"
        android:priority="1"
        android:requiredSystemPropertyName="ro.power.profile"
        android:requiredSystemPropertyValue="yyy" />
</manifest>

The important line is android:requiredSystemPropertyName="ro.power.profile"; that property gates which overlay is eligible. Both overlay APKs are included in the build:

PRODUCT_PACKAGES += \
    FrameworksResTarget_Vendor \
    FrameworksResTarget_Vendor2

Selecting the overlay at boot

At early-init, the rc file sets ro.power.profile based on ro.boot.hwc. The property value then determines which overlay APK is selected.

on early-int && on property:ro.boot.hwc=CN
    setprop ro.power.profile=xxx

on early-int && on property:ro.boot.hwc=IN
    setprop ro.power.profile=yyy

Verification

After boot, inspect the active overlay and the resulting power profile to confirm that the property selected the expected APK.

Verification screenshot for the dynamic RRO switch