]> Chaos Git - misc/random-utils.git/commitdiff
First round of scripts (autodeodex)
authorchaoskagami <chaos.kagami@gmail.com>
Wed, 11 Jun 2014 01:56:24 +0000 (21:56 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Wed, 11 Jun 2014 01:56:24 +0000 (21:56 -0400)
LICENSE.md [new file with mode: 0644]
README.md [new file with mode: 0644]
android/autodeodex/deodex.sh [new file with mode: 0644]
android/autodeodex/perf-deodex.sh [new file with mode: 0644]
android/autodeodex/pull-deodex.sh [new file with mode: 0644]
android/autodeodex/push-deodex.sh [new file with mode: 0644]

diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644 (file)
index 0000000..73530dc
--- /dev/null
@@ -0,0 +1,18 @@
+Permission is hereby granted, free of charge, to any person obtaining a 
+copy of this software and associated documentation files (the 
+"Software"), to deal in the Software without restriction, including 
+without limitation the rights to use, copy, modify, merge, publish, 
+distribute, sublicense, and/or sell copies of the Software, and to 
+permit persons to whom the Software is furnished to do so, subject to 
+the following conditions:
+
+The above copyright notice and this permission notice shall be included 
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..5dd9432
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+This is a collection of random scripts, some written for occasions, some 
+not. Point being, it's a large compilation of simple things meant to do 
+one thing and do it well.
+
+I can only hope many of this (random) stuff helps somebody with their 
+own scripting problem or solves it entirely.
diff --git a/android/autodeodex/deodex.sh b/android/autodeodex/deodex.sh
new file mode 100644 (file)
index 0000000..d12a4d7
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Remove previous.
+rm -rf dex odex >> tmp.log 2>&1
+
+echo -e $(tput setaf 2)$(tput bold)\(*\) $(tput setaf 7)Fetching /system/app and /system/framework. $(tput sgr 0)
+
+bash pull-deodex.sh
+
+echo -e $(tput setaf 2)$(tput bold)\(*\) $(tput setaf 7)Beginning deodex of framework and app dirs. $(tput sgr 0)
+
+bash perf-deodex.sh
+
+echo -e $(tput setaf 2)$(tput bold)\(*\) $(tput setaf 7)Installing deodexed files. $(tput sgr 0)
+
+bash push-deodex.sh
\ No newline at end of file
diff --git a/android/autodeodex/perf-deodex.sh b/android/autodeodex/perf-deodex.sh
new file mode 100644 (file)
index 0000000..5e0e3ea
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/bash
+export BOOTCLASSPATH="am.jar:android.policy.jar:android.test.runner.jar:apache-xml.jar:bmgr.jar:bouncycastle.jar:bu.jar:com.android.location.provider.jar:com.google.android.maps.jar:com.google.android.media.effects.jar:com.google.widevine.software.drm.jar:com.motorola.android.addressingwidget.jar:com.motorola.android.camera.jar:com.motorola.android.customization.jar:com.motorola.android.drm1.jar:com.motorola.android.encryption.jar:com.motorola.android.frameworks.jar:com.motorola.android.settings.shared.jar:com.motorola.android.storage.jar:com.motorola.android.telephony.jar:com.motorola.android.widget.jar:com.motorola.android.xmp.jar:com.motorola.app.admin.jar:com.motorola.app.epm.jar:com.motorola.atcmd.base.jar:com.motorola.atcmd.pluginMgr.jar:com.motorola.blur.library.app.service.jar:com.motorola.blur.library.apputils.jar:com.motorola.blur.library.friendfeed.jar:com.motorola.blur.library.home.jar:com.motorola.blur.library.mother.service.jar:com.motorola.blur.library.serviceutils.jar:com.motorola.calendarcommon.jar:com.motorola.contextual.location.ils.jar:com.motorola.frameworks.core.addon.jar:com.motorola.frameworks.core.checkin.jar:com.motorola.MCDownloadLibrary.services_lib.jar:com.motorola.motosignature.jar:com.motorola.vpn.ext.jar:com.scalado.android.photoeditor.jar:com.scalado.caps.jar:com.softwareimaging.mot.jar:core.jar:core-junit.jar:ext.jar:filterfw.jar:framework-ext.jar:framework.jar:ime.jar:input.jar:javax.obex.jar:jcifs-1.3.16.jar:monkey.jar:pm.jar:services.jar:svc.jar"
+
+# Deodex function.
+ddex() {
+       echo -e $(tput setaf 2)$(tput bold)\(*\) $(tput setaf 7)Beginning framework deodex. $(tput sgr 0)
+
+       cd ./odex
+       mkdir ../dex >> ../system.log 2>&1
+       for od in *.jar
+       do
+               echo -e $(tput setaf 2)$(tput bold)\(D\) $(tput setaf 7) Deodex $od. $(tput sgr 0)
+               if [ -e `basename $od .jar`.odex ]
+               then
+                       java -Xmx1G -jar ../supl/baksmali-*.jar -a 14 -d . -x `basename $od .jar`.odex >> tmp.log 2>&1
+                       java -Xmx1G -jar ../supl/smali-*.jar out -a 14 -o classes.dex >> tmp.log 2>&1
+                       RESULT=$(grep 'EXCEPTION' tmp.log)
+                       if [ -z "$RESULT" ]
+                       then
+                               echo -e $(tput setaf 6)$(tput bold)\(-\) $(tput setaf 7) Merge classes.dex with jar. $(tput sgr 0)
+                               zip -g $od classes.dex >> tmp.log 2>&1
+                               cp $od ../dex/ >> tmp.log 2>&1
+                       else
+                               echo -e $(tput setaf 1)$(tput bold)\(\!\) $(tput setaf 7) Deodex failed on $od. Error Logged. $(tput sgr 0)
+                       fi
+                       
+                       cat tmp.log >> ../system.log
+                       rm -rf classes.dex out tmp.log >> ../system.log 2>&1
+               else
+                       echo -e $(tput setaf 5)$(tput bold)\(?\) $(tput setaf 7) No odex for file $od. Skipping. $(tput sgr 0)
+               fi
+       done
+       echo -e $(tput setaf 2)$(tput bold)\(*\) $(tput setaf 7)Beginning apk deodex. $(tput sgr 0)
+       for od in *.apk
+       do
+               if [ -e `basename $od .apk`.odex ]
+               then
+                       echo -e $(tput setaf 2)$(tput bold)\(D\) $(tput setaf 7) Deodex $od. $(tput sgr 0)
+                       java -Xmx1G -jar ../supl/baksmali-*.jar -a 14 -d . -x `basename $od .apk`.odex >> tmp.log 2>&1
+                       java -Xmx1G -jar ../supl/smali-*.jar out -a 14 -o classes.dex >> tmp.log 2>&1
+                       RESULT=`grep 'EXCEPTION' tmp.log`
+                       if [ -z "$RESULT" ]
+                       then
+                               echo -e $(tput setaf 6)$(tput bold)\(-\) $(tput setaf 7) Merge classes.dex with apk. $(tput sgr 0)
+                               zip -g $od classes.dex >> tmp.log 2>&1
+                               echo -e $(tput setaf 6)$(tput bold)\(-\) $(tput setaf 7) Zipalign $od. $(tput sgr 0)
+                               zipalign -v 4 $od >> tmp.log 2>&1
+                               cp $od ../dex/ >> tmp.log 2>&1
+                       else
+                               echo -e $(tput setaf 1)$(tput bold)\(\!\) $(tput setaf 1) Deodex failed on $od. Error Logged. $(tput sgr 0)
+                       fi
+
+                       cat tmp.log >> ../system.log
+                       rm -rf classes.dex out tmp.log >> ../system.log 2>&1
+               else
+                       echo -e $(tput setaf 5)$(tput bold)\(?\) $(tput setaf 7) No odex for file $od. Skipping. $(tput sgr 0)
+               fi
+       done
+       cd ..
+       return $TRUE
+}
+
+ddex
+
+echo $(tput setaf 2)$(tput bold)\(\~\) Done with deodex.$(tput sgr 0)
diff --git a/android/autodeodex/pull-deodex.sh b/android/autodeodex/pull-deodex.sh
new file mode 100644 (file)
index 0000000..6cb4212
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+adb wait-for-device
+
+mkdir odex >> system.log 2>&1
+cd odex
+
+echo -e $(tput setaf 2)$(tput bold)\(*\) $(tput setaf 7)Pulling odexed /system/app. $(tput sgr 0)
+
+adb pull /system/app >> ../system.log 2>&1
+
+echo -e $(tput setaf 2)$(tput bold)\(*\) $(tput setaf 7)Pulling odexed /system/framework. $(tput sgr 0)
+
+adb pull /system/framework >> ../system.log 2>&1
+
+cd ..
diff --git a/android/autodeodex/push-deodex.sh b/android/autodeodex/push-deodex.sh
new file mode 100644 (file)
index 0000000..78ce7ab
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+cd dex
+
+adb shell su -c 'mount -o remount,rw /system'
+
+echo $(tput setaf 2)$(tput bold)\(I\) $(tput setaf 7)Installing freshly deodexed files...$(tput sgr 0)
+
+# Push deodexed goods to system.
+
+for file in *.jar; do
+       echo -e $(tput bold)$(tput setaf 2)\(*\) Install framework $file.$(tput sgr 0)
+       adb push $file /data/tmp/
+       echo -e cp /data/tmp/$file /system/framework/ >> scp.sh
+done
+
+echo $(tput setaf 2)$(tput bold)\(+\) $(tput setaf 7)Cleaning up framwork odex.$(tput sgr 0)
+for file in *.apk; do
+       echo -e $(tput bold)$(tput setaf 2)\(*\) Install framework $file.$(tput sgr 0)
+       adb push $file /data/tmp/
+       echo -e cp /data/tmp/$file /system/app/ >> scp.sh
+done
+
+adb push scp.sh /data/tmp/
+
+# Flush cache.
+adb shell su -c 'rm -rf /data/dalvik-cache/*'
+# Install deodexed.
+adb shell su -c 'cd /data/tmp && sh scp.sh'
+
+echo $(tput setaf 2)$(tput bold)\(+\) $(tput setaf 7)Cleaning up app odex.$(tput sgr 0)
+
+# Clean up remnants.
+adb shell su -c 'rm /system/app/*.odex && rm /system/framework/*.odex'
+
+adb shell  su -c 'mount -o remount,ro /system'
+
+cd ..
+