Hello All,
I was trying to get the option of waking the phone using volume keys. I am on ICS (Asia Retail) on my MB865. Editing the Keylayout files did not work. It had worked for me before, but now they did not probably since my phone is locked by a password lock screen due to corporate policies. I tried to decompile android.policy.odex and change isWakeKeyWhenKeyguardShowing. But after I compiled it back and put the changed odex back to system/framwork. But strangely I got a boot loop. I tried a battery pull and also cleared cache and Dalvik cache. But could not get it to boot. Finally I had to restore /system from a backup.
I have detailed my steps below. Can anyone please point out what I am doing wrong here.
1. Get /system/framwork out and put it in a folder
2. Download smali-1.4.2 and baksmali-1.4.2 utilities.
3. I extracted android.policy.odex by java -jar baksmali.jar -d framework -x android.policy.odex
4. I changed the file KeyguardViewMediator.smali (removed lines for 0x18 and 0x19 under the switch case of the method isWakeKeyWhenKeyguardShowing(IZ)Z
5. Packed the odex file back by java -jar smali.jar -o android.policy.odex out
where "out" is the previously extracted folder
Then I replaced the android.policy.odex back to /system/framework
Please help! My power key is already showing some signs that it does not want to stay with me any more.
Thanks,
Sayantan
Re: Solved - Volume Rocker wake via android.policy.jar
Okay! I have been a total noob. I did not read enough about odexing and deodexing.. should have read more before I posted. Here's what I did (in short), thanks to Jordan Hotmann from http://www.jordanhotmann.com/2011/08/how-to-change-default-orientation-of.html
For detailed explanations, please visit the above website.
1. Downloaded smali and baksmali tools
2. Downloaded and installed dexopt-wrapper (just Google)
3. Extracted /system/framwork
4. Extracted android.policy.odex (used api level 15)
5. Modified the required files - KeyguardViewMediator.smali (removed lines for 0x18 and 0x19 under the switch case of the method isWakeKeyWhenKeyguardShowing(IZ)Z
6. Repacked the folder to classes.dex
7. Integrated classes.dex into android.policy and pushed the latter to /sdcard/
8. Created new odex file from android.policy.jar (dexopt-wrapper android.policy.jar new.odex BOOTCLASSPATH)
Got the BOOTCLASSPATH from init.rc which I pulled from the phone root directory
9. Copied the "signature" from the original .odex file to the newly created one (busybox dd if=/system/framework/android.policy.odex of=new.odex bs=1 count=20 skip=52 seek=52 conv=notrunc)
10. Replaced android.policy.odex
cd /system/framework/
busybox cp /sdcard/new.odex android.policy.odex
busybox chmod 644 android.policy.odex
(I already had my keylayout file modded. So not sure if they are actually required after the above mod)
Please take a nandroid backup before attempting this. I am not responsible for any damage being done to your phone as a result of this!
Thanks again to XDA forums and Devs here and Jordan Hotmann (from the link above)
Can't say about ICS but in JB we use the lab menu *#*#6686#*#* to have the functionality of the volume key waking the phone.
Right. I used the same when I was on the JB leak. It doesn't work on ICS. However, last time I was on ICS, changing the key layout files sufficed with the lock screen set to none. This time my phone has to have a password lock screen due to corporate policy and editing android.policy.jar seems to be the only way.
Regards,
Sayantan
Sent from my MB865 using xda app-developers app
Ok, in that case I learned something new to use in ICS as per your tutorial below :good:
Hi guys.
I stumbled upon this thread while researching info for modding framework-res.apk and android.policy.jar. I'm trying to make some changes to the power menu.
I'm pretty much a noob and so far I managed to get framework-res.apk to compile and install successfully, but android.policy.odex is giving me nightmares My rom is odexed, and no matter what I do I always end up stuck at boot.
So I tried to just baksmali and smali it again with no changes whatsoever, then dexopt-wrap from the phone exactly like the guide SMONDAL84 linked says, dd the old signature into the new odex file and finally move it to /system/framework.
Even that isn't working, so I wonder what am I doing wrong?
Related
Hi people i was wondering if anyone could help me, i want to use Quick Panel in UBKPD ROM, I pulled the apk from XXKPQ to /system/app but itsn't working, should I have to modify something in UBKPD to make it work?
Thanks and sorry for my bad english.
It's not enough, you have to mod /system/app/SystemUI.apk first and copy another apk. If you want there's a guide made by the creator of this mod: http://forum.xda-developers.com/showthread.php?t=1289896.
I followed the guide to port Quick Panel several times and always with the same result, boot loop at boot logo :'(
also tried to port extended power menu following this guide http://forum.xda-developers.com/showthread.php?t=1169443 and the result are the same, boot loop.
I dont kwnow what i am doing wrong, i follow the guides step by step. For compile/decompile apks i am using apktool in archlinux
Man if I uderstood corect you have need this:http://forum.xda-developers.com/showthread.php?t=633246 and
http://forum.xda-developers.com/showthread.php?t=1427959 and this:
http://forum.xda-developers.com/showthread.php?t=695701
The only problem I had when I modded SystemUI.apk was no statusbar, it always booted.
Bootloops usually happen when you mod framework-res.apk. That's because before you recompile it, you must select as compression level 0, otherwise you'll have bootloops.
If you want I can help you, just give me the files.
I think that I made some advances, because phone is booting now but still not working :'( i will explain:
Quick Panel:
I have status bar working after mod SystemUI.apk, but dont have the toogles.
SytemUI.apk and QuickPanelSettings.apk in /system/app, Permisions rw-,r--,r--
lidroid-res.apk in /system/framework, Permisions rw-,r--,r--
Done several times and allways the same result :'(
Extend Power Menu:
Phone now is booting after mod framework-res.apk
so i made the second phase mod android.policy.jar, compile and decompile is fine, after replace original the phone boot normal but when i long press the power button the phone hangs for a few seconds and then reboots, i make the process several thimes and always same result :'(
I want to learn that is why I am doing this over and over again. I compared the codes with the codes in XXKPQ.10lockscreen.14Toggle and are the same that I moded following the instructions in the previous post. Thanks in advice for the understandig and for the bad english
That's weird.
Try apkmanager instead of apktool (linux: http://apkmultitool.com/downloads/apk_manager_linux_5.0.zip). It's just a console script that makes your work easier. Read this guide that explains how to apply the "1% battery mod", you'll understand how to properly decompile and compile system apks (other than applying the "1% battery mod" ) with apkmanager.
Here what I usually do for android.policy.jar.
First of all you need baksmali.jar and smali.jar (download them from here: http://code.google.com/p/smali/downloads/list):
Exract classes.dex from android.policy.jar (jar = zip)
Decompile classes.dex running this command (of course you need to specify the correct path for baksmali.jar and classes.dex etc):
Code:
java -jar path/to/baksmali.jar -o classout/ classes.dex
Do all the changes to the files as explained in the guide
Recompile:
Code:
java -Xmx512M -jar smali.jar classout/ -o new-classes.dex
Replace classes.dex with new-classes.dex (rename new-classes.dex of course) inside android.policy.jar
I will read the guide for "1% battery mod" it would be usefull too for UBKPD , and also will try apkmanager about smali/baksmali I have allready installed maybe the way to compile was the error, cos i compiled like
Code:
java -jar smali.jar classes.dex
and then replaced in original android.policy.jar
Manually Deodexing (Windows/Linux/OSX)
Let's start first with deodexing manually in order to learn about how the whole process works. Deodexing manually can be very useful if you only want to deodex a couple apks, or if some apks are giving tools such as xUltimate trouble. So here's what you'll need:
Basic knowledge of odex vs. deodex... READ THIS
Smali/baksmali installed correctly (if you are on Linux/OSX you can get the wrapper script as well, otherwise just use the .jars)
Java JRE installed correctly
The apks you want to deodex
ALL of the files in /system/framework from your ROM
This is also an excellent read for understanding the process of deodexing an apk
The first thing we want to do is find the bootclasspath for the ROM you are using. You will have to get the file /init.rc from your phone in some way; if you prefer using root explorer then use root explorer to copy it to your sd card, I prefer using adb. Once you have init.rc on your computer, open it up in a text editor. Search for the line that begins with "export BOOTCLASSPATH" and copy the rest of the line. It should look like this:
Code:
/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework-ext.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar:/system/framework/com.motorola.frameworks.core.addon.jar:/system/framework/kafdex.jar:/system/framework/com.motorola.orange.simauth.jar
The bootclasspath is simply a list of dependencies that the system apps need to run - i.e. jars/apks that contain code that the system apps use. It is necessary to have the correct bootclasspath when deodexing.
Now that we have the bootclasspath we can start to set up for the actual deodexing. All the files listed in the bootclasspath are found in /system/framework, so grab all the jars/apks in /system/framework from your ROM (adb pull them or take them from the flashable zip if available) and put them in a folder named "framework" somewhere that you can remember, such as your desktop or at the root of your hard drive (i.e. C:\framework). We will use the bootclasspath to find all the files in this folder that are needed to deodex the apps properly.
Now we have to modify the bootclasspath in order to get the baksmali command to work correctly. The current bootclasspath that we have is saying that all the frameworks are in the /system/framework folder of your computer, but most of you have the frameworks somewhere like C:\framework or /home/me/framework. So open your text editor again and paste the current bootclasspath. Hopefully your editor will have a find/replace function; if so, just keep replacing all instances of "/system/framework" with the path to your frameworks. For example, this is what it would look like if your frameworks are in C:\framework:
Code:
C:\framework\core.jar:C:\framework\core-junit.jar:C:\framework\bouncycastle.jar:C:\framework\ext.jar:C:\framework\framework.jar:C:\framework\framework-ext.jar:C:\framework\android.policy.jar:C:\framework\services.jar:C:\framework\apache-xml.jar:C:\framework\filterfw.jar:C:\framework\com.motorola.android.frameworks.jar:C:\framework\com.motorola.android.widget.jar:C:\framework\com.motorola.frameworks.core.addon.jar:C:\framework\kafdex.jar:C:\framework\com.motorola.orange.simauth.jar
Finally we are ready to actually deodex the apks. Place the apks and odex's (odexes?) you want to deodex anywhere... your desktop, a folder somewhere, the root of your hard drive... it does not matter. Place the smali/baksmali .jar's in the same directory as the apps you wish to deodex. Open up a command prompt/terminal/etc and "cd" to the directory that the .apk's are in. For example if they are in C:\apps_to_deodex then I would type
Code:
cd C:\apps_to_deodex
The process for deodexing is a little dance like this:
Use baksmali to decompile the .odex file to smali
Use smali to compile the .smali files to a .dex
Use an archive manager (ex. 7zip) to put the newly created .dex file into the original .apk
Delete the old .odex file and all the decompiled smali.
So, let's begin.
BAKSMALI
Since baksmali/smali are .jar's, we will be using java to execute them. The syntax for the baksmali command is something like this:
Code:
java -jar baksmali.jar -a [COLOR="Red"]api_level[/COLOR] -c [COLOR="red"]bootclasspath[/COLOR] -x [COLOR="red"]file.odex[/COLOR]
The -a argument is not necessary with ICS. If you are on GB then you must use "-a 10" in order for it to deodex properly.
The bootclasspath is the bootclasspath that we determined earlier
The file.odex is, of course, the name of the odex file you want to decompile.
So let's say I want to decompile abc.odex, which was built for ICS. The command would be:
Code:
java -jar baksmali.jar -c C:\framework\core.jar:C:\framework\core-junit.jar:C:\framework\bouncycastle.jar:C:\framework\ext.jar:C:\framework\framework.jar:C:\framework\framework-ext.jar:C:\framework\android.policy.jar:C:\framework\services.jar:C:\framework\apache-xml.jar:C:\framework\filterfw.jar:C:\framework\com.motorola.android.frameworks.jar:C:\framework\com.motorola.android.widget.jar:C:\framework\com.motorola.frameworks.core.addon.jar:C:\framework\kafdex.jar:C:\framework\com.motorola.orange.simauth.jar -x abc.odex
This command creates a directory called "out" containing the decompiled odex file.
SMALI
Now that we have "baksmalid" the odex file, we now need to "smali" it to turn the .smali code into the .dex format. The syntax for this command is something like this:
Code:
java -jar smali.jar out -o classes.dex
We are calling the newly generated file "classes.dex" because that is the file that Android looks for in deodexed apks.
When the command completes you will have a file called "classes.dex" sitting in the directory holding all the deodexed apps.
ARCHIVE MANAGER
Hopefully by now you understand the difference between an odexed app and a deodexed app...
Odexed -> abc.apk AND abc.odex
Deodexed -> abc.apk ONLY which contains classes.dex
So, since we have the classes.dex, all we have to do is drag-n-drop it into the respective.apk using an archive manager such as 7zip (Windows). The result is an .apk which contains all the files necessary for it to install and run... it is deodexed.
CLEANUP
If you are going to repeat the process multiple times you will begin to get confused with filenames and everything. Since you now have a fully funtional abc.apk, you can delete:
-The abc.odex file as it is no longe necessary
-The "out" folder created in step 1
-The classes.dex because it is already copied into abc.apk
TROUBLESHOOTING
Sometimes, no matter what you try, you just can not get an app to deodex because it just isn't finding the right dependencies to load. If you come across some troublesome apps, you can use the "-I" argument when baksmaling to force it to decompile:
Code:
java -jar baksmali.jar -a [COLOR="Red"]api_level[/COLOR] -c [COLOR="red"]bootclasspath[/COLOR] -x -I [COLOR="red"]file.odex[/COLOR]
A warning... if you use the -I option on an app that is normally able to deodex fine, you will most likely get force closes and other random errors. Only use -I as a last resort.
For some reason our BOOTCLASSPATH on the ICS leak seems to list some files that don't exist in /system/framework. This means that when you try to baksmali you will get an error about not being able to load class files. If you get this error, look for the .jar that it references, and delete it from the BOOTCLASSPATH and try again. In the end it should look something like this in Windows:
Code:
C:\path_to_frameworks\core.jar:C:\path_to_frameworks\core-junit.jar:C:\path_to_frameworks\bouncycastle.jar:C:\path_to_frameworks\ext.jar:C:\path_to_frameworks\framework.jar:C:\path_to_frameworks\framework-ext.jar:C:\path_to_frameworks\android.policy.jar:C:\path_to_frameworks\services.jar:C:\path_to_frameworks\apache-xml.jar:C:\path_to_frameworks\filterfw.jar:C:\path_to_frameworks\com.motorola.android.frameworks.jar:C:\path_to_frameworks\com.motorola.android.widget.jar:C:\path_to_frameworks\com.motorola.frameworks.core.addon.jar
Thanks alteredlikeness for the tip!
Deodexing Automatically with xUltimate (Windows)
Coming soon...
Hope this helps clear up some questions that you've had... enjoy!
Nice work!
Mods, stickify please?
Sent from my SAMSUNG-SGH-I747 using xda premium
Grrreat! Thank you for putting this together! I swear I dreamed about this last nite...
But, a note on bootclasspath: For ICS, I have run into problems using it directly from the init.rc - we don't physically have all of those jar files in our framework. So, I removed a couple and have not ran into problems since. Here's what I got:
Code:
/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework-ext.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar:/system/framework/com.motorola.frameworks.core.addon.jar
Edit: edited.
alteredlikeness said:
Grrreat! Thank you for putting this together! I swear I dreamed about this last nite...
But, a note on bootclasspath: For ICS, I have run into problems using it directly from the init.rc - we don't physically have all of those jar files in our framework. So, I removed a couple and have not ran into problems since. Here's what I got:
Code:
/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework-ext.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar:/system/framework/com.motorola.frameworks.core.addon.jar
Click to expand...
Click to collapse
Thanks! I haven't manually done anything in ICS so I forgot about that... modified OP
hello i got classes.dex and put it in Bluetooth.apk , i put it on system/app and removed old apk, .odex files but after reboot i can't find bluetooth.odex in system/app , and not working what i changed in apk...
Error when attempting first deodex
I get this error not matter how I do the command in CMD.
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: Cannot locate boot class path file C
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.java:218)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:146)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:101)
at org.jf.baksmali.main.main(main.java:308)
I am a noob when it comes to this stuff...do you have any insight on this? Thanks.
jcvermillion
HTC Droid Incredible 4G LTE
Rooted
Unlocked Bootloader
Ready to Deodex the old fashion way.
First: I got this error:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: Cannot locate boot class path file C
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.java:218)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:146)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:101)
at org.jf.baksmali.main.main(main.java:308)
Click to expand...
Click to collapse
after writing this
Code:
java -jar baksmali-1.4.2.jar -a 10 -c \framework\core.jar:\framework\bouncycastle.jar:\framework\ext.jar:\framework\framework.jar:\framework\android.policy.jar:\framework\services.jar:\framework\core-junit.jar -x framework.odex
(I am using mac os x)
Second: what should I use to put classes.dex files inside .jar files??
I have the same error and where i must put your solution
"java -jar baksmali-1.4.2.jar -a 10 -c \framework\core.jar:\framework\bouncycastle.jar:\framework\ext.jar:\framework\framework.jar:\framework\android.policy.jar:\framework\services.jar:\framework\core-junit.jar -x framework.odex"
Where i must put this?
Thanks.
Edit: i used this topic to deodex my pre-rooted ROM: http://forum.xda-developers.com/showthread.php?t=2374008
Help-Me Memo.odex Samsung GT-S5360B
Help-me
C:\framework>java -jar baksmali.jar -a 10 -c c:\framework\core.jar:c:\framework\
bouncycastle.jar:c:\framework\ext.jar:c:\framework\framework.jar:c:\framework\an
droid.policy.jar:c:\framework\services.jar:c:\framework\core-junit.jar -x Memo.o
dex
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: Cannot locate boot class path file c
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.jav
a:237)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:14
5)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.j
ava:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:111)
at org.jf.baksmali.main.main(main.java:293)
anexo: Memo.apk, Memo.odex, init.rc, BOOTCLASSPATH.txt
Anyone got solution for these 'cannot find boot class path in C' error ?
EDIT:FOUND IT!!!
Just copy all framework files in C:/framework and instead of -c use -d
and command should look like
Code:
java -jar baksmali.jar -a [COLOR="Red"]##(api lvl)[/COLOR] -d C:/framework/ -x [COLOR="red"][.odex file][/COLOR]
No need to type the whole bootclasspath he just needs the path to framework folder
Hope it helps
I am trying to deodex telephony-common.jar and telephony-common.odex
I tried first
Code:
java -jar baksmali.jar -x telephony-common.odex
and got
Code:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Code.Analysis.ClassPath$ClassNotFoundException: Could not find superclass Landroid/app/Service;
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.loadSuperclass(ClassPath.java:784)
at org.jf.dexlib.Code.Analysis.ClassPath$ClassDef.<init>(ClassPath.java:668)
at org.jf.dexlib.Code.Analysis.ClassPath.loadClassDef(ClassPath.java:280)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:163)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPathFromOdex(ClassPath.java:110)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:98)
at org.jf.baksmali.main.main(main.java:278)
Error while loading class Landroid/accessibilityservice/AccessibilityService; from file ./framework.zip
Error while loading ClassPath class Landroid/accessibilityservice/AccessibilityService;
then
Code:
java -jar baksmali.jar -c "/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/core.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/core-junit.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/bouncycastle.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/ext.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/framework.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/framework-ext.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/android.policy.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/services.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/apache-xml.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/filterfw.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/com.motorola.android.frameworks.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/com.motorola.android.widget.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/com.motorola.frameworks.core.addon.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/kafdex.jar:"/home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework"/com.motorola.orange.simauth.jar -x telephony-common.odex
and got
Code:
Error occured while loading boot class path files. Aborting.
org.jf.dexlib.Util.ExceptionWithContext: Cannot locate boot class path file /home/matthew/temp/X9006&X9076ColorOS_V1.2.7i_full/system/framework/core.jar
at org.jf.dexlib.Code.Analysis.ClassPath.loadBootClassPath(ClassPath.java:237)
at org.jf.dexlib.Code.Analysis.ClassPath.initClassPath(ClassPath.java:145)
at org.jf.dexlib.Code.Analysis.ClassPath.InitializeClassPath(ClassPath.java:131)
at org.jf.baksmali.baksmali.disassembleDexFile(baksmali.java:105)
at org.jf.baksmali.main.main(main.java:278)
WHAT IS THIS, AND WHAT IS IT FOR?
This is a guide for creating a new odex file from a deodexed file, one at a time – manually, or with the tool provided. There are tools/methods for doing the entire system at once, but I have not had any luck with those. Plus, typically, one does not need the entire system re-odexed. This is more for those who want to personally mod their stock odexed systems, or create an odexed ROM maybe.
For starters, you can get away with modding a lot on an odexed system, without needing to deodex. You really only need to deodex in order to edit the smali files within the classes.dex (which is required to achieve the cooler mods). See cogeary’s great guide for deodexing tips.
-------------------------
SCRIPT METHOD (using the 1by1_ReOdexer):
I made this script to speed up the process a little bit (thanks! to jimbridgman and cogeary for their input).
NOTE: This could hurt your phone if you don't place your original files (the ones that are currently running on your odexed system) in the 'orig-odexed' folder…
Requirements:
Windows OS (for now – Linux coming soon)
odexed system
root
busybox installed
DOWNLOAD the 1by1_ReOdexer_v2.0.zip for Windows
Unzip it on your desktop or other convenient place (with no spaces in the file path), and read the README.txt.
NOTES
-It will show a few failed processes right when the script starts - it's just trying to clean stuff that isn't there..
-This will not push the new modded files to your phone - but, the re-odex process needs to take place in the /system, so this script does a quick switcheroo by pushing the deodexed file to your running odexed system, then replaces the originals (that's why you must place copies of the odexed ones from your system to the 'orig-odexed' folder - I plan on automating that too eventually) - that's also why you may need to reboot afterwards to straighten things out
-It still needs A LOT of work... but it does the job
MAJOR NOTE: The script is currently set up based on Motorola’s ICS bootclasspath.
To change the file name/path and/or the bootclasspath, right-click on the .bat file and open with a text editor (preferably something like Notepad++) and edit accordingly. The bootclasspath was taken from /init.rc.
-------------
MANUAL METHOD:
I will use the services.jar in this example. Just change the file name and path to existing .odex accordingly for other files. (thanks! to jhotmann for helping me to nail down this method)
Requirements:
odexed system
root
adb
busybox installed
dexopt-wrapper
Put this dexopt-wrapper file in /system/bin with 775 permissions:
X X X
X....X
X....X
Put the deodexed services.jar (or other jar/apk file you want to make a new odex of) on the root your /sdcard (on some phones that means internal storage).
Make sure USB Debugging is enabled.
Put your USB connection to MTP or PTP mode.
The bootclasspath is located in the /init.rc file at the root of your phone. Just make sure that all jars listed in init.rc are actually in your /system/framework folder and only include those in your bootclasspath in the command below. The one from Moto A2/Razr/other ICS is used below (minus the extra jar paths). To replace it with that of a different device, change the word bootclasspath with yours, using the path style as shown in the example below: dexopt-wrapper services.jar new.odex bootclasspath...
Connect with adb (do a adb devices check to make sure you're all good).
To create the new odex, enter the following one line at a time:
Code:
adb shell
su
cd /sdcard/
dexopt-wrapper services.jar new.odex /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework-ext.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/filterfw.jar:/system/framework/com.motorola.android.frameworks.jar:/system/framework/com.motorola.android.widget.jar:/system/framework/com.motorola.frameworks.core.addon.jar
To copy the signature from the existing odex (change path to /system/app/.. if necessary):
Code:
busybox dd if=/system/framework/services.odex of=new.odex bs=1 count=20 skip=52 seek=52 conv=notrunc
Done! Rename new.odex (created on your /sdcard) to services.odex since that is your new signed odex file... and move to your phone using the method of your choice.
---------------------
CHANGE LOG:
Code:
11/7/12 (v2.0)
-more automated
-changed the location where the new odex is made
-thanks to [URL="http://forums.acsyndicate.net/showthread.php?113-Re-Odexing-script&p=1369&viewfull=1#post1369"]tanimn[/URL] for the hint
-thanks to [URL="http://forum.xda-developers.com/showthread.php?t=1879128"]alkhafaf[/URL] for his bat files that I got ideas from (his script didn't work for me)
8/25/12 (v1.0)
-initial release
Thanks to the following for testing!:
-A2Trip (formerly DX2Trip) on the A2 ICS
-RETIEF on the RAZR Maxx ICS
-iwabashu on the RAZR ICS
(I tested it on GB - but I am not high-fiving myself :D)
-----------------
Some vague notes on what to do next:
Depending on what you are after by re-odexing, there are different routes. For example, if you only edited or copied smali files, then you only need the new.odex file. Meaning that all of the smali code was inside of that classes.dex of the deodexed file on your sdcard, and you just made that into a new odex file (and copied the signatures from the existing .odex in /system).
If you have a deodexed apk with more edits than just smali (you could really just copy those edits over to your existing odexed apk with 7-zip or similar), but – if you want to, you will need to remove the classes.dex from the deodexed apk, and make sure that the signatures (/META-INF folder) and AndroidManifest.xml are the same as your existing apk (check, and or copy with 7-zip or similar).
.
.
.
Good job on this!
Mods, am I crazy or are we in need of a separate "stickied" section here"?
Please stickify...
An Edit: I'm glad were seeing so many great guides here in this forum, before long, we'll have a directory that other forums will envy -if not already.
Sent from my SAMSUNG-SGH-I747 using xda premium
Updated the tool (not the guide).. eh, it's still a work-in-progress but gets the job done
Please help me deodex part of samsung p3100 firmware. My aim is to make tablet view for 4.1.1 android(firmware - vodafone), but I stuck with simple deodex. The only file I need to deodex is android.policy.jar Here is what I do:
1) Installed JDK
2) Copied /system/framework from device(I think that way of copying is not significant, I unpacked tar file of cwm backup) +copied init.rc file
3) Downloaded Smali and Backsmali 1.4.1, renamed them into smali.jar and backsmali.jar,
4) Put them all in the same folder (in my case c:\smali\)
5) Unpacked android.policy.jar with script(BOOTCLASSPATH taken from init.rc):
java -Xmx1024m -jar baksmali.jar -c :core.jar:core-junit.jar:bouncycastle.jar:ext.jar:framework.jar:framework2.jar:android.policy.jar:services.jar:apache-xml.jar:sec_edm.jar:seccamera.jar -x android.policy.odex
Click to expand...
Click to collapse
6) Build classes.dex file with script:
java -Xmx1024m -jar smali.jar out -o classes.dex
Click to expand...
Click to collapse
7) Opened android.policy.jar with 7zip and copied classes.dex there
8) Ready file I put to the device and deleted android.policy.odex file
The only result I receive - stuck on bootlogo. After returning unchanged jar and odex file through cwm it boots normally.
What I'm doing wrong?
Hey there!
I'm having the same problem Did you ever resolve this?
I did this for myself, and thought I would share. I got tired of the "Raise volume above safe level?" warning, and I removed it. I like to learn, so rather than use the existing xposed framework mod, I built a flashable zip to make the change via framework-res.apk.
WARNING: I AM NOT RESPONSIBLE IF YOU MESS UP YOUR PHONE
Prerequisite:
ATT Moto X running stock official 4.4 kitkat (140.44.5)
TWRP or CWM (safestrap for those who don't have an unlocked bootloader, thanks Hashcode)
backup all of your data in case something goes horribly wrong
Instructions:
using your choice of file manager, backup /system/framework/framework-res.apk
Download or copy flashable zip (below) to sdcard
Reboot to [safestrap] TWRP recovery
flash zip file
Below are the 'broad strokes' of how I did this in linux: (Each of these steps below require various skills, and my intent is not to do too much 'hand holding.')
DUMP AND DECOMPILE framework-res.apk
make sure java 7 is installed
download/extract apktool_2.0.0b7.jar (thanks brut.all)
move /system/framework/framework-res.apk to apktool directory
install framework: java -jar apktool_2.0.0b7.jar if framework-res.apk
dump framework-res.apk: java -jar apktool_2.0.0b7.jar d framework-res.apk
--
CHANGE SETTING IN TWO FILES:
edit this file: framework-res/res/values/bools.xml
search for the line with this info: config_safe_media_volume_enabled
change the value to: false
repeat with framework-res/res/values-mcc310/bools.xml
--
DELETE DIRECTORY STRUCTURE (not sure why framework wouldn't compile with this, but it is unused on AT&T phones)
delete this directory: framework-res/values-mcc310-1
--
RECOMPILE AND COPY EXISTING SIGNATURE:
recompile: java -jar apktool_2.0.0b7.jar b framework-res -o framework-res-new.apk
move META-INF structure from inside the original framework-res.apk to the new framework-res-new.apk (I used 7z)
--
ZIPALIGN NEW FILE:
zipalign -f -v 4 framework-res-new.apk framework-res.apk
--
CREATE FLASHABLE ZIP WITH NEW framework-res.apk
you can use mine as a template and just replace my framework-res.apk under /system/framework
TWRP/CWM flashable zip: http://www.androidfilehost.com/?fid=23252070760973197
(Replaces /system/framework/framework-res.apk with my modified version.)
Trying this now on my Rogers ATT KK based Moto X. Ill update soon.
Updated script brakes at device check.
Sent from my XT1058 using XDA Premium 4 mobile app
slimdizzy said:
Updated script brakes at device check.
Sent from my XT1058 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
Do you mean the updater-script in the flashable zip? If so, you can modify those checks for your phone if you can see the error. I used twrp->advanced->copy logs to /sdcard to see the error messages.
Ctrl-Freak said:
Do you mean the updater-script in the flashable zip? If so, you can modify those checks for your phone if you can see the error. I used twrp->advanced->copy logs to /sdcard to see the error messages.
Click to expand...
Click to collapse
Will do. Ill post shortly.
Update:
Installing '/sdcard/motox-att-140.44.5-framework-res-1.zip'...
Checking for MD5 file...
I:Cannot find file /sdcard/motox-att-140.44.5-framework-res-1.zip.md5
Skipping MD5 check: no MD5 file found.
I:Zip does not contain SELinux file_contexts file in its root.
script aborted: This package is for "ghost" devices; this is a "xt1060".
This package is for "ghost" devices; this is a "xt1060".
E:Error executing updater binary in zip '/sdcard/motox-att-140.44.5-framework-res-1.zip'
My build.prop shows 1058 for the record.
slimdizzy said:
Will do. Ill post shortly.
Update:
Installing '/sdcard/motox-att-140.44.5-framework-res-1.zip'...
Checking for MD5 file...
I:Cannot find file /sdcard/motox-att-140.44.5-framework-res-1.zip.md5
Skipping MD5 check: no MD5 file found.
I:Zip does not contain SELinux file_contexts file in its root.
script aborted: This package is for "ghost" devices; this is a "xt1060".
This package is for "ghost" devices; this is a "xt1060".
E:Error executing updater binary in zip '/sdcard/motox-att-140.44.5-framework-res-1.zip'
My build.prop shows 1058 for the record.
Click to expand...
Click to collapse
Did you build this from your Rogers framework? (If not, keep in mind my framework-res if from an AT&T phone. I have no idea if there are any differences.)
To continue, you can edit the updater-script and make the change from "ghost to "xt1060".
I have a rogers phone but ATT firmware. This is just what happens when I flash your zip. Your updated script asks for a 1058, which is my model but breaks and says my device is a 1060. That is nowhere in my prop. This should flash no problem and it doesn't. I even tried to manually overwrite using root explorer and my phone wouldn't boot after. I replaced original file and all is well.
Sent from my XT1058 using XDA Premium 4 mobile app
Thanks, this worked like a charm for my Moto G.
I used Advanced ApkTool v2.0.0 to decompile 'framework-res.apk',
I used Notepad++ to set all 'config_safe_media_volume_enabled' entries to false,
After the recompilation, I extracted the content of the original 'framework-res.apk' with 7-zip, and just replaced 'resources.arsc' with the modified one. (can be found in the '\build\apk' directory)
Recompressed again with 7-zip (compression level: store) and used adb to replace the file:
adb push framework-res.apk /sdcard/Download/framework-res.apk
adb shell
Code:
su
mount -o remount,rw -t ext4 /dev/block/platform/msm_sdcc.1/by-name/system /system
mv /system/framework/framework-res.apk /system/framework/framework-res.apk.bak
cat /sdcard/Download/framework-res.apk > /system/framework/framework-res.apk
chmod 644 /system/framework/framework-res.apk
sync
reboot