[XPERIA X10 Android Development] CosmicDan:
Introduction

Here I am releasing the kitchen and a lengthy guide on what makes it special, how it works, et cetera; as my goodbye gift to the X10 forum as I want to keep this knowledge open so others might be able to help. Please be aware that this is not for newbies, I hope that other people still building custom ROM's for X10 will put my research to good use. It is directly (but heavily modified and enhanced) based on the script by erenz1202 and probably has additional credits, I don't know. His original thread is here for your reference.

I hope to keep this kitchen/guide a progressive effort, I will do my best to keep this thread maintained with the help of all contributors. If you have any questions, don't hesitate to ask! But if you're a newbie and don't know anything about development, please don't spam the thread with silly questions... I don't have the time to teach someone how to use a computer ;)

This thread is under construction, I did rush writing it. Please post your suggestions for sections/updates/anything in this thread. I would love to see a good "Team-XDA" effort :D

If any other MIUI ROM builders want to take my sh!t and use it in their ROM, I really don't care so go for it. LOL. Credit would be nice but I wouldn't be surprised if you don't. But I really hope this doesn't cause a bunch of people to release ROM's based on this MIUI with no real GOOD changes without sharing the knowledge here, the X10 Dev forum is already enough of a popularity-contest :rolleyes:

Notable Features

- Automatic APK/JAR injection subroutines (see below for details)

- Full logging of the build script/process

- Unique tweaks/hacks not present in any other MIUI ROM, fully documented and explained (see below for details)

Requirements

- Windows Vista/7

required

(Windows XP cannot handle this advanced batch file)

- Java Runtime Environment

- Above-average knowledge of batch files, XML, smali

Downloads

You can find all relevant downloads, including old versions of CosmicUI, in my Mediafire folder - the important stuff is in the 'Kitchen' subfolder.

http://www.mediafire.com/?ksvtupinjw8nd

- Kitchen update for v0.6.x is also added. You still need to original kitchen, download the update ZIP and extract it to your kitchen folder (overwrite all) to update it. The new version brings a pre-build script to inject language files, and also a post-build script to PNG Optimize/zipalign/recompress JAR's and APK's.

Also included as a separate download is a self-extracting EXE of MIUI 2.4.20 for Incredible S (from MIUI UK i.e. miuiandroid.com), which Cosmic UI was based on. FXP-CM7 is not included, you will need download that from the OT too.

Instruction/Guide

Unpack the kitchen.zip archive to a new folder on your Windows Vista/7 PC. Doesn't matter where, just as long as you have full administration rights (and run the batch file as administrator if you have UAC enabled). Here is an explanation of the kitchen contents:

base_cm7source

- Extract FXP-CM7 files here. CosmicUI v0.5 uses FXP-124. Use the /system contents of the flashable ZIP, not the system subfolder (i.e. this is valid - .\base_cm7source\build.prop)

base_miui

- Extract MIUI files here. Note that this folder is modified with every build, I have created a self-extracting EXE of MIUI 2.4.20 for Incredible S from miuiandroid.com and uploaded it to the mediafire folder. Place this in the

root

kitchen folder and run it if you need to unpack again, it will extract to the base_miui folder. Open the EXE with WinRAR (or 7-Zip) if you want to inspect it. If you want an original ZIP of MIUI 2.4.20 for various devices, check the page here for direct downloads.

base_postmods

- Precompiled stuff for the MIUI build, either replacing original MIUI/FXP files or completely new. Some is unique to CosmicUI, details in next section.

base_postmods_inject

- Source files for automated JAR/APK injection functions, with a specific folder structure and details of each modification included. Details in next section.

base_postmods_inject_obsolete

- As above, but these are no longer used (and excluded from the build script). They were either for older versions of CosmicUI or only ever used in my test builds.

base_postmods_special

- Special injections for use with my automated mods/scripts in CosmicUI, currently used for building Extended Settings APK/JAR and HW-LED fixed framework APK. The build script will show that these injections are not automated like the base_postmods_inject folder.

base_tool

- All the dependencies and tools used for the build script. Includes 7z binary, aapt, apktool and package-signing jar's. Note that I use APKTool for jar files instead of smali/baksmali, because APK tool has some fixes that the original (bak)smali doesn't. So if you manually decompile APK's/JAR's, you will need to use Apktool v1.4.3 to keep smali/xml compatibility with the mods in this kitchen (you will get compile errors if you mix decompiled files from different versions). This folder also contains a custom 'usr' folder from the original kitchen, I never updated it and it is still used by the build script.

CosmicUI Modpack (obsolete since 0.4)

- Just an extracted Flashable-ZIP of the old Modpack for 0.3 (pre-Aroma). Don't use it on new versions

CosmicUI-FixPermissions

- Just an extracted Flashable-ZIP of a little updater-script that fixes all permissions on /system partition, useful when pushing new files via adb in CWR without having to chmod/chown. I originally made it to save time but it's a bit redundant if you use my modified kCernel-v01 since it boots directly to TouchRecovery (which has Fix Permissions in the menu).

CosmicUI-kernel-kCernel_v01

- Just an extracted Flashable-ZIP of my modified kCernel v01. Only differences are (a) the boot graphic and (b) Boot Menu removed and only uses Touch Recovery (saves time).

CosmicUI-v0.4.01.122

CosmicUI-v0.5.01.124

- Templates for CWM-flashable ZIP after building. Move the system folder into this folder, ZIP the contents and flash. Includes all the Aroma install stuff.

~build.bat

- The main magic. This batch file is well commented and has a lot of experimental stuff commented-out. Take a look. If it makes no sense to you at all, you're not experienced enough to use a kitchen! But feel free to ask specific questions about it ;)

~build.txt

- This is the log file (new one created every time) when running the above script. Good for checking errors with the build, especially with APK Tool (de)compiling or missing files. Pretty fancy stuff there!

How to do a quick build to make CosmicUI v0.5.x?

1) Extract contents of FXP-124 .\system\ to base_cm7source

2) Extract MIUIandroid.com's 2.4.20 for Incredible S contents of .\system\ to base_miui

3) Run the ~build.bat file (yes, it takes a while - the JAR/APK injection mainly)

4) Move the new created .\system\ folder to the flashable-CWM ZIP template folder (e.g., .\CosmicUI-v0.5.01.124\)

5) ZIP up the contents of the template folder you used above, and install the update in CWR.

About base_postmods_inject

Inside the folder you will see two others, app and framework - this is pretty self explanatory. If we go inside framework for example, we will see three folders and three files:

framework.jar [folder]

framework-res.apk [folder]

services.jar [folder]

framework.txt

framework-res.txt

services.txt

Let's take a look at framework.jar. The txt file for it just explains what is in there, it's not used in the build script but is for your info. In this case, it details the changed files used for patching-in some WebKit and Net code to eliminate the need for the 2048 read_ahead_kb tweak that most other MIUI ROM's for X10 need to prevent the WLOD's. Anyway, inside the folder is a smali folder - it follows the same directory tree of the original decompiled package (remember - with apktool 1.4.3), but with only the changes necessary for the patch. [FYI, The 'build' folder is re-created with every build, designed to be a cached-compile to speed the build process but it doesnt work right - probably because of changed timestamps. Don't worry about it.]

Anyway, you could use a program like WinMerge to examine the differences of the changed files and find the patches I made. In the case of framework.jar there is a problem with battery drain in the \net\ code (I think), it's a fairly dirty hack that might put the system_server in a constant loop. I don't know. Anyway, that's everything explained about the apk/jar injection feature. I think. If you want to mod another .apk or .jar, remember to compare your changes to the original and then - following the directory tree of existing injection mods as a template - make new folders and move the modified files there.

UNDER CONSTRUCTION, NOT FINISHED. Ideas/suggestions welcome! Peace :cool: