ROM Android: Tuning Custom ROM

From OnnoWiki
Jump to navigation Jump to search

here's my problem :

I've already done some research with Google, Stack Overflow and XDA Developers forums but I didn't even find a related question.

I'm trying to customize this CyanogenMod ROM so the "Unknown sources" checkbox (in Settings > Applications) is checked by default after the installation of the ROM using ClockWorkMod, but I can't seem to find where to do it.

I searched into the following APK files using apktool :

   /system/framework/framework-res.apk
   /system/app/Settings.apk
   /system/app/SettingsProvider.apk
   /system/app/ApplicationsProvider.apk
   /system/app/PackageInstaller.apk
   /system/app/CertInstaller.apk



Ok, turns out I didn't search hard enough.

For those who are interested, the file to edit is located into SettingsProvider.apk. You have to decompile it (with apktool) and edit the file SettingsProvider/res/values/bools.xml, replacing this line :

<bool name="def_install_non_market_apps">false</bool>

by this one :

<bool name="def_install_non_market_apps">true</bool>

And then, recompile, etc.

Hope this helps.




How to create your own Android ROM Part 2: Changing and Modifying ROM by Adeel Inam on March 28, 2013

20110627140705

You all should have created your Android Kitchen by following How to create your own Android ROM Part 1: Setting up Environment. This tutorial will cover the next part which deals with changing and modify an existing ROM according to your likings.

Remember, this will only change settings related to the Android ROM that you have chosen. You just cannot create a brand new ROM out of it. So just be clear that you are modifying an already made ROM from another user. How to Add or Remove Applications

If you have correctly followed the previous part of the tutorial, you will have a working folder buy now.

   Go to the working folder where you originally extracted Android ROM.
   Go to system/app. You will see a list of all the .apk files that are in the Android ROM.
   Change or delete any apk you want, just be careful not to delete any important apk. If you do not know what to do here, leave this step as it is.

Adding a Boot Animation

Boot animation refers to the flash screen that you see before your phone boots. Like in SONY phones, you see XPERIA flashing on the screen before the actual startup.

For this, replace the bootanimation.zip located in the workingfolder/system/media with any animation of your choice. You can choose the animations from this link

boot animation Fixing GPS location for your country

Since a ROM is free for all and anyone can install it, there is no certain position of the GPS to which the Android ROM should target. Therefore, if you ever try to customize a ROM, make sure you edit the GPS settings as well.

   Go to workingfolder/system/etc
   Go to the file named “gps.conf”. Open it in notepad++(not in simple notepad). Notepad++ is a free utility and you can download it from anywhere.
   Download the required gps script file of your country from this link. Extract it and replace with the above “gps.conf”

Changing the default wallpaper

Changing default wallpaper is easy but you have to be careful while editing or deleting it.

   Go to workingfolder/system/framework/
   If you have installed 7zip on your computer, then its good, otherwise do it. Then from the same folder, open framework-res.apk
   Go to res/drawable-hdpi/ and you will see default_wallpaper.jpg file. Just replace this file with any other you like. Make sure both are in the same format.

Changing the system interface

This part deals with the change in the overall menu appearance throughout the ROM. This is the most crucial step and if you are unsure about this, please do not try.

   Go to workingfolder/system/ and open the file named “build.prop” with notepad++.
   Now you will see a lot of options that you can change. I cannot tell all of them as they are a lot but I will change the LCD density here.
   Locate ro.sf.lcd_density=240 inside the “build.prop” file and change the value to anything you like. Just replace it with 240.

build.prop

Now you have changed your ROM according to your likings and are ready for the final step of the whole process which is repacking the Android ROM to install onto the mobile. I will discuss it in the next part of the tutorial.






ZIP-based ROM Tweaking Difficulty Level: Beginner-Intermediate What you will need: Basic tools

- Notepad++

- ZIP manager tool like 7zip/WinZip/WinRAR Advanced tools

- Cygwin

- smali (assembler/disassembler)

- APKTool/APK Multi-tool


Lets Begin:

Download a ROM (we use CM in this guide) of your choice (don’t forget to get the permissions for it modding from the developer) and extract it. When you extract it, you will see atleast two folders and one file. Please note the minimum contents will be as follows Folders

- system

- META-INF Files

- boot.img


The Folders: The System Folder

Open the system folder and the first folder you will notice is ‘apps’. This is the place where all the system apps are situated (if you are using a stock ROM, you might also see ‘.odex’ files for most apps. These odex files are used to speed up the booting of the device but cause problems when we modify or theme apps. Just for a record, these ‘.odex’ files contain the ‘dex’ part of the apk. So,if you remove an app,you should delete the odex file too). If you want to add an app,just drag and drop. Take care not to delete each and every app you find,because each of them has their own functions. The list of removable apps can be found here.

If you want to deodex them,then use the xUltimate software. It is an auto deodexer. If you want to edit the xml files in an app, you will have to decompile it. This is where apktool comes into picture. Use apktool to decompile an app. Edit the xmls and recompile it. Here is a complete guide along with images on how to decompile and recompile apk’s. SystemUI.apk

SystemUI.apk is one of the core apps needed by the system to function. If you mess this app, your device will enter into a bootloop, or you will get a series of FC’s (Force Close) on system applications. So please edit this file with care. By editing systemui.apk,you can get transparent status bars, transparent notification bars, centre the clock, etc. So in short, this apk decides the visuals of your rom. For some systemui mods, refer this guide.

Some apk files are lib-dependent, which means that they need certain libraries to work. A few examples are, Swype keyboard, Google Maps etc. Swype wouldnt work if the lib file libswypecore.so is not included in the rom. So if you add any lib-dependent app, make sure you add the lib file too. Same goes for removing a lib-dependent app. The Bin Folder

The bin folder contains all the binary files required by the android operating system core to function! It may include how the system handles process and other advanced stuff. So please refrain from modifying any files in this folder. The Etc folder

This folder contains a lot of miscellaneous files. Although miscellaneous, the files are important! The main folder which you can mod is the init.d folder. The ‘init.d folder’ handles all the scripts which run on device boot. You can command the system to carry out any function using these scripts.

Other files include NOTICE.html and CHANGELOG-CM. These files just contain the version changelogs and the CM license. Do not edit or remove these files. The Fonts folder

This folder contains all the system fonts. Clockopia is the font used to display on the lockscreen. You can delete the fonts, but make sure you have at-least one. You can also add fonts to this folder and they will be available in the ‘Select Font’ option in the Settings.apk. When replacing fonts, take care that the new font has the exact name as the old one, otherwise the new font won’t work. The Framework folder

In this folder, you will find all the core system framework apps. These apps act as the system skeleton. In this folder, the only app which we can mod is the ‘framework-.apk’. This app contains battery icons, status bar icons, lockscreen icons, etc. If a framework app is incorrectly modified, the ROM won’t boot. So, please be cautious. The Libs folder

The ‘libs folder’ contains all the library files needed by the apps to function. It contains libraries of all apps ranging from core system apps to user apps. As stated earlier, if you add a lib-dependent app, its lib file goes into this folder. Nothing to mod here. The Media folder

This folder contains all the media used in the Android system, complete from the starting boot animation to the shutdown animation. The common contents of this folder are, ‘ringtones, notification sounds, alarms, boot animations, key press sounds’. If you need to add some audio, just drag and drop it into the correct folder. You can also create your custom boot-animations. For the process please refer this guide by Ethan Hunt (Ethan Hunt.. Seriously ?). The Tts folder

The ‘TTS folder’ is all about Text-To-Speech. It contains all the files needed by the Android system to get Text-To-Speech working. If you are removing the TTS feature from your ROM, make sure you remove this entire folder and the TTS related apps from the ‘system folder’, as this will save a lot of space. The WiFi and Usr folders

The WiFi folder contains the drivers required by the WiFi module to function. So i strongly recommend NOT to touch this folder. If you delete any file from this folder, you will mess up the WiFi functionality.

The usr folder contains some miscellaneous but very important stuff. It may contain anything and everything needed by the Android operating system. For instance, this folder contains all the key-mapping. If such files are messed with, your device will be non-functional although it will boot. The Build.prop

The build.prop file is pretty self-explanatory. Here, you can change the most basic things, like the android version that setting shows. Wondered how people are making 2.3.4 look like 4.0.3 in settings? Its build.prop. Also,you can change what ‘About phone’ shows here.

Other things,you can change things like,how long your wifi scans,how much battery your phone saves while in sleep, Dalvik VM heapsize and default ringtones. If you are wondering what # stands for, it signifies that, the particular line is commented out, and the system does not read it. You can use it add comments to the build.prop. This helps others understand, what is the function of a particular tweak.

A guide for some basic build.prop tweaks can be found here.

Please be aware that, these build.prop modifications are not universal. So, you will have to experiment with the tweaks and their values. The META-INF folder

This folder contains instructions for the Android Recovery about how to work with the files present in the zip. This folder contains many folders, but the only one we need to edit is the update-script file. Updater-script reference

Now,the updater-script is not something that you should mess around with, as a single line of error in the script could result in an error.

The two common languages used in the update-script are ‘Amend’ (update-script) and ‘Edify’ (updater-script & update-binary). Amend has been discontinued since Android version 1.5 (Donut). Now only Edify is used, and thus, we will deal only with Edify.

Please understand that all the commands used in the updater-script are functions. Thus if you have some knowledge of C or Java, this file is easy to understand.

Lets look at a simple example of how the script works. If you flash an Amend script for a version of Android newer than 1.5, or a version of CWM newer than 3.x, there is a risk it will not operate correctly.

ifelse(mount("yaffs2", "MTD", "system", "/system") == "system", ui_print("Successfully Mounted!"), ui_print("Mount Failed!"); 1

ifelse(mount("yaffs2", "MTD", "system", "/system") == "system", ui_print("Successfully Mounted!"), ui_print("Mount Failed!");

This command will attempt to mount the MTD partition named “system” to “/system” partition. If the mount succeeds, the script will display Successfully Mounted!, otherwise(else) it will display Mount Failed!


Some common updater-script commands are :

   mount : Mounts a filesystem to the defined mount point
   is_mounted : Checks if a filesystem is mounted
   unmount : Unmounts the filesystem
   format : Formats a filesystem as specified
   delete : Deletes a file.  Must specify at least one file; multiple files can be specified as multiple arguments with the use of ‘,’
   delete_recursive : Deletes a folder and all of its contents.  At least 1 directory must be specified;  multiple directories can be specified as additional arguments
   show_progress : Displays flashing progress in the recovery system
   package_extract_dir :  Extract the all of the files in a directory in the package to the target specified
   package_extract_file : Extracts a single file from your update package to the target specified
   symlink : Unlinks any existing symbolic links before creating the new symbolic links.
   set_perm :  Sets permissions of a file or set of files specified.  At least one file must be specified (the first four parameters are required)
   set_perm_recursive : Set permissions of a directory or set of directories and all files and folders within them.  At  least one directory must be specified (The first 5 parameters are required)
   write_raw_image : This function writes an img file to a partition
   ui_print : This function prints/echos a message to the console while the script is running.  At least 1 parameter needs to be specified, you can specify additional msg parameters and they will be concatenated to the output
   run_program : Executes a program with the arguments specified.   Returns a string, I assume it is the buffer of the stdout of the program executed, need to test
   assert : If condition evaluates to false, stops script execution, otherwise continues processing



A complete guide on Edify Scripting can be found here. The Files: Boot.img

The boot.img is a very important file. If you are reading this then, probably you have to wait a little bit more to modify this image file.

This image file contains the kernel, ramdisk, recovery etc. These files are very important and may vary from modules to layouts. NOTE: A kernel is the file that acts as an intermediary between the hardware and the software. A pretty decent explanation about the android kernel can be found here. Making Flashable ZIP

In order to create a flashable zip, first zip the ‘system, META-INF’ folder and the ‘boot.img’. Let’s name this zip as ‘update.zip’. Next we need to sign the zip. Get a signer here. Put your update zip in the same folder as the signer. Then run the ‘signer.bat’ file. This will sign your zip file. After the signing process is complete, you can change the name of the zip to your liking. Signing is not necessary. You can turn Signature Verification OFF in the recovery. But i strongly recommend signing to reduce incompatibilities.

If you are reading this, you just made your first custom rom. Cheers. Some Tips:

   Always use NotePad++ to edit files related to Android.
   Always stick to the guide.
   If you have any problems, first search for similar cases. If you still fail to find the solution, post your problem in a forum. The correct way of posting can be found here. Please adhere to it.





Referensi