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?
Unfortunately, there is no default time, so you have to change your time depending on the time zone used in the place.
setDefault(TimeZone. getTimeZone("GMT+3")); This sets the default timezone.
The Time Zone Data module updates daylight saving time (DST) and time zones on Android devices, standardizing both the data (which can change frequently in response to religious, political, and geopolitical reasons) and the update mechanism across the ecosystem. For more details on Time Zone Data, see Time Zone Rules.
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
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:
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.
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]
- 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.
- 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.
- 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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With