Android 添加一个产品

google官方有给出android这么添加一个产品,可在google搜索“android add a new device”

接下来,说说我对android添加一个产品的想法和思路。

产品的目录结构:

在vendor目录创建公司目录,在公司目录下创建两个目录分别为common(公共配置)和对应产品目录(此产品相关的配置)

创建一个产品必要的一些配置文件(以产品K50为例):

AndroidProduct.mk   // 指定产品Makefile 文件

PRODUCT_MAKEFILES := \
    $(LOCAL_DIR)/evideo_k50.mk

 

BoardConfig.mk   // 主板特定配置

include device/realtek/kylin/BoardConfig.mk
include vendor/evideo/common/BoardConfig.mk

TARGET_ARCH := arm
TARGET_ARCH_VARIANT := armv7-a-neon
TARGET_CPU_ABI := armeabi-v7a
TARGET_CPU_ABI2 := armeabi
TARGET_CPU_VARIANT := cortex-a7

TARGET_2ND_ARCH :=
TARGET_2ND_ARCH_VARIANT :=
TARGET_2ND_CPU_ABI :=
TARGET_2ND_CPU_ABI2 :=
TARGET_2ND_CPU_VARIANT :=
# for system configuration
PRODUCT_PACKAGE_OVERLAYS += \
    vendor/evideo/K50/overlay

# System: 2GB
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648

# Cache: 222MB
BOARD_CACHEIMAGE_PARTITION_SIZE := 232783872

vendorsetup.sh  //添加产品变体

add_lunch_combo evideo_k50-eng
add_lunch_combo evideo_k50-userdebug
add_lunch_combo evideo_k50-user

evideo_k50.mk  // 指定产品Makefile文件

DEVICE_PACKAGE_OVERLAYS := \
    device/realtek/kylin/overlay \
    device/realtek/kylin/overlay_common

$(call inherit-product, vendor/evideo/K50/device.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base.mk)
$(call inherit-product, device/realtek/kylin/rtkbt/rtkbt.mk)

PRODUCT_AAPT_CONFIG := normal large tvdpi mdpi hdpi
PRODUCT_AAPT_PREF_CONFIG := mdpi
PRODUCT_CHARACTERISTICS := tablet

PRODUCT_DEVICE := K50
PRODUCT_NAME   := evideo_k50
PRODUCT_MODEL  := K50
PRODUCT_BRAND  := eVideo
PRODUCT_MANUFACTURER := StarNet eVideo
PRODUCT_LOCALES := zh_CN

PRODUCT_PROPERTY_OVERRIDES += ro.sf.lcd_density=240

device.mk  // 非必要

# For factory firmware
ifeq ($(strip $(BUILD_FACTORY_FIRMWARE)), true)
    PRODUCT_PACKAGES += \
        DCLauncher
else
    $(call inherit-product-if-exists, vendor/evideo/K50/jenkins.mk)
endif

# K50/K30应用包含工厂
ifeq ($(strip $(BUILD_FACTORY_FIRMWARE)), false)
    PRODUCT_PACKAGES += \
        evfactory \
        stressapptest2 \
        evfactoryclient

    PRODUCT_COPY_FILES += \
        vendor/evideo/common/evfactory/memtester:/system/bin/memtester
endif

PRODUCT_PACKAGES += \
    Music \
        libaudiorecord

PRODUCT_COPY_FILES += \
    vendor/evideo/K50/etc/install_apk.sh:system/vendor/bin/install_apk.sh

$(call inherit-product, vendor/evideo/common/device.mk)

overlay资源叠加层技术(以产品K50为例):

BoardConfig.mk声明overlay路径:

PRODUCT_PACKAGE_OVERLAYS += \
    vendor/evideo/K50/overlay

接下来举个默认壁纸定制的例子:

android默认壁纸图片路径 frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.jpg

利用android overlay资源叠加层技术我们可以定制K50的默认壁纸为我指定的图片而不影响系统原有的默认壁纸

在K50 overlay 目录添加文件 frameworks/base/core/res/res/drawable-nodpi/default_wallpaper.jpg即可。

自定义平台签名:

对android系统进行签名,需要生成四种类型的key文件:releasekey、media、shared、platform

The following commands were used to generate the release key pairs:

  development/tools/make_key testkey  '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]'
  development/tools/make_key platform '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]'
  development/tools/make_key shared   '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]'
  development/tools/make_key media    '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/[email protected]'

对于K50还有 verity_key 用于system.img签名

mm -B system/extras/verity/   编译生成  out/host/linux-x86/bin/generate_verity_key 

verity_key生成:  generate_verity_key -convert verity.x509.pem verity_key

common/BoardConfig.mk 指定releasekey

PRODUCT_DEFAULT_DEV_CERTIFICATE := \
    vendor/evideo/$(PRODUCT_MODEL)/security/platform_keys/releasekey

build/core/Makefile 需修改的地方

# The "test-keys" tag marks builds signed with the old test keys,
# which are available in the SDK.  "dev-keys" marks builds signed with
# non-default dev keys (usually private keys from a vendor directory).
# Both of these tags will be removed and replaced with "release-keys"
# when the target-files is signed in a post-build step.
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),vendor/evideo/$(PRODUCT_MODEL)/security/platform_keys/releasekey)
BUILD_KEYS := release-keys
else
BUILD_KEYS := dev-keys
endif

build/core/config.mk 对 DEFAULT_SYSTEM_DEV_CERTIFICATE设置

# The default key if not set as LOCAL_CERTIFICATE
ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
  DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
else
  DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
endif

 

你可能感兴趣的:(android)