Skip to content

Latest commit

 

History

History
448 lines (228 loc) · 11.8 KB

README.md

File metadata and controls

448 lines (228 loc) · 11.8 KB

Android-AOSP

This repo has all the information about AOSP things.

Requirements

Hardware and Software Requirements for downloading and building AOSP:

https://source.android.com/setup/build/requirements#hardware-requirements

Preparing WorkStation for AOSP

Setup Build Environment - Install required packages for building aosp:

https://source.android.com/setup/build/initializing

Install Source Control Tools:

https://source.android.com/setup/develop

Install Repo Client:

https://source.android.com/setup/build/downloading

Initialize AOSP Source Repository

Initialize and sync the code

https://source.android.com/setup/start

Initiate the Repo Source

aosp_root$ repo init -u https://android.googlesource.com/platform/manifest -b [TAG]

TAG is the build Number that could be <android-10.0.0_r25> that you can choose from:

https://source.android.com/setup/start/build-numbers

Removing Repo

aosp_root$ rm -r .repo

Sync the Repo

Sync the repo source code:

aosp_root$ repo sync -j16

Sync only a specific project:

aosp_root$ repo sync --force-sync [project-dir]

[Project-dir] could be any directory like this - /aosp_root/packages/apps/Settings

Otherwise, we can go to the [project-dir] and sync it there:

aosp_root/[project-dir]$ repo sync .

Resolving Repo Sync Errors

If Repo fails to sync, then try the below:

Tweak TCP Setting:

aosp_root$ sudo sysctl -w net.ipv4.tcp_window_scaling=0

or

aosp_root$ repo sync -j16 --force-sync

or

aosp_root$ repo sync -j16 --fail-fast

Some known-issues while syncing AOSP:

https://source.android.com/setup/build/known-issues

Checking Repo Status:

aosp_root$ repo status

Checking out all the projects in the repo:

Normally, when repo sync completes, it automatically checkout all projects to the current branch mentioned in the repo manifest file. If it does not checkout properly, try below:

aosp_root$ repo sync -l

The above will checkout all projects locally.

If not sure about the repo manifest branch set correctly, then try resetting the repo:

aosp_root$ cd .repo/

aosp_root/.repo$ rm -rf manifest.xml

aosp_root/.repo$ rm -rf manifests

aosp_root/.repo$ cd ..

aosp_root$ repo forall -c git clean -xdf; repo forall -c git reset HEAD --hard; repo sync -j32;

If any project in the repo fails to sync:

Delete the corrupt project:

aosp_root$ cd .repo/

Find the [project].git inside /aosp_root/.repo

There will two [project].git in /aosp_root/.repo/projects/ and /aosp_root/.repo/project-objects/

Delete those two [project].git

And, try sync the repo alone by:

aosp_root$ repo sync --force-sync [project]

[project] could be any directory like this - /aosp_root/packages/apps/Settings

If the repo locked due to multiple sync at the same time, then:

Find the locked object [.lock]

aosp_root$ cd .repo/

aosp_root/.repo$ find . -iname *.lock

And delete all the locked objects:

aosp_root$ rm *.lock

Sync the repo after all...

aosp_root$ repo sync -j16

Building the repo

Setup environment:

aosp_root$ source build/envsetup.sh

Choose build variant:

aosp_root$ lunch

And, hit enter, give the build variant number (or) its text as the input like:

aosp_root$ 8 (or) aosp_root$ [build-variant]

(or) give it straight away...

aosp_root$ lunch [build-variant]

Build the repo by:

aosp_root$ make -j16

Clean the entire build directory [/aosp_root/out/] by:

aosp_root$ make clean

Updating Framework APIs

If you try to make (or) add changes in the Framework APIs, then you need to update the build as well

aosp_root$ make update-api

These APIs are recorded and updated on the below files:

root_aosp/frameworks/base/api/current.txt

root_aosp/frameworks/base/api/test-current.txt

Download Factory Images and AOSP Builds

  1. AOSP CI Builds > https://ci.android.com/builds/branches/aosp-master/grid

  2. AOSP Factory Images > https://developers.google.com/android/images

  3. Android Flash Tool > https://flash.android.com

  4. Flashing Devices > https://source.android.com/setup/build/running

Accessing FastBoot

Fastboot can be found in:

/aosp_root/out/host/linux-x86/bin/fastboot

Just copy it in your build and linux user directory to access it.

aosp_root/out/target/product/[build-variant]$ cp /aosp_root/out/host/linux-x86/bin/fastboot .

$ sudo cp aosp_root/out/host/linux-x86/bin/fastboot /usr/local/bin/fastboot

$ fastboot devices

That will list down connected fastboot devices.

Syncing changes to your device

After successful build, you can sync the changes you've made to your device instead of flashing the build again and again.

$ export ANDROID_PRODUCT_OUT=/aosp_root/out/target/product/[build-variant]

$ adb root

$ adb remount

$ adb sync

$ adb reboot

Working with ADB

If your adb not detecting your connected device, kill it and start it again

$ adb kill-server

$ adb start-server

Lists all ABD devices:

$ adb devices

(I) Accessing adb device wirelessly:

  1. Run $ adb tcpip 5555

  2. Disconnect your device (remove the USB cable)

  3. Go to the Settings > About phone > Status to view the IP address of your phone. IP address will be available only if it has internet access.

  4. adb connect [ip_address_of_your_device>:5555

  5. Run $ adb devices to check whether the device was connected.

  6. Referenced from https://futurestud.io/tutorials/how-to-debug-your-android-app-over-wifi-without-root

(II) Accessing adb device wirelessly:

  1. Navigate to developer options on the device, and enable wireless debugging.

  2. Copy the IP Address and Port Number from the device (192.168.0.100:32435)

  3. Open the terminal and navigate to the android platform tools and enter IP Address and Port Number

  4. $ adb pair 192.168.0.100:32435

  5. Enter the pairing code from the device to the terminal.

AOSP Libraries

All aosp project's shared common libraries are generated in the below path:

/aosp_root/out/target/common/obj/JAVA_LIBRARIES/

Jetpack Libraries are in AOSP:

/aosp_root/frameworks/support/

JNI in AOSP:

/aosp_root/libnativehelper/

AOSP APKs

All AOSP Android Application APKs are generated in the below paths

/aosp_root/out/target/product/[build-variant]/system/product/priv-app/

/aosp_root/out/target/product/[build-variant]/system/product/app/

/aosp_root/out/target/product/[build-variant]/system/app/

/aosp_root/out/target/product/[build-variant]/system/priv-app/

Searching AOSP

Search Java Code Files:

$ jgrep

Search Android Resource Files:

$ resgrep

Search C/C++ Files:

$ cgrep

Search anything:

$ grep -nrw "anything_that_you_want_to_search"

Working on AOSP with Android Studio

Run idegen.sh from aosp development tools

aosp_root$ make idegen && development/tools/idegen/idegen.sh

The android.ipr will get generated on the /aosp_root/ path

Go to Studio > Help > Edit Custom VM and increase the memory:

-Xms1g -Xmx5g

Go to Studio > Help > Edit custom properties and increase file size limit:

idea.max.intellisense.filesize=100000

Then, restart your IDE

Go to /aosp_root/ path and right click and open the "android.ipr" file with Android Studio.

After all the index process are done, go to "project structure > SDK" and create a new JDK (no_libraries) configuration.

Then remove all of the jar entries under the "Classpath" tab to access only the aosp core libraries.

Changing Android Boot Animation

The bootanimation.zip file can be found in system/media/ folder of an android powered device.

During build time, the bootanimation.zip file is copied to the system/media/ directory.

This can be done by Car.mk build file found in /aosp_root/packages/services/Car/car_product/build/car.mk

PRODUCT_COPY_FILES +=
packages/services/Car/car_product/bootanimations/bootanimation-832.zip:system/media/bootanimation.zip

The original "bootanimation.zip" file is located at:

/aosp_root/packages/services/Car/car_product/bootanimations/bootanimation-832.zip

Making your own bootanimation.zip file:

  1. Create a "new_folder" and go to that folder.

  2. Create part0 folder inside "/new_folder/" and include all your PNG Animation Sequence Images.

  3. Create desc.txt file and edit the desc.txt file by following the animation format:

    width height frame-rate

    p loops pause folder-sequence

    The example would be:

    832 520 30

    p 1 100 part0

  4. After this, "new_folder" will have part0 folder with images and desc.txt file.

    new_folder$ ls

    part0 desc.txt

  5. Create uncompressed format of bootanimation.zip file

    new_folder$ zip -r -0 bootanimation.zip .

  6. Rename bootanimation.zip file as bootanimation-832.zip file.

  7. Copy and replace the new bootanimation-832.zip file in /aosp_root/packages/services/Car/car_product/bootanimations/ path

  8. Build the aosp project and flash the new build image.

  9. You can easily test this bootanimation by:

    $ adb root

    $ adb remount

    $ adb push bootanimation.zip /system/media/

  10. Make it executable:

    $ adb shell chmod 666 /system/media/bootanimation.zip

  11. Restart the device, you will see the bootanimation.

  12. If not working, then launch bootanimation via adb shell:

    $ adb shell bootanimation

Changing Android Boot Image:

  1. Use any online portal and convert PNG Boot Logo file into PPM (Portable Pixmap Format) format.

  2. Make sure that the image width and height are supported by the system. ex) 832 x 520

  3. Reduce the number of colors to 224 using ppmquant

    $ ppmquant 224 custom_logo.ppm > custom_logo_224.ppm

  4. Convert the image to ASCII format using pnmnoraw

    $ pnmnoraw custom_logo_224.ppm > custom_logo_ascii_224.ppm

  5. The final image would be custom_logo_ascii_224.ppm and replace this in your android build system.

References

  1. Embedded Android > https://www.oreilly.com/library/view/embedded-android/9781449327958/ch04.html

  2. Building AOSP > https://www.polidea.com/blog/How-to-Build-your-Own-Android-Based-on-AOSP

  3. Building Custom ROM > https://www.talentica.com/blogs/build-custom-android-rom-using-android-open-source-projectaosp/

  4. How to build Android ROMs on Ubuntu > https://www.digitalocean.com/community/tutorials/how-to-build-android-roms-on-ubuntu-16-04

  5. AOSP Part 1 by UDI COHEN > http://blog.udinic.com/2014/05/24/aosp-part-1-get-the-code-using-the-manifest-and-repo

  6. AOSP Part 2 by UDI COHEN > http://blog.udinic.com/2014/06/04/aosp-part-2-build-variants

  7. AOSP Part 3 by UDI COHEN > http://blog.udinic.com/2014/07/24/aosp-part-3-developing-efficiently

  8. IDEGEN Development Tool from Google > https://android.googlesource.com/platform/development/+/master/tools/idegen/README

  9. Setting up AOSP with IntelliJ > https://shuhaowu.com/blog/setting_up_intellij_with_aosp_development.html

  10. AOSP Code Search by Google > https://cs.android.com

  11. Changing Android Boot Image and Animation > https://www.digi.com/resources/documentation/digidocs/90001546/task/android/t_faq_change_android_boot_images.htm

License


Copyright 2021 LiteKite Startup

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.