Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

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

OP ThePCGuy

4th February 2012, 01:29 AM   |  #1  
OP Member
Flag Santa Rita do Sapucaí
Thanks Meter: 55
 
34 posts
Join Date:Joined: Jun 2011
More
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
Last edited by ThePCGuy; 19th April 2012 at 05:36 PM. Reason: Added more info
The Following 32 Users Say Thank You to ThePCGuy For This Useful Post: [ View ]
4th February 2012, 11:33 AM   |  #2  
Senior Member
Thanks Meter: 139
 
781 posts
Join Date:Joined: Nov 2011
Maybe you should post it at Dev section... So, more people can see it..

Sent from my E15i using Tapatalk
The Following 2 Users Say Thank You to sidewalk_ For This Useful Post: [ View ]
4th February 2012, 11:52 AM   |  #3  
Senior Member
Flag West-Flanders
Thanks Meter: 14
 
106 posts
Join Date:Joined: Jan 2011
More
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...
4th February 2012, 01:40 PM   |  #4  
OP Member
Flag Santa Rita do Sapucaí
Thanks Meter: 55
 
34 posts
Join Date:Joined: Jun 2011
More
Arrow
Quote:
Originally Posted by ThePietn1

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
5th February 2012, 05:09 AM   |  #5  
Member
Thanks Meter: 19
 
86 posts
Join Date:Joined: Nov 2011
More
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: [ View ]
5th February 2012, 05:23 AM   |  #6  
lucastan96's Avatar
Senior Member
Flag Malacca
Thanks Meter: 2,104
 
2,866 posts
Join Date:Joined: Dec 2011
More
Quote:
Originally Posted by Coudy73

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
5th February 2012, 09:57 AM   |  #7  
wilbso's Avatar
Senior Member
Flag The Internet
Thanks Meter: 245
 
1,369 posts
Join Date:Joined: Aug 2011
Donate to Me
More
will this work for linux mint? i dont have windows
The Following User Says Thank You to wilbso For This Useful Post: [ View ]
5th February 2012, 01:37 PM   |  #8  
Member
Flag Kurnool
Thanks Meter: 1
 
41 posts
Join Date:Joined: Mar 2010
More
"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?
5th February 2012, 02:12 PM   |  #9  
OP Member
Flag Santa Rita do Sapucaí
Thanks Meter: 55
 
34 posts
Join Date:Joined: Jun 2011
More
Quote:
Originally Posted by jayasimhareddy

"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
Last edited by ThePCGuy; 5th February 2012 at 02:15 PM. Reason: updates
The Following 2 Users Say Thank You to ThePCGuy For This Useful Post: [ View ]
5th February 2012, 03:37 PM   |  #10  
deedii's Avatar
Recognized Contributor
Thanks Meter: 1,018
 
1,616 posts
Join Date:Joined: 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: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes