Merge "Add support for auto-generated characteristics RRO" into main

This commit is contained in:
Inseob Kim 2023-11-17 05:02:28 +00:00 committed by Gerrit Code Review
commit 8fc7cf6301
3 changed files with 34 additions and 0 deletions

View file

@ -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

View file

@ -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,
},
},
}

View file

@ -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>
''')