[Q] Need advice on creating script - Android Q&A, Help & Troubleshooting

I need help on creating an app which requires root access.
Purpose of this app
1) Able to access a file in root/data/data/*APP XYZ*/*THIS FILE*
2) Generate a random string of number
3) Replace the specific string in *THIS FILE* with the randomly generated number
4) Saves *This File*
Right now I can do it manually but it is rather tedious. Was thinking if it would be possible to create an app to do this automatically with one click.
__________________________________________________________________________
After typing the above, I was thinking that maybe a shell script would do just fine.

Yeah a script would simply be more than enough !

#!/system/bin/sh
set number=$RANDOM
echo "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
*random unimportant stuff*
<string name="uuid">302$number-abcdefghijk</string>
</map>
" > /data/data/com.app/shared_prefs/app.xml
For some reason this script fails to run.
I want to change the uuid string but it doesnt seem to want to run.

Related

[HOW TO]Sign Your Apk For Google Play

Hey Guys,
I found it very hard to find this method on the net. I looked for around 12 hours (over a period of 2 days). But here it is!
This method is very helpful if you need to increase the length of your signature on your apk. As Google Play has a minimum length of validity for signatures.
This tutorial contains some knowledge from other websites and some from my own self. Please feel free to use my hard work below. But try to reference me if you can. Thanks!
First of all,
jarsigner and keytool are .exe files that help create your "signed" application for release to the market to prevent fraud.
1.
Make a folder somewhere called "keytools" and make a folder in that called "key"
2. Now move your apk file to the folder keytools.
(Not inside any other folders)
3. Check
"C:\Program Files\Java\jdk1.7.0_11\bin" for jarsigner and keytools..
... or whatever jdk version you have
If you DONT have it install the following: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
4. open cmd.exe,
5. cd your way to where you have your keytools folder...
I had to do.. cd desktop, and to keytools to get to C:\Users\Matt\Desktop\keytools\
In this directory is you apk file which we will manipulate.
Now add the directory C:\"Program Files"\Java\jdk1.7.0_11\bin\ or something like that to PATH in Environment Variables.
Directions on how to do this can be found here: http://www.computerhope.com/issues/ch000549.htm
type the following now (or something similar to my example)
keytool -genkey -alias xda.keystore -keyalg RSA -validity 20000 -keystore keys/xda.keystore
Then you will have be presented with:
Enter keystore password: (type in a password you will use)
Re-enter new password: (type in same password here)
What is your first and last name? Matt <LAST NAME HERE>
What is the name of your Organization unit? (You dont NEED to type anything)
What is the name of your city or locality? <What it says>
What is the name of your state or providence? <What it says>
what is the two-letter country code for this unit? AU
is CN=Matt C=AU.....etc. correct?
[no]: yes (type yes there)
Enter key password for <xda.keystore>
<RETURN if same as keystore password>: (push enter)
6.
To add the directory of jarsigner to the PATH variable just do the steps from here: http://www.computerhope.com/issues/ch000549.htm but with the path of jarsigner. Which should be something like this: echo "PATH=/cygdrive/c/Program\ Files/Java/jdk1.7.0.11/bin:\${PATH}" >> .bash_profile
Now, type the following now (or something similar to my example) NOTE: This is all in cmd.
jarsigner -verbose -keystore key/donate.keystore -signedjar Donate_signed.apk xda.apk xda.keystore
Enter Passphase for keystore: (your password you made earlier)
DO NOT TYPE --> adding: META-INF/MINFEST.MF ....
.......
.....
...Signing: classes.dex <--DO NOT TYPE
and you're all set! you signed your apk file or whatever you wanted to create!
Congratulations.
NOW STOP BEING FRUSTRATED LIKE I WAS FOR HOURS!
Or, if your using Eclipse just right-click your project and choose Android Tools > Export Signed Application Package.. and follow the export wizard.
@M4ttz
Thanks a lot mate!!!!!!!!!
mytheme_signed.apk is created! Let's go to Google Play
EDIT
Google told me that I need to zipalign my apk file.... If I zipalign Google says that my file isn't signed!!!!

[Q] lockstyle coding

Hi, i'm wondering where i can read more about /system/media/lockstyle file structure and coding language. Yeah, i know that manifest is an XML file, but if we for example have this code:
Code:
<Var name="isreached_to_pressed" expression="1" const="true"/>
<Var name="lock_state_pressed" expression="eq(#unlocker_lock.state,1)+eq(#unlocker_call.state,1)+eq(#unlocker_mess.state,1)"/>
<Var name="lock_state_normal" expression="eq(#unlocker_lock.state,0)*eq(#unlocker_call.state,0)*eq(#unlocker_mess.state,0)"/>
<Var name="lockstate" expression="#unlocker_lock.state+#unlocker_call.state+#unlocker_mess.state"/>
<VariableCommand name="camera_show_ani_end" expression="ifelse(#leftToRight,#screen_width-abs(#touch_dist),abs(#touch_dist)-#screen_width)" const="true" condition="#camera_show_ani_con"/>
Where do i get more information about all this eq, abs, ifelse expression, and Var names like lock_state_pressed, lock_state_normal, camera_show_ani_end etc. Is there any guide out there, i wasn't able to find by myself.
Oh, one more thing.
Does the lockstyle file only describes the outlook of lock screen or does it also handle the actions like how to unblock (press, swap or tap)?

[Q] Adding a Status Bar signal option to Settings.apk

I hope this is the correct forum
I am doing this to Cyanogenmod 11.
I want to add an option to Settings > Interface > Status Bar > Signal Status Style. I am so close to having it done, but there is one thing I am missing, and that is actually getting the radio button to switch the Icon to the correct .java. Here is what I have done so far:
Added to Setting/res/values/cm_strings.xml;
Code:
<string name="status_bar_signal_style_always">Always show type</string>
Added two lines to Settings/res/values/cm_arrays.xml;(marked with *'s)
Code:
<string-array name="entries_status_bar_signal" translatable="false">
<item>@string/status_bar_signal_style_icon</item>
<item>@string/status_bar_signal_style_text</item>
*<item>@string/status_bar_signal_style_always</item>
<item>@string/status_bar_style_hidden</item>
</string-array>
<string-array name="values_status_bar_signal" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
*<item>3</item>
</string-array>
Created a new java file named SignalClusterAlwaysView.java in SystemUI/src/com/android/systemui/statusbar and signal_cluster_always_view.xml in SystemUI/res/layout, respectively;
Added to SystemUI/res/layout/status_bar.xml;
Code:
<include layout="@layout/signal_cluster_always_view"
android:id="@+id/signal_cluster_always"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Added (changed STYLE_HIDDEN to 3) in SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java.
Code:
public static final int STYLE_ALWAYS = 2;
Really all I am trying to do is create a setting to show network type even while WiFi is connected. This is accomplished by simply clearing this line from SignalClusterView.java,
Code:
mMobileType.setVisibility(
!mWifiVisible ? View.VISIBLE : View.GONE);
and changing android:layout_marginEnd to 3dip in signal_cluster_view.xml.
I can't seem to figure out how the existing setting for a text only network icon sends that to SystemUI. I've explored StatusBar.java in the Settings.apk source, and I think the issue may be in this line,
Code:
int signalStyle = Settings.System.getInt(resolver, Settings.System.STATUS_BAR_SIGNAL_TEXT, 0);
where it is setting the value of the option selected to Settings.System.STATUS_BAR_SIGNAL_TEXT. I think it is properly setting the value to 2, like I want, but it still sees 2 as HIDDEN instead of ALWAYS; or that it does see I want ALWAYS, but doesn't know to refer to SignalClusterAlwaysView.java in SystemUI.
What am I missing? Is there an easier way to do this?
Sorry if this is in the wrong thread.
I just checked, and yes, the value of STATUS_BAR_SIGNAL is changing to my intended values. My one missing link is defining what those values do.
Where is the file that contains the value assignments? i.e. STATUS_BAR_SIGNAL = 1 starts StatusBarTextView.java in systemui, while 2 and 3 don't do anything. I don't care about 3, just need to make 2 start StatusBarAlwaysView.java (or that process, obviously it isn't .java once compiled).
I answered my own question here: http://stackoverflow.com/questions/21869758/adding-a-setting-option-in-android-settings-apk/21881423#21881423

[GIT][REPO][WIP][MEGA GUIDE] How to create your first CM based ROM

How to create your first CM based ROM ​
Introduction​
In this mega thread guys i will show you basically how to create your own custom CM based ROM, i will take CM in consideration because it is the most used here, but the native sources could be from Omni, or to be based on AOSP. But be aware that not all the things said here will be able to be applied to the ROM because some CM things may not be present in other ROM sources. So before jumping to the guides make sure to check out the first part of the thread from the Index.
Usually there are 4 kind of ROM developers:
Those who Create ROMs
Those who port a created ROM for an other device (device which is not supported officially) by adapting kernel sources, propietary files and vendors....
Those who maintain a ROM for a specific device which is not officially supported but the device sources in use are already prepared by an other developer in order to succeed the compilation process
Those who maintain a ROM for a device that is officially supported by the team or organization but the user also has the goal to help the users and know what he is publishing on the forum
We all know that the Bosses of all are Cyanogenmod, OmniROM and so on and after them there are the secondary ROMs which can be: PAC-MAN,Slim,AICP etc... Which they are all based on an already ROM sources (Could be CM or AOSP for example).
So why they can and you not?
That's because your are thinking from a different perspective.
Let me show you:
For sure you are thinking that "Oh my god there is too much coding for me i can't do all these stuff alone"
Exactly you can't do all these stuff alone, for sure you will need at least one more person to work on it but belive me i was also thinking in the same way but looking here and there i learned how to do many things that for example 2 years ago was something unknown for me coming from a different planet.Trust here i will explain you all you need to know about how to create a custom based ROM or at least show you the basics and then learn for your own.(Not necessary an organization for many devices but a small one just to get familiar and to help you starting from there)
So in this guide i will not show you how to compile a new ROM because i assume that you already know that, instead i will show all the common things that can be changed and even also added in the custom ROM sources by eliminating also the CM or the native ROM name from you're taking the sources as much as possible by including your ROM name instead and also showing you strategies which may help you.
Note.
When you fork the repos make sure to always work on the cm-12.1 branch because some changes which we will gonna make in the guide may not exists in cm-12.
For the fact that the guide will be very big, if you will need help, just write it on the thread but in this way:
Make sure that the post title start in this way:
Section of the thread: Settings, Repo part ....
Part of the section (If we talking about the CM Removable part in Settings for example)
Requirements​
Knowledge and experience in compiling ROMs
Github knowledge (Usually you should know this if you compiled a ROM for a device)
Basic knowledge about XML, Java, C (At least know how to work on it not NOOBS on this OK?)
Good computer running Ubuntu (14.04/14.10/15.04/15.10) or a custom Distro based on the specified ones
High quantity of storage for all the file which you will gonna use.
SmartGit which it will help you very much
Index​
Disclaimer and ROM specifications
Environment
Environment Setup
Linux Distribution Part
SmartGit Part
Repo Part
Android Build part
Extra features to be added to the Android Build files
Android Venodr files
Extra features to be added to the Android Vendor files
Settings && Packages part
Extra Features
*******************************************WIP**********************************************
For the fact that the Guide will be very long and it will take some time to complete it all,so please be patient
In the main time will leave here the staus for every part of the guide:
1- Introduction (First post) (Completed! )
2- Linux Distribution Part (Completed!)
3- Environment Setup Part (Completed!)
2- SmartGit Part (Completed! )
3- Repo part (Needs revisions )
4- android_build (Needs revisions )
5- Packages (Working on it!)
6- vendor (Needs revisions )
7- Extra features (Working on it )
8- ROM Description Part (Completed! )
Repo Part​
Ok so let's begin with the Repo part.
In order to have multiple Projects (I mean repo) you need to create an Organization in Github:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Now just follow the Github instructions and you should now have this screen:
Now before doing something you need to think and choose what repo to fork and what repo to create manually.
Remember that i will not help you with the Repo created manually those are created by you and only you know what to include there.
By default the repo which need to be forked first are these:
platform_mainfest
android_vendor_files
These usually should be always present in your Github organization, so i recommend you at the begining to fork these repo from Cyanogenmod if you want that your ROM should be based on CM.
So go and fork the these repositories and then go back to your ROM Project.
For the platform_manifest you can fork it here: https://github.com/SlimRoms/platform_manifest/tree/lp5.1
(We will modify it later)
Remember that when you fork the repositories to fork them in your Organization and not in your Github profile.
You should have this screen:
Now you need to think about what Apps or things you are gonna change i mean, there are plenty of things that you can modify before the compilation process like Java files, create new Preference headers in Settings, modify the framework and so go on....
Once you choosed what repo to include in your Organization then you can start to modify your platform manifest.
But what is platform manifest actually?
Platform manifest is that repo that include a file called default.xml which includes all the Projects that should be fetched by the organization. And represent the most important part of a ROM Project followed after by the android_vendor_files.
Once you cloned platform manifest
Go and open the default.xml file.
So let's the modifications begin!
As you can see the default.xml is composed entirely by these sort of strings:
Code:
<project path="android" name="XOSP/platform_manifest" remote="github" revision="lollipop" />
(For example)
So let me explain you what is this:
project path=means the path used from where the files will be stored in your ROM folder
name: reffer to the path used in Github like https://github.com/CyanogenMod/.....
remote=The Origin of the files (Sort of) it can also be bitbucket or Sourceforge but mainly Github is used always
revision= The branch that you want to checkout
So now you know how the default .xml works go and add your repo that should be fetched!
Tip!
Because the default.xml includes all the projects to be fetched, some of them are not required in most of the cases so some strings can be deleted:
Code:
<project path="device/generic/mini-emulator-arm64" name="device/generic/mini-emulator-arm64" groups="pdk" remote="aosp" />
<project path="device/generic/mini-emulator-armv7-a-neon" name="device/generic/mini-emulator-armv7-a-neon" groups="pdk" remote="aosp" />
<project path="device/generic/mini-emulator-mips" name="device/generic/mini-emulator-mips" groups="pdk" remote="aosp" />
<project path="device/generic/mini-emulator-x86" name="device/generic/mini-emulator-x86" groups="pdk" remote="aosp" />
<project path="device/generic/mini-emulator-x86_64" name="device/generic/mini-emulator-x86_64" groups="pdk" remote="aosp" />
<project path="hardware/intel/audio_media" name="platform/hardware/intel/audio_media" groups="intel" remote="aosp" />
<project path="hardware/intel/bootstub" name="platform/hardware/intel/bootstub" groups="intel" remote="aosp" />
<project path="hardware/intel/common/bd_prov" name="platform/hardware/intel/common/bd_prov" groups="intel" remote="aosp" />
<project path="hardware/intel/common/libmix" name="platform/hardware/intel/common/libmix" groups="intel" remote="aosp" />
<project path="hardware/intel/common/libstagefrighthw" name="platform/hardware/intel/common/libstagefrighthw" groups="intel" remote="aosp" />
<project path="hardware/intel/common/libva" name="platform/hardware/intel/common/libva" groups="intel" remote="aosp" />
<project path="hardware/intel/common/libwsbm" name="platform/hardware/intel/common/libwsbm" groups="intel" remote="aosp" />
<project path="hardware/intel/common/omx-components" name="platform/hardware/intel/common/omx-components" groups="intel" remote="aosp" />
<project path="hardware/intel/common/utils" name="platform/hardware/intel/common/utils" groups="intel" remote="aosp" />
<project path="hardware/intel/common/wrs_omxil_core" name="platform/hardware/intel/common/wrs_omxil_core" groups="intel" remote="aosp" />
<project path="hardware/intel/img/hwcomposer" name="platform/hardware/intel/img/hwcomposer" groups="intel" remote="aosp" />
<project path="hardware/intel/img/libdrm" name="platform/hardware/intel/img/libdrm" groups="intel" remote="aosp" />
<project path="hardware/intel/img/psb_headers" name="platform/hardware/intel/img/psb_headers" groups="intel" remote="aosp" />
<project path="hardware/intel/img/psb_video" name="platform/hardware/intel/img/psb_video" groups="intel" remote="aosp" />
<project path="hardware/nvidia/audio" name="CyanogenMod/android_hardware_nvidia_audio" groups="nvidia_audio" />
<project path="hardware/nvidia/tegra124" name="CyanogenMod/android_hardware_nvidia_tegra124" groups="tegra124" />
Usually are these, so now when you will make repo sync to your ROM path those projects won't be fetched by the manifest.
Don't forget to commit the changes made to default.xml with SmartGit (Check this post about how to configure it
More tips about platform_manifest:
If you want to simpify the work for the other users who will want to build your ROM (If they are new comers) you can use this script written originally by the Resurrection Team and then adapted by me:
Code:
#!/bin/bash
#Based on the original one from Resurrection Remix
clear
echo ____ ___________ ___________________ __________ __ __
echo \ \/ /\_____ \ / _____/\______ \ \______ \_______ ____ |__| ____ _____/ |_
echo \ / / | \ \_____ \ | ___/ | ___/\_ __ \/ _ \ | |/ __ \_/ ___\ __\
echo / \ / | \/ \ | | | | | | \( <_> ) | \ ___/\ \___| |
echo /___/\ \\_______ /_______ / |____| |____| |__| \____/\__| |\___ >\___ >__|
echo \_/ \/ \/ \______| \/ \/
echo Installing Dependencies in 5 Seconds...
sleep 1
echo Installing Dependencies in 4 Seconds...
sleep 1
echo Installing Dependencies in 3 Seconds...
sleep 1
echo Installing Dependencies in 2 Seconds...
sleep 1
echo Installing Dependencies in 1 Seconds...
sleep 1
echo Insert your User Password
sudo apt-get update
sudo apt-get install openjdk-7-jdk
y
sudo apt-get update && sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jre openjdk-6-jdk pngcrush schedtool libxml2 libxml2-utils xsltproc lzop libc6-dev schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib
y
clear
echo Dependencies have been installed!
sleep 4
clear
echo Installing REPO in 5 Seconds...
sleep 1
echo Installing REPO in 4 Seconds...
sleep 1
echo Installing REPO in 3 Seconds...
sleep 1
echo Installing REPO in 2 Seconds...
sleep 1
echo Installing REPO in 1 Seconds...
sleep 1
mkdir ~/bin
PATH=~/bin:$PATH
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
clear
echo REPO has been Downloaded!
sleep 4
clear
cd ..
mkdir XOSP
echo Creating and Initializing XOSP Source at $XOSPpath in 5...
sleep 1
echo Creating and Initializing XOSP Source at $XOSPpath in 4...
sleep 1
echo Creating and Initializing XOSP Source at $XOSPpath in 3...
sleep 1
echo Creating and Initializing XOSP Source at $XOSPpath in 2...
sleep 1
echo Creating and Initializing XOSP Source at $XOSPpath in 1...
sleep 1
cd XOSP
repo init -u https://github.com/XOSP-Project/platform_manifest.git -b lollipop
clear
echo XOSP Source Code has been initialized!
sleep 4
clear
echo Enter 1 to repo sync now, anything else to do it later
read ch
if [ $ch -eq 1 ] ; then
echo Enter number of jobs to repo sync with. If you\'re not sure, enter 4
read jobs
echo Syncing/Downloading in 5 seconds...
sleep 1
echo Syncing/Downloading in 4 seconds...
sleep 1
echo Syncing/Downloading in 3 Seconds...
sleep 1
echo Syncing/Downloading in 2 Seconds...
sleep 1
echo Syncing/Downloading in 1 Seconds...
repo sync -j$jobs
clear
echo Source code has been Set-Up Succesfully.
else
echo repo has been initialized in $XOSPpath
echo To sync the source, cd to $XOSPpath and run the following command
echo "repo sync"
fi
Just change the XOSP name with your ROM name in all the cases (Just make CTRL F and write XOSP, it will find all the names)
Save it as .sh file, give it a name and then make the commit.
To run it on the computer just open a terminal window and write ./filename.sh
Once you done all these things it's time to repo init your ROM path:
If you done the script then the commands will be less:
Code:
git clone https://github.com/Your Project/platform_manifest.git
cd ~/platform_manifest
./scriptname.sh
Now just sit and relax because it will take a while..
Repo-synched, your ROM path should look like this:
If you made some mistakes into the default.xml files please write it in the Thread.
If it's all good now your brain maybe is gonna to explode because you don't know what are those folders but you don't even to know all these folders, why?
Because is not necessary.
Usually folders like external, developers, bootable are not modified only but the main source which usually is CM or of course Android (AOSP)
So calm down because we will not gonna modify files from each of these folders but just a part of them:
build (Many things to do here)
Framework (Customization most of it)
Packages (Settings for sure + some other ones)
vendor (Many things also here)
So mainly these are the projects which they will be modified.
If you didn't forked framework base on Github or you don't want now to modify framework stuff it's ok but remember that when you want to modfify files in a Project repo to be yours in order to commit the changes after.
Before to proceed i want to add something you should absolutely need to know:
In order to work on the different Projects you can't work in the ROM Path because it's always better to clone that specific repo in an other folder and commit the changes.
SmartGit
Intro and Installation​
In order to commit the changes that you are going to do on the different Repositories i recommend you to use SmrtGit which is a free tool and it will help very much in the work that we will gonna do.
1) First of all if you didn't downloaded the link is situated in the first post
2) Once you downloaded unpack the tar package and unpacked it to your Desktop or /home
3) Now open the folder and go to the bin one.
Now go to the smartgit file proprieties and check if the file is executable, if it's not check the check box and open it.
g
4) Once you opneed a window will be prompted to configure SmartGit, choose the non-commercial use only and click next
5) Now choose to use SmartGit as SSH Client
6) Configure a new hosting provider which it will be Github in our case.
Insert your e-mail and after click the Generate API token button
7) Insert your master password which it will be useed for the commits
8) Insert your Github password
9) Now the that the token is generated click next
10) Now SmartGit will search if you got already repositories in your home folder, if you want to include some of yours go ahead.
11) Now next and finish. Hurray! You finished to configure SmartGit
How to use SmartGit​
Now in order to apply the incoming commits that we will gonna do, first you need to understand some concepts:
In the early post about Repo we were talked about the fact that we could have 2 kind of repositories, the forked ones and the created ones in that organization.
If you want to add a forked repo from SmartGit you will have an origin branch which is yours then it comes the upstream one.
Upstream is corresponding to the original repo that includes the branches from the Original forked repo. So when you want to add a new forked repo from your organization to Smart Git make sure that you clone it with SmartGit in order to include also the upstream tracking one because we will work and commit our changes but in the main time maybe CM will also push new commits so these commits should also be included in your forked repo.
If you want to add a created repo from your organization instead, and you also want to include the upstream changes from the native repo from where you taking the code then you will need to add the upstream for your own. So just follow my commands:
For example i will be taking Settings (The package) and i will add the upstream in order to have in my local repo also the original sources (In my case from crDroid):
Just adapt the link to your repo one.
The upstream should now be visible as it here and also in SmartGit.
It's not mandatory to include every single commit that for example Cyanogenmod make but most of them should absolutely be included. Yup,so upstream it's very important guys but it will also create difficult situations because now we will talking about the conflicts problem.
But what are exactly the conflicts?
The conflicts are generated when you want to include upstream commits to your own Repo no matter if it's created or forked, so the thing to do is only to adapt them and here once again SmartGit will save our "lives"
Why it will save our lives ?
Because SmartGit includes an inbuilt file compare which is very useful when resolving conflicts.
So to show you let's take in consideration still Settings. In my case the repo is not forked but it's created and the upstream is created for myself. So let's include some commits and see how it goes. In the major part of the cases you will not get conflicts errors. But if you do get then follow up this procedure:
As we know here is the Origin remote which is mine an the upstream remote which is crDroid one:
So what you need to do in order to include a commit made in the upstream one?
Well there are a few methods to do it.:
There is the cherry-pick method and usually is the most used to pick up two or three commits.
The merge method which allows you to merge all the missing commits from a based branch into your current one. (Here the possibility to find out conflicts are bigger)
The rebase method, which basically rebase your current branch to a specified one.
In my case i will use the merge method, and i will sync up my remote with the original crDroid one by including the missing commits.
For me everything went good, so i'm just gonna push now the new changes
Now if something go bad which means you end up with conflicts here is how you need to solve them.
Basically conflicts are appearing most of the cases because you for example modified a file and the commit which you want to apply go modifying the same file but for the fact that the file is not the same as the upstream on conflicts appear, so you need to find out a solution in order to keep your changes made to that file but in the same way including the specific commit.
When you will rebase, cherry-pick or merge the conflicted files will be the first ones to appear so to solve them here is what you need to do:
Double click the conflicted file
Now a new window will be displayed:
You will see that the file compare will be split in three parts, i mean three columns.
So let me explain you what are the three columns:
By starting from the left the first one indicates our branch the origin one.
The second one represent the Working Tree *
The third one represent the upstream branch from where we are cherry-picking or merging the commit
Working three*
The working three basically represents a detached branch,where you are working.
On local the branch is still the same (name etc..) but is being considered in a different way till you push up the changes.
If you will get familiar with this then you will not have problems with other minor issues.
So this is it, if you got questions or errors just write them on the Thread
Android Build​
So guys are you ready for the modifications?
Well, let's begin...
If you understood the last posts then you should be ready because now we will gonna work on the android_build files.
But what is android_build?
Android build is that Repo that includes all the files necessary in order to make the compilation, don't get me wrong i mean it doesn't include all the files for the compilation but includes the files which includes all the commands and strings necessary for the compilation.
So first thing to do is to fork this repo.
As in the previous post you need to go on the CM repo and to fork the android_build to your ROM organization.
And finally clone it to your computer.
So what you can modify here?
Well quite a lot of things because you can eliminate the CM name almost completely and to include your ROM name instead.
So the first file we will gonna take is the Makefile which is situated in the core folder.
So what we gonna need to modify here?
Here we will gonna modify the Target Device name + some more ones...
So first search this line:
Code:
CM_DEVICE
And change it with YourROMname_DEVICE
Done !
Now the second one is:
Code:
CM_BUILD
In the same way change the CM with your ROM name.
Now go and find these lines:
Code:
CM_TARGET_PACKAGE
CM_VERSION
In the same way change the CM with your ROM name.
On the same line which is this:
Code:
CM_TARGET_PACKAGE := $(PRODUCT_OUT)/cm-$(CM_VERSION).zip
Change also the red marked cm with your ROM name.
Now, go and find these lines:
Code:
.PHONY: otapackage bacon
CM_TARGET_PACKAGE
Ok so bacon agaain to be changed with your ROM name, and the same also for the Target Package
Tip!
That's only if want to....
If you want to include a cool banner with ascii art when the ROM has finished the compilation you can include one:
To generate strings with ascii art go HERE
Choose your prefered one and copy it.
Now go to this line:
Code:
@echo -e ${CL_CYN}"Package Complete:
Right after the line paste the generated ascii string.
But make sure to add also this little entry in order to print it in terminal:
Code:
@echo -e $(CL_CYN)
And add it for each line.
If you want to change the color of the line (cause now the color is the Cyano one)
You can choose from these ones:
Code:
@echo -e $ (CL_RED)
@echo -e $ (CL_GRN)
@echo -e $ (CL_YLW)
@echo -e $ (CL_BLU)
@echo -e $ (CL_MAG)
@echo -e $ (CL_CYN)
@echo -e $ (CL_RST)
This is just for personalize a bit your build environment
So this is it!
The Makefile is now modified and ready to be commited.
Now let's move to: config.mk which is situated still in the core folder.
Here we only need to modify one string:
Code:
ifneq ($(CM_BUILD),)
In the same way change the CM name with your ROM name.
Done !
Now let's move on dumpvar.mk which is also situated in the core folder.
If you are a maintainer you will for sure asking that i seen these lines before,
Yes you are correct!
Those lines are used to display the Compiling Info before the start process.
And those are displayed when you lunch the command: breakfast or of course brunch.
So why we are here?
We are here to change the ROM Version which it will be displayed so because in the Makefile we changed the CM_VERSION with our ROM name we need to change it also here.
Tip!
These lines are not necessary, so they can be deleted
Code:
ifeq ($(CYNGN_TARGET),true)
$(info CYNGN_TARGET=$(CYNGN_TARGET))
$(info CYNGN_FEATURES=$(CYNGN_FEATURES))
endif
So we are also done here. Now let's move on product_config.mk and envsetup.sh
Here we will change the mode about how the Compilation environment will recognize your device.
If you are a maintainer and you compiled Slim ROM or OmniROM, you will for sure notice that you need to change the cm.mk file from your device propper files with the name of the ROM for example if you want to compile SlimRom you need to change the cm.mk to slim.mk and so go on...
Soooo that's what we will gonna do.
First take the product_config.mk file located in teh core folder :
And now find these lines:
Code:
# A CM build needs only the CM product makefiles.
ifneq ($(CM_BUILD),)
all_product_configs := $(shell ls device/*/$(CM_BUILD)/cm.mk)
Now change the CM name with your ROM name (as always)
Now find this string:
Code:
CM_BUILD
And change it with your ROM name.
The same also for the next line.
Ok, so now we are done with the product_config.mk file so let's witch now on the envsetup.sh one:
Find this line:
Code:
if (echo -n $1 | grep -q -e "^cm_") ; then
Ok, now change the all the cm names with your ROM Name (as usual), after go and find this line:
Code:
CM_BUILD=
Change it as usual, the same also for the next one.
Now find this line:
Code:
if [ "z${CM_DEVICES_ONLY}" != "z" ]; then
And change it as usual. The same also for the upcoming one after 10 strings.
Again, find the bacon string and change it with your ROM Name.
Now find this line:
Code:
CM_DEVICES_ONLY
And change it as usual.
Now, go and find this line:
Code:
lunch cm_$target-$variant
And also this one change it as usual.
Now, find these lines:
Code:
MODVERSION=$(get_build_var CM_VERSION)
ZIPFILE=cm-$MODVERSION.zip
And change them as usual.
Don't worry we are nearly to the end.
The last strings which need to be modify at least are:
Code:
ro.cm.device=$CM_BUILD
CM_BUILD
So make CTRL F and search for those lines and change them with your ROM name.
So boom! Now when you will gonna compile for your device you will no longer see the CM name on it, of course that now you will need to change also the cm.mk name with your ROMName.mk situated in your Device common files.
Another thing which you can do is to add the dependencies which are an extra part and they will be explained in the Extra Part post.
Now close the two files and go and open buildinfo.sh which is situated in tools folder.
Now go and find this string:
Code:
echo "ro.cm.device=$CM_DEVICE"
Also here change it as we did in the lasts two files.
Close it, and now the last file which we will gonna modify is: roomservice.py which is situated in the tools folder.
So what this file do actually?
This file together with some others are responsible with the device build. I mean if for some reasons the device which you want to build for, isn't present in your local repo the build environment will automatically go and search in your ROM Organization (fetch) if there is such a device, so because we don't want that the build environment search in the CM Repo we need to change this file in order to search in your ROM Repo.
So first find this line:
Code:
githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:CyanogenMod+in:name+fork:true" % device)
And change the user with the ROM of the Organization from Github (exactly)
Now search for this line:
Code:
dependencies_path = repo_path + '/cm.dependencies'
And change the cm name with your ROM name (please make the ROM Name all lowercase to avoid confusion)
Now for the rest just search:
Code:
CM
CyanogenMod
And change it as we did earlier (your ROM Name)
So we finally done !
The build files are now modified and ready to be commited on Github, now when you will compile the ROM for your device you will not see anymore the CM Name
Extra features to add in Android Build files​
So this post mainly will gather user's proposed features and also mine which aren't included in the principal one.
This idea came up while i was writing the vendor part were i said that if users want to add some features to be added in the files which is not listed in the OP to write it and i will decide if is good enough to include it.
So because this thread is still WIP i will be the first to start this
Autoremove build.prop, .zip and .md5 files after each compilation​
I find a commit on the Euphoria git where a developer " Cl3Kener" (Github name) added some new features which should be included by default in my opinion..
So we know that when we make a compilation process a .md5 file will be created a .zip file will be created and also a build.prop .
Basically these files are created every time we make a new build and, to don't go and remove the build.prop every time for the new compilation or even for the zip and md5 files ,
These strings will autoremove these files every time you make a new build:
Code:
ifeq ($(MAKECMDGOALS),dirty)
+dont_bother := true
+endif
And this one also:
Code:
# Clears out zip and build.prop
.PHONY: dirty
dirty:
@rm -rf $(OUT_DIR)/target/product/*/system/build.prop
@rm -rf $(OUT_DIR)/target/product/*/*.zip
@rm -rf $(OUT_DIR)/target/product/*/*.md5sum
@rm -rf $(OUT_DIR)/target/product/*/*.txt
@echo -e ${CL_GRN}"build.prop, changelog and zip files erased"${CL_RST}
The first block of code needs to be putted here:
And the second block instead here:
Basically the end of file
Vendor files (First part)​
Now guys let's contimue the modifications also with the vendor files shaw we?
Make sure that you forked and cloned the repo to your computer with SmartGit by including also the upstream branches.
Before continue obviously we need to explain what this repo means, well exactly as from the title vendor we can assume that these vendors files are the propietary ones which every ROM have.
For example, each phone got propietary files (vendor) so the same is also here, so every ROM differ from each other.
Ok so now, for the fact that there will gonna be more things to do here i will split the vendor part in two.
In the first one we will remove all the CM stuff as in the android build.
In the second one instead we will talk about features or modifications that can be made on it.
So let's begin with the CM removable modifications:
Open the config folder.
Now here you will find multiple xml files, each of them will need to be modified.
But first let's take cm_audio.mk
The first thing to do is to remove this little cm and rename it with your ROM name (in lower case)
Now open it, and make CTRL F and search:
Code:
cm
And change it with your ROM name, do it for all of the search results.
Now you will need to do the exactly same thing also with the others located in the config folder except for the common.mk which is for later.
Now the last thing about this part is this:
Take the default.xml from platform manifest and change this line:
Code:
<project path="vendor/cm"
And change the path by changing the cm with your ROM name instead.
Now commit it and let's move on to the second part.
Vendor files (Second part)​
**Attention**
Before continue make sure to have commited the changes made earlier...
*************
Now, let's continue with the second part where we will add new features and make the latest changes....
Earlier i said that the common.mk is left for later, but i had reasons to do so.
That's because the common.mk is the most of important one (I think in my opinion).
So what we are waiting for let's open it!
The first thing you may see is : "Mooore Cyanogen stuff", yes you right bro mooore cyanogen stuff but here will be a bit different because we will not change everything at the moment because some of the strings will be left as their are.
A proper guide will be made to the Extra section where these strings will be able to be modified.
So let's go on:
The first thing to do is to change the vendor path exactly as we did in the previous files so for example:
Code:
vendor/cm/prebuilt/common/bin/backuptool.sh:install/bin/backuptool.sh \
The cm name change it with your ROM name just as you did in the previous files (lowercase)
Now go to the first string::
So change the Product Brand name with yours.
Now remove this entire ifndef because is not necessary:
Code:
ifdef CM_NIGHTLY
PRODUCT_PROPERTY_OVERRIDES += \
ro.rommanager.developerid=cyanogenmodnightly
else
PRODUCT_PROPERTY_OVERRIDES += \
ro.rommanager.developerid=cyanogenmod
endif
Now remove also this entire block:
Code:
ifndef CM_BUILDTYPE
ifdef RELEASE_TYPE
# Starting with "CM_" is optional
RELEASE_TYPE := $(shell echo $(RELEASE_TYPE) | sed -e 's|^CM_||g')
CM_BUILDTYPE := $(RELEASE_TYPE)
endif
endif
Also for this one:
Code:
ifeq ($(filter RELEASE NIGHTLY SNAPSHOT EXPERIMENTAL,$(CM_BUILDTYPE)),)
CM_BUILDTYPE :=
endif
Now remove this block and sobstitute it with this one provided by me
(To Remove)
Code:
ifdef CM_BUILDTYPE
ifneq ($(CM_BUILDTYPE), SNAPSHOT)
ifdef CM_EXTRAVERSION
# Force build type to EXPERIMENTAL
CM_BUILDTYPE := EXPERIMENTAL
# Remove leading dash from CM_EXTRAVERSION
CM_EXTRAVERSION := $(shell echo $(CM_EXTRAVERSION) | sed 's/-//')
# Add leading dash to CM_EXTRAVERSION
CM_EXTRAVERSION := -$(CM_EXTRAVERSION)
endif
else
ifndef CM_EXTRAVERSION
# Force build type to EXPERIMENTAL, SNAPSHOT mandates a tag
CM_BUILDTYPE := EXPERIMENTAL
else
# Remove leading dash from CM_EXTRAVERSION
CM_EXTRAVERSION := $(shell echo $(CM_EXTRAVERSION) | sed 's/-//')
# Add leading dash to CM_EXTRAVERSION
CM_EXTRAVERSION := -$(CM_EXTRAVERSION)
endif
endif
else
# If CM_BUILDTYPE is not defined, set to UNOFFICIAL
CM_BUILDTYPE := Release_1_Revision_1
CM_EXTRAVERSION :=
(To Add)
Code:
ifdef ROMNAME_BUILDTYPE
# If ROMNAME_BUILDTYPE is not defined, set to UNOFFICIAL
ROMNAME_BUILDTYPE := YOUR RELEASE
Now change these names:
Code:
CM_BUILDTYPE
CM_EXTRAVERSION
CM_VERSION
CM_BUILD
CM_DISPLAY_VERSION (Except for the ro.cm.display.version=$(CM_DISPLAY_VERSION) don't modify this one)
So now that the common.mk file is completed and modified, let's move on by telling you the basics things to know:
- The first thing to know is that the bootanimation is situated here in this repo in prebuilt/common/bootanimation so if you want to add a bootanimation for your own this is the place where you can store (Make sure to include different screensize for each type of device i mean the Resolution of every bootaimation)
- The default wallpaper is situated here: overlay/common/frameworks/base/core/res/res so if you want to change the wallpaper of the ROM here you will need to put it (Also here, make sure to include the wallpaper with the exact same name of the stock one and also change the wallpaper for all the drawable folders (to be sure))
- You can also add files for your own and add it to your out folder in order to be included in your ROM.
Just follow this syntax:
Code:
PRODUCT_COPY_FILES += \
Full origin path of the file / File(zip,apk it doesn't matter what type of file is) :Full destination path including also the file name\
When you finished to add your files at the last file don't put the:
Code:
/
Because at the last file to copy you don't need to put it because it means that this the last file to add and after there is nothing more to add .
Now for example this syntax:
Code:
PRODUCT_PROPERTY_OVERRIDES += \
Will be explained in the Settings section because you need also to modify some files inside the Settings sources.
Basically these are the main changes which you can made.
If you got something some new stuff which could be added just write it on the thread and i will add it on the Guide
As always after making the changes make sure to commit the changes, and if you got problems regarding this section just write it on the thread and i will answer you
Now let's move on the Settings part….
Extra fearures to add in the Android Vendor files ​
Packages​
As i stated in the OP i will make also a little part about the Packages which are included in the ROM sources before going to the Settings sources.
Well first of all let's take the packages folder from the ROM dir:
So we've got these folders.
In these folders there are several packages which you don't need it (most of it)
So these packages can be easily removed, but remember to remove also the entru from the default.xml from platform manifest in order to don't fetch the project again.
In apps
You can easily remove these projects:
CMBugReport
HTML Viewer
Speech recorder
TVSettings (Optional)
In experimental
Here i suggest you to maintain all the projects because you need them all
The same also for the providers
In screensavers
The screensavers folder instead can be entirely removed because they are also outdated and i think you don't need it for your sources.
The same also for the wallpapers folder.
Add apps to the sources
Now if you have an app and want to include it to your ROM you can add the app sources to the apps folder including in the app folder the Android.mk file.
But wait what is it?
Android.mk can be found in almost every folder of the ROM sources and represent an identity for the build environment in order know what to do with files located inside that folder.
So basically the Android.mk just tell to the build environment what to do with the files contained in that folder.
So how you can make an Android.mk ?
Simply, usually if you include basic apps, i mean apps which not require special build process by including special flags then the basic Android.mk used for the compilation of an app is this:
Code:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_PACKAGE_NAME := YourApp name
include $(BUILD_PACKAGE)
So if you want to include an app made for your own to the ROM sources and as i said is a basic app which not requires special flags for the compilation this is the Android.mk schema to use
Before jumping and going to work on the Settings sources, another thing which in my opinion can be easily added is an OTA Updater app.
Don't worry you don't need to make an app for this but i can suggest you one made by an XDA User , it's tested by and i can asure you that is working very well, but you need to follow a bit some instructions which i think aren't so difficult to follow.
Once you red the instructions, you can fork the repo to your repo organization and start working on the sources files. I'm not going to make a guide of this but i will just tell you to be careful with the sources and to don't modify the Android.mk contained in the app sources.
And the link is this: https://github.com/Kryten2k35/OTAUpdates
That's it!
Now we can proceed with the Settings part
Settings Part​
So here we are guys, finally we arrived to the Settings sources part, which in my opinion is one of the most featured part of all.
As usual we will split the post in two parts:
CM Removable Part
Features part
But before we continue, make sure to have forked and cloned the repo to your PC.
CM Removable part​
Ok so let's begin with the CM removable stuff part.
Open the sources and go and find Android Manifest , open it, now find this activity :
Code:
<activity android:name="SettingsCMLicenseActivity"
Now delete the etire activity.
After, find also these activities, and remove them all:
Code:
<activity android:name="Settings$AnonymousStatsActivity"
<activity android:name=".cyanogenmod.ChangeLog" />
<activity android:name=".cyanogenmod.ContributorsCloud" />
Now go to res/values/cm_strings
And remove all these lines:
Code:
<!-- Anonymous Statistics #CM -->
<!-- About device screen, list item title. Takes the user to the screen about opting in or out of anonymous statistics. -->
<string name="anonymous_statistics_title">CyanogenMod statistics</string>
<string name="anonymous_statistics_summary">Help make CyanogenMod better by opting into anonymous statistics reporting</string>
<string name="anonymous_statistics_warning_title">About</string>
<string name="anonymous_statistics_warning">Opting into CyanogenMod Statistics will allow non-personal data to be submitted to the
developers of CyanogenMod to track unique installations across devices. The information submitted includes an unique identifier,
which does not compromise your privacy or personal data. The data is submitted during each boot.\n\nFor an example of the data that is submitted, tap on Preview Data.</string>
<string name="enable_reporting_title">Enable reporting</string>
<string name="preview_data_title">Preview data</string>
<string name="view_stats_title">View stats</string>
<string name="anonymous_learn_more">Learn more</string>
Now go to res/drawable-hdpi
And remove this png:
Code:
ic_cm_stats_notif.png
Now go to res/drawable-mdpi
And remove the same png also here.
And finally the same also for drawable/xhdpi
After go to res/xml/device_info_settings
And delete this whole preference screen:
Code:
<!-- System update settings - launches activity -->
<PreferenceScreen android:key="system_update_settings"
android:title="@string/system_update_settings_list_item_title"
android:summary="@string/system_update_settings_list_item_summary">
<intent android:action="android.settings.SYSTEM_UPDATE_SETTINGS"
android:targetPackage="com.cyngn.fota"
android:targetClass="com.cyngn.fota.SystemUpdateActivity" />
</PreferenceScreen>
<PreferenceScreen android:key="additional_system_update_settings"
android:title="@string/additional_system_update_settings_list_item_title">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="@string/additional_system_update"
android:targetClass="@string/additional_system_update_menu" />
</PreferenceScreen>
<!-- CyanogenMod Updates -->
<PreferenceScreen android:key="cm_updates"
android:title="@string/cmupdate_settings_title"
android:summary="@string/system_update_settings_list_item_summary">
<intent android:action="android.intent.action.MAIN"
android:targetPackage="com.cyanogenmod.updater"
android:targetClass="com.cyanogenmod.updater.UpdatesSettings" />
</PreferenceScreen>
This one also:
Code:
<!-- Contributors cloud -->
<PreferenceScreen android:key="contributor_cloud"
android:title="@string/contributor_cloud_title"
android:fragment="com.android.settings.cyanogenmod.ContributorsCloud" >
</PreferenceScreen>
This one also:
Code:
<!-- CM License information -->
<PreferenceScreen
android:key="cmlicense"
android:title="@string/cmlicense_title">
<intent android:action="android.settings.CMLICENSE" />
</PreferenceScreen>
And also this one:
Code:
<!-- Change Log -->
<PreferenceScreen android:key="changelog"
android:title="@string/changelog_title"
android:fragment="com.android.settings.cyanogenmod.ChangeLog" >
</PreferenceScreen>
Now find also these xml files: which are located in the same folder:
Code:
anonymous_stats.xml
preview_data.xml
And delete them.
Now return to the main directory of settings and go to src/com/android/settings/Settings
Find:
Code:
CMLicenseActivity.java
And delete it.
Now go here: src/com/android/settings/cyanogenmod/
Find:
Code:
ContributorsCloud.java
And delete it.
Now go here: src/com/android/settings
Open:
Code:
DeviceInfoSettings.java
And delete the following lines (in order):
Code:
import android.content.pm.PackageManager.NameNotFoundException;
private static final String KEY_CM_UPDATES = "cm_updates";
Code:
// Only the owner should see the Updater settings, if it exists
if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
removePreferenceIfPackageNotInstalled(findPreference(KEY_CM_UPDATES));
} else {
getPreferenceScreen().removePreference(findPreference(KEY_CM_UPDATES));
}
Code:
private boolean removePreferenceIfPackageNotInstalled(Preference preference) {
String intentUri=((PreferenceScreen) preference).getIntent().toUri(1);
Pattern pattern = Pattern.compile("component=([^/]+)/");
Matcher matcher = pattern.matcher(intentUri);
String packageName=matcher.find()?matcher.group(1):null;
if(packageName != null) {
try {
PackageInfo pi = getPackageManager().getPackageInfo(packageName,
PackageManager.GET_ACTIVITIES);
if (!pi.applicationInfo.enabled) {
Log.e(LOG_TAG,"package "+packageName+" is disabled, hiding preference.");
getPreferenceScreen().removePreference(preference);
return true;
}
} catch (NameNotFoundException e) {
Log.e(LOG_TAG,"package "+packageName+" not installed, hiding preference.");
getPreferenceScreen().removePreference(preference);
return true;
}
}
return false;
}
Now save and close it.
After that go here: src/com/android/settings/
Open
Code:
Settings.java
And delete this line:
Code:
public static class AnonymousStatsActivity extends Settings { /* empty */ }
Save and close it.
Now the last part delete these java files:
Code:
src/com/android/settings/cmstats/AnonymousStats.java
src/com/android/settings/cmstats/PreviewData.java
src/com/android/settings/cmstats/ReportingService.java
src/com/android/settings/cmstats/ReportingServiceManager.java
src/com/android/settings/cmstats/Utilities.java
Now the very last part of these modifications....
Go here: src/com/android/settings/cyanogenmod/
And cut the ChangeLog.java file because we will need it to your Desktop.
So that's it.
Mostly these are the files to be deleted but as always if you consider that some other CM stuff needs to be deleted just write it on the Thread and i will add them
Now let's move on to the second part!
Features part​
Ok so finally we can talk about the features in Settings.
Here you can add plenty of things, and i will try now to include now to most important ones but as always if you got some new ones that you consider that can be added to the Guide just write it on the thread and i will looking forward to add them
I will add also here a difficulty level exactly as i did in the Extra Features part.
So let's start guys
Add more info about phone like Hardware etc...​
Difficulty level:
Difficulty level: (*°°°°)
This is optionally but if you want to include more hardware informations just follow this mini guide .
First go to res/values
Now create a new strings xml fine starting in this way:
Code:
romname_strings.xml (all lowercase)
Ok, now open it and include the following strings:
Code:
<!-- About device screen, Hardware info -->
<string name="hardware_info">Hardware info</string>
<!-- About device Screen, hardware info, rear camera -->
<string name="device_rear_camera">Rear camera</string>
<!-- About device Screen, hardware info, front camera -->
<string name="device_front_camera">Front facing camera</string>
<!-- About device Screen, hardware info, screen res -->
<string name="device_screen_resolution">Screen resolution</string>
<!-- About device Screen, hardware info, GPU info -->
<string name="gpu_info">GPU</string>
<!-- About device screen, Cpu info. -->
<string name="cpu_info">CPU</string>
<!-- About phone screen, Free memory info -->
<string name="mem_info">Memory</string>
Ok, now save and close it.
Now go to the xml folder
And open:
Code:
device_info_settings.xml
And add the following lines at the bottom:
Code:
<PreferenceScreen
android:key="hardware_info"
android:title="@string/hardware_info">
<!-- Device cpu info -->
<Preference android:key="device_cpu"
style="?android:preferenceInformationStyle"
android:title="@string/cpu_info"
android:summary="@string/device_info_default"/>
<!-- Device gpu info -->
<Preference android:key="device_gpu"
style="?android:preferenceInformationStyle"
android:title="@string/gpu_info"
android:summary="@string/device_info_default"/>
<!-- Device mem info -->
<Preference android:key="device_memory"
style="?android:preferenceInformationStyle"
android:title="@string/mem_info"
android:summary="@string/device_info_default"/>
<!-- Device rear camera -->
<Preference android:key="device_rear_camera"
style="?android:preferenceInformationStyle"
android:title="@string/device_rear_camera"/>
<!-- Device front camera -->
<Preference android:key="device_front_camera"
style="?android:preferenceInformationStyle"
android:title="@string/device_front_camera"/>
<!-- Device screen resolution -->
<Preference android:key="device_screen_resolution"
style="?android:preferenceInformationStyle"
android:title="@string/device_screen_resolution"/>
</PreferenceScreen>
And remove the following lines:
Code:
<!-- Device cpu info -->
<Preference android:key="device_cpu"
style="?android:preferenceInformationStyle"
android:title="@string/cpu_info"
android:summary="@string/device_info_default"/>
<!-- Device mem info -->
<Preference android:key="device_memory"
style="?android:preferenceInformationStyle"
android:title="@string/mem_info"
android:summary="@string/device_info_default"/>
Ok now save and close it.
Now go to the main dir of Settings and go to src/com/android/settings
And open:
Code:
DeviceInfoSettings.java
Now remove the following lines:
Code:
private static final String KEY_DEVICE_CPU = "device_cpu";
private static final String KEY_DEVICE_MEMORY = "device_memory";
And instead add these ones:
Code:
private static final String KEY_DEVICE_CPU = "device_cpu";
private static final String KEY_DEVICE_GPU = "device_gpu";
private static final String KEY_DEVICE_MEMORY = "device_memory";
private static final String KEY_DEVICE_REAR_CAMERA = "device_rear_camera";
private static final String KEY_DEVICE_FRONT_CAMERA = "device_front_camera";
private static final String KEY_DEVICE_SCREEN_RESOLUTION = "device_screen_resolution";
Now add these lines after this one:
Code:
setValueSummary(KEY_MOD_BUILD_DATE, "ro.build.date");
Code:
addStringPreference(KEY_DEVICE_CPU,
SystemProperties.get("ro.device.cpu", getCPUInfo()));
addStringPreference(KEY_DEVICE_GPU,
SystemProperties.get("ro.device.gpu", null));
addStringPreference(KEY_DEVICE_MEMORY, getMemInfo());
addStringPreference(KEY_DEVICE_FRONT_CAMERA,
SystemProperties.get("ro.device.front_cam", null));
addStringPreference(KEY_DEVICE_REAR_CAMERA,
SystemProperties.get("ro.device.rear_cam", null));
addStringPreference(KEY_DEVICE_SCREEN_RESOLUTION,
SystemProperties.get("ro.device.screen_res", null));
Then the last ones need to be added at the end of file:
Code:
private void addStringPreference(String key, String value) {
if (value != null) {
setStringSummary(key, value);
} else {
getPreferenceScreen().removePreference(findPreference(key));
}
}
}
That's it! Now you will be able to see more info about your phon in device info settings.
Just make sure that you add also these lines to your build.prop:
Code:
ro.device.cpu
re.device.gpu
ro.device.front_cam
ro.device.rear_cam
ro.device.screen_res
Add your own ROM banner in Settings​
Difficulty level: (*°°°°)
This one is very simple to follow and i think in my opinion everyone should add a banner to their Settings app
So first take the res folder and go to the layout folder.
And create a new xml file by adding these lines into it:
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/banner" />
</LinearLayout>
And save it as banner for example.
Now for the banner size, in my opinion you should resize you banner to a size like a : 480x180
This should fit perfectly.
Then after you prepared your banner copy it to the drawable folder and make sure that the image is saved with the "banner" name.
Now the last thing to do is to display it in Settings.
So now go to res/xml
And open:
Code:
device_info_settings.xml
And copy this line after the third line:
Code:
<PreferenceScreen android:layout="@layout/banner" android:key="od_logo" />
That's it now your logo is added in Settings!
Extra features to add in the Settings sources​
Extra Features​
This last part of the guide will be dedicated to the..... "hard features modifications", Yes let's call it in this way !
I called it in this way because by meaning hard modifications i mean that we will gonna modify more files from not just one repo but more than one.
So i will start it with some minor modifications, but mainly this part will be left to the users, because if you got talent and made some cool modifications and want to share it on the thread, i will add them to the post by including also a propper guide to it
In this post i will also include a difficulty level because as the modifications are not at the same level of all, i will include also a difficulty level in order to make it know to the Developer what he is dealing with.
As always if you got trouble just write in the thread the problem by following the schema written in the OP
That's all
Manage and add new strings to Settings and override them in the compilation process​
Difficulty level: (**°°°)
So, first of all here are the repos which we will gonna modify:
android_vendor_files
Settings (Repo)
Before continue let me give you a basic intro about what we are talking about.
For example when you are seeing a string in Settings (About phone for example) like the Version of the ROM, in order to display the version of the ROM the files beeing modified weren't just one but more than one.
So if you want to add a new string which you know that is gonna to be modified many times like the version of the ROM to display something in Settings here is what you gonna need to do:
At first let's take the Settings repo:
Now go to res/values
Now, here you have two options:
Or you take the default Strings xml and you will add there your new strings
Or you create a new xml file exactly as the Strings one is and you start adding yours there (Better this one in my opinion)
Now open Strings xml (The one created or the default one)
And create a new entry as the other ones
For example i made a string for the Revisions of my ROM.
Now you have to decide where to display this string.
In my opinion the better place is in About phone
So now go to the xml folder and search for:
Code:
device_info_settings.xml
Open it, and now create also here a new entry exactly as the others .
The only thing you need to modify is the android:title and the android:summary
If you don't need a summary of it you can just write only the android:title string as i did:
So after, we move to the Java part.
Go to src/com/android/settings
And search for:
Code:
DeviceInfoSettings.java
Open it, now you will need to create also here an entry for the new string so right after the last private static final String create another one like i did:
Now we will need to assign the value we are gonna override from the vendor files more exactly,
Find this string:
Code:
setValueSummary(KEY_MOD_VERSION,"ro.cm.display.version");
In this string for example we assign the value for the mod version which is the version of the ROM and we are assigning the value coming from the ro.cm.display.version which you all know that is coming from the build.prop but actually is coming from the vendor files
So do the same also for you string (Make sure that the string which the Settings one will read the value from build.prop to start with ro.)
Ok, so done that we can switch repo and go to the vendor files.
Now take the common.mk file which is located inside the config folder.
As i did an entry for the Revision number earlier in Settings, i will made an entry here:
I put it together with the build type because also this string offer informations regarding the ROM, thats' why, but you can put yours anywhere you want (But read always when you write something if it is in the right place)
Now the last thing to do is to Overrride the new value assigned in the common.mk to the desired String, as stated here:
So that's it you finally created a new string which it will gonna change in Settings everytime you change the value here in the Common.mk file.
To modify an existing one just follow the steps made earlier and you should be fine
Add a device to your Organization and add dependencies ​
Difficulty level: (*°°°°)
Another thing to be added here is the one about how to add a device to your organization and to add also propper dependencies for your device.
As you remember when we worked on Android Build i told you to change this file:
Code:
roomservice.py
This file is very important if you want to add dependencies to your device when you want to build the ROM because if you don't have the Device sources cloned to your Main Repo folder the build environment will automatically go and download them all from the Organization.
These dependencies are very useful because avoid confusions and allow also to organize better your Organization.
So what you need to do ?
First go and clone your device tree for example (Not the vendor one) to your Organization
Image
I choosed the ariesve one which is mine.
Clone it to your desktop in order to work on it.
Now before to continue you need to think what dependencies to add i mean to be downloaded, usually the common ones are:
Kernel
Vendor (propietary)
But if you will need to add more repo, just need to follow the schema that i will show you now:
Code:
[
{
"repository": "android_device_samsung_ariesve",
"target_path": "device/samsung/ariesve"
"branch": "lollipop5.1"
}
{
"repository": "android_vendor_samsung",
"target_path": "vendor/samsung"
"branch": "lollipop5.1"
}
{
"repository": "android_kernel_samsung_msm7x30",
"target_path": "kernel/samsung/msm7x30"
"branch": "lollipop5.1"
}
]
This schema is just an example and is made for my device.
As you can see the schema is very simple and you can add as many repo as you want, the only thing to do when you save is to save it in this way: yourromname.dependenicies (all lower case).
We use this syntax to save the file, in order to make i t recognize to the build environment.
So if it's all good then when you will need to build for your device then the build environment will download all the dependencies needed by the device.
Note.
Make sure also to include all the repos needed in the dependencies because if the repo isn't located in the Organization then it will not be downloaded and it will be skipped automatically.
reserved10
reserved
reserved
reserved 13
Linux Distribution Part​
As stated in OP, for building you will need Ubuntu. If you already got it running somewhere on a decent machine, you're fine and can jump to the next post. If you don't like Ubuntu as Desktop system like I do and are using something else (like Arch Linux which I am using) you need to setup Ubuntu. Mostly you don't like to install a full system, so you can choose to install a chroot environment. For this, you only need a separate partition (you can also choose to do this on the partition you have your host system on, but it's better to do it on an own partition so you don't have to reinstall it when you need to reinstall the host system). In this post I'll show you how to setup a chroot environment with Ubuntu installed into it:
1. On the host system, you'll need debootstrap (for installing Ubuntu) and schroot (for chroot-ing to the new environment). On a debian based system, these packages should be installable by apt-get, so you just do
apt-get install debootstrap schroot​If you use Arch Linux like me, schroot is installable by pacman, debootstrap is available in the AUR (so just install it with yaourt). To do so you also need to install gnupg1 from the AUR (including importing the GPG key of the gnupg1 maintainer like described in the comments of the AUR package) and also ubuntu-keyring to validate the Ubuntu release after downloading.
2. If you installed debootstrap and schroot succesfully and got your partition setup and mounted (I use /mnt in this example), you do:
debootstrap --arch=amd64 trusty /mnt (optionally point to a mirror here)​This will take some time (around 500 MB will be downloaded and installed). Once this is done, you need to setup schroot. Open up /etc/schroot/schroot.conf in a text editor of your choice and put in something like this:
[trusty]
description=Ubuntu Build Environment
type=directory
directory=/mnt
users=root​Change directory to the place you mounted the partition for the chroot. To finally get into the new environment, just do
schroot -c trusty​
Environment Setup Part​Now that you have the initial system ready, some software needs to be installed so you can get started. First thing would be to install the java jdk. If you build for Lollipop and later, you'll need openjdk 7. To install that, do
apt-get update
apt-get install openjdk-7-openjdk​if you run into some errors like I did, you'll need to work around them. If you get the error "dependencies failed" (or similar), and sgml-base is in the list of packages that couldn't be installed, just do
groupadd staff
dpkg --configure sgml-base​and try to install openjdk again using the above command. If you run into errors concerning libpam-systemd:amd64 you'll need to do two things, first you do
dpkg-divert --local --rename --add /sbin/initctl​to avoid upstart and init errors and then
sed -i 's/exit 100/exit 0/' /usr/sbin/invoke-rc.d​to work around the systemd-login script not found error (known bug in Ubuntu 14.04).
Now that you've installed openjdk, you need some packages to build android from source. Install them using
apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zip schedtool​Now you need to select a location inside the chroot to build. One remark here: schroot mounts your home directory from the host system into the chroot, so it's not advisable to build there. You can put the repo binary there if you like, but the sources and output directory should be somewhere else. I chose /opt/android (folder android needed to be created of course), but that's completely up to you. Also, please keep in mind that you shouldn't build as root to avoid replacing system files (just use the user from your host system, it's available under the chroot environment as mentioned earlier). Now just download the repo binary and you're ready to download the sources:
mkdir ~/bin
echo "PATH=~/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo​
Disclaimer and ROM specifications
Hey guys, so before to proceed with anything, please take 2 minutes to read this, because it may help you later.
When i was writing this thread i was thinking to allow the users to take in consideration as ROM base sources any kind of ROM, but i realized that for ROMs like AOSP, PAC or even Omni there's need more than a simply knowledge to modify the sources and make then the builds.
When i refer to AOSP i refer also to all the others AOSP based ROMs.
Those needs more time to stand on it and requires more skills rather than written here.
So the guide name was changed during the work in progress and changed to how it's now in this moment.
All CM based ROMs took as base sources are all good, so every change which i wrote here can be applied to any of the CM based ROMs.
If you want to make a try, go ahead but i will not provide support for that, i will provide my help for the ones who are making CM based ROMs.
Thanks to @jackeagle for pointing me and give me the ideas to write this part of the guide and don't forget guys, if you're having problems with the ROM compilation just go and see his guide ----> [GUIDE][COMPLETE] Android ROM Development From Source To End
So that's it, you can now close this post and go ahead with Guide
Good luck!

Help with Tasker command/script

How can I create a tasker script to automate the amendment of a file in an app?
Basically I wish to add a line of text to a file in the Freedompop app to disable android dialer integration.
I would have to amend the file located at /data/data/com.freedompop.phone/shared_prefs/com.freedompop.phone_preferences.xml
and add this line <boolean name="integrate_with_native_dialer" value="false" />
just before </map>
I have already done this manually with root explorer but its tedious after every app update and I have to do this again manually

Categories

Resources