[Android Software Development] STRYDER~007:
Port MIUI from another device

Requirements:-

7-zip, Winrar or similar software

Notepad++

Instructions:-

First of all, make 2 folders- 1. BASE ROM 2. PORT ROM

What is Base ROM: It is the ROM which is built for your device. (AOSP or CM etc.)

What is Port ROM: MIUI ROM of other device which you want to port to your device.

NOTE-

It's better if the port device and your device has same CPU architecture and specifications. If you couldn't find same specification device then try the device having almost similar specification of your device.

Now extract the Base ROM zip in BASE ROM folder and Port ROM zip in PORT ROM folder.

Next, Delete addon.d (If present), app, framework, fonts, media and priv-app folder in System folder of BASE ROM.

Now copy addon.d (If present), app, framework, fonts, media and priv-app folder from system folder of PORT ROM to system folder of BASE ROM.

Now open etc folder in both ROMs folder. Go to init.d folder of PORT and copy and replace any extra files except 00banner to init.d of BASE ROM.

Now open permissions folder in etc of both ROMs and copy and replace all the permissions files from PORT ROM to your BASE ROM folder except handheld_core_hardware.xml and platform.xml. (In case of CM based BASE ROM, also don't replace org.cyanogenmod.hardware.xml).

Also copy any extra folder available in PORT ROM etc/ to BASE ROM etc/ e.g. miui_feature folder.

Now open your system_fonts.xml in etc folder of BASE ROM and copy this before </familyset> end of file

<family>
<nameset>
<name>miui</name>
</nameset>
<fileset>
<file>Miui-Regular.ttf</file>
<file>Miui-Bold.ttf</file>
</fileset>
</family>

<family>
<nameset>
<name>miuiex</name>
</nameset>
<fileset>
<file>MiuiEx-Regular.ttf</file>
<file>MiuiEx-Bold.ttf</file>
</fileset>
</family>

<family>
<nameset>
<name>miuiex-light</name>
</nameset>
<fileset>
<file>MiuiEx-Light.ttf</file>
</fileset>
</family>

Now copy all the extra files from PORT ROM bin, lib and xbin folder to BASE ROM respective folders. Remember, DO NOT REPLACE anything. Just copy and paste and skip the files with same name.

Now, open build.prop of BASE ROM. You can change these value to anything you like-

ro.build.id=
ro.build.display.id=
ro.build.date=
ro.build.date.utc=
ro.product.locale.language=en
ro.product.locale.region=US
ro.cm.version=
ro.modversion=

Now copy paste these values at the end of your BASE ROM build.prop. You can edit the fields but keep the structure same.You can look at PORT ROM build.prop for reference.

ro.build.description=devicename-user 4.4.2 yourname C2104XXUCNG1 release-keys
ro.build.fingerprint=devicemanufacturer/devicemodel/device:4.4.2/yourname/C2104XXUCNG1:user/release-keys
ro.product.model=Xperia L
ro.product.device=taoshan
ro.build.characteristics=default
#MIUI_Features
ro.miui.has_real_blur=0
ro.miui.has_handy_mode_sf=1
ro.config.sms_received_sound=FadeIn.ogg
ro.config.sms_delivered_sound=MessageComplete.ogg
ro.product.manufacturer=Xiaomi
ro.config.elder-ringtone=Angel.mp3
persist.sys.mitalk.enable=true
ro.miui.ui.version.code=5
ro.miui.ui.version.name=V7
persist.sys.strictmode.disable=true
ro.product.mod_device=yourdevice

Change these fields in BASE ROM build.prop according to PORT ROM build.prop-

ro.config.notification_sound=
ro.config.alarm_alert=
ro.config.ringtone=

If your device has On-screen buttons, then add this value at the end of BASE ROM build.prop-

qemu.hw.mainkeys=0

Now we're done with build.prop.

Next, open META-INF/com/google/android/updater-script from BASE ROM using Notepad++ and change, compare and replace all the symlink and set_metadata lines in updater-script according to PORT ROM updater-script.If some extra lines are there in BASE ROM updater-script, keep it as it is.

NOTE:

-I have attached one sample updater-script with this post. Look below. You can refer from that if you feel any difficulty. :cowboy:

Add these before unmount("/system"); at the end of updater-script-

set_perm(0, 1000, 06750, "/system/xbin/shelld");
run_program("/sbin/busybox", "mount", "/data");
package_extract_dir("data", "/data");
package_extract_file("META-INF/com/miui/relink", "/tmp/relink");
set_perm(0, 0, 0555, "/tmp/relink");
run_program("/tmp/relink");
delete("/tmp/relink");
set_perm_recursive(1000, 1000, 0755, 0644, "/data/miui");
set_metadata("/system/bin/debuggerd", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:system_file:s0");
set_metadata("/system/bin/debuggerd_vendor", "uid", 0, "gid", 2000, "mode", 0755, "capabilities", 0x0, "selabel", "u:object_r:debuggerd_exec:s0");
set_metadata("/system/xbin/su", "uid", 0, "gid", 2000, "mode", 06755, "capabilities", 0x0, "selabel", "u:object_r:su_exec:s0");
delete_recursive("/data/miui/preinstall_apps");
delete_recursive("/data/miui/cust/preinstall_apps");
ui_print("Installation finished...Enjoy!");
unmount("/data");

Also copy META-INF/com/miui and data folder to BASE ROM from PORT ROM.

Now modify your BASE ROM boot.img using the tutorial from previous post and put that new boot.img in BASE ROM folder.

Finally, select META-INF, system, boot.img, file_contexts(If present) and data folder in BASE ROM.

Right click and select Add to Archive. Select Zip. Type the name of zip. (Don't delete ".zip" at the end!) Click OK.

Now you're ready to flash this zip from recovery.

Sometimes, your device might get stuck on bootanimation so in this case, take LOGCAT and look for the error and solve it. You can use some tools like Advanced Logcat Viewer to read the log. Look HERE for fixing bootloop. :D

I hope you guys understood how to build and port MIUI. I wish you good luck! If you get stuck anywhere, If you become successful building MIUI, feel free to post here. Also if you succeed, I'll appreciate if you give me credits and add link to this thread in your ROM thread on XDA. :)