extract_utils: Use vdexExtractor for extracting oreo classes.dex

vdexExtractor is a tool made by anestisb that is written in C++
with code taken directly from art. However, anestisb has also added
a quicken decompiler to oatdump that was merged upstream, so we only
need vdexExtractor for 8.1 and 8.0.

Change-Id: Ic2cf2dc627a1ad2fa4d500d02d9eac8b8a9577b5
Signed-off-by: Joe Maples <joe@frap129.org>
This commit is contained in:
Joe Maples
2018-01-05 14:51:33 -05:00
committed by Rashed Abdel-Tawab
parent fb7b1fd92a
commit 9be579f8d7
3 changed files with 21 additions and 6 deletions

BIN
build/tools/Darwin/vdexExtractor Executable file

Binary file not shown.

BIN
build/tools/Linux/vdexExtractor Executable file

Binary file not shown.

View File

@@ -742,12 +742,17 @@ function oat2dex() {
local SRC="$3"
local TARGET=
local OAT=
local HOST="$(uname)"
if [ -z "$BAKSMALIJAR" ] || [ -z "$SMALIJAR" ]; then
export BAKSMALIJAR="$LINEAGE_ROOT"/vendor/lineage/build/tools/smali/baksmali.jar
export SMALIJAR="$LINEAGE_ROOT"/vendor/lineage/build/tools/smali/smali.jar
fi
if [ -z "$VDEXEXTRACTOR" ]; then
export VDEXEXTRACTOR="$LINEAGE_ROOT"/vendor/lineage/build/tools/"$HOST"/vdexExtractor
fi
# Extract existing boot.oats to the temp folder
if [ -z "$ARCHES" ]; then
echo "Checking if system is odexed and locating boot.oats..."
@@ -786,22 +791,32 @@ function oat2dex() {
if get_file "$OAT" "$TMPDIR" "$SRC"; then
if get_file "$VDEX" "$TMPDIR" "$SRC"; then
echo "WARNING: Deodexing with VDEX. Still experimental"
"$VDEXEXTRACTOR" -o "$TMPDIR/" -i "$TMPDIR/$(basename "$VDEX")" > /dev/null
mv "$TMPDIR/$(basename "${OEM_TARGET%.*}").apk_classes.dex" "$TMPDIR/classes.dex"
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"
fi
java -jar "$BAKSMALIJAR" deodex -o "$TMPDIR/dexout" -b "$BOOTOAT" -d "$TMPDIR" "$TMPDIR/$(basename "$OAT")"
elif [[ "$LINEAGE_TARGET" =~ .jar$ ]]; then
# try to extract classes.dex from boot.oats for framework jars
# TODO: check if extraction from boot.vdex is needed
JAROAT="$TMPDIR/system/framework/$ARCH/boot-$(basename ${OEM_TARGET%.*}).oat"
JARVDEX="$TMPDIR/system/framework/$ARCH/boot-$(basename ${OEM_TARGET%.*}).vdex"
if [ ! -f "$JAROAT" ]; then
JAROAT=$BOOTOAT;
fi
java -jar "$BAKSMALIJAR" deodex -o "$TMPDIR/dexout" -b "$BOOTOAT" -d "$TMPDIR" "$JAROAT/$OEM_TARGET"
# try to extract classes.dex from boot.vdex for frameworks jars
# fallback to boot.oat if vdex is not available
if [ -f "$JARVDEX" ]; then
"$VDEXEXTRACTOR" -o "$TMPDIR/" -i "$JARVDEX" > /dev/null
mv "$TMPDIR/boot-$(basename "${OEM_TARGET%.*}").apk_classes.dex" "$TMPDIR/classes.dex"
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"
fi
else
continue
fi
java -jar "$SMALIJAR" assemble "$TMPDIR/dexout" -o "$TMPDIR/classes.dex" && break
done
rm -rf "$TMPDIR/dexout"