5,598,718 Members 37,475 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE][Updated 19/04/12] PatchROM - MIUI 2.3 and 4.0 Porting

Tip us?
 
ThePCGuy
Old
(Last edited by ThePCGuy; 19th April 2012 at 04:36 PM.) Reason: Added more info
#1  
Member - OP
Thanks Meter 55
Posts: 34
Join Date: Jun 2011
Location: Santa Rita do Sapucaí
Arrow [GUIDE][Updated 19/04/12] PatchROM - MIUI 2.3 and 4.0 Porting

Hello guys!

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:
  1. Download the tools
  2. Get an Gingerbread/ICS ROM to install MIUI stuff;
  3. Create the required file structure
  4. Change the Makefile
  5. Apply MIUI changes to the selected ROM
  6. 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:
  1. Make sure you have the Android SDK installed and on your PATH.
  2. 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:
Code:
repo init -u git://github.com/MiCode/patchrom.git -b ics
repo sync
This command will download the PatchROM system to the ~/patchrom folder.

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:
  • /system/framework/android.policy.jar
  • /system/framework/framework.jar
  • /system/framework/framework-res.apk
  • /system/app/SystemUI.apk
  • /system/framework/services.jar
  • and the apps defined on the 'local-modified-apps' below
STEP 4: Editing the Makefile
The makefile has the following structure:
Code:
#
# 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"
Here's how it works:
  • 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:
Code:
source build/envsetup.sh
cd shakira # CHANGE THIS LINE TO MATCH THE FOLDER YOU CREATED IN STEP 3
make
Now it should decompile the ROM and merge the ROM's smali files with the MIUI files, and create an ZIP file with the MIUI rom, but I got some errors decompiling SystemUI.apk maybe some of the awesome devs there can solve this

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

SOURCES:
PDF in the docs folder on PatchROM (thank you Google Translate!)
Github README
The Following 32 Users Say Thank You to ThePCGuy For This Useful Post: [ Click to Expand ]
 
sidewalk_
Old
#2  
Senior Member
Thanks Meter 124
Posts: 725
Join Date: Nov 2011
Location: Fairhaven City
Maybe you should post it at Dev section... So, more people can see it..

Sent from my E15i using Tapatalk
Ktouch U86
ROM: Symbean Unofficial CM10.1
Kernel: Stock

Ainol Novo 7 Legend
Rom : Stock Official ICS 4.0.4
Kernel : Stock 3.0.8+

My X8 is a paperweight now

[GUIDE][CM9]How to apply HDPI themes to MDPI
The Following 2 Users Say Thank You to sidewalk_ For This Useful Post: [ Click to Expand ]
 
ThePietn1
Old
#3  
Senior Member
Thanks Meter 14
Posts: 106
Join Date: Jan 2011
Location: West-Flanders
It might be a stupid question, but did you deodex the files? MiniCM7 is fully odexed for better loading times, but most probably this won't work with those files...
 
ThePCGuy
Old
#4  
Member - OP
Thanks Meter 55
Posts: 34
Join Date: Jun 2011
Location: Santa Rita do Sapucaí
Quote:
Originally Posted by ThePietn1 View Post
It might be a stupid question, but did you deodex the files? MiniCM7 is fully odexed for better loading times, but most probably this won't work with those files...
Yes, I deodexed them
 
Coudy73
Old
#5  
Member
Thanks Meter 19
Posts: 86
Join Date: Nov 2011
You must post it at developing section

Sent from my e15i using XDA App
The Following User Says Thank You to Coudy73 For This Useful Post: [ Click to Expand ]
 
lucastan96
Old
#6  
lucastan96's Avatar
Senior Member
Thanks Meter 2085
Posts: 2,858
Join Date: Dec 2011
Location: Malacca
Quote:
Originally Posted by Coudy73 View Post
You must post it at developing section

Sent from my e15i using XDA App
+1...

Hit the THANKS button if I helped!!

Sent from my W8 using Tapatalk
 
wilbso
Old
#7  
wilbso's Avatar
Senior Member
Thanks Meter 243
Posts: 1,366
Join Date: Aug 2011
Location: XDA

 
DONATE TO ME
will this work for linux mint? i dont have windows
My irc channel: @freenode #wilbso
Contact me by that if you need help.
I ignore all private messages regarding your phone.If you wanna contact me ^^^

My work
I've lost all the links. So im starting fresh. Will update soon
The Following User Says Thank You to wilbso For This Useful Post: [ Click to Expand ]
 
jayasimhareddy
Old
#8  
Member
Thanks Meter 1
Posts: 41
Join Date: Mar 2010
Location: Kurnool
"You also need to decompile the following APK files and put the resulting folder on the 'shakira' folder:
/system/framework/android.policy.jar
/system/framework/framework.jar
/system/framework/framework-res.apk
/system/app/SystemUI.apk
/system/framework/services.jar
and the apps defined on the 'local-modified-apps' below"
Are these files from i9100 folder?, How to decompile?
 
ThePCGuy
Old
(Last edited by ThePCGuy; 5th February 2012 at 01:15 PM.) Reason: updates
#9  
Member - OP
Thanks Meter 55
Posts: 34
Join Date: Jun 2011
Location: Santa Rita do Sapucaí
Quote:
Originally Posted by jayasimhareddy View Post
"You also need to decompile the following APK files and put the resulting folder on the 'shakira' folder:
/system/framework/android.policy.jar
/system/framework/framework.jar
/system/framework/framework-res.apk
/system/app/SystemUI.apk
/system/framework/services.jar
and the apps defined on the 'local-modified-apps' below"
Are these files from i9100 folder?, How to decompile?
Those files are from the rom .zip. To decompile them, make sure that you have apktool installed and type:
Code:
apktool d <file>
This command will spit an folder, move that folder to the 'shakira' folder.

EDIT: Just contacted a mod to move this thread to the Development section
Motorola Defy | CyanogenMod 4.4
Xperia X8 | CyanogenMod 4.1

MIUI PatchROM Porting Guide (2.3 and 4.0)
The Following 2 Users Say Thank You to ThePCGuy For This Useful Post: [ Click to Expand ]
 
deedii
Old
#10  
deedii's Avatar
Recognized Contributor
Thanks Meter 1016
Posts: 1,603
Join Date: May 2011
Do i read this right? MIUI is now possible? OMG love ya guys..

The Following User Says Thank You to deedii For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes