From 52d752c1ee0b3f6bcc25020c9be427aae92b20a8 Mon Sep 17 00:00:00 2001 From: superr Date: Thu, 30 Jul 2015 16:57:28 -0500 Subject: [PATCH] v1.8 Final. Added support for ROMs with fake odexed files; Added ARCH auto detection; Added API auto detection if build.prop is present --- README.md | 5 +- deodex_lollipop | 186 ++++++++++++++++++++++++++++++------------------ 2 files changed, 121 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 9d87c67..01aa4cf 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Deodex Lollipop v1.7 +# Deodex Lollipop v1.8 # by SuperR This tool is intended to deodex /system/app, /system/priv-app, and /system/framework in Android Lollipop. @@ -6,7 +6,8 @@ This tool is intended to deodex /system/app, /system/priv-app, and /system/frame Usage: 1. Copy the 3 above mentioned directories from your odexed ROM into the /system directory at the root of this tool. -2. run "deodex_lollipop" from it's location in terminal +2. (optional) Copy /system/build.prop from your ROM for automatic API detection +2. Run "deodex_lollipop" from it's location in terminal Example: diff --git a/deodex_lollipop b/deodex_lollipop index cdbdbb8..1754fad 100755 --- a/deodex_lollipop +++ b/deodex_lollipop @@ -2,15 +2,14 @@ # Do not edit this file unless you know what you are doing +romdir=$(pwd) framedir=$(pwd)/system/framework appdir=$(pwd)/system/app privdir=$(pwd)/system/priv-app tools=$(pwd)/tools logs=$(pwd)/logs +oat2dex=$(ls $tools | grep oat2dex) -echo "" -echo "" -echo "" echo "" echo "----------------------------------------------------" echo "- -" @@ -46,41 +45,50 @@ if [ ! -d "$framedir" ]; then exit fi +if [[ -f $romdir/system/build.prop ]]; then + api="" + androidversion=$(cat $romdir/system/build.prop | grep "ro.build.version.release" | sed 's/ro\.build\.version\.release=//') + if (( $(echo "$androidversion 5.1" | awk '{print ($1 >= $2)}') && $(echo "$androidversion 5.1.1" | awk '{print ($1 <= $2)}') )); then + export api=22 + elif (( $(echo "$androidversion 5.0" | awk '{print ($1 >= $2)}') && $(echo "$androidversion 5.0.2" | awk '{print ($1 <= $2)}') )); then + export api=21 + elif (( $(echo "$androidversion 4.4.4" | awk '{print ($1 <= $2)}') )); then + echo "Sorry, this tool only supports deodexing Lollipop." + echo "" + read -p "Press ENTER to exit" + exit + fi +else + api="" + while [[ $api -lt "21" || $api -gt "22" ]] ; do + echo "" + echo "Type the API level of the ROM and press ENTER." + echo "" + echo "HINT:" + echo "5.0.x = 21" + echo "5.1.x = 22" + echo "" + read api + clear + done +fi + arch="" -while [[ ! -f $framedir/$arch/boot.oat ]]; do - echo "" - echo "Configure the arch of your device." - echo "" - echo "HINT:" - echo "Check the framework directory, you should see" - echo "another directory inside. The name of it should go" - echo "here (ex. arm, arm64, x86)." - echo "" - echo "If you can't get past this part, check the" - echo "following:" - echo "" - echo "1. Make sure this is a Lollipop rom." - echo "2. Make sure you typed the arch variable correctly." - echo "3. Make sure your rom is not already deodexed." - echo "" - echo "Type the arch of your device and press ENTER." - echo "" - read arch - clear -done +cd $framedir +arch=$(ls -d */ | sed 's/\///') -api="" -while [[ $api -lt "21" || $api -gt "22" ]] ; do - echo "" - echo "Type the API level of the ROM and press ENTER." - echo "" - echo "HINT:" - echo "5.0.x = 21" - echo "5.1.x = 22" - echo "" - read api +echo "ANDROID VERSION: $androidversion" +echo "API LEVEL: $api" +echo "ARCH: $arch" +echo "" +read -n 1 -p "Would you like to deodex now? y/n " +echo "" +echo "" +if [[ $REPLY = "y" ]]; then clear -done +else + exit +fi rm -rf $logs/*.log @@ -92,7 +100,7 @@ echo "" cd $tools if [ ! -d "$framedir/$arch/odex" ]; then - java -Xmx512m -jar oat2dex.jar boot $framedir/$arch/boot.oat >> $logs/main.log + java -Xmx512m -jar $oat2dex boot $framedir/$arch/boot.oat >> $logs/main.log fi clear @@ -116,22 +124,31 @@ done cd $tools app="" for app in $( ls $appdir ); do - if [ -d "$appdir/$app/$arch" ]; then - echo "" - echo "... Deodexing $app" - echo "" - java -Xmx512m -jar oat2dex.jar $appdir/$app/$arch/$app.odex $framedir/$arch/odex >> $logs/main.log - mv $appdir/$app/$arch/$app.dex $appdir/$app/$arch/classes.dex + if [[ $(7za l $appdir/$app/$app.apk | grep classes) = "" ]]; then + if [ -d "$appdir/$app/$arch" ]; then + echo "" + echo "... Deodexing $app" + echo "" + java -Xmx512m -jar $oat2dex $appdir/$app/$arch/$app.odex $framedir/$arch/odex >> $logs/main.log + mv $appdir/$app/$arch/$app.dex $appdir/$app/$arch/classes.dex if [ -f "$appdir/$app/$arch/$app-classes2.dex" ]; then mv $appdir/$app/$arch/$app-classes2.dex $appdir/$app/$arch/classes2.dex fi if [ -f "$appdir/$app/$arch/$app-classes3.dex" ]; then mv $appdir/$app/$arch/$app-classes3.dex $appdir/$app/$arch/classes3.dex fi - 7za u -tzip $appdir/$app/$app.apk $appdir/$app/$arch/classes*.dex >> $logs/zip.log + 7za u -tzip $appdir/$app/$app.apk $appdir/$app/$arch/classes*.dex >> $logs/zip.log + rm -rf $appdir/$app/$arch + else + echo "" + echo "... $app is already deodexed" + echo "" + fi + else + echo "" + echo "$app is already deodexed" + echo "" rm -rf $appdir/$app/$arch - else - echo "... $app is already deodexed" fi done clear @@ -156,22 +173,31 @@ done cd $tools privapp="" for privapp in $( ls $privdir ); do - if [ -d "$privdir/$privapp/$arch" ]; then - echo "" - echo "... Deodexing $privapp" - echo "" - java -Xmx512m -jar oat2dex.jar $privdir/$privapp/$arch/$privapp.odex $framedir/$arch/odex >> $logs/main.log - mv $privdir/$privapp/$arch/$privapp.dex $privdir/$privapp/$arch/classes.dex + if [[ $(7za l $privdir/$privapp/$privapp.apk | grep classes) = "" ]]; then + if [ -d "$privdir/$privapp/$arch" ]; then + echo "" + echo "... Deodexing $privapp" + echo "" + java -Xmx512m -jar $oat2dex $privdir/$privapp/$arch/$privapp.odex $framedir/$arch/odex >> $logs/main.log + mv $privdir/$privapp/$arch/$privapp.dex $privdir/$privapp/$arch/classes.dex if [ -f "$privdir/$privapp/$arch/$privapp-classes2.dex" ]; then mv $privdir/$privapp/$arch/$privapp-classes2.dex $privdir/$privapp/$arch/classes2.dex fi if [ -f "$privdir/$privapp/$arch/$privapp-classes3.dex" ]; then mv $privdir/$privapp/$arch/$privapp-classes3.dex $privdir/$privapp/$arch/classes3.dex fi - 7za u -tzip $privdir/$privapp/$privapp.apk $privdir/$privapp/$arch/classes*.dex >> $logs/zip.log + 7za u -tzip $privdir/$privapp/$privapp.apk $privdir/$privapp/$arch/classes*.dex >> $logs/zip.log + rm -rf $privdir/$privapp/$arch + else + echo "" + echo "... $privapp is already deodexed" + echo "" + fi + else + echo "" + echo "$privapp is already deodexed" + echo "" rm -rf $privdir/$privapp/$arch - else - echo "... $privapp is already deodexed" fi done clear @@ -183,34 +209,58 @@ echo "----------------------------------------------------" echo "" for frame in $( ls $framedir/$arch | grep .odex | rev | cut -c 6- | rev ); do - echo "" - echo "... Deodexing $frame" - echo "" - java -Xmx512m -jar oat2dex.jar $framedir/$arch/$frame.odex $framedir/$arch/odex >> $logs/main.log - mv $framedir/$arch/$frame.dex $framedir/$arch/classes.dex + if [[ $(7za l $framedir/$frame.jar | grep classes) = "" ]]; then + echo "" + echo "... Deodexing $frame" + echo "" + java -Xmx512m -jar $oat2dex $framedir/$arch/$frame.odex $framedir/$arch/odex >> $logs/main.log + mv $framedir/$arch/$frame.dex $framedir/$arch/classes.dex if [ -f "$framedir/$arch/$frame-classes2.dex" ]; then mv $framedir/$arch/$frame-classes2.dex $framedir/$arch/classes2.dex fi if [ -f "$framedir/$arch/$frame-classes3.dex" ]; then mv $framedir/$arch/$frame-classes3.dex $framedir/$arch/classes3.dex fi - 7za u -tzip $framedir/$frame.jar $framedir/$arch/classes*.dex >> $logs/zip.log - rm -rf $framedir/$arch/classes*.dex -done -for frame2 in $( ls $framedir/$arch/dex | grep .dex | rev | cut -c 5- | rev ); do - if [[ $frame2 != *"classes"* ]]; then + if [[ ! -f $framedir/$frame.apk ]]; then + 7za u -tzip $framedir/$frame.jar $framedir/$arch/classes*.dex >> $logs/zip.log + else + 7za u -tzip $framedir/$frame.apk $framedir/$archthey/classes*.dex >> $logs/zip.log + fi + rm -rf $framedir/$arch/classes*.dex + else echo "" - echo "... Deodexing $frame2" + echo "$frame is already deodexed" echo "" - mv $framedir/$arch/dex/$frame2.dex $framedir/$arch/dex/classes.dex + rm -rf $framedir/$arch/$frame.odex + fi +done +for frame2 in $( ls $framedir/$arch/dex | grep .dex | rev | cut -c 5- | rev ); do + if [[ $(7za l $framedir/$frame2.jar | grep classes) = "" ]]; then + if [[ $frame2 != *"classes"* ]]; then + echo "" + echo "... Deodexing $frame2" + echo "" + mv $framedir/$arch/dex/$frame2.dex $framedir/$arch/dex/classes.dex if [ -f "$framedir/$arch/dex/$frame2-classes2.dex" ]; then mv $framedir/$arch/dex/$frame2-classes2.dex $framedir/$arch/dex/classes2.dex fi if [ -f "$framedir/$arch/dex/$frame2-classes3.dex" ]; then mv $framedir/$arch/dex/$frame2-classes3.dex $framedir/$arch/dex/classes3.dex fi - 7za u -tzip $framedir/$frame2.jar $framedir/$arch/dex/classes*.dex >> $logs/zip.log - rm -rf $framedir/$arch/dex/classes*.dex + if [[ $(ls $framedir | grep $frame2.apk) = "" ]]; then + 7za u -tzip $framedir/$frame2.jar $framedir/$arch/dex/classes*.dex >> $logs/zip.log + else + 7za u -tzip $framedir/$frame2.apk $framedir/$arch/dex/classes*.dex >> $logs/zip.log + fi + rm -rf $framedir/$arch/dex/classes*.dex + fi + else + if [[ $frame2 != *"classes"* ]]; then + echo "" + echo "$frame2 is already deodexed" + echo "" + rm -rf $framedir/$arch/dex/$frame2.dex + fi fi done clear