AOSP - Porting
https://source.android.com/setup/develop
Adding a New Device
This information applies only to creating a new device type and is intended specifically for company build and product teams.Understand Build Layers
Each layer relates to the one above it in a one-to-many relationship. For example, an architecture can have more than one board and each board can have more than one product.
Layer | Example | Description |
---|---|---|
Product | myProduct, myProduct_eu, myProduct_eu_fr, j2, sdk | The product layer defines the feature specification of a shipping product such as the modules to build, locales supported, and the configuration for various locales. In other words, this is the name of the overall product. Product-specific variables are defined in product definition makefiles. A product can inherit from other product definitions, which simplifies maintenance. A common method is to create a base product that contains features that apply for all products, then creating product variants based on that base product. For example, you can have two products that differ only by their radios (CDMA vs GSM) inherit from the same base product that does not define a radio. |
Board/Device | sardine, trout, goldfish | The device/board layer represents the physical layer of plastic on the device (i.e. the industrial design of the device). For example, North American devices probably include QWERTY keyboards whereas devices sold in France probably include AZERTY keyboards. This layer also represents the bare schematics of a product. These include the peripherals on the board and their configuration. The names used are merely codes for different board/device configurations. |
Arch | arm, x86, mips, arm64, x86_64, mips64 | The architecture layer describes the processor configuration and ABI (Application Binary Interface) running on the board. |
Use Build Variants
Each new Android module must have a configuration file to direct the build system with module metadata, compile-time dependencies, and packaging instructions.
In a module definition, the module can specify tags with LOCAL_MODULE_TAGS, which can be one or more values of: optional (default), debug, eng.
If a module doesn't specify a tag (by LOCAL_MODULE_TAGS), its tag defaults to optional. An optional module is installed only if it is required by product configuration with PRODUCT_PACKAGES.
These are the currently-defined build variants:
Variant | Description |
---|---|
eng | This is the default flavor.
|
user | This is the flavor intended to be the final release bits.
|
userdebug | The same as user, except:
|
Customize the Build with Resource Overlays
The Android build system uses resource overlays to customize a product at build time.Resource overlays specify resource files that are applied on top of the defaults.
To use resource overlays, modify the project buildfile ( build/make/core/*.mk ) to set PRODUCT_PACKAGE_OVERLAYS to a path relative to your top-level directory. That path becomes a shadow root searched along with the current root when the build system searches for resources.
The most commonly customized settings are contained in the file frameworks/base/core/res/res/config.xml.
To set up a resource overlay on this file, add the overlay directory to the project buildfile,
PRODUCT_PACKAGE_OVERLAYS := device/DEVICE_IMPLEMENTER/DEVICE_NAME/overlay
or
PRODUCT_PACKAGE_OVERLAYS := vendor/VENDOR_NAME/overlay
Then, add an overlay file to the directory,
vendor/VENDOR_NAME/overlay/frameworks/base/core/res/res/config.xml
Any strings or string arrays found in the overlay config.xml file replace those found in the original file.Build a Product
There are many ways to organize the source files for your device.
Write the Makefiles
The following steps describe how to set up product makefiles in a way similar to that of the Nexus 6 product line:
- Create a device/<company_name>/<device_name> directory for your product. For example, device/moto/shamu. This directory will contain source code for your device along with the makefiles to build them.
- Create a device.mk makefile that declares the files and modules needed for the device. For an example, see device/moto/shamu/device.mk.
- Create a product definition makefile to create a specific product based on the device. The following makefile is taken from device/moto/shamu/aosp_shamu.mk as an example. Notice the product is inheriting from the device/moto/shamu/device.mk and vendor/moto/shamu/device-vendor.mk files via the makefile while also declaring the product-specific information such as name, brand, and model.
- Create an AndroidProducts.mk file that points to the product's makefiles. In this example, only the product definition makefile is needed. The example below is from device/moto/shamu/AndroidProducts.mk
- Create a BoardConfig.mk makefile that contains board-specific configurations. For an example, see device/moto/shamu/BoardConfig.mk.
- Create a vendorsetup.sh file to add your product (a "lunch combo") to the build along with a build variant separated by a dash. For example:
- At this point, you can create more product variants based on the same device.
# Inherit from the common Open Source product configuration
$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
PRODUCT_NAME := aosp_shamu
PRODUCT_DEVICE := shamu
PRODUCT_BRAND := Android
PRODUCT_MODEL := AOSP on Shamu
PRODUCT_MANUFACTURER := motorola
PRODUCT_RESTRICT_VENDOR_FILES := true
$(call inherit-product, device/moto/shamu/device.mk)
$(call inherit-product-if-exists, vendor/moto/shamu/device-vendor.mk)
PRODUCT_NAME := aosp_shamu
PRODUCT_PACKAGES += \
Launcher3
See Product Definition Variables for additional product-specific variables you can add to your makefiles.
#
# This file should set PRODUCT_MAKEFILES to a list of product makefiles
# to expose to the build system. LOCAL_DIR will already be set to
# the directory containing this file.
#
# This file may not rely on the value of any variable other than
# LOCAL_DIR; do not use any conditionals, and do not look up the
# value of any variable that isn't set in this file or in a file that
# it includes.
#
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/aosp_shamu.mk
add_lunch_combo -userdebug
Set Product Definition Variables
Product-specific variables are defined in the product's makefile.
Variables maintained in a product definition files include:
Parameter | Description | Example |
---|---|---|
PRODUCT_AAPT_CONFIG | aapt configurations to use when creating packages | |
PRODUCT_BRAND | The brand (e.g., carrier) the software is customized for, if any | |
PRODUCT_CHARACTERISTICS | aapt characteristics to allow adding variant-specific resources to a package. | tablet,nosdcard |
PRODUCT_COPY_FILES | List of words like source_path:destination_path. The file at the source path should be copied to the destination path when building this product. The rules for the copy steps are defined in config/makefile | |
PRODUCT_DEVICE | Name of the industrial design. This is also the board name, and the build system uses it to locate the BoardConfig.mk. | tuna |
PRODUCT_LOCALES | A space-separated list of two-letter language code, two-letter country code pairs that describe several settings for the user, such as the UI language and time, date and currency formatting. The first locale listed in PRODUCT_LOCALES is used as the product's default locale. | en_GB de_DE es_ES fr_CA |
PRODUCT_MANUFACTURER | Name of the manufacturer | acme |
PRODUCT_MODEL | End-user-visible name for the end product | |
PRODUCT_NAME | End-user-visible name for the overall product. Appears in the Settings > About screen. | |
PRODUCT_OTA_PUBLIC_KEYS | List of Over the Air (OTA) public keys for the product | |
PRODUCT_PACKAGES | Lists the APKs and modules to install. | Calendar Contacts |
PRODUCT_PACKAGE_OVERLAYS | Indicate whether to use default resources or add any product specific overlays | vendor/acme/overlay |
PRODUCT_PROPERTY_OVERRIDES | List of system property assignments in the format "key=value" |
HIDL
HAL interface definition language or HIDL (pronounced "hide-l") is an interface description language (IDL) to specify the interface between a HAL and its users. HIDL specifies data structures and method signatures, organized in interfaces (similar to a class) that are collected into packages.
Overview
Terminology
- binderized Indicates HIDL is being used for remote procedure calls between processes, implemented over a Binder-like mechanism. See also passthrough.
- callback, asynchronous Interface served by a HAL user, passed to the HAL (via a HIDL method), and called by the HAL to return data at any time.
- callback, synchronous Returns data from a server's HIDL method implementation to the client. Unused for methods that return void or a single primitive value.
- client Process that calls methods of a particular interface. A HAL or framework process may be a client of one interface and a server of another. See also passthrough.
- extends Indicates an interface that adds methods and/or types to another interface. An interface can extend only one other interface. Can be used for a minor version increment in the same package name or for a new package (e.g. a vendor extension) to build on an older package.
- generates Indicates an interface method that returns values to the client. To return one non-primitive value, or more than one value, a synchronous callback function is generated.
- interface Collection of methods and types. Translated into a class in C++ or Java. All methods in an interface are called in the same direction: a client process invokes methods implemented by a server process.
- oneway When applied to a HIDL method, indicates the method returns no values and does not block.
- package Collection of interfaces and data types sharing a version.
- passthrough Mode of HIDL in which the server is a shared library, dlopened by the client. In passthrough mode, client and server are the same process but separate codebases. Used only to bring legacy codebases into the HIDL model. See also Binderized.
- server Process that implements methods of an interface. See also passthrough.
- transport HIDL infrastructure that moves data between the server and client.
- version Version of a package. Consists of two integers, major and minor. Minor version increments may add (but not change) types and methods.
Network Stack Configuration Tools
The Android operating system contains standard Linux networking utilities(in system.img) such as ifconfig, ip, and ip6tables. On devices running Android 7.x and earlier, vendor code is allowed to call these binaries directly, Android 8.0 includes the netutils-wrapper-1.0 tool.
Netutils wrapper
The netutils wrapper utility provides a subset of the Linux network stack configuration that is not affected by system partition updates.
留言