[RK3399][Android7.1] 调试笔记 --- 设置开机默认语言为中文

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: $@
    ......
    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]语言和语言区域

你可能感兴趣的:(RK3399,子类__Android)