[RK3399][Android7.1] 除錯筆記 — 設定開機預設語言為中文

NO IMAGE

Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83

解決方法:

diff --git a/target/product/full_base.mk b/target/product/full_base.mk
index 65bdf0f..071d299 100644
--- a/target/product/full_base.mk
b/target/product/full_base.mk
@@ -43,7  43,8 @@ PRODUCT_PROPERTY_OVERRIDES := \
ro.config.notification_sound=pixiedust.ogg
# Put en_US first in the list, so make it default.
-PRODUCT_LOCALES := en_US
#Kris,180713, Use Chinese as default.
PRODUCT_LOCALES := zh_CN
# Get some sounds
$(call inherit-product-if-exists, frameworks/base/data/sounds/AllAudio.mk)

下面部分也可以不改,主要是用於縮減掉不用的語言包。

diff --git a/target/product/locales_full.mk b/target/product/locales_full.mk
index 3a90d2b..a2e1cf0 100644
--- a/target/product/locales_full.mk
b/target/product/locales_full.mk
@@ -1,3  1,6 @@
-PRODUCT_LOCALES := en_US cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA en_GB en_NZ en_SG eo_EU es_ES fr_CA fr_CH fr_BE fr_FR it_CH it_IT ja_JP ko_KR nb_NO nl_B
#PRODUCT_LOCALES := en_US cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA en_GB en_NZ en_SG eo_EU es_ES fr_CA fr_CH fr_BE fr_FR it_CH it_IT ja_JP ko_KR nb_NO nl_
-$(call inherit-product, build/target/product/languages_full.mk)
#$(call inherit-product, build/target/product/languages_full.mk)
#Kris, 180713, Only use following languages.
PRODUCT_LOCALES := en_US zh_HK zh_TW ja_JP fr_FR

target/product下面有好幾個.mk包含PRODUCT_LOCALES,要快速確定哪幾個檔案被用到可以直接在檔案中
加編譯資訊。


原理:

PRODUCT_LOCALES在編譯生成build.prop的時候會被用到。
build/core/Makefile:

$(intermediate_system_build_prop): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET)
@echo Target buildinfo: [email protected]
......
PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \

get-default-product-locale返回第一個locale

define get-default-product-locale
$(strip $(subst _,-, $(firstword $(1))))
endef

PRODUCT_DEFAULT_LOCALE最終被編譯成ro.product.locale,所以你在system.prop中直接設定此屬性本質也是一樣的。
build/tools/buildinfo.sh

if [ -n "$PRODUCT_DEFAULT_LOCALE" ] ; then
echo "ro.product.locale=$PRODUCT_DEFAULT_LOCALE"
fi

參考:
[GitHub][Android] Change locale, default locale, language list
[Google]語言和語言區域