Commit 19c36cd7 authored by Rashed Abdel-Tawab's avatar Rashed Abdel-Tawab Committed by Rashed Abdel-Tawab
Browse files

extract_utils: Support multidex


Co-authored-by: default avatarErfan Abdi <erfangplus@gmail.com>
Change-Id: I4881658d303b6c5c7f0b141beb50c1e9100af611
parent bf5dcb13
......@@ -860,13 +860,17 @@ function oat2dex() {
if get_file "$OAT" "$TMPDIR" "$SRC"; then
if get_file "$VDEX" "$TMPDIR" "$SRC"; then
"$VDEXEXTRACTOR" -o "$TMPDIR/" -i "$TMPDIR/$(basename "$VDEX")" > /dev/null
# 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%.*}")_classes.dex" "$TMPDIR/classes.dex"
fi
CLASSES=$(ls "$TMPDIR/$(basename "${OEM_TARGET%.*}")_classes"*)
for CLASS in $CLASSES; do
NEWCLASS=$(echo "$CLASS" | sed 's/.*_//;s/cdex/dex/')
# Check if we have to deal with CompactDex
if [[ "$CLASS" == *.cdex ]]; then
"$CDEXCONVERTER" "$CLASS" &>/dev/null
mv "$CLASS.new" "$TMPDIR/$NEWCLASS"
else
mv "$CLASS" "$TMPDIR/$NEWCLASS"
fi
done
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"
......@@ -881,13 +885,17 @@ function oat2dex() {
# fallback to boot.oat if vdex is not available
if get_file "$JARVDEX" "$TMPDIR" "$SRC"; then
"$VDEXEXTRACTOR" -o "$TMPDIR/" -i "$TMPDIR/$(basename "$JARVDEX")" > /dev/null
# Check if we have to deal with CompactDex
if [ -f "$TMPDIR/$(basename "${JARVDEX%.*}")_classes.cdex" ]; then
"$CDEXCONVERTER" "$TMPDIR/$(basename "${JARVDEX%.*}")_classes.cdex" &> /dev/null
mv "$TMPDIR/$(basename "${JARVDEX%.*}")_classes.cdex.new" "$TMPDIR/classes.dex"
else
mv "$TMPDIR/$(basename "${JARVDEX%.*}")_classes.dex" "$TMPDIR/classes.dex"
fi
CLASSES=$(ls "$TMPDIR/$(basename "${JARVDEX%.*}")_classes"*)
for CLASS in $CLASSES; do
NEWCLASS=$(echo "$CLASS" | sed 's/.*_//;s/cdex/dex/')
# Check if we have to deal with CompactDex
if [[ "$CLASS" == *.cdex ]]; then
"$CDEXCONVERTER" "$CLASS" &>/dev/null
mv "$CLASS.new" "$TMPDIR/$NEWCLASS"
else
mv "$CLASS" "$TMPDIR/$NEWCLASS"
fi
done
else
java -jar "$BAKSMALIJAR" deodex -o "$TMPDIR/dexout" -b "$BOOTOAT" -d "$TMPDIR" "$JAROAT/$OEM_TARGET"
java -jar "$SMALIJAR" assemble "$TMPDIR/dexout" -o "$TMPDIR/classes.dex"
......@@ -1203,8 +1211,8 @@ function extract() {
if [[ "$FULLY_DEODEXED" -ne "1" && "${VENDOR_REPO_FILE}" =~ .(apk|jar)$ ]]; then
oat2dex "${VENDOR_REPO_FILE}" "${SRC_FILE}" "$SRC"
if [ -f "$TMPDIR/classes.dex" ]; then
zip -gjq "${VENDOR_REPO_FILE}" "$TMPDIR/classes.dex"
rm "$TMPDIR/classes.dex"
zip -gjq "${VENDOR_REPO_FILE}" "$TMPDIR/classes"*
rm "$TMPDIR/classes"*
printf ' (updated %s from odex files)\n' "${SRC_FILE}"
fi
elif [[ "${VENDOR_REPO_FILE}" =~ .xml$ ]]; then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment