Merge "webview_packages: prefer the more powerful webview packages If Gapps are installed, better webview providers become avaliable." into android-8.0
diff --git a/build/tools/extract_utils.sh b/build/tools/extract_utils.sh
index 4bed018..1a3a895 100755
--- a/build/tools/extract_utils.sh
+++ b/build/tools/extract_utils.sh
@@ -26,8 +26,7 @@
 ARCHES=
 FULLY_DEODEXED=-1
 
-TMPDIR="/tmp/extractfiles.$$"
-mkdir "$TMPDIR"
+TMPDIR=$(mktemp -d)
 
 #
 # cleanup
@@ -157,8 +156,46 @@
 }
 
 #
+# prefix_match_file:
+#
+# $1: the prefix to match on
+# $2: the file to match the prefix for
+#
+# Internal function which returns true if a filename contains the
+# specified prefix.
+#
+function prefix_match_file() {
+    local PREFIX="$1"
+    local FILE="$2"
+    if [[ "$FILE" =~ ^"$PREFIX" ]]; then
+        return 0
+    else
+        return 1
+    fi
+}
+
+#
+# truncate_file
+#
+# $1: the filename to truncate
+# $2: the argument to output the truncated filename to
+#
+# Internal function which truncates a filename by removing the first dir
+# in the path. ex. vendor/lib/libsdmextension.so -> lib/libsdmextension.so
+#
+function truncate_file() {
+    local FILE="$1"
+    RETURN_FILE="$2"
+    local FIND="${FILE%%/*}"
+    local LOCATION="${#FIND}+1"
+    echo ${FILE:$LOCATION}
+}
+
+#
 # write_product_copy_files:
 #
+# $1: make treble compatible makefile - optional, default to false
+#
 # Creates the PRODUCT_COPY_FILES section in the product makefile for all
 # items in the list which do not start with a dash (-).
 #
@@ -167,6 +204,7 @@
     local TARGET=
     local FILE=
     local LINEEND=
+    local TREBLE_COMPAT=$1
 
     if [ "$COUNT" -eq "0" ]; then
         return 0
@@ -181,8 +219,19 @@
         fi
 
         TARGET=$(target_file "$FILE")
-        printf '    %s/proprietary/%s:system/%s%s\n' \
-            "$OUTDIR" "$TARGET" "$TARGET" "$LINEEND" >> "$PRODUCTMK"
+        if [ "$TREBLE_COMPAT" == "true" ] || [ "$TREBLE_COMPAT" == "1" ]; then
+            if prefix_match_file "vendor/" $TARGET ; then
+                local OUTTARGET=$(truncate_file $TARGET)
+                printf '    %s/proprietary/%s:$(TARGET_COPY_OUT_VENDOR)/%s%s\n' \
+                    "$OUTDIR" "$TARGET" "$OUTTARGET" "$LINEEND" >> "$PRODUCTMK"
+            else
+                printf '    %s/proprietary/%s:system/%s%s\n' \
+                    "$OUTDIR" "$TARGET" "$TARGET" "$LINEEND" >> "$PRODUCTMK"
+            fi
+        else
+            printf '    %s/proprietary/%s:system/%s%s\n' \
+                "$OUTDIR" "$TARGET" "$TARGET" "$LINEEND" >> "$PRODUCTMK"
+        fi
     done
     return 0
 }
@@ -221,6 +270,7 @@
         ARGS=$(target_args "$P")
 
         BASENAME=$(basename "$FILE")
+        DIRNAME=$(dirname "$FILE")
         EXTENSION=${BASENAME##*.}
         PKGNAME=${BASENAME%.*}
 
@@ -301,6 +351,11 @@
         if [ ! -z "$EXTENSION" ]; then
             printf 'LOCAL_MODULE_SUFFIX := .%s\n' "$EXTENSION"
         fi
+        if [ "$CLASS" = "SHARED_LIBRARIES" ] || [ "$CLASS" = "EXECUTABLES" ]; then
+            if [ "$DIRNAME" != "." ]; then
+                printf 'LOCAL_MODULE_RELATIVE_PATH := %s\n' "$DIRNAME"
+            fi
+        fi
         if [ "$EXTRA" = "priv-app" ]; then
             printf 'LOCAL_PRIVILEGED_MODULE := true\n'
         fi
@@ -385,6 +440,10 @@
     if [ "${#FRAMEWORK[@]}" -gt "0" ]; then
         write_packages "JAVA_LIBRARIES" "false" "" "FRAMEWORK" >> "$ANDROIDMK"
     fi
+    local V_FRAMEWORK=( $(prefix_match "vendor/framework/") )
+    if [ "${#FRAMEWORK[@]}" -gt "0" ]; then
+        write_packages "JAVA_LIBRARIES" "true" "" "V_FRAMEWORK" >> "$ANDROIDMK"
+    fi
 
     # Etc
     local ETC=( $(prefix_match "etc/") )
@@ -393,7 +452,7 @@
     fi
     local V_ETC=( $(prefix_match "vendor/etc/") )
     if [ "${#V_ETC[@]}" -gt "0" ]; then
-        write_packages "ETC" "false" "" "V_ETC" >> "$ANDROIDMK"
+        write_packages "ETC" "true" "" "V_ETC" >> "$ANDROIDMK"
     fi
 
     # Executables
@@ -611,6 +670,7 @@
 # write_makefiles:
 #
 # $1: file containing the list of items to extract
+# $2: make treble compatible makefile - optional
 #
 # Calls write_product_copy_files and write_product_packages on
 # the given file and appends to the Android.mk as well as
@@ -618,7 +678,7 @@
 #
 function write_makefiles() {
     parse_file_list "$1"
-    write_product_copy_files
+    write_product_copy_files "$2"
     write_product_packages
 }
 
@@ -696,7 +756,12 @@
         echo "Checking if system is odexed and locating boot.oats..."
         for ARCH in "arm64" "arm" "x86_64" "x86"; do
             mkdir -p "$TMPDIR/system/framework/$ARCH"
-            if get_file "system/framework/$ARCH/" "$TMPDIR/system/framework/" "$SRC"; then
+            if [ -d "$SRC/framework" ] && [ "$SRC" != "adb" ]; then
+                ARCHDIR="framework/$ARCH/"
+            else
+                ARCHDIR="system/framework/$ARCH/"
+            fi
+            if get_file "$ARCHDIR" "$TMPDIR/system/framework/" "$SRC"; then
                 ARCHES+="$ARCH "
             else
                 rmdir "$TMPDIR/system/framework/$ARCH"
diff --git a/config/packages.mk b/config/packages.mk
index 669c4e3..39fbe42 100644
--- a/config/packages.mk
+++ b/config/packages.mk
@@ -31,7 +31,11 @@
     vim \
     mkfs.ntfs \
     mount.ntfs \
-    fsck.ntfs
+    fsck.ntfs \
+    mkshrc_vendor \
+    toybox_vendor \
+    sh_vendor
+
 
 # Telephony extension
 PRODUCT_PACKAGES += telephony-ext
@@ -47,5 +51,5 @@
     PixelTheme \
     Stock
 
-# for easter fun
-#PRODUCT_PACKAGES += EggGame
+# for fun
+PRODUCT_PACKAGES += EggGame
diff --git a/prebuilt/app/Chromium/32bit/ChromePublic.apk b/prebuilt/app/Chromium/32bit/ChromePublic.apk
deleted file mode 100644
index a858380..0000000
--- a/prebuilt/app/Chromium/32bit/ChromePublic.apk
+++ /dev/null
Binary files differ
diff --git a/prebuilt/app/Chromium/32bit/MonochromePublic.apk b/prebuilt/app/Chromium/32bit/MonochromePublic.apk
new file mode 100644
index 0000000..0958567
--- /dev/null
+++ b/prebuilt/app/Chromium/32bit/MonochromePublic.apk
Binary files differ
diff --git a/prebuilt/app/Chromium/Android.mk b/prebuilt/app/Chromium/Android.mk
index e1f9e71..e246e8f 100644
--- a/prebuilt/app/Chromium/Android.mk
+++ b/prebuilt/app/Chromium/Android.mk
@@ -5,7 +5,7 @@
 LOCAL_MODULE       := Chromium
 LOCAL_MODULE_TAGS  := optional
 LOCAL_MODULE_CLASS := APPS
-LOCAL_SRC_FILES    := 32bit/ChromePublic.apk
+LOCAL_SRC_FILES    := 32bit/MonochromePublic.apk
 LOCAL_CERTIFICATE  := PRESIGNED
 LOCAL_MODULE_PATH  := $(TARGET_OUT_APPS)
 include $(BUILD_PREBUILT)
diff --git a/prebuilt/app/Fun/EggGame.apk b/prebuilt/app/Fun/EggGame.apk
index 35b1a71..cc2b4c8 100644
--- a/prebuilt/app/Fun/EggGame.apk
+++ b/prebuilt/app/Fun/EggGame.apk
Binary files differ
diff --git a/prebuilt/bootanimation/bootanimation.zip b/prebuilt/bootanimation/bootanimation.zip
old mode 100644
new mode 100755
index 8c48726..f55693b
--- a/prebuilt/bootanimation/bootanimation.zip
+++ b/prebuilt/bootanimation/bootanimation.zip
Binary files differ
diff --git a/prebuilt/bootanimation/res/1080p.zip b/prebuilt/bootanimation/res/1080p.zip
new file mode 100755
index 0000000..f55693b
--- /dev/null
+++ b/prebuilt/bootanimation/res/1080p.zip
Binary files differ
diff --git a/prebuilt/bootanimation/res/1080x608.zip b/prebuilt/bootanimation/res/1080x608.zip
deleted file mode 100644
index 8c48726..0000000
--- a/prebuilt/bootanimation/res/1080x608.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/1080x720.zip b/prebuilt/bootanimation/res/1080x720.zip
deleted file mode 100644
index 7e22741..0000000
--- a/prebuilt/bootanimation/res/1080x720.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/1440p.zip b/prebuilt/bootanimation/res/1440p.zip
new file mode 100755
index 0000000..65fd448
--- /dev/null
+++ b/prebuilt/bootanimation/res/1440p.zip
Binary files differ
diff --git a/prebuilt/bootanimation/res/1440x814.zip b/prebuilt/bootanimation/res/1440x814.zip
deleted file mode 100644
index 8a8594f..0000000
--- a/prebuilt/bootanimation/res/1440x814.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/1440x960.zip b/prebuilt/bootanimation/res/1440x960.zip
deleted file mode 100644
index 752f8eb..0000000
--- a/prebuilt/bootanimation/res/1440x960.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/1536p.zip b/prebuilt/bootanimation/res/1536p.zip
new file mode 100755
index 0000000..727c952
--- /dev/null
+++ b/prebuilt/bootanimation/res/1536p.zip
Binary files differ
diff --git a/prebuilt/bootanimation/res/2560x1440.zip b/prebuilt/bootanimation/res/2560x1440.zip
deleted file mode 100644
index 77c7754..0000000
--- a/prebuilt/bootanimation/res/2560x1440.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/320x181.zip b/prebuilt/bootanimation/res/320x181.zip
deleted file mode 100644
index ac320f3..0000000
--- a/prebuilt/bootanimation/res/320x181.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/360x240.zip b/prebuilt/bootanimation/res/360x240.zip
deleted file mode 100644
index 7f8e828..0000000
--- a/prebuilt/bootanimation/res/360x240.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/420x280.zip b/prebuilt/bootanimation/res/420x280.zip
deleted file mode 100644
index 5b154c8..0000000
--- a/prebuilt/bootanimation/res/420x280.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/480x320.zip b/prebuilt/bootanimation/res/480x320.zip
deleted file mode 100644
index c339a8c..0000000
--- a/prebuilt/bootanimation/res/480x320.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/640x362.zip b/prebuilt/bootanimation/res/640x362.zip
deleted file mode 100644
index e3702de..0000000
--- a/prebuilt/bootanimation/res/640x362.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/720p.zip b/prebuilt/bootanimation/res/720p.zip
new file mode 100755
index 0000000..524f1fe
--- /dev/null
+++ b/prebuilt/bootanimation/res/720p.zip
Binary files differ
diff --git a/prebuilt/bootanimation/res/720x407.zip b/prebuilt/bootanimation/res/720x407.zip
deleted file mode 100644
index 8325316..0000000
--- a/prebuilt/bootanimation/res/720x407.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/720x480.zip b/prebuilt/bootanimation/res/720x480.zip
deleted file mode 100644
index 4231848..0000000
--- a/prebuilt/bootanimation/res/720x480.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/840p.zip b/prebuilt/bootanimation/res/840p.zip
new file mode 100755
index 0000000..a4ca609
--- /dev/null
+++ b/prebuilt/bootanimation/res/840p.zip
Binary files differ
diff --git a/prebuilt/bootanimation/res/840x560.zip b/prebuilt/bootanimation/res/840x560.zip
deleted file mode 100644
index 057a2d2..0000000
--- a/prebuilt/bootanimation/res/840x560.zip
+++ /dev/null
Binary files differ
diff --git a/prebuilt/bootanimation/res/960p.zip b/prebuilt/bootanimation/res/960p.zip
new file mode 100755
index 0000000..6699bdf
--- /dev/null
+++ b/prebuilt/bootanimation/res/960p.zip
Binary files differ
diff --git a/prebuilt/bootanimation/res/960x640.zip b/prebuilt/bootanimation/res/960x640.zip
deleted file mode 100644
index 8930225..0000000
--- a/prebuilt/bootanimation/res/960x640.zip
+++ /dev/null
Binary files differ
diff --git a/utils/aosp-forked-list b/utils/aosp-forked-list
index ad86142..3fc149d 100644
--- a/utils/aosp-forked-list
+++ b/utils/aosp-forked-list
@@ -2,12 +2,19 @@
 build/make
 build/soong
 development
+external/e2fsprogs
+external/exfat
+external/fuse
+external/mksh
 external/tinycompress
+external/toybox
 external/selinux
 frameworks/av
 frameworks/base
+frameworks/native
 frameworks/opt/telephony
 hardware/invensense
+hardware/interfaces
 hardware/libhardware
 hardware/qcom/audio
 hardware/qcom/bt
@@ -17,14 +24,15 @@
 hardware/qcom/media
 hardware/qcom/power
 hardware/qcom/wlan
-packages/apps/Calendar
-packages/apps/Launcher3
-packages/apps/Gallery2
-packages/apps/MusicFX
 packages/apps/Nfc
 packages/apps/Settings
+packages/services/Telephony
 packages/inputmethods/LatinIME
+system/bt
 system/core
+system/libhidl
 system/media
+system/nfc
+system/netd
 system/sepolicy
 system/vold
diff --git a/utils/aosp-merge.sh b/utils/aosp-merge.sh
index 7599b82..f2c9eaa 100755
--- a/utils/aosp-merge.sh
+++ b/utils/aosp-merge.sh
@@ -28,6 +28,7 @@
     project=`echo android_${path} | sed -e 's/\//\_/g'`
     if [ "${project}" == "android_build_make" ] ; then
         project="android_build"
+        buildpath="build"
     fi
 
     echo ""
@@ -46,9 +47,15 @@
     fi
 
     repo start ${branch_name} .
+    if [ buildpath="build" ] ; then
+        if ! git remote | grep "aosp" > /dev/null; then
+            git remote add aosp https://android.googlesource.com/platform/$buildpath > /dev/null
+        fi
+    else
 
-    if ! git remote | grep "aosp" > /dev/null; then
-        git remote add aosp https://android.googlesource.com/platform/$path > /dev/null
+        if ! git remote | grep "aosp" > /dev/null; then
+            git remote add aosp https://android.googlesource.com/platform/$path > /dev/null
+        fi
     fi
 
     git fetch --tags aosp
@@ -56,7 +63,11 @@
     #echo "====================================================================="
     #echo " Merging {$ref}"
     #echo "====================================================================="
-    git merge $ref;
+    if [ buildpath="build" ] ; then
+        git merge --squash $ref && git commit -m "Merge $ref";
+    else
+        git merge $ref;
+    fi
 
     cd - > /dev/null