Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Android take default timezone from?

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?

like image 740
Marian Paździoch Avatar asked Apr 08 '14 07:04

Marian Paździoch


People also ask

What is the default time zone?

Unfortunately, there is no default time, so you have to change your time depending on the time zone used in the place.

How do I change the default timezone on Android?

setDefault(TimeZone. getTimeZone("GMT+3")); This sets the default timezone.

What is time zone data on Android?

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.


2 Answers

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

like image 165
Ken Wolf Avatar answered Oct 23 '22 13:10

Ken Wolf


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"

like image 24
Juge Avatar answered Oct 23 '22 13:10

Juge