7

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?

Marian Paździoch
  • 8,813
  • 10
  • 58
  • 103

3 Answers3

9

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

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Ken Wolf
  • 23,133
  • 6
  • 63
  • 84
1

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"

Juge
  • 536
  • 8
  • 21
0

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.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
  • my device has neither SIM card, nor WIFI (it gets connected to WIFI later but during Setup Wizard there's no WIFI connection) and somehow there's a default timezone set. – Marian Paździoch Apr 08 '14 at 08:04
  • Did you purchase the device from the same location where you live ? – Lucifer Apr 08 '14 at 08:05
  • @MarianPaździoch what is the time zone in your settings of your phone by default. – Raghunandan Apr 08 '14 at 08:06
  • @Kedarnath yes, I'm guessing that producer somehow put it to the device and I'm trying to figure out where – Marian Paździoch Apr 08 '14 at 08:09
  • @Raghunandan see my question for answer :) – Marian Paździoch Apr 08 '14 at 08:10
  • @MarianPaździoch By default you have a timezone european and that is what is reflected. Its by default settings from the phone manufacturere. Try changing the settings and then again restore to default and check again. If you want to know how it changes upon selection of each time zone you can look at the source code. – Raghunandan Apr 08 '14 at 08:11
  • @MarianPaździoch, No What I am assuming is that, If my device is manufactured in India, then I think it automatically takes Indian Timezone. – Lucifer Apr 08 '14 at 08:12
  • @Kedarnath and that is becoz the manufacturer set the timezone by default. – Raghunandan Apr 08 '14 at 08:13
  • @Raghunandan, I think yes. – Lucifer Apr 08 '14 at 08:14
  • @Kedarnath there's no such thing as "automatically" for software developer. Somebody somewhere sets it and I'm trying to find where. – Marian Paździoch Apr 08 '14 at 08:15
  • @MarianPaździoch its by default set. default setting by the phone manufacturer i guess. – Raghunandan Apr 08 '14 at 08:16
  • @Raghunandan Yes I agree with you. I bought my device from US and when I start it, it was showing me US's Timezone here in India. – Lucifer Apr 08 '14 at 08:20