droidzone

data/app odex-er

Mar 5th, 2011
149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/system/bin/sh
  2. #
  3. # Posted by Droidzone
  4. # data/app odex-er
  5. # experimental - nandroid backup before you run this script!
  6. #
  7.  
  8. rm /tmp.odex
  9. cd /data/app
  10.  
  11. # Check for and delete leftover .odex files after uninstalled apps
  12. for filename in *.odex
  13. do
  14. name=`basename $filename .odex`
  15. if [ ! -f $name.apk -a -f $filename ]
  16. then
  17. rm $filename
  18. echo "Removed $filename"
  19. fi
  20. done;
  21.  
  22. # Loop through all installed apps
  23. for filename in *.apk
  24. do
  25. name=`basename $filename .apk`
  26. if [ ! -f $name.odex -o $filename -nt $name.odex ]
  27. then
  28. # step 1 - odex the apk
  29. rm -f /tmp.odex
  30. /system/bin/dexopt-wrapper $filename /tmp.odex
  31.  
  32. # step 2 - did we succesfully odex?
  33. if [ $? -eq 0 ]
  34. then
  35. # step 3 - remove the classes.dex from the apk
  36. /system/bin/zip -d $filename classes.dex
  37.  
  38. # continue only if classes.dex was present
  39. if [ $? -eq 0 ]
  40. then
  41. # step 4 - zipalign, just in case
  42. /system/bin/zipalign -f -v 4 $filename /$filename.new
  43. mv -f /$filename.new $filename
  44. mv -f /tmp.odex $name.odex
  45. touch $name.odex
  46. echo "Odexed $filename"
  47. else
  48. echo "Error $filename did not contain classes.dex"
  49. fi
  50. else
  51. echo "Error creating odex from $filename"
  52. fi
  53. else
  54. echo "Nothing to do: $filename"
  55. fi
  56. done;
RAW Paste Data