MIUI recently opensourced a set of tools made for porting it's ROM to other devices. Although I haven't managed to build a working ROM for our dear X8, here's a little guide on how it (kinda) works, maybe it helps someone.
Any contribution is welcome
Here's what I've found of PatchROM:
Edit: MIUI changed the way to download the source code. Now you can use PatchROM on Android 2.3 and 4.0!
And make sure you have apktool installed.
The overall proccess looks like this:
- Download the tools
- Get an Gingerbread/ICS ROM to install MIUI stuff;
- Create the required file structure
- Change the Makefile
- Apply MIUI changes to the selected ROM
- Flash it!
STEP 1: Downloading the tools
If you want to patch a 2.3 ROM, just click the 'ZIP' button on the PatchROM Github: https://github.com/MiCode/legacy-patchrom
If you want to patch a 4.0 ROM, do the following:
Supposing you are on Linux:
- Make sure you have the Android SDK installed and on your PATH.
- Install repo following this guide. Do only the 'Installing repo' section.
Then, create a new folder (in my case, ~/patchrom), enter it and type the following commands:
repo init -u git://github.com/MiCode/patchrom.git -b ics repo sync
STEP 2: Choosing the ROM
The PatchROM docs recommend that we use a stock AOSP ROM from the device manufacturer, but there's no official Gingerbread or ICS for our device, so we need to use one of the CM7/CM9 roms. Use an CM7 rom if you are using patchrom-legacy, and use an CM9 rom if you are using the regular patchrom. Make sure you use an deodexed rom or deodex your rom.
The rest of this guide was tested on patchrom-legacy (2.3), not tested on the regular patchrom for 4.0.
STEP 3: Creating the file structure
To port, we need to create a folder inside the PatchROM root directory for our device. There's an example device for the Samsung Galaxy S on the i9000 folder, we'll use that as a base. I created a folder called 'shakira' and copied the makefile file from the i9000 folder and the MiniCM7 zip to it.
You also need to decompile the following APK files and put the resulting folder on the 'shakira' folder:
- and the apps defined on the 'local-modified-apps' below
The makefile has the following structure:
# # Makefile for i9100 # # The original zip file, MUST be specified by each product local-zip-file := I9100ZCKJ1.zip # The output zip file of MIUI rom, the default is porting_miui.zip if not specified local-out-zip-file := MIUI_9100.zip # All apps from original ZIP, but has smali files chanded local-modified-apps := LogsProvider Phone MediaProvider Settings # All apks from MIUI execept MIUISystemUI and framework-miui-res.apk local-miui-apps := Contacts ContactsProvider Mms TelephonyProvider ThemeManager Launcher2 \ DownloadProvider TelocationProvider Notes Music Torch DownloadProviderUi Updater # All apps need to be removed from original ZIP file local-remove-apps := AlipayGphone AmsComposer AndroidQQ_Samsung_Seine BuddiesNow cooldict glyder2 \ ImgoTV iReader kaixin001 Memo MiniDiary MinimalHome mreader PressReader ReadersHub Renren \ Sinamicroblog SinaNews SinaStock SinaWeather SocialHub Tencentmicroblog \ TomEbook Tonghuashun TouchWiz30Launcher Youku_Samsung_seine MusicPlayer \ MediaHub PhotoRetouching VideoEditor thinkdroid QYVideoClient \ Days DigitalClock Dlna DualClock Email EmailWidget FTC FTM FTS Kobo \ Microbesgl Navigator PostIt Protips QuickSearchBox SamsungApps SamsungAppsUNA3 \ SamsungIM SamsungWidget_ProgramMonitor SecretWallpaper1 SecretWallpaper2 \ SevenEngine SnsAccountKx SnsAccountRr SnsDisclaimer SnsImageCache SnsProvider \ Tasks TasksProvider Term TrimApp TwCalendarAppWidget Zinio \ samsungappswidget syncmldm viva_tts # To include the local targets before and after zip the final ZIP file, # and the local-targets should: # (1) be defined after including porting.mk if using any global variable(see porting.mk) # (2) the name should be leaded with local- to prevent any conflict with global targets local-pre-zip := local-zip-misc local-after-zip:= local-test # The local targets after the zip file is generated, could include 'zip2sd' to # deliver the zip file to phone, or to customize other actions include $(PORT_BUILD)/porting.mk # To define any local-target local-zip-misc: cp misc/com.google.android.maps.jar $(ZIP_DIR)/system/framework/ @echo Add google apks cp misc/apk/* $(ZIP_DIR)/system/app/ @echo Replace build.prop cp misc/build.prop $(ZIP_DIR)/system/build.prop local-test: echo "an example action"
- The 'local-zip-file' should match your rom's ZIP (on my case MiniCM-2.1.ZIP)
- The 'local-out-zip-file' is the MIUI ROM output name (put any name you want here)
- The 'local-modified-apps', as pointed by MisterGT, 'are those that are required from the original rom because they do important stuff (like Phone.apk communicates with your phone's radio). Thus these can not be easily copied from miui but have to be modified.'
- The 'local-miui-apps' point to the MIUI files; I didn't changed those
- The 'local-remove-apps' indicates apps to be removed from the ROM
- As MisterGT also pointed out here (thanks mate!), the "local-pre-zip := local-zip-misc" line executes the code block before the zip is done, and the "local-after-zip:= local-test" executes the code block after the zip is done.
STEP 5: Apply MIUI Changes
To apply the MIUI changes on the choosen ROM, type those commands in the root of PatchROM:
source build/envsetup.sh cd shakira # CHANGE THIS LINE TO MATCH THE FOLDER YOU CREATED IN STEP 3 make
EDIT: The 'sh build/envsetup.sh' command was wrong; it's actually 'source build/envsetup.sh'. Fixed it above. That fixes the porting.mk errors
PDF in the docs folder on PatchROM (thank you Google Translate!)