[AT&T Samsung Galaxy S II SGH-I777] Entropy512:
Obtaining firmware and deodexing

The best place to find I9100 stock firmware images for deodexing is, in my opinion, Intratech's thread in the I9100 Original Android Development forum. This thread is at:

http://xdaforums.com/showthread.php?t=1075278

For the purposes of this guide, I'm originally going to use the XWKL1 download.

The next thing you need (in addition to a Linux box and the knowledge of how to use it...) is dsixda's Android Kitchen. While kitchens are generally frowned upon by firmware maintainers, deodexing manually is a massive pain in the ass and usually using dsixda's kitchen for this purposes is considered OK. To paraphrase gtg465x: "Deodexing with it is OK, but anything more and the ROM gods will frown upon you". Some of the other features of the kitchen like preintegrating busybox and rooting have issues - namely that they often inject old versions of busybox/su.

While the kitchen officially is supported on Windows, I cannot help you with any Windows-specific issues - you're on your own.

To get dsixda's kitchen, start with his GS2 thread at:

http://xdaforums.com/showthread.php?t=1227549

I am going to use the latest version as of the time of this writing, which is 0.188

Extract the kitchen somewhere in your filesystem - I will refer to the directory unzipping the kitchen creates as $KITCHEN_ROOT

Extract factoryfs.img from the stock firmware TAR you downloaded earlier - you don't need anything else. You may need to fix its permissions by making it readable:

chmod a+r factoryfs.img

Place factoryfs.img in:

$KITCHEN_ROOT/original_update/

Start the kitchen by going to $KITCHEN_ROOT and running the menu:

./menu

Choose 1) Setup working folder from ROM

Accepting all of the defaults should work. It'll complain about not finding any kernel or cache - but this is OK. Neither of these are really needed as Hellraiser will take care of these later. The kitchen will ask for root permissions (sudo password) to extract the firmware contents. Say yes when it asks about a fake boot.img

Next, we deodex. Choose 0) Advanced Options

Choose 11) Deodex

Choose b) to deodex both /system/app and /system/framework

This will take a while. Go do something else. For example, I'm going to take a shower. (You don't need that much time - but I need a shower. ;) )

Take a careful look at the last few lines of results here. If the deodex job worked perfectly, you should see no failure reports and 0 odex files in /system/framework or /system/app. However, for I9100 XWKL1, three .odex files will remain in /system/app, and you will see the following error:

Could not deodex the following (you can try to deodex these files again):
Maps.odex Phonesky.odex VoiceSearch.odex

Sometimes a second deodex pass will fix these, but not for these three files for XWKL1. You need to find a different way to fix them. Now I've heard that some advanced options like API Level mangling can fix these errors, but we're going to go with a simpler and easier approach for now.

We are now going to enter our last steps of the kitchen before we switch to manual maintenance of the firmware:

Return back to the main menu of the kitchen.

Choose option 99) Build ROM from working folder

Go ahead and use the defaults EXCEPT when it asks you to sign the firmware - note that this will zipalign all files (this is why zipalign scripts in init.d are rarely useful - on any decent firmware everything should already be zipaligned.)

Say no when it says to sign the firmware - since you're going to be making manual changes to the results, the signature will be broken.

You will now have a ZIP file in the following location:

$KITCHEN_ROOT/OUTPUT_ZIP/

DO NOT FLASH THIS FILE. IT STILL HAS SERIOUS ISSUES THAT REQUIRE REPAIR.

On to the next step... We take this firmware that is high in fiber and digest it a bit ourselfs, preparing to plop it out.