Frage

Where does Android device take default timezone from?

Example - you boot a brand new Android device and there is Setup Wizard with "Date & time" activity where a default timezone is already selected (in my case http://en.wikipedia.org/wiki/Central_European_Time) - where it comes from?

War es hilfreich?

Lösung

It's a build flag that's baked into the ROM (it becomes a system property).

It's in quite a few places so the easiest is to download the AOSP source and grep for:

persist.sys.timezone

A bit more info here: https://stackoverflow.com/search?q=persist.sys.timezone

Andere Tipps

Here is long post about the setting timezone. https://blog.csdn.net/victoryckl/article/details/7969433 It's in Chinese so use translate.

Here is main points how to set locale and timezone

The original android code, the system default language is English, generally need to be changed to the default Chinese, a lot of methods of modification:

  1. Modify the PRODUCT_LOCALES field, Put the language you want to choose first, such as: PRODUCT_LOCALES := en_US zh_CN The default language is English, copy it from build/target/product/sdk.mk and paste it into device/{hardware platform}/{product}. In mk, put zh_CN in the first place. Or paste directly into build/target/product/core.mk and all branches inherit this setting.

  2. Modify device/{hardware platform}/{product}/system.prop or default.prop and add:

[persist.sys.language]: [zh]

[persist.sys.country]: [CN]

[persist.sys.localevar]: []

[persist.sys.timezone]: [Asia/Shanghai]

[ro.product.locale.language]: [zh]

[ro.product.locale.region]: [CN]

  1. Modify init.rc and add:

Setprop persist.sys.language en

Setprop persist.sys.country CN

Setprop persist.sys.localevar

Setprop persist.sys.timezone Asia/Shanghai

Setprop ro.product.locale.language en

Setprop ro.product.locale.region CN

This method has a problem, because it will be executed every time you boot, so the language is the default language after each boot.

  1. Modify device/{hardware platform}/{product}/device.mk and add : PRODUCT_PROPERTY_OVERRIDES += \

Persist.sys.language=zh \

Persist.sys.country=CN \

Persist.sys.localevar= "" \

Persist.sys.timezone=Asia/Shanghai \

Ro.product.locale.language=zh \

Ro.product.locale.region=CN

I am using the fourth. Note that the quotes above cannot be removed, otherwise the two lines will become one line in build.prop:

Persist.sys.localevar= persist.sys.timezone=Asia/Shanghai

This will result in the value of persist.sys.timezone not being obtained, and the time zone is still incorrect.

  1. Modify build/tools/buildinfo.sh:

Echo "persist.sys.language=zh"

Echo "persist.sys.country=CN"

Echo " persist.sys.localevar= "

Echo "persist.sys.timezone=Asia/Shanghai"

Echo "ro.product.locale.language=zh"

Echo "ro.product.locale.region=CN"

When you start a new phone with SIM card then based on the operator it automatically sets the locality in the phone.

If it is using SIM data then based on the Telephony Manager API phone, automatically sets the current locality.

Same way when your device is not having any SIM card but it is connected to any local WiFi then based on the Wifi Manager API it sets the Locality in the Phone automatically.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top