[Android Software Development] STRYDER~007:
Modifying boot.img

Now, let's modify the boot.img from base ROM zip to it make compatible with our MIUI ROM.

First of all, download any boot image kitchen or editor. I used Android Image Kitchen for Windows.

Assuming you're using the same kitchen, Extract the files from Android Image Kitchen in a separate folder. Copy your base ROM boot.img in that folder.

Now drag and drop the boot.img on unpackimg. The kernel files will be extracted in ramdisk and split_img folder.

We have to modify the ramdisk so move to that. In sbin folder, you'll see the extracted files.

Now there are two chances- First, Your ramdisk is already extracted with various folders and files. In that case ignore the next steps and directly modify in respective files using Notepad++.

While in second case, you'll get the ramdisk as ramdisk.cpio file. If you get this the you'll have to move to Ubuntu again for extracting it.

Now in Ubuntu, copy your ramdisk.cpio in a seperate folder (suppose in stryder folder) in your home directory.

Now, open terminal and run the following command-[No need as superuser]

cd stryder

cpio -i -F ramdisk.cpio

Some output will be shown in terminal as 2320 blocks or something like that!

Now in your folder, you'll see the extracted ramdisk files.

Now comes the actual modification.

First of all, download attached zip and extract the files in appropriate folders. (If the folder is not present, add that folder).

Open default.prop and edit the lines like this-

#
# ADDITIONAL_DEFAULT_PROPERTIES
#
ro.adb.secure=0
ro.secure=0
ro.allow.mock.location=0
ro.debuggable=1
persist.sys.usb.config=mtp,adb
persist.service.adb.enable=1
persist.service.debuggable=1

Save the changes and open init.cm.rc (In case of CyanogenMod) or init.pa.rc (In case of AOSPA). Add # before the import line like this-

# Superuser
#import /init.superuser.rc

Save this file and now open init.rc.

At the end of init.rc file, add these lines-

#service for shelld
service shelld /system/xbin/shelld
class main

#service for su
service su_daemon /system/xbin/su --daemon
class main
oneshot

service lbesec /system/xbin/lbesec
class main
oneshot

Save this file and then open seapp_contexts.

In that file, add at the end-

user=theme seinfo=platform domain=platform_app type=platform_app_data_file
user=backup seinfo=platform domain=platform_app type=platform_app_data_file
user=updater seinfo=platform domain=platform_app type=platform_app_data_file
user=theme_man domain=system_app type=system_data_file

Also modify these lines (if present) to look like this-

user=_app domain=untrusted_app type=app_data_file
user=_app seinfo=platform domain=platform_app type=app_data_file
user=_app seinfo=shared domain=shared_app type=app_data_file
user=_app seinfo=media domain=media_app type=app_data_file
user=_app seinfo=release domain=release_app type=app_data_file

Save this file and if present, open init.qcom.rc.

And before this line (at the end)-

on property:sys.boot_completed=1

Add these lines-

service shelld /system/xbin/shelld
class main

Save the file. Now it's time to repack your ramdisk.

First, move your original ramdisk.cpio from the extracted folder to /home. That is, if your extracted ramdisk is in

/home/stryder/

Move original ramdisk.cpio file to-

/home/

After that, run this command in terminal-

cpio -i -t -F ../ramdisk.cpio | cpio -o -H newc -O ../ramdisk_new.cpio

Now a new file ramdisk_new.cpio will be created. Take a look if it's of the same size as the original one just a few bytes difference.

Also open this ramdisk_new.cpio and make sure you have the newly added files in it. (Ex. otad in bin folder etc.)

Now move this ramdisk_new.cpio to previously extracted Android Image kitchen ramdisk/sbin/ directory.

Delete the original ramdisk.cpio from it and rename the ramdisk_new.cpio to ramdisk.cpio.

Now come back and directly run repackimg. The modified image_new will be generated. Rename it to boot and include this modified boot.img in your MIUI ROM zip. Now you can proceed to flash your MIUI ROM!

Special Thanks- [MENTION=6896091]Zenamp[/MENTION]