安卓系统启动时,根据系统当前的属性信息,设定了语言和区域参数
所依赖的属性参数,可以在系统编译时指定。下面的两个文件是有关通过当前系统属性设置 Locale 的动作:
1. frameworks/base/core/jni/AndroidRuntime.cpp
里面有个方法,方法上有说明,表明了根据几个属性值加载,先判断的属性如果不为空,就不会去判断后面的属性了,如下:
/*
* Read the persistent locale. Inspects the following system properties
* (in order) and returns the first non-empty property in the list :
*
* (1) persist.sys.locale
* (2) persist.sys.language/country/localevar (country and localevar are
* inspected iff. language is non-empty.
* (3) ro.product.locale
* (4) ro.product.locale.language/region
*
* Note that we need to inspect persist.sys.language/country/localevar to
* preserve language settings for devices that are upgrading from Lollipop
* to M. The same goes for ro.product.locale.language/region as well.
*/
const std::string readLocale()