Android device
based on android12
android device结构:
device/vendor_name/product_name/
Writing product makefiles
The following steps describe how to set up product makefiles in a way similar to that of the Pixel product line:
- Create a device// directory for your
product. For example, device/google/marlin. 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/google/marlin/device-marlin.mk. - Create a product definition makefile to create a specific product
based on the device. The following makefile is taken from
device/google/marlin/aosp_marlin.mk as an example. Notice that the
product inherits from the device/google/marlin/device-marlin.mk and
vendor/google/marlin/device-vendor-marlin.mk files through the
makefile while also declaring the product-specific information such
as name, brand, and model.
# Inherit from the common Open Source product configuration
$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
PRODUCT_NAME := aosp_marlin
PRODUCT_DEVICE := marlin
PRODUCT_BRAND := Android
PRODUCT_MODEL := AOSP on msm8996
PRODUCT_MANUFACTURER := Google
PRODUCT_RESTRICT_VENDOR_FILES := true
PRODUCT_COPY_FILES += device/google/marlin/fstab.common:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.marlin
$(call inherit-product, device/google/marlin/device-marlin.mk)
$(call inherit-product-if-exists, vendor/google_devices/marlin/device-vendor-marlin.mk)
PRODUCT_PACKAGES += \
Launcher3QuickStep \
WallpaperPicker
See Setting product definition variables for additional product-specific variables that you can add to your makefiles.
- 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/google/marlin/AndroidProducts.mk (which contains both marlin,
the Pixel, and sailfish, the Pixel XL, which shared most
configuration):
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/aosp_marlin.mk \
$(LOCAL_DIR)/aosp_sailfish.mk
COMMON_LUNCH_CHOICES := \
aosp_marlin-userdebug \
aosp_sailfish-userdebug
- Create a BoardConfig.mk makefile that contains board-specific
configurations. For an example, see
device/google/marlin/BoardConfig.mk. - For Android 9 and lower only, 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:
add_lunch_combo <product-name>-userdebug
- At this point, you can create more product variants based on the
same device.