xref: /aosp_15_r20/system/timezone/README.android (revision 2fd832c65f8b41db7ddb4ac802b9196762fe4888)
1*2fd832c6SAndroid Build Coastguard WorkerThis directory contains code, tools and data related to time zone rules data
2*2fd832c6SAndroid Build Coastguard Workerand updates.
3*2fd832c6SAndroid Build Coastguard Worker
4*2fd832c6SAndroid Build Coastguard WorkerDirectory structure
5*2fd832c6SAndroid Build Coastguard Worker===================
6*2fd832c6SAndroid Build Coastguard Worker
7*2fd832c6SAndroid Build Coastguard Workerapex
8*2fd832c6SAndroid Build Coastguard Worker  - Code related to the Android time zone update APEX file that can be used
9*2fd832c6SAndroid Build Coastguard Worker    to update time zone rules on Android devices.
10*2fd832c6SAndroid Build Coastguard Worker
11*2fd832c6SAndroid Build Coastguard Workerdebug_tools
12*2fd832c6SAndroid Build Coastguard Worker  - Contains tools useful for debugging time zone issues on Android devices.
13*2fd832c6SAndroid Build Coastguard Worker
14*2fd832c6SAndroid Build Coastguard Workerinput_data
15*2fd832c6SAndroid Build Coastguard Worker  - Contains files that provide inputs to the time zone rules update process.
16*2fd832c6SAndroid Build Coastguard Worker    Some files come from external sources and some are mastered in Android.
17*2fd832c6SAndroid Build Coastguard Worker    See also download-iana-data.py.
18*2fd832c6SAndroid Build Coastguard Worker
19*2fd832c6SAndroid Build Coastguard Workerinput_tools
20*2fd832c6SAndroid Build Coastguard Worker  - Contains tools that generate Android time zone files.
21*2fd832c6SAndroid Build Coastguard Worker
22*2fd832c6SAndroid Build Coastguard Workeroutput_data
23*2fd832c6SAndroid Build Coastguard Worker  - Contains some derived files from the time zone rules update process and
24*2fd832c6SAndroid Build Coastguard Worker    used in the Android system image and APEX files. Some files are also held
25*2fd832c6SAndroid Build Coastguard Worker    by ICU - see also update-tzdata.py
26*2fd832c6SAndroid Build Coastguard Worker
27*2fd832c6SAndroid Build Coastguard Workertesting
28*2fd832c6SAndroid Build Coastguard Worker  - Contains tools and scripts related to testing time zone update code. See
29*2fd832c6SAndroid Build Coastguard Worker    testing/data/README for details.
30*2fd832c6SAndroid Build Coastguard Worker
31*2fd832c6SAndroid Build Coastguard Worker
32*2fd832c6SAndroid Build Coastguard Worker
33*2fd832c6SAndroid Build Coastguard WorkerData file update tools
34*2fd832c6SAndroid Build Coastguard Worker======================
35*2fd832c6SAndroid Build Coastguard Worker
36*2fd832c6SAndroid Build Coastguard Workerdownload-iana-files.py
37*2fd832c6SAndroid Build Coastguard Worker  - A helper script run before update-tzdata.py.
38*2fd832c6SAndroid Build Coastguard Worker    It downloads the latest tzdata and/or tzcode files from IANA and puts them
39*2fd832c6SAndroid Build Coastguard Worker    in the input_data/iana and input_tools/iana directories for use by the
40*2fd832c6SAndroid Build Coastguard Worker    update-tzdata.py script. See download-iana-files.py --help for more.
41*2fd832c6SAndroid Build Coastguard Worker
42*2fd832c6SAndroid Build Coastguard Workerupdate-tzdata.py
43*2fd832c6SAndroid Build Coastguard Worker  - Regenerates the external/icu and system/timezone/output_data timezone
44*2fd832c6SAndroid Build Coastguard Worker    data files.
45*2fd832c6SAndroid Build Coastguard Worker
46*2fd832c6SAndroid Build Coastguard WorkerSee update instructions below for how these tools are used.
47*2fd832c6SAndroid Build Coastguard Worker
48*2fd832c6SAndroid Build Coastguard WorkerIANA rules data changes
49*2fd832c6SAndroid Build Coastguard Worker=======================
50*2fd832c6SAndroid Build Coastguard Worker
51*2fd832c6SAndroid Build Coastguard WorkerWhen IANA release new time zone rules, the update process is:
52*2fd832c6SAndroid Build Coastguard Worker
53*2fd832c6SAndroid Build Coastguard Worker1) Run "download-iana-files.py --data" to update the input_data/iana file.
54*2fd832c6SAndroid Build Coastguard Worker2) Make manual modifications to input_data/android files as needed.
55*2fd832c6SAndroid Build Coastguard Worker3) There are sometimes metadata and/or test changes associated with tzdata updates
56*2fd832c6SAndroid Build Coastguard Worker  that should be applied to Android's copy of ICU and CLDR.
57*2fd832c6SAndroid Build Coastguard Worker  e.g. see https://unicode-org.atlassian.net/issues/?jql=text%20~%20%222024a%2A%22
58*2fd832c6SAndroid Build Coastguard Worker4) Run update-tzdata.py to regenerate the system/timezone/output_data,
59*2fd832c6SAndroid Build Coastguard Worker  system/timezone/testing/data, external/icu runtime files and testing equivalents.
60*2fd832c6SAndroid Build Coastguard Worker5) Build/flash a device image with the changes and run CTS:
61*2fd832c6SAndroid Build Coastguard Worker    ```
62*2fd832c6SAndroid Build Coastguard Worker    $ m cts
63*2fd832c6SAndroid Build Coastguard Worker    $ cts-tradefed
64*2fd832c6SAndroid Build Coastguard Worker    cts-tf > run cts --include-filter CtsLibcoreTestCases \
65*2fd832c6SAndroid Build Coastguard Worker                     --include-filter CtsLibcoreOjTestCases \
66*2fd832c6SAndroid Build Coastguard Worker                     --include-filter CtsIcuTestCases \
67*2fd832c6SAndroid Build Coastguard Worker                     --include-filter CtsBionicTestCases \
68*2fd832c6SAndroid Build Coastguard Worker                     --include-filter CtsTextTestCases \
69*2fd832c6SAndroid Build Coastguard Worker                     --include-filter CtsIcu4cTestCases \
70*2fd832c6SAndroid Build Coastguard Worker                     --include-filter CtsIcuTestCases
71*2fd832c6SAndroid Build Coastguard Worker    ```
72*2fd832c6SAndroid Build Coastguard Worker   (And any others that you think may have been affected)
73*2fd832c6SAndroid Build Coastguard Worker6) Run tests from 5) for every affected Android release.
74*2fd832c6SAndroid Build Coastguard Worker7) Upload, review, submit the changes from external/icu, external/cldr and system/timezone.
75*2fd832c6SAndroid Build Coastguard Worker
76*2fd832c6SAndroid Build Coastguard WorkerREMINDER: Any prebuilt APEX files containing time zone data files will also
77*2fd832c6SAndroid Build Coastguard Workerneed to be regenerated.
78*2fd832c6SAndroid Build Coastguard Worker
79*2fd832c6SAndroid Build Coastguard WorkerIANA tools changes
80*2fd832c6SAndroid Build Coastguard Worker==================
81*2fd832c6SAndroid Build Coastguard Worker
82*2fd832c6SAndroid Build Coastguard WorkerOccasionally it might be necessary / desirable to update the version of zic
83*2fd832c6SAndroid Build Coastguard Workerused to generate Android's tzdata file. For example, if IANA introduce new
84*2fd832c6SAndroid Build Coastguard Workersyntax to the text rules files (e.g. asia, north_america, etc.) or adds useful
85*2fd832c6SAndroid Build Coastguard Workercommand-line arguments to zic. This should be needed very rarely.
86*2fd832c6SAndroid Build Coastguard Worker
87*2fd832c6SAndroid Build Coastguard WorkerIt is recommended that this is done independently of a data update to help
88*2fd832c6SAndroid Build Coastguard Workerisolate unexpected changes to behavior.
89*2fd832c6SAndroid Build Coastguard Worker
90*2fd832c6SAndroid Build Coastguard WorkerNote that updating the version of zic used to create the tzdata file is
91*2fd832c6SAndroid Build Coastguard Workerindependent of the copy of zic used by ICU. Also, bionic contains
92*2fd832c6SAndroid Build Coastguard Workera copy of tzcode (e.g. localtime.c) which is different from system/timezone copy used to generate
93*2fd832c6SAndroid Build Coastguard WorkerTZif files. For consistency and compatibility purposes Android tries to keep them in sync. The
94*2fd832c6SAndroid Build Coastguard Workerlatter is controversial as IANA tries to be careful to make newer TZif files readable and correctly
95*2fd832c6SAndroid Build Coastguard Workerinterpreted by older tzcode and vice versa.
96*2fd832c6SAndroid Build Coastguard Worker
97*2fd832c6SAndroid Build Coastguard WorkerThe steps for updating IANA tools are similar to updating IANA data except
98*2fd832c6SAndroid Build Coastguard Workeryou can use "download-iana-files.py --tools" instead of "--data" and testing
99*2fd832c6SAndroid Build Coastguard Workershould be more rigorous.
100*2fd832c6SAndroid Build Coastguard Worker
101*2fd832c6SAndroid Build Coastguard WorkerREMINDER: As above, having updated the tooling then all binaries that contain
102*2fd832c6SAndroid Build Coastguard Workertzdata should also be regenerated.
103*2fd832c6SAndroid Build Coastguard Worker
104*2fd832c6SAndroid Build Coastguard Worker
105*2fd832c6SAndroid Build Coastguard WorkerTime Zone Data Set Versioning
106*2fd832c6SAndroid Build Coastguard Worker=============================
107*2fd832c6SAndroid Build Coastguard Worker
108*2fd832c6SAndroid Build Coastguard WorkerAndroid needs various files to be updated to take a time zone data update.
109*2fd832c6SAndroid Build Coastguard WorkerThese files come from various sources and we needed a concise shorthand
110*2fd832c6SAndroid Build Coastguard Workerto indicate compatibility between a set of files and an Android release. This is
111*2fd832c6SAndroid Build Coastguard Workerknown as the "Time Zone Data Set Version". Currently we expect to increment this
112*2fd832c6SAndroid Build Coastguard Workerversion with every dessert release, though this may change in future.
113*2fd832c6SAndroid Build Coastguard Worker
114*2fd832c6SAndroid Build Coastguard WorkerThe idea of a single version to describe time zone data updates was first
115*2fd832c6SAndroid Build Coastguard Workerintroduced in O-MR1 with the concept of a "distro" which could be delivered by
116*2fd832c6SAndroid Build Coastguard Workeran APK. The Android time zone "distro" was a zip archive containing the files
117*2fd832c6SAndroid Build Coastguard Workerneeded to update a device's time zone rules by overlaying files into locations
118*2fd832c6SAndroid Build Coastguard Workerin /data.
119*2fd832c6SAndroid Build Coastguard Worker
120*2fd832c6SAndroid Build Coastguard WorkerThe "distro" concept has been replaced by an APEX file containing the same data.
121*2fd832c6SAndroid Build Coastguard WorkerAs the APEX contains the same files we continue to use a shorthand version code.
122*2fd832c6SAndroid Build Coastguard WorkerSee apex/ for details.
123*2fd832c6SAndroid Build Coastguard Worker
124*2fd832c6SAndroid Build Coastguard WorkerStarting from Android V the tzdata APEX through the inclusion of tz data set version numbers in the
125*2fd832c6SAndroid Build Coastguard Workerfile paths can be installed to a range of Android releases.
126*2fd832c6SAndroid Build Coastguard Worker
127*2fd832c6SAndroid Build Coastguard WorkerTime Zone Data Set Versions have a major and minor version number:
128*2fd832c6SAndroid Build Coastguard Worker
129*2fd832c6SAndroid Build Coastguard Worker- Major version numbers are mutually incompatible. e.g. v2 is not compatible
130*2fd832c6SAndroid Build Coastguard Worker  with a v1 or a v3 device.
131*2fd832c6SAndroid Build Coastguard Worker- Minor version numbers are backwards compatible. e.g. a v2.2 time zone data set
132*2fd832c6SAndroid Build Coastguard Worker  will work on a v2.1 device but not a v2.3 device.
133*2fd832c6SAndroid Build Coastguard Worker- The minor version is reset to 1 when the major version is incremented.
134*2fd832c6SAndroid Build Coastguard Worker
135*2fd832c6SAndroid Build Coastguard WorkerHistorically, the most obvious/common change that could occur between Android releases was an
136*2fd832c6SAndroid Build Coastguard WorkerICU upgrade, which required a major version increment: Android used
137*2fd832c6SAndroid Build Coastguard Workerthe ICU4C's native file format (.dat file) for both ICU4C and ICU4J time zone code which is
138*2fd832c6SAndroid Build Coastguard Workertied to the ICU major version.
139*2fd832c6SAndroid Build Coastguard Worker
140*2fd832c6SAndroid Build Coastguard WorkerThe main .dat file used by ICU is held in external/icu and will naturally be updated when
141*2fd832c6SAndroid Build Coastguard WorkerICU is updated. But the time zone data set version code is not necessarily updated as part of ICU
142*2fd832c6SAndroid Build Coastguard Workerupgrade any more as from V tzdata now ships .res files which are compatible with older ICU releases.
143*2fd832c6SAndroid Build Coastguard Worker
144*2fd832c6SAndroid Build Coastguard WorkerOther examples of changes that affect format versioning:
145*2fd832c6SAndroid Build Coastguard Worker
146*2fd832c6SAndroid Build Coastguard WorkerMajor version increment:
147*2fd832c6SAndroid Build Coastguard Worker- A non-backwards compatible change to the tzdata or tzlookup.xml files used
148*2fd832c6SAndroid Build Coastguard Worker  by bionic / com/android/i18n/timezone code.
149*2fd832c6SAndroid Build Coastguard Worker- Removal of an existing file from the time zone data set.
150*2fd832c6SAndroid Build Coastguard Worker
151*2fd832c6SAndroid Build Coastguard WorkerMinor version increment:
152*2fd832c6SAndroid Build Coastguard Worker- Backwards compatible changes:
153*2fd832c6SAndroid Build Coastguard Worker  - A new file in the time zone data set.
154*2fd832c6SAndroid Build Coastguard Worker  - Additional required data in an existing file (e.g. a backwards compatible
155*2fd832c6SAndroid Build Coastguard Worker    change to tzdata / tzlookup.xml).
156*2fd832c6SAndroid Build Coastguard Worker
157*2fd832c6SAndroid Build Coastguard WorkerVersions mapping
158*2fd832c6SAndroid Build Coastguard Worker----------------
159*2fd832c6SAndroid Build Coastguard Worker
160*2fd832c6SAndroid Build Coastguard Worker|Android release|Major version|
161*2fd832c6SAndroid Build Coastguard Worker|---------------|-------------|
162*2fd832c6SAndroid Build Coastguard Worker|Android V      | 8           |
163*2fd832c6SAndroid Build Coastguard Worker|Android U      | 7           |
164*2fd832c6SAndroid Build Coastguard Worker|Android T      | 6           |
165*2fd832c6SAndroid Build Coastguard Worker|Android SC v2  | 5           |
166*2fd832c6SAndroid Build Coastguard Worker|Android S      | 5           |
167*2fd832c6SAndroid Build Coastguard Worker|Android R      | 4           |
168*2fd832c6SAndroid Build Coastguard Worker|Android Q      | 3           |
169*2fd832c6SAndroid Build Coastguard Worker
170*2fd832c6SAndroid Build Coastguard WorkerIn SC v2 neither ICU nor tzcode-s were updated, hence no major version bump.
171*2fd832c6SAndroid Build Coastguard Worker
172*2fd832c6SAndroid Build Coastguard Worker
173*2fd832c6SAndroid Build Coastguard WorkerChanging the Time Zone Data Set Version
174*2fd832c6SAndroid Build Coastguard Worker---------------------------------------
175*2fd832c6SAndroid Build Coastguard Worker
176*2fd832c6SAndroid Build Coastguard Worker1) Modify following files:
177*2fd832c6SAndroid Build Coastguard Worker    * external/icu/android_icu4j/libcore_bridge/src/java/com/android/i18n/timezone/TzDataSetVersion.java
178*2fd832c6SAndroid Build Coastguard Worker      * CURRENT_FORMAT_MAJOR_VERSION and CURRENT_FORMAT_MINOR_VERSION fields.
179*2fd832c6SAndroid Build Coastguard Worker    * external/icu/android_icu4j/src/main/java/android/icu/platform/AndroidDataFiles.java
180*2fd832c6SAndroid Build Coastguard Worker      * CURRENT_MAJOR_VERSION field.
181*2fd832c6SAndroid Build Coastguard Worker    * Version mapping table above.
182*2fd832c6SAndroid Build Coastguard Worker    * system/timezone/output_data/icu_overlay/Android.bp and system/timezone/output_data/android/Android.bp.
183*2fd832c6SAndroid Build Coastguard Worker      * Update `relative_install_path` in `prebuilt_root_host` targets.
184*2fd832c6SAndroid Build Coastguard Worker2) Run update-tzdata.py to regenerate the system/timezone/output_data,
185*2fd832c6SAndroid Build Coastguard Worker   system/timezone/testing/data, external/icu runtime files and testing equivalents.
186*2fd832c6SAndroid Build Coastguard Worker3) Build/flash a device image with the changes and run tests from "IANA rules data changes" section.
187*2fd832c6SAndroid Build Coastguard Worker4) Upload, review, submit the changes from system/timezone, external/icu and external/cldr.
188*2fd832c6SAndroid Build Coastguard Worker
189*2fd832c6SAndroid Build Coastguard WorkerREMINDER: Any prebuilt apks / apex files (i.e. ones that that contain time zone files)
190*2fd832c6SAndroid Build Coastguard Workerwill also need to be regenerated after this change.
191*2fd832c6SAndroid Build Coastguard Worker
192