extract_utils: Add helper functions to generate RRO package structure
To be used for CarrierSettings extract integration.
Change-Id: I116efbb75aa53d9117076ff0e4e8fa239ab8002f
diff --git a/extract_utils.sh b/extract_utils.sh
index a452fb7..80a309c 100644
--- a/extract_utils.sh
+++ b/extract_utils.sh
@@ -901,6 +901,60 @@
}
#
+# write_rro_androidmanifest:
+#
+# $2: target package for the RRO overlay
+#
+# Creates an AndroidManifest.xml for an RRO overlay.
+#
+function write_rro_androidmanifest() {
+ local TARGET_PACKAGE="$1"
+
+ cat << EOF
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="$TARGET_PACKAGE.vendor"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <application android:hasCode="false" />
+ <overlay
+ android:targetPackage="$TARGET_PACKAGE"
+ android:isStatic="true"
+ android:priority="0"/>
+</manifest>
+EOF
+}
+
+#
+# write_rro_blueprint:
+#
+# $1: package name for the RRO overlay
+# $2: target partition for the RRO overlay
+#
+# Creates an Android.bp for an RRO overlay.
+#
+function write_rro_blueprint() {
+ local PKGNAME="$1"
+ local PARTITION="$2"
+
+ printf 'runtime_resource_overlay {\n'
+ printf '\tname: "%s",\n' "$PKGNAME"
+ printf '\ttheme: "%s",\n' "$PKGNAME"
+ printf '\tsdk_version: "%s",\n' "current"
+ printf '\taaptflags: ["%s"],\n' "--keep-raw-values"
+
+ if [ "$PARTITION" = "vendor" ]; then
+ printf '\tsoc_specific: true,\n'
+ elif [ "$PARTITION" = "product" ]; then
+ printf '\tproduct_specific: true,\n'
+ elif [ "$PARTITION" = "system_ext" ]; then
+ printf '\tsystem_ext_specific: true,\n'
+ elif [ "$PARTITION" = "odm" ]; then
+ printf '\tdevice_specific: true,\n'
+ fi
+ printf '}\n'
+}
+
+#
# write_blueprint_header:
#
# $1: file which will be written to
@@ -951,6 +1005,70 @@
}
#
+# write_xml_header:
+#
+# $1: file which will be written to
+#
+# writes out the warning message regarding manual file modifications.
+# note that this is not an append operation, and should
+# be executed first!
+#
+function write_xml_header() {
+ if [ -f $1 ]; then
+ rm $1
+ fi
+
+ [ "$COMMON" -eq 1 ] && local DEVICE="$DEVICE_COMMON"
+ [ "$COMMON" -eq 1 ] && local VENDOR="${VENDOR_COMMON:-$VENDOR}"
+
+ cat << EOF >> $1
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Automatically generated file. DO NOT MODIFY
+
+ This file is generated by device/$VENDOR/$DEVICE/setup-makefiles.sh
+-->
+EOF
+}
+
+#
+# write_rro_package:
+#
+# $1: the RRO package name
+# $2: the RRO target package
+# $3: the partition for the RRO overlay
+#
+# Generates the file structure for an RRO overlay.
+#
+function write_rro_package() {
+ local PKGNAME="$1"
+ if [ -z "$PKGNAME" ]; then
+ echo "A package name must be provided to write_rro_package()!"
+ exit 1
+ fi
+
+ local TARGET_PACKAGE="$2"
+ if [ -z "$TARGET_PACKAGE" ]; then
+ echo "A target package must be provided to write_rro_package()!"
+ exit 1
+ fi
+
+ local PARTITION="$3"
+ if [ -z "$PARTITION" ]; then
+ PARTITION="vendor"
+ fi
+
+ local RROBP="$ANDROID_ROOT"/"$OUTDIR"/rro_overlays/"$PKGNAME"/Android.bp
+ local RROMANIFEST="$ANDROID_ROOT"/"$OUTDIR"/rro_overlays/"$PKGNAME"/AndroidManifest.xml
+
+ write_blueprint_header "$RROBP"
+ write_xml_header "$RROMANIFEST"
+
+ write_rro_blueprint "$PKGNAME" "$PARTITION" >> "$RROBP"
+ write_rro_androidmanifest "$TARGET_PACKAGE" >> "$RROMANIFEST"
+}
+
+#
# write_headers:
#
# $1: devices falling under common to be added to guard - optional