在https://opengapps.org/根据API,platform,variant下载合适的gms包,这里推荐pice size,可以最精简地保证基础谷歌服务功能
解压GMS包
Core和Optional目录下为谷歌服务核心文件和应用,需要预置到源码中
GApps目录下为一些功能应用,可不预置到源码中
继续解压Core和Optional两个目录下的所有文件,得到一些APK,权限Config和jar包等
使用宏PRODUCT_COPY_FILES,在源码编译时将非APK文件拷贝到/system/下,在device.mk里加上
PRODUCT_COPY_FILES += $(call find-copy-subdir-files,*,$(LOCAL_PATH)/gms/copyToSystem,/system)
增加Android.mk预置到/system/app或/system/priv-app,开启预编译减少第一次开机时间
PS: 注意LOCAL_CERTIFICATE := PRESIGNED 保证使用APK本身的签名信息,否则无法正常使用
#预置到/system/app下
include $(CLEAR_VARS)
LOCAL_MODULE := GoogleContactsSyncAdapter
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := app/$(LOCAL_MODULE)/$(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_DEX_PREOPT := true
include $(BUILD_PREBUILT)
#预置到/system/priv-app下
include $(CLEAR_VARS)
LOCAL_MODULE := ConfigUpdater
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := priv-app/$(LOCAL_MODULE)/$(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_DEX_PREOPT := true
LOCAL_PRIVILEGED_MODULE := true
include $(BUILD_PREBUILT)
PRODUCT_PACKAGES += GoogleContactsSyncAdapter
PRODUCT_PACKAGES += GoogleExtShared
PRODUCT_PACKAGES += SoundPickerPrebuilt
PRODUCT_PACKAGES += AndroidPlatformServices
PRODUCT_PACKAGES += CarrierSetup
PRODUCT_PACKAGES += ConfigUpdater
PRODUCT_PACKAGES += GmsCoreSetupPrebuilt
PRODUCT_PACKAGES += GoogleBackupTransport
PRODUCT_PACKAGES += GoogleExtServices
PRODUCT_PACKAGES += GoogleFeedback
PRODUCT_PACKAGES += GoogleOneTimeInitializer
PRODUCT_PACKAGES += GooglePartnerSetup
PRODUCT_PACKAGES += GoogleServicesFramework
PRODUCT_PACKAGES += Phonesky
PRODUCT_PACKAGES += PrebuiltGmsCorePi
如果拷贝预置,需要在vendor/mediatek/proprietary/frameworks/base/data/etc/pms_sysapp_removable_system_list.txt中添加需要预制APK的package name
if(如果全编系统成功) goto 5
else if error == out of space? the tree size of
{
}
else 联系qq: 373683458
翻下install.sh
for gapp_name in $core_gapps_list; do
get_apparchives "Core/$gapp_name"
for archive in $apparchives; do
case $gapp_name in
setupwizarddefault) if [ "$device_type" != "tablet" ]; then extract_app "$archive"; fi;;
setupwizardtablet) if [ "$device_type" = "tablet" ]; then extract_app "$archive"; fi;;
googlepixelconfig) if [ "$googlepixel_compat" = "true" ]; then extract_app "$archive"; fi;;
backuprestore) if [ "$googlepixel_compat" = "false" ]; then extract_app "$archive"; fi;;
datatransfertool) if [ "$googlepixel_compat" = "true" ]; then extract_app "$archive"; fi;;
*) extract_app "$archive";;
esac
done
done
extract_app() {
tarpath="$TMP/$1.tar" # NB no suffix specified here
if "$TMP/unzip-$BINARCH" -o "$OPENGAZIP" "$1.tar*" -d "$TMP"; then # wildcard for suffix
app_name="$(basename "$1")"
which_dpi "$app_name"
echo "Found $1 DPI path: $dpiapkpath"
folder_extract "$tarpath" "$dpiapkpath" "$app_name/common"
else
echo "Failed to extract $1.tar* from $OPENGAZIP"
fi
}
folder_extract() {
archive="$1"
shift
if [ -e "$archive.xz" ]; then
for f in "$@"; do
if [ "$f" != "unknown" ]; then
"$TMP/xzdec-$BINARCH" "$archive.xz" | "$TMP/tar-$BINARCH" -x -C "$TMP" -f - "$f" && install_extracted "$f"
fi
done
}
install_extracted() {
file_list="$(find "$TMP/$1/" -mindepth 1 -type f | cut -d/ -f5-)"
dir_list="$(find "$TMP/$1/" -mindepth 1 -type d | cut -d/ -f5-)"
for file in $file_list; do
install -D "$TMP/$1/${file}" "/system/${file}"
.....
}
注意 install -D "$TMP/$1/${file}" "/system/${file}"
结论:gms包主要是把文件解压到/system/目录下,在源码中通过一些编译项可以达到类似效果
https://tieba.baidu.com/p/5032829149?fid=12980469&pid=105404260767&red_tag=1621002966#105404260767