connglli / blog-notes

My personal notes ✍️
MIT License
32 stars 2 forks source link

Runtime Resource Overlay (RRO) Mechanism (运行时资源替换机制) #38

Open connglli opened 4 years ago

connglli commented 4 years ago

RRO Overview

Each android app can have multiple set of resources; each set is packaged into a single apk, which is called an overlay, and overlay has priority

image

Above shows how the Android system looks for a resource. Specifically, when finding a resource via its id (i.e., R.id.xxx), the system will search the overlays according to the overlay priority, and return the first searched one (i.e., if multiple resources has the same id, the one with largest priority is chosen)

To see all overlays of a same app, use

$ adb shell cmd overlay list <pkgName>

To enable an overlay of an app, use

$ adb shell cmd overlay enable <overlayPkg>

References

Overlay Management

OverlayManager and OverlayManagerService

:question::question::question::question::question::question::question::question::question::question: