AOSP On New Deivce
AOSP On New Deivce
My Product on
Android Open Source Project
1
Agenda
● Motivation
● Build System Overview
● Simple Build
● Product Customization Structure
● Create My Own Products
● Summary
● Q&A
2
Motivation
3
Motivation
4
Motivation
5
Motivation
6
Android Build System
7
Android Build System Architecture
8
Simple build
9
Simple build
$ source build/envsetup.sh
$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. aosp_arm-eng
2. aosp_arm64-eng
3. aosp_mips-eng
Which would you like? [aosp_arm-eng]
$ make -j16
Wait…
10
Simple build… envsetup
envsetup.sh
This script is for setting up the build environment on the
current shell
● adding macros
● type hmm to list all macros created
● godir - move to the directory containing a file
● m, mm, mmm - macros to start a build with different args
● cgrep - alias to execute grep on c/c++ files
● jgrep - alias to execute grep on java files
11
Simple build… lunch
lunch
● It lists all the combos available in the current
environment to be built
● By following all vendor/* and device/* folders looking for the
vendorsetup.sh files.
● vendorsetup.sh files actually executes the add_lunch_combo with
parameters
12
Simple build… combos
13
Simple build… env variables
ANDROID_EABI_TOOLCHAIN aosp-root/prebuilt/linux-x86/toolchain/arm-
eabi-4.4.3/bin
ANDROID_TOOLCHAIN $ANDROID_EABI_TOOLCHAIN
ANDROID_BUILD_TOP aosp-root
TARGET_BUILD_VARIANT eng,user,userdebug
14
Simple build… output
15
Simple build… images
16
Simple build… images
● userdata.img
● Partition to hold the user data. Usually empty after the build
● recovery.img, ramdisk-recovery.img
● basic image partition used to recover user data or even the actual
system if anything goes wrong.
17
Simple build… emulator
18
Product customization structure
19
Product customization structure
20
Android product makefile
● Product properties
● PRODUCT_NAME := aosp_arm
● This is the name that will appear in the lunch combo option. This must match this
product folder under devices folder.
● PRODUCT_DEVICE := generic
● This must match the device’s sub directory. TARGET_DEVICE derives from this
variable.
● PRODUCT_MODEL := AOSP on ARM Emulator
● The end-user-visible name for the end product.
23
Android product makefile
24
Android product makefile
● Modules to be included
PRODUCT_PACKAGES += \
my_own_service_module \
CustomGallery \
lib4mywifi
● Defines which modules, besides any inherited (due to the ‘+’ before
the equals), we want to include on the build.
● It could include libs/apps that are only defined under
device/<my_company>/<my_product>.
25
Android product makefile
26
Android product makefile
27
Android product makefile
28
Android product inheritance
● Inherit to reuse
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
29
Android product inheritance
● Makefile inheritance
● In order to have the minimal configuration you need
embedded.mk
base.mk
core_minimal.mk
telephony.mk & aosp_base.mk
core.mk
full_base_telephony.mk
generic_no_telephony.mk
full_base.mk
30
Android product inheritance
31
Android.mk
32
AndroidBoard.mk
33
BoardConfig.mk
34
BoardConfig.mk
Simple BoardConfig.mk
35
device.mk
full_<product>.mk
device_<board>.mk
AndroidBoard.mk
AndroidProducts.mk BoardConfig.mk
Android.mk vendorsetup.sh
37
Creating my own product
39
Creating my own product
Folders/files content
● AndroidProducts.mk
PRODUCT_MAKEFILES := $(LOCAL_DIR)/full_girlofipanema.mk
● device_tomjobim.mk
Includes Emulator’s make file
include $(SRC_TARGET_DIR)/product/emulator.mk
Define this devices overlay directory (Just wallpaper replacement)
DEVICE_PACKAGE_OVERLAYS := device/bossanova/tomjobim/boardoverlays
frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.jpg
40
Creating my own product
Folders/files content
● BoardConfig.mk
● Pretty much the emulator’s one
● Reducing the size of userdata partition to 256M
BOARD_USERDATAIMAGE_PARTITION_SIZE := 268435456
● vendorsetup.sh
● Added our combos
41
Creating my own product
Folders/files content
● full_girlofipanema.mk
Define products info (model, name, device…)
Setting this product overlay defining the launchers wallpaper
PRODUCT_PACKAGE_OVERLAYS := device/bossanova/tomjobim/goi_overlays
Customized config.xml overlay
config_toastDefaultGravity=top|center_horizontal
42
Creating my own product build
43
Emulator
44
Create a second product
46
Creating my own product
Folders/files content
● AndroidProducts.mk
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/full_girlofipanema.mk \
$(LOCAL_DIR)/full_onenotesamba.mk
● vendorsetup.sh
Added our combos
add_lunch_combo full_onenotesamba-userdebug
add_lunch_combo full_onenotesamba-user
add_lunch_combo full_onenotesamba-eng
47
Creating my own product
Folders/files content
● full_onenotesamba.mk
Add a new package to be included into the build, set the overlay folder and
the tablet characteristic
PRODUCT_PACKAGES += OneNoteSambaPlayer
PRODUCT_PACKAGE_OVERLAYS := device/bossanova/tomjobim/ons_overlays
PRODUCT_CHARACTERISTICS := tablet
PRODUCT_COPY_FILES += device/bossanova/tomjobim/bootanimation.zip:
system/media/bootanimation.zip
48
Creating my own product
Folders/files content
● full_onenotesamba.mk
Customized config.xml overlay (setting toast to be in the center)
config_toastDefaultGravity=center_vertical|center_horizontal
49
Adding a prebuilt app
50
Adding a prebuilt app
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Module name should match apk name to be installed.
LOCAL_MODULE := OneNoteSambaPlayer
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
include $(BUILD_PREBUILT)
51
Summary
52
References
53
Q&A*
● Now
● Later
● rafael.coutinho@phiinnovations.com
● @rafaelcoutinho