[Verizon Samsung Galaxy S III] razz1:
5. THE MODS

So we have that nice clean base but what about all them mods in the roms we download and flash everyday? There are a few different ways we can do this and we will start with the easiest but first, do a nandroid backup of your new base. If one of your mods you perform next goes bad it's simply quicker to recover. Now, If you have flashable zips of some of the mods you like then you can flash them now and make sure they are working the way they should in your rom. Remember, just cause we have the d2vzw does not mean mods from the sprint or T-mobile won't work on our devices. Sometimes it's worth a try. It's all about which firmware they are on and what has changed with the firmware.

So we flashed a few mods but don't have everything we wanted. At this point you are left with only one option and that is to get on that PC of yours and learn to decompile a APK. I may touch on this subject later as it is a bit more involved for someone new to this sort of thing.

6. UNDERSTANDING THE FLASHABLE ZIP

The alternate method of a flashable zip is to extract your flashable using Root Explorer and picking it apart. For example we will use "Lean Kernel" and kill 2 topics with one stone. If you unzip the kernel you will see...

BOOT.IMG

META-INF

SYSTEM

As you can see there are some familiar files to us just like when we extracted our base rom in the beginning. Basically when you flash a mod like this or any flashable for that matter, it installs files into your rom in certain places. In this example we will be installing in BOOT.IMG and SYSTEM. But what? And what is that META-INF file for? Well this META-INF file is what tells your rom what files and what to do with those files. Inside META-INF is a text file called an "updater script".

Here is what it looks like...

show_progress(0.500000, 0);
mount("ext4", "EMMC", "/dev/block/mmcblk0p14", "/system");
package_extract_dir("system", "/system");
set_perm(0, 0, 0777, "/system/etc/init.d/00leanKernel");
unmount("/system");
assert(package_extract_file("boot.img", "/cache/boot.img"),
write_raw_image("/cache/boot.img", "/dev/block/mmcblk0p7"),
delete("/cache/boot.img"));
show_progress(0.100000, 0);

Line 2 shows it mounting the system so we can write to it.

Line 3 shows us extracting the entire directory of the system file in the flashable into the system file of our rom.

Line 4 shows we are setting permissions for one of the system files we just installed in the rom. In this case it is an INIT.D file.

Line 5 shows us returning the system to an un-writable state.

Line 6 shows we are now installing the other file called BOOT.IMG.

So we installed BOOT.IMG and the SYSTEM file. The BOOT.IMG file is usually only found in a rom or kernel zip so most of the time you won't see this file in a flashable but I wanted to use this as an example to show a bit about the kernel side of things.

Ok, so lets get back to the original files of this flashable zip. The updater script stated we installed a new system file into the rom so whats in there? If we open the SYSTEM file from our flashable with Root Explorer you will find a file hierarchy...

SYSTEM

-- ETC

--- INIT.D

---- "00LEANKERNEL"

-- LIB

--- MODULES

---- Listed here are a bunch of ".ko" modules and i'm not listing them all.

So whats the point of all this? Well lets say when we originally debloated our rom in the begining we could of included some of our flashable mods like a custom kernel before we zip the rom to test the base. So in this case we can manually install this kernel before we zip the base. We can take the BOOT.IMG from our extracted kernel and replace the BOOT.IMG in our extracted rom. We only need the files from the flashable so we need to copy and paste the "00LEANKERNEL" file from our flashable to our roms /system/etc/init.d folder. We can also take those ".ko" files from the flashable and dump those into the /system/lib/module folder and we are done. You have now manually installed a kernel into your base rom before you zipped it. Now when you zip your rom and flash it, your new base rom will boot with your custom kernel. Since we manually installed the kernel we don't need the META-INF file provides an auto install script for installing through recovery. Technically we could take all of our flashable mods, extract them, look at the file hierarchy and copy and paste the those files to our extracted base rom. That way we can zip our rom and test it with the mods right off the bat. You can really make things quicker this way and is in general the way to go.

I think it's rather important to fully understand a flashable zip. How it's built and how it completes it's task. It's used so often and makes mods so incredibly easy to install but it is also what installs our rom! One of the files we see when we open "slick" is a META-INF and there inside is the updater script to flash the rom. Again we are doing the same thing as we do with the flashable mod but this time we are installing a lot more files with a lot more permissions. It is the exact same thing as shown above just a bit more extensive.