MTK Android12 开机向导

文章目录


需求-场景

开机向导定制

备注:开机向导是一个单独的apk 无源码,在单独apk 基础上,修改apk 实现开机向导定制。

参考资料:

博客资料

如果您有开机向导的需求,建议看一下相关开机向导定制例子,介绍,这一块内容本身对外资料很少,需要自己理解一下,然后针对需求更改。

Android 运行时资源替换----Runtime Resource Overlay:

Android8.0 Setupwizard 定制:

Android开机向导setupwizard,设置系统语言,WiFi向导:

Android Q新增Google Setup Wizard页面

Android10定制Google开机向导

Android集成自定义Google Setup Wizard

GMS如何客制化GMS开机向导

官网参考资料:

官网资料相关开机向导部分本身不对外开放的,需要谷歌账号有一定的开发权限。
自定义向导脚本
配置可选步骤:
自定义SUW:

参考资料注意点

开机向导内容属于Framework层内容模块,单独apk,没有源码,需要知晓修改原理。

开机向导修改,针对不同的主控芯片平台不一样,RK、全志、mtk、展锐、谷歌... 不同的Android版本 参考资料只是思路,针对自身平台找到自身的DEMO或者对应的修改点,不可照抄照搬。

本文针对自己在MTK Android12 上面实现需求的一个思路、编译位置、涉及到知识业务点一个总结。

存在不同平台开机引导包、不同版本开机引导包apk 名称都不一样的情况。

附件资料文件说明:

SetupWizard.apk MTK的开机向导app

SetupWizardOverlay-master.zip 第三方自定义开机向导源码

GmsSampleIntegration MTK Android12 开机向导叠加DEMO
附件资料-MTKAndroid12 开机向导相关资料

推荐工具:

2024最新版Android逆向教程------第2天:dex反编译工具的安装和使用

推荐工具目的,查看附件中的SetupWizard.apk 源码,找到 wizard_script.xml 里面的配置,这样不管需求是什么,好对应上对应的action和resultCode,

不然造成找不到加载资源crash掉、按钮点击按钮无反应不跳转;同时自己需要添加界面或者删除界面时候,好修改wizard_script.xml 文件 及 关联的xml 文件。

其源码如下:

xml 复制代码
<?xml version="1.0" encoding="utf-8"?>
<WizardScript xmlns:wizard="http://schemas.android.com/apk/res/com.google.android.setupwizard" wizard:version="2">
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.OEM_PRE_SETUP;end"
        id="oem_pre_setup"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.WELCOME;end"
        id="welcome">
        <result
            wizard:action="check_user_unlock_qr"
            wizard:name="start_qr_provision"
            wizard:resultCode="101"/>
        <result
            wizard:action="check_user_unlock_dpm_user_complete"
            wizard:name="dpm_user_complete"
            wizard:resultCode="111"/>
        <result
            wizard:action="check_user_unlock_dpm_user_complete"
            wizard:name="dpm_profile_complete"
            wizard:resultCode="112"/>
        <result
            wizard:action="check_user_unlock_work_setup_interrupted_qr_scan"
            wizard:name="check_user_unlock_work_setup_interrupted_qr_scan"
            wizard:resultCode="114"/>
        <result
            wizard:action="check_user_unlock_work_setup_interrupted_consumer_flow"
            wizard:name="check_user_unlock_work_setup_interrupted_consumer_flow"
            wizard:resultCode="115"/>
        <result
            wizard:action="check_user_unlock_nfc"
            wizard:name="check_user_unlock_nfc"
            wizard:resultCode="124"/>
        <result
            wizard:action="check_user_unlock_work_setup_interrupted_nfc_tap"
            wizard:name="check_user_unlock_work_setup_interrupted_nfc_tap"
            wizard:resultCode="125"/>
        <result
            wizard:action="check_user_unlock_fail_provisioning"
            wizard:name="provisioning_extras_not_saved"
            wizard:resultCode="128"/>
        <result wizard:action="check_user_unlock"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_USER_UNLOCK;end"
        id="check_user_unlock_fail_provisioning">
        <result wizard:action="fail_provisioning"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.SHOW_PROVISIONING_ERROR;end"
        id="fail_provisioning"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_USER_UNLOCK;end"
        id="check_user_unlock_work_setup_interrupted_nfc_tap">
        <result wizard:action="work_setup_interrupted_nfc_tap"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.google.android.setupwizard.WORK_SETUP_INTERRUPTED;end"
        id="work_setup_interrupted_nfc_tap">
        <result
            wizard:action="nfc_provision_flow"
            wizard:name="continue_start_nfc_provisioning"
            wizard:resultCode="1"/>
        <result wizard:action="factory_reset"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_USER_UNLOCK;end"
        id="check_user_unlock_nfc">
        <result wizard:action="nfc_provision_flow"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_nfc_provision_flow"
        id="nfc_provision_flow">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_USER_UNLOCK;end"
        id="check_user_unlock_work_setup_interrupted_qr_scan"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.google.android.setupwizard.WORK_SETUP_INTERRUPTED;end"
        id="work_setup_interrupted_qr_scan">
        <result
            wizard:action="check_user_unlock_qr"
            wizard:name="continue_start_qr_scan"
            wizard:resultCode="1"/>
        <result wizard:action="factory_reset"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_USER_UNLOCK;end"
        id="check_user_unlock_work_setup_interrupted_consumer_flow"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.google.android.setupwizard.WORK_SETUP_INTERRUPTED;end"
        id="work_setup_interrupted_consumer_flow">
        <result
            wizard:action="check_user_unlock"
            wizard:name="continue_start_consumer_flow"
            wizard:resultCode="1"/>
        <result wizard:action="factory_reset"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_USER_UNLOCK;end"
        id="check_user_unlock_qr">
        <result wizard:action="qr_provision_flow"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_USER_UNLOCK;end"
        id="check_user_unlock_dpm_user_complete">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_USER_UNLOCK;end"
        id="check_user_unlock"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.SLOTS_SELECTION;end"
        id="slots_selection">
        <result
            wizard:action="sim_missing"
            wizard:name="skip"
            wizard:resultCode="1"/>
        <result wizard:action="carrier_setup"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.SIM_MISSING;end"
        id="sim_missing">
        <result
            wizard:action="esim_intro"
            wizard:name="esim"
            wizard:resultCode="101"/>
        <result
            wizard:action="carrier_setup"
            wizard:name="esim_only"
            wizard:resultCode="102"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.SIM_READY;end"
        id="sim_ready">
        <result wizard:action="carrier_setup"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.ESIM_INTRO;end"
        id="esim_intro"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CARRIER_SETUP;end"
        id="carrier_setup">
        <result
            wizard:action="sim_setup"
            wizard:name="all_subscriptions_completed"
            wizard:resultCode="98765"/>
        <result wizard:action="carrier_setup"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.SIM_SETUP;end"
        id="sim_setup"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.google.android.setupwizard.DEVICE_OWNER_WARNING;end"
        id="device_owner_warning">
        <result
            wizard:action="check_frp"
            wizard:name="skip"
            wizard:resultCode="1"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.google.android.setupwizard.FACTORY_RESET;end"
        id="factory_reset"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.google.android.setupwizard.CHECK_FRP;end"
        id="check_frp"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.CHECK_QUICK_START;end"
        id="check_quick_start">
        <result
            wizard:action="quick_start_flow"
            wizard:name="quick_start"
            wizard:resultCode="101"/>
        <result wizard:action="connect_and_update"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_quick_start_flow"
        id="quick_start_flow">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_connect_and_update_flow"
        id="connect_and_update">
        <result
            wizard:action="no_network_flow"
            wizard:name="no_connection"
            wizard:resultCode="1"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_zero_touch_flow"
        id="zero_touch">
        <result
            wizard:action="post_dpm_user_flow"
            wizard:name="dpm_user_complete"
            wizard:resultCode="111"/>
        <result
            wizard:action="add_personal_account_after_work_profile"
            wizard:name="add_personal_account_after_work_profile"
            wizard:resultCode="120"/>
        <result
            wizard:action="setup_as_new_flow"
            wizard:name="financed_device_provisioning_complete"
            wizard:resultCode="121"/>
        <result
            wizard:action="work_profile_setup"
            wizard:name="work_profile_setup"
            wizard:resultCode="122"/>
        <result
            wizard:action="post_dpm_user_flow"
            wizard:name="device_owner_setup"
            wizard:resultCode="123"/>
        <result
            wizard:action="setup_as_new_flow"
            wizard:name="gmscore_zero_touch"
            wizard:resultCode="116"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_unified_restore_flow"
        id="unified_restore_flow">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_post_dpm_provision_finalization_flow"
        id="work_profile_setup">
        <result wizard:action="transition_to_personal_profile_setup"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_no_network_flow"
        id="no_network_flow">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.google.android.setupwizard.TRANSITION_TO_PERSONAL_PROFILE_SETUP;end"
        id="transition_to_personal_profile_setup">
        <result wizard:action="add_personal_account_after_work_profile"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_account_flow"
        id="add_personal_account_after_work_profile">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:flow="SetupAsNewFlow"
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_account_flow"
        id="setup_as_new_flow">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_post_dpm_user_flow"
        id="post_dpm_user_flow">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_qr_provision_flow"
        id="qr_provision_flow">
        <result wizard:action="oem_post_setup"/>
    </WizardAction>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.OEM_POST_SETUP;end"
        id="oem_post_setup"/>
    <WizardAction
        wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_post_dpm_provision_finalization_flow"
        id="enterprise_finalization_flow"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.google.android.setupwizard.KID_POST_SETUP;end"
        id="kid_post_setup"/>
    <WizardAction
        wizard:uri="intent:#Intent;action=com.android.setupwizard.EXIT;end"
        id="exit"/>
</WizardScript> 

配置定制的 声明叠加层 APK

查看官网是怎么说明的

所以在 MTKAndroid2 中的GmsSampleIntegration 里面有这样的配置 AndroidManifest.xml, SUW 仅将其用于查找此 APK,配置后不需要做任何需求和实现。

xml 复制代码
  <receiver android:name=".SuwCustomizationReceiver"
                  android:exported="true">
            <intent-filter>
                <action android:name="com.android.setupwizard.action.PARTNER_CUSTOMIZATION" />
            </intent-filter>
  </receiver>

需求实现

替换字符、删减开机向导界面、添加开机向导界面

先给介绍一下官网相关资料:

删除部分界面需求,官网说明如下

所以,先确认下需要删除的界面是否是可删的,不然删除无用,崩溃。

更新部分字符串、图片资源,官网说明如下


所以只有指定的可以叠加的资源才能叠加,动画、背景、主题、字符串...等。根据实际需求,对比可以修改的叠加资源是否可以修改,如果不满足则修改无用。

遇到问题

如上已经知晓修改资源的 name,如何查找具体的 id 或者 标签name 呢? 因为只有找到了 具体需要修改的name 你才能在对应的values、drawable...文件里面配置吧。

比如:

可叠加资源包括以下资源:

java 复制代码
@array/deferred_high_priority_actions

那么 deferred_high_priority_actions 到底是什么,有哪些内容,这样才能方便copy 到自定义叠加apk 资源包里面去。

实际发现 在源码里面是不存在的,找不到。 在开机引导包 SetupWizard.apk里面找,这个时候反编译工具派上用场了。比如:

@string/sim_missing_text

在设备中未检测到 SIM 卡时显示的文本。此资源在 Android 7.0 及更高版本中有所更改。

具体实现

找到叠加apk 源码,对应的module 下面,添加需要修改的内容。

配置系统编译环境

找到了对应的叠加apk,但是需要把这个源码编译到系统才起作用的嘛

先查看一下叠加apk 源码目录下面的Android.mk,它是有很多模块的,每个模块对应不同的res 资源包,可查看如下 源码。

java 复制代码
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_full $(LOCAL_PATH)/res
java 复制代码
###############################################################################
# Various GMS Sample Integration targets
LOCAL_PATH:= $(my-dir)

# GmsSampleIntegration
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsSampleIntegration
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_SYSTEM_EXT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_full $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsSampleIntegrationGo
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsSampleIntegrationGo
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_SYSTEM_EXT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_go $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsSampleIntegrationGo_2GB
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsSampleIntegrationGo_2GB
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_SYSTEM_EXT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
ifeq ($(strip $(MTK_PRODUCT_LINE)),tablet)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_go_2gb_tb $(LOCAL_PATH)/res
else
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_go_2gb $(LOCAL_PATH)/res
endif

LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType2Integration (No GSA, Chrome)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType2Integration
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_no_gsa $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType2IntegrationGo (No GSA, Chrome)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType2IntegrationGo
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_no_search_go $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType3aIntegration (GSA, No Chrome, no placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType3aIntegration
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_min $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType3aIntegrationGo (GSA, No Chrome, no placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType3aIntegrationGo
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_min_go $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType3bIntegration (GSA, No Chrome, search placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType3bIntegration
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_no_chrome $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType3bIntegrationGo (GSA, No Chrome, search placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType3bIntegrationGo
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_no_chrome_go $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType4aIntegration (GSA, Chrome, no placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType4aIntegration
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_min $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType4aIntegrationGo (GSA, Chrome, no placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType4aIntegrationGo
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_min_go $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType4bIntegration (GSA, Chrome, search placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType4bIntegration
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_no_chrome $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType4bIntegrationGo (GSA, Chrome, search placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType4bIntegrationGo
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_no_chrome_go $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType4cIntegration (GSA, Chrome, search+chrome placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType4cIntegration
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_SYSTEM_EXT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_full $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType4cIntegrationGo (GSA, Chrome, search+chrome placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType4cIntegrationGo
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_SYSTEM_EXT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_go $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType4cIntegrationGo_2GB (GSA, Chrome, search+chrome placement)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType4cIntegrationGo_2GB
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_SYSTEM_EXT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_go_2gb $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

# GmsEEAType1Integration (No GSA, No Chrome)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsEEAType1Integration
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_TAGS := optional
LOCAL_SYSTEM_EXT_MODULE := true
LOCAL_CERTIFICATE := platform
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_min $(LOCAL_PATH)/res
LOCAL_SDK_VERSION := current
include $(BUILD_PACKAGE)

根据源码项目名称搜索编译配置位置: 当然,如果你知道自己项目配置的位置,俺就直接在对应的编译文件中配置下。 这里说明一下,其实我自己项目是不知道在哪里配置的,

但是是GMS项目,那么一定有GMS项目自带apk 比如Youtube/SetupWizard/Photos/Gmail2 所以找到他们然后 添加自己的叠加apk GmsSampleIntegration

java 复制代码
fise4@ubuntu-PowerEdge-R730:~/Android/mt6769-alps-release-s0.mp1.rc/alps-release-s0.mp1.rc/vendor$ grep -rn GmsSampleIntegration



google/apps/GmsSampleIntegration/Android.mk:5:# GmsSampleIntegration
google/apps/GmsSampleIntegration/Android.mk:7:LOCAL_PACKAGE_NAME := GmsSampleIntegration
google/apps/GmsSampleIntegration/Android.mk:17:# GmsSampleIntegrationGo
google/apps/GmsSampleIntegration/Android.mk:19:LOCAL_PACKAGE_NAME := GmsSampleIntegrationGo
google/apps/GmsSampleIntegration/Android.mk:29:# GmsSampleIntegrationGo_2GB
google/apps/GmsSampleIntegration/Android.mk:31:LOCAL_PACKAGE_NAME := GmsSampleIntegrationGo_2GB
google/products/gms_go.mk:88:    GmsSampleIntegrationGo
google/products/gms_go_2gb.mk:86:    GmsSampleIntegration \
google/products/gms_go_2gb.mk:108:    #GmsSampleIntegrationGo_2GB
google/products/gms_go_2gb.mk:109:    GmsSampleIntegration
google/products/gms.mk:29:    GmsSampleIntegration \

注意点:Android.mk 里面有很多几个module,比如如下几个:

java 复制代码
...
GmsSampleIntegration  
GmsSampleIntegrationGo  
GmsSampleIntegrationGo_2GB  
GmsEEAType2Integration  
GmsEEAType2IntegrationGo   
GmsEEAType3aIntegration  
GmsEEAType3aIntegrationGo  
GmsEEAType3bIntegration
...

我们自己用到的是GmsSampleIntegration ,对应配置查看下:

java 复制代码
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res_dhs_full $(LOCAL_PATH)/res

那不就是res_dhs_full 目录嘛,那就在对应的目录添加资源文件和字符串了。

总结

本文仅仅针对定制开机向导提供了一些思路和实践思路,具体需要针对不同平台来实现。