Patching a single .odex in G1's core system

244 views
Skip to first unread message

luke

unread,
Jan 8, 2009, 8:43:13 PM1/8/09
to android-platform
I have written a patch for a class in "framework" that I want to
install on my G1. I have root, but I want to make sure I don't break
my phone. I rebuilt the framework .dex file:

$ ls -l out/target/common/obj/JAVA_LIBRARIES/framework_intermediates
total 11800
-rw-r--r-- 1 luke luke 4889000 2009-01-08 07:11 classes.dex
-rw-r--r-- 1 luke luke 4823689 2009-01-08 07:09 classes.jar
-rw-r--r-- 1 luke luke 197692 2009-01-08 07:25 droiddoc-src-list
-rw-r--r-- 1 luke luke 2126019 2009-01-08 07:11 javalib.jar
drwxr-xr-x 7 luke luke 4096 2008-10-21 23:23 src

I understand I need to convert this to a .odex file after installing,
but what is the right tool and what is the right way of using it? Do
I just call dexopt-wrapper on the file to build the .odex and the
correct small corresponding .jar, then replace the installed ones and
reboot?

Also what is the chance of this framework.odex being incompatible with
the rest of the classes in the G1 system image, if I grabbed a git
clone of the 1.0 repository shortly after the release of the 1.0
code? (i.e. how likely am I to break my system?)

fadden

unread,
Jan 9, 2009, 12:46:06 AM1/9/09
to android-platform
On Jan 8, 5:43 pm, luke <luke.hu...@gmail.com> wrote:
> I understand I need to convert this to a .odex file after installing,
> but what is the right tool and what is the right way of using it?  Do
> I just call dexopt-wrapper on the file to build the .odex and the
> correct small corresponding .jar, then replace the installed ones and
> reboot?

You can read all about the exciting world of .odex in davlik/docs/
dexopt.html in the source tree or git repository.

If you remove framework.odex and replace framework.jar with what
you've built, the necessary optimized DEX file will be generated in /
data/dalvik-cache when you restart the framework. Keep an eye on
"logcat" to see it do its thing. You probably want out/target/product/
dream/system/framework/framework.jar, not the stuff from the
intermediates directory, if you go this route.

Otherwise, running dexopt-wrapper on the device will work to convert
classes.dex into classes.odex. You can leave the corresponding jar
file alone unless your change affects it somehow.

You may want to experiment with this stuff on the emulator, where the
price of doing it wrong is small.

> Also what is the chance of this framework.odex being incompatible with
> the rest of the classes in the G1 system image, if I grabbed a git
> clone of the 1.0 repository shortly after the release of the 1.0
> code?  (i.e. how likely am I to break my system?)

Mixing and matching from different releases is not a good idea.

luke

unread,
Jan 9, 2009, 1:04:36 AM1/9/09
to android-platform
Thanks for the info. What is the closest git version to what made it
into the G1?

Dianne Hackborn

unread,
Jan 9, 2009, 2:45:59 AM1/9/09
to android-...@googlegroups.com
On Thu, Jan 8, 2009 at 10:04 PM, luke <luke....@gmail.com> wrote:
Thanks for the info.  What is the closest git version to what made it
into the G1?

There isn't anything close enough to selectively replace the framework jar.  The open source tree represents a version of the code with a number of changes from after the image shipped on the G1 that impact the framework.

--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support.  All such questions should be posted on public forums, where I and others can see and answer them.

luke

unread,
Jan 9, 2009, 1:41:25 PM1/9/09
to android-platform
Hmm. Is there some way to just replace one class in an odex file?

I rebuilt the entire system image using non-cupcake git head and
loaded it onto the phone, but several things are broken (Messaging,
phone radio) so I can't use this patched system image for my daily
phone use. I want to apply the least invasive patch possible, just
enough to add the framework functionality I need to start building a
specialized app on top of my patched phone that makes use of the added
framework functionality, but I need to be able to continue actually
using the phone.

I notice that as well as a framework.odex on the phone, there's also a
framework.jar but it's tiny. Is there some way I can get a copy of
the original framework.jar that was used to generate the
framework.odex, so that I can just replace the one .jar file for the
framework class I'm modifying, then have the phone re-create the .odex
file from the modified .jar?

Thanks!



On Jan 9, 2:45 am, "Dianne Hackborn" <hack...@android.com> wrote:
> On Thu, Jan 8, 2009 at 10:04 PM, luke <luke.hu...@gmail.com> wrote:
> > Thanks for the info.  What is the closest git version to what made it
> > into the G1?
>
> There isn't anything close enough to selectively replace the framework jar.
> The open source tree represents a version of the code with a number of
> changes from after the image shipped on the G1 that impact the framework.
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com

luke

unread,
Jan 9, 2009, 1:44:10 PM1/9/09
to android-platform
> Is there some way I can get a copy of
> the original framework.jar that was used to generate the
> framework.odex, so that I can just replace the one .jar file for the
> framework class I'm modifying, then have the phone re-create the .odex
> file from the modified .jar?

(sorry, that should say "so that I can just replace the one .class
file for the framework class I'm modifying")

fadden

unread,
Jan 9, 2009, 8:22:46 PM1/9/09
to android-platform
On Jan 9, 10:41 am, luke <luke.hu...@gmail.com> wrote:
> Hmm.  Is there some way to just replace one class in an odex file?

Is it theoretically possible? Yes.

It would not be easy though. You'd have to spend a bunch of time
developing tools to break apart and reassemble the DEX, and the
presence of "quickened" instructions in the .odex make it even harder.
Reply all
Reply to author
Forward
0 new messages