irsen
irsen

Reputation: 21

How Generate boot.oat

I need modify android.policy.jar in Android L. I just have ROM and device, no aosp.

Now, I can decompiler boot.oat by oat2dex.jar, get dex like android.policy.dex/framework.dex ...

My preblem is that I do not know how to generate boot.oat after decompiler it.

I want to modify android.policy and then re-generate boot.oat, replace the original one.

Is there any one please help me on that?

Upvotes: 2

Views: 3562

Answers (1)

user3363866
user3363866

Reputation: 457

The dex2oat on-device compiler is used to compile the java libraries including the android.policy.jar. I did not explicitly test it, but the following might work for you:

You probably want to find out the cmd line args for dex2oat required to create an updates boot.oat that includes your changes. Fortunately, boot.oat stores the cmd line used to generate it in its header. You can use the oatdump binary (available on device, at least for AOSP builds) to dump the header and extract the correct cmd line args. Now issue this command again so that a new boot.oat is generated, this time including your modified policy jar. Make sure that the result is placed in the correct location so that it overwrites the previous version of boot.oat. After a reboot, the new boot.oat should be used everywhere.

Of course, I would recommend to only do this on a test device and make appropriate backups.

Once again, I did not test this, so it is possible that there are additional checks that detect changes in boot.oat so it might happen that it is again regenerated during boot.

Alternative paths in case this one does not work: - the boot.oat file needs to be recreated upon major version updates, so the system definitely knows how to do it. Try to find a way to trigger this. - compile AOSP and print out the command lines used for dex2oat to see how the boot.oat compilation is done for AOSP. Custom ROMs might and will probably differ, but then you have at least a base configuration that you can start to tweak.

Hope this helps.

Upvotes: 1

Related Questions