[Captivate General] MikeyMike01:
Note: This guide was written for Froyo

Well to start, the Samsung leaked firmwares (many of them, at least) are located here:

http://www.samfirmware.com/WEBPROTECT-i9000.htm

You unpack that with WinRAR, and you'll get a modem.bin, factory.rfs, zImage, cache.rfs, and maybe some other crap. The modem.bin and zImage are useless as they're the modem and kernel, which would technically work on a Captivate but is less than ideal. For example the screen will be rotated 90 degrees incorrectly (Captivate kernels based on i9000 firmwares that have the problems fixed are frequently called reoriented kernels for this reason). The speaker will only work if headphones are plugged in (and headphones only work when they're not plugged in, which is a bit of a problem).

The cache.rfs has the CSC folder, mostly, which you can use but it's also not ideal. If there's ever an sbl.bin or boot.bin those need to be deleted as they're locked bootloader files. The leaked firmware for the Tab had these and people got locked into Samsung firmwares from flashing them. Don't know if that was ever fixed or not.

Then there's factory.rfs. You can open up the .rfs in Magic ISO and extract the /system files.

From there the system apps have to be deodexed, (which takes the .apk files and their corresponding .odex file and puts it into one single .apk file). This allows the .apk to be modified without worrying about the .odex becoming incompatible. The /system/framework contains a bunch of .jar files and two .apks that have to be deodexed also.

From there you can begin to remove the useless junk. The Samsung Apps, the FM Radio (doesn't work), the Book Reader app, Voice Recorder, etc. Some things you're stuck with, the Contacts and the Dialer.

In this particular firmware base (JPY) there's a couple things that are messed up that need to be addressed. The wifi firmware needs to be rolled back to an older one to improve battery life, the gallery app needs to be swapped out to prevent a battery drain problem, there's a camera-related driver file that needs to be swapped out so the Camera will work without the Email app being present. Things like that.

The .apks can be decompiled to edit them (for example Contacts, Dialer, etc. have "Video Call" buttons that need to be edited out in the .xml files that are contained). This can de done with APK Manager, or directly with APK Tool. Either way it comes down to changing things in Notepad++. I've got a guy named ChanceM that I talk to in IRC... he's great with this part and helped with a lot of different things. Particularly the 4 lock screen mod, and he keeps a battery mod maintained for people that like that sort of thing.

As far as theming them, you can either copy over images in 7-zip, or decompile them with APK Manager. Depends on what you need to do. To change colors of text, what the text says, layouts, etc. you need to decompile it and look at the .xml files. If it's a .png that doesn't end in .9.png then you can just copy it over as you see fit.

If the .png ends in .9.png, there's a special 1 pixel border around the image that only appears after it's been decompiled. It's either black or transparent and that governs the stretching of the image. This is called 9patch data. If you simply copy over an image without decompiling it, decompiling it afterwards will not work correctly and you'll have to recreate the image with that one pixel border.

As far as what the 9patch data actually tells the system, I'll differ to this picture I found on developer.android.com:

This is used on buttons and things, so that one image can be used to create multiple buttons with different sizes. For example:

Beyond the theming of the system apps and the (tw)framework-res.apk (these two are used to draw things like the status bar and menus), there's also some heavy duty modifying to the android.policy.jar. This changes the Power Menu such that Reboot/Recovery/Download are added to the bottom of the standard options. This gives easy access to those modes without the use of the SDK. The fix for the home haptic button is also in android.policy.jar. The lock screens are all inside android.policy.jar.

Unlike .apks, it's a bit more difficult to modify the .jar files. You've got to open the .jar in 7-zip or some such, and then extract a classes.dex file into any old folder. You'll also need a baksmali.jar and smali.jar inside that folder too. Then (after you've installed the Java SDK, Android SDK, and added them to the Windows PATH file) you must enter into a Command Prompt the following:

This creates a classout folder that contains an entire hierarchy of .smali files ready to be edited in Notepad++. Not as easy as .xml edits, because these are written in straight up code and can be thousands of lines long for each .smali. However, once you're done, the following will convert it back into a classes.dex file, which can replace the original using 7-zip:

From there you can add any apps and tweaks you like. A custom kernel, a modem you like, and you're almost done.

You've still got to install the files for busybox, root, etc. Those go in /system/xbin.

Once you've got it down to a useable state you've got to write an update-script to actually install it. This is what mine is:

Sets the progress bar equal to zero.

Out with the old...

...and in with the new.

This creates symlinks for various commands that you or the system might need.

This sets the permissions on the files and folders to what's necessary.

This will install busybox.

This installs the modem.

This installs the kernel.

That's a followup command to the original command for the progress bar.

-----

That pretty much covers the basic stuff. I tried to keep it as short as possible. ;)