diff options
author | 2023-11-07 13:36:59 +0900 | |
---|---|---|
committer | 2023-11-07 14:06:14 +0900 | |
commit | d8cde776070d0a2b592d5b53dac5c188b73a671b (patch) | |
tree | 9d0039a9e5a16dddaedad7c46a811d94d7c58dac | |
parent | 5f24ce615843c8ac4010bc3949ca8c4100ca83cd (diff) |
Add support for auto-generated characteristics RRO
Setting use_rro_for_product will automatically generate an RRO package
which contains resources with 'product="{PRODUCT_CHARACTERISTICS}"'. The
RRO package will be installed to /product partition. The app will be
compiled with '--product default', making the app identical to all
targets.
Motivation for this change is to minimize divergence of system.img.
Bug: 294799593
Test: boot and idmap2 dump
Change-Id: I549c2589c69eab7a1568510a7d1ff0c8a003f7ea
-rw-r--r-- | core/artifact_path_requirements.mk | 1 | ||||
-rw-r--r-- | tools/Android.bp | 10 | ||||
-rw-r--r-- | tools/characteristics_rro_generator.py | 23 |
3 files changed, 34 insertions, 0 deletions
diff --git a/core/artifact_path_requirements.mk b/core/artifact_path_requirements.mk index 566b9f7446..c949cc4d2b 100644 --- a/core/artifact_path_requirements.mk +++ b/core/artifact_path_requirements.mk @@ -4,6 +4,7 @@ # Fakes don't get installed, and NDK stubs aren't installed to device. static_allowed_patterns := $(TARGET_OUT_FAKE)/% $(SOONG_OUT_DIR)/ndk/% # RROs become REQUIRED by the source module, but are always placed on the vendor partition. +static_allowed_patterns += %__auto_generated_characteristics_rro.apk static_allowed_patterns += %__auto_generated_rro_product.apk static_allowed_patterns += %__auto_generated_rro_vendor.apk # Auto-included targets are not considered diff --git a/tools/Android.bp b/tools/Android.bp index b8ab162b76..5c54fcf315 100644 --- a/tools/Android.bp +++ b/tools/Android.bp @@ -96,3 +96,13 @@ python_test_host { unit_test: true, }, } + +python_binary_host { + name: "characteristics_rro_generator", + srcs: ["characteristics_rro_generator.py"], + version: { + py3: { + embedded_launcher: true, + }, + }, +} diff --git a/tools/characteristics_rro_generator.py b/tools/characteristics_rro_generator.py new file mode 100644 index 0000000000..6489673f4b --- /dev/null +++ b/tools/characteristics_rro_generator.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +import sys +from xml.dom.minidom import parseString + +def parse_package(manifest): + with open(manifest, 'r') as f: + data = f.read() + dom = parseString(data) + return dom.documentElement.getAttribute('package') + +if __name__ == '__main__': + if len(sys.argv) != 3: + sys.exit(f"usage: {sys_argv[0]} target_package_manifest output\n") + package_name = parse_package(sys.argv[1]) + with open(sys.argv[2], "w") as f: + f.write(f'''<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="{package_name}.auto_generated_characteristics_rro"> + <application android:hasCode="false" /> + <overlay android:targetPackage="{package_name}" + android:isStatic="true" + android:priority="0" /> +</manifest> +''') |