Gms定制中经常需要修改Gms app在launcher中的布局,通常有两个方法
一 修改gms_overlay
首先根据Launcher3/res/xml/device_profiles.xml中的defaultLayoutId值确定修改那个布局,比如下面定义
路径:/vendor/google/overlay/gms_overlay/packages/apps/Launcher3/res/xml/default_workspace_5x5.xml(注意:mtk平台的路径为:vendor/google/overlay/gms_overlay/vendor/mediatek/proprietary/packages/apps/Launcher3/res/xml/default_workspace_5x5.xml)
目录列表
folder_google.xml
folder_media.xml
folder_productivity.xml
folder_tool.xml
效果图如下
二 GmsSampleIntegration中修改
GmsSampleIntegration中默认已经支持了setupwizard和launcher3的客户定制修改
AndroidManifest.xml
LauncherCustomizationReceiver.java
/* Copyright (C) 2017 Google Inc. All Rights Reserved. */
package com.google.android.gmsintegration;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class LauncherCustomizationReceiver extends BroadcastReceiver {
public LauncherCustomizationReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
}
}
通过注册com.android.launcher3.action.PARTNER_CUSTOMIZATION的广播监听,launcher定制生效,需要注意的是gmsintegration如果打包到项目中,gms-overlay会失效,优先使用gmsintegration的配置。不过要注意GmsSampleIntegration中的android.mk,因为GmsSampleIntegration下的res配置有几个,看下你需要编译哪个。
修改前的android.mk
###############################################################################
# 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_PRODUCT_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_PRODUCT_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_PRODUCT_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)
# GmsSampleIntegrationGo512M
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := GmsSampleIntegrationGo512M
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_go_512m $(LOCAL_PATH)/res
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_PRODUCT_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_PRODUCT_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_PRODUCT_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_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)
修改后的android.mk.我们项目中选第一个
###############################################################################
# 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_PRODUCT_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)
关于launcher的默认布局加载流程可以参考下面这个文章:
https://blog.csdn.net/csdn_conda/article/details/79728651