[Android] Haze028:
Edit Source​

If you plan to edit the device/kernel repos for your phone you should either have used git clone to obtain your repos, or created forks of the repos to your own Github account to use in your local manifest. This way you can still do a repo sync to update the source without overwriting your changes or creating conflicts.

That being said these are the items disscused so far:

Adding Prebuilt APK's to Build

Open the device folder for your phone. ie device/lge/geeb

Add these lines to android.mk

Name - Any name you want to asign to this apk to call for it in the build process

**NOTE** LOCAL_SRC_FILES is the location of the apk file. Above assumes it is in the root of your device folder**

Then edit your device.mk to call for your newly assigned apk

If the apk you want to add requires additional files to be added along with it, also add this

Path-to-additional-file - Where the file is located in your device tree that you need to add to your build

Destination-path-in-finished-build - Where in the final rom structure this file needs to be

Here is an example for adding required libs for Terminal Emulator to the geeb device tree:

Adding Apps Via Source Code

Adding apps to your build using source code is easier then adding prebuilt apks.

Example given is using Gallery2(I realize this is included with builds by default, just using it as an example)

Copy or clone your app's source code to working-dir/packages/apps in its own folder. ie. aokp/packages/Gallery2

Go into the source code folder for your app and open Android.mk

Look for this line LOCAL_PACKAGE_NAME , This will tell you what the call name for your app is

Then open device.mk from your phones device tree and add the call name for the app.

Add these lines:

Changing Toolchain

Download a new prebuilt toolchain that you wish to use

Example: Linaro 4.7 toolchain

Copy unziped prebuilt toolchain folder to working-folder/prebuilt/gcc/linux-x86/arm

Open build/envsetup.sh

Find this block of code:

Replace bold text with your toolchain folder name

The following group of instructions are for making edits to your own repo. Before using any of the info below PLEASE create your own GitHub account and Fork the repo you'd like to edit. Then clone YOUR forked repo from YOUR github account and make edits to it.

If that didn't make sence then you may want to refrain from using this for the time being.

Cherry Picking Commits

Move to the directory for the git repo you wish to add the commit to. ie kernel/lge/geeb

cd path-to-git-repo

Add the remote repo that holds the commit - This only needs to be done the first time

git remote add [COLOR="Red"]name[/COLOR] [COLOR="SeaGreen"]url[/COLOR]

name - a name you choose to identify that remote repo

url - the location of the repo ie. https://github.com/TeamPlaceholder/android_kernel_lge_gee.git

Fetch the repo

git fetch [COLOR="Red"]name[/COLOR]

Cherry pick commit

git cherry-pick [COLOR="DarkOrange"]commit-id[/COLOR]

commit-id - An unique id given to every commit. It's a long alphanumeric id shown on the commit page of your repo. ie. cc3581ff8692b517ddda8baad73a5d110568f0da

Fixing Conflicts From Cherry Picks

Somtimes when you cherry pick a commit to your repo you'll have a conflict. This is just saying that it did not see what it expected to see when adding the commit to a certain file. To fix a conflict and commit the cherry pick do as follows:

Determine which file(s) contain conflicts.

git status

This will show you edits waiting to be commited from the cherry-pick. The files shown in green accepted the changes without conflict, the files listed in red contain conflicts that need to be addressed.

Open the file in red

gedit [COLOR="DarkOrange"]Path-To-File-In-Red[/COLOR]

Press crtl+f to bring up a find window and search for head. Conflicts will be shown in the file using the following structure

Compare the original code to the code from the cherry pick and see if anything needs to be saved. If so, merge what needs to be saved into the code from the cherry pick. Then delete the original code and the <<<< ===== >>>>> lines(everything shown in red above). In the end you should be left only with the code from the cherry pick, plus anything you may have merged to it.

Search again for 'head' to see if there are any further conflicts within that file. If there is use the same method to resolve them, if there is not save and exit the file.

Add the newly edited file to the pending commit

git add [COLOR="DarkOrange"]Path-To-File-In-Red[/COLOR]

Check for any more files that need to be addressed

git status

If you still have files in red, repeat the process above for those files.

Once all files from git status are shown in green you are ready to commit the cherry pick.

git commit

Save and exit the commit log by pressing ctrl+x

Done. That cherry pick is now commited to your repo, you can move on to the next cherry pick you wish to add.

Sync Forked Repo with Upstream(Parent) Repo

If you would like to commit to your forked repo all the commits made upstream since you forked(or previously sync'd)

Add the upstream repo - This only needs to be done the first time

git remote add [COLOR="Red"]name[/COLOR] [COLOR="SeaGreen"]url[/COLOR]

name - a name you choose to identify that remote repo

url - the location of the repo ie. https://github.com/TeamPlaceholder/android_kernel_lge_gee.git

Fetch the upstream repo

git fetch [COLOR="Red"]name[/COLOR]

Merge upstream commits

git merge [COLOR="Red"]name[/COLOR]/[COLOR="DarkOrange"]branch[/COLOR]

branch - The branch from the upstream repo you are syncing up

Syncing Your Local Changes to Your Github Repo

Check to ensure you have everything in order to push your changes

git status

If there are no conflicts/changes that need to be commited you are ready to push. If everything is good it will simply state your are x number of commits ahead

Push your commits to your GitHub account

git push

Enter your github user name then password. All your local commits will then be applied to your github repo.

More to Come...