AOSP Android13 新增Product实践

  1. 在device目录新建下面目录hht\hht_x86_64,其中hht代表公司、hht_x86_64代表某台设备,即device/<vendor>/<TARGET_DEVICE>。

  2. 在hht_x86_64目录下,分别创建AndroidProducts.mk、BoardConfig.mk、hht_x86_64.mk文件。

  3. 由于直接要在PC上通过emulator运行,所以拷贝device\generic\goldfish\pc\sdk_pc_x86_64.mk内容到hht_x86_64.mk。

    修改PRODUCT_DEVICE与第1步创建的<TARGET_DEVICE>名称一致,即hht_x86_64,其他三个属性随意。修改后文件:

    bash 复制代码
    #
    # Copyright (C) 2021 The Android Open Source Project
    #
    # 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.
    
    PRODUCT_COPY_FILES += device/generic/goldfish/pc/config.ini.pc:config.ini
    
    $(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_x86_64.mk)
    
    PRODUCT_NAME := HHT Edu Phone
    PRODUCT_DEVICE := hht_x86_64
    PRODUCT_BRAND := HHT
    PRODUCT_MODEL :=  1st
    PRODUCT_PACKAGE_OVERLAYS := device/generic/goldfish/pc/overlay
    PRODUCT_COPY_FILES += \
        device/generic/goldfish/pc/data/etc/pc.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/pc.xml
    PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP := device/generic/goldfish/pc/images_source.prop_template

    由于要在pc上直接运行emulator,所以参考sdk_pc_x86_64.mk文件内容,其中sdk表示生成文件带userdata.img等文件,可以通过emulator执行。如果是aosp,生成标准系统GSI,不带userdata.img,无法直接通过emulator运行。

    通过下面命令查找目标配置文件:

    bash 复制代码
    # 进入源码根目录,查找该文件
    find . -type f -name "sdk_pc_x86_64.mk"
  4. 将build\make\target\board\generic_x86_64\BoardConfig.mk拷贝到BoardConfig.mk。无需修改。

  5. AndroidProduct.mk添加如下内容。

    bash 复制代码
    PRODUCT_MAKEFILES := \
        $(LOCAL_DIR)/hht_x86_64.mk
    
    COMMON_LUNCH_CHOICES := \
        hht_x86_64-eng \
        hht_x86_64-userdebug \
        hht_x86_64-user
  6. 重新编译

    bash 复制代码
    source build/envsetup.mk
    lunch
    #得到下面选项
    lunch 62
    #编译等到结果
    make -j24

备注:

新产品的添加更多是参考现有配置文件,然后参考修改,且修改内容不多。例如可能在PC运行automatic,而现有产品,lunch menu不存在。

相关推荐
三少爷的鞋19 分钟前
现代 Android 架构指南:不要再主动设计 Callback 接口
android
TimeFine6 小时前
AI 编码工作流的设计
android·ai编程
骑着蜗牛撵大象3277 小时前
C++20 协程 × 屏障:手写一个 co_await 版 Barrier,让等待不再钉死线程
android·c++20·协程·并发编程·co_await·屏障同步
山东孙燕姿8 小时前
设备台账重构:从一张表到三层模型
android·java·网络·低代码·重构·rxjava
蒸鱼Yuzheng9 小时前
移动端 CPU 调度分析:线程亲和性、大小核迁移与卡顿
android·perfetto·性能分析·线程优化·cpu调度
booboosui10 小时前
安卓唤醒词:12 维 MFCC 加 DTW,阈值 1.8
android
传奇开心果10 小时前
Compose Multiplatform 共享边界实战:架构契约、互操作同步与可回退设计
android·kotlin
事圆则缓10 小时前
从开机到首帧:Android 系统与应用启动流程源码分析
android
AI吃大瓜10 小时前
指针压力表读数4:Android实现指针压力表读数(可实时检测)
android·指针读数·指针压力表·压力表·压力表读数
fengci.10 小时前
CTF2刷题记录(困难部分)
android·开发语言·前端·学习·php