extract_utils: Add support for overriding packages

 * An example of how this can be used is say a device
   wants to use the original OEM camera, e.g. Essential PH-1.
   Klik is required in order to use the external camera
   module that you could buy for the device so it's preferred
   to use it over Camera2 or Snap.

  * An example of how to use this argument:
    -system/priv-app/Klik/Klik.apk;OVERRIDES=Camera2

Change-Id: I2504cbb760b20ed86c2dc088cc4bd74b78ba64d9
diff --git a/build/tools/extract_utils.sh b/build/tools/extract_utils.sh
index 8a5d3ee..a5e6e68 100755
--- a/build/tools/extract_utils.sh
+++ b/build/tools/extract_utils.sh
@@ -356,6 +356,7 @@
     local EXTENSION=
     local PKGNAME=
     local SRC=
+    local OVERRIDEPKG=
 
     for P in "${FILELIST[@]}"; do
         FILE=$(target_file "$P")
@@ -421,12 +422,21 @@
                 SRC="$SRC/app"
             fi
             printf '\tapk: "%s/%s",\n' "$SRC" "$FILE"
-            if [ "$ARGS" = "PRESIGNED" ]; then
-                printf '\tpresigned: true,\n'
-            elif [ ! -z "$ARGS" ]; then
-                printf '\tcertificate: "%s",\n' "$ARGS"
-            else
+            ARGS=(${ARGS//;/ })
+            if [ -z "$ARGS" ]; then
                 printf '\tcertificate: "platform",\n'
+            else
+                for ARG in "${ARGS[@]}"; do
+                    if [ "$ARG" = "PRESIGNED" ]; then
+                        printf '\tpresigned: true,\n'
+                    elif [[ "$ARG" =~ "OVERRIDES" ]]; then
+                        OVERRIDEPKG=${ARG#*=}
+                        OVERRIDEPKG=${OVERRIDEPKG//,/ }
+                        printf '\toverrides: ["%s"],\n' "$OVERRIDEPKG"
+                    elif [ ! -z "$ARG" ]; then
+                        printf '\tcertificate: "%s",\n' "$ARG"
+                    fi
+                done
             fi
         elif [ "$CLASS" = "JAVA_LIBRARIES" ]; then
             printf 'dex_import {\n'