Fix characteristic rro for overridden packages

Overridden packages can have different package names. This change reads
output APKs to parse package name, instead of manifest xml.

Bug: 325011777
Test: boot and idmap2 dump
Change-Id: Iafd792b6fb9c8548441c8ca5c9216be160028088
This commit is contained in:
Inseob Kim 2024-02-14 16:57:34 +09:00
parent ae025131ba
commit 620a234d3f

View file

@ -1,22 +1,14 @@
#!/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])
sys.exit(f"usage: {sys_argv[0]} target_package_name output\n")
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">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="{sys.argv[1]}.auto_generated_characteristics_rro">
<application android:hasCode="false" />
<overlay android:targetPackage="{package_name}"
<overlay android:targetPackage="{sys.argv[1]}"
android:isStatic="true"
android:priority="0" />
</manifest>