extract_utils: add CDEX support via compact_dex_converter

Source: https://github.com/anestisb/vdexExtractor#compact-dex-converter

Change-Id: I63664cae02e51a05e5a62c0c5c0595eead6c6513
diff --git a/build/tools/Darwin/compact_dex_converter b/build/tools/Darwin/compact_dex_converter
new file mode 100755
index 0000000..1c89476
--- /dev/null
+++ b/build/tools/Darwin/compact_dex_converter
Binary files differ
diff --git a/build/tools/Darwin/lib64/libart-dexlayout.dylib b/build/tools/Darwin/lib64/libart-dexlayout.dylib
new file mode 100755
index 0000000..88e940f
--- /dev/null
+++ b/build/tools/Darwin/lib64/libart-dexlayout.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libart.dylib b/build/tools/Darwin/lib64/libart.dylib
new file mode 100755
index 0000000..53f8712
--- /dev/null
+++ b/build/tools/Darwin/lib64/libart.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libbacktrace.dylib b/build/tools/Darwin/lib64/libbacktrace.dylib
new file mode 100755
index 0000000..c2e6d89
--- /dev/null
+++ b/build/tools/Darwin/lib64/libbacktrace.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libbase.dylib b/build/tools/Darwin/lib64/libbase.dylib
new file mode 100755
index 0000000..71130e5
--- /dev/null
+++ b/build/tools/Darwin/lib64/libbase.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libc++.dylib b/build/tools/Darwin/lib64/libc++.dylib
new file mode 100755
index 0000000..739164b
--- /dev/null
+++ b/build/tools/Darwin/lib64/libc++.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libcutils.dylib b/build/tools/Darwin/lib64/libcutils.dylib
new file mode 100755
index 0000000..73a6c07
--- /dev/null
+++ b/build/tools/Darwin/lib64/libcutils.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libdexfile.dylib b/build/tools/Darwin/lib64/libdexfile.dylib
new file mode 100755
index 0000000..abb0fe2
--- /dev/null
+++ b/build/tools/Darwin/lib64/libdexfile.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/liblog.dylib b/build/tools/Darwin/lib64/liblog.dylib
new file mode 100755
index 0000000..66a34d8
--- /dev/null
+++ b/build/tools/Darwin/lib64/liblog.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/liblz4.dylib b/build/tools/Darwin/lib64/liblz4.dylib
new file mode 100755
index 0000000..0a6bfc6
--- /dev/null
+++ b/build/tools/Darwin/lib64/liblz4.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libmetricslogger.dylib b/build/tools/Darwin/lib64/libmetricslogger.dylib
new file mode 100755
index 0000000..0b2ae0c
--- /dev/null
+++ b/build/tools/Darwin/lib64/libmetricslogger.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libnativebridge.dylib b/build/tools/Darwin/lib64/libnativebridge.dylib
new file mode 100755
index 0000000..f53c20e
--- /dev/null
+++ b/build/tools/Darwin/lib64/libnativebridge.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libnativehelper.dylib b/build/tools/Darwin/lib64/libnativehelper.dylib
new file mode 100755
index 0000000..56a485a
--- /dev/null
+++ b/build/tools/Darwin/lib64/libnativehelper.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libnativeloader.dylib b/build/tools/Darwin/lib64/libnativeloader.dylib
new file mode 100755
index 0000000..cba9b63
--- /dev/null
+++ b/build/tools/Darwin/lib64/libnativeloader.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libsigchain.dylib b/build/tools/Darwin/lib64/libsigchain.dylib
new file mode 100755
index 0000000..5f6ecbf
--- /dev/null
+++ b/build/tools/Darwin/lib64/libsigchain.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libz-host.dylib b/build/tools/Darwin/lib64/libz-host.dylib
new file mode 100755
index 0000000..386865c
--- /dev/null
+++ b/build/tools/Darwin/lib64/libz-host.dylib
Binary files differ
diff --git a/build/tools/Darwin/lib64/libziparchive.dylib b/build/tools/Darwin/lib64/libziparchive.dylib
new file mode 100755
index 0000000..394c191
--- /dev/null
+++ b/build/tools/Darwin/lib64/libziparchive.dylib
Binary files differ
diff --git a/build/tools/Linux/compact_dex_converter b/build/tools/Linux/compact_dex_converter
new file mode 100755
index 0000000..0a99e32
--- /dev/null
+++ b/build/tools/Linux/compact_dex_converter
Binary files differ
diff --git a/build/tools/extract_utils.sh b/build/tools/extract_utils.sh
index e9fff89..4a51991 100644
--- a/build/tools/extract_utils.sh
+++ b/build/tools/extract_utils.sh
@@ -787,6 +787,10 @@
         export VDEXEXTRACTOR="$LINEAGE_ROOT"/vendor/lineage/build/tools/"$HOST"/vdexExtractor
     fi
 
+    if [ -z "$CDEXCONVERTER" ]; then
+        export CDEXCONVERTER="$LINEAGE_ROOT"/vendor/lineage/build/tools/"$HOST"/compact_dex_converter
+    fi
+
     # Extract existing boot.oats to the temp folder
     if [ -z "$ARCHES" ]; then
         echo "Checking if system is odexed and locating boot.oats..."
@@ -821,7 +825,13 @@
         if get_file "$OAT" "$TMPDIR" "$SRC"; then
             if get_file "$VDEX" "$TMPDIR" "$SRC"; then
                 "$VDEXEXTRACTOR" -o "$TMPDIR/" -i "$TMPDIR/$(basename "$VDEX")" > /dev/null
-                mv "$TMPDIR/$(basename "${OEM_TARGET%.*}").apk_classes.dex" "$TMPDIR/classes.dex"
+                # Check if we have to deal with CompactDex
+                if [ -f "$TMPDIR/$(basename "${OEM_TARGET%.*}")_classes.cdex" ]; then
+                    "$CDEXCONVERTER" "$TMPDIR/$(basename "${OEM_TARGET%.*}")_classes.cdex" &> /dev/null
+                    mv "$TMPDIR/$(basename "${OEM_TARGET%.*}")_classes.cdex.new" "$TMPDIR/classes.dex"
+                else
+                    mv "$TMPDIR/$(basename "${OEM_TARGET%.*}").apk_classes.dex" "$TMPDIR/classes.dex"
+                fi
             else
                 java -jar "$BAKSMALIJAR" deodex -o "$TMPDIR/dexout" -b "$BOOTOAT" -d "$TMPDIR" "$TMPDIR/$(basename "$OAT")"
                 java -jar "$SMALIJAR" assemble "$TMPDIR/dexout" -o "$TMPDIR/classes.dex"