blob: 423fda5b9ac6c19c86144fd7cad590e6ad6dbc86 [file] [log] [blame]
Neil Fuller3830d702017-08-18 17:03:59 +01001This directory contains code, tools and data related to time zone rules data
2and updates.
Neil Fuller86e72c52017-06-12 15:36:06 +01003
Neil Fuller3830d702017-08-18 17:03:59 +01004Directory structure
5===================
6
Neil Fuller9bfe7122019-04-16 15:11:59 +01007apex
8 - Code related to the Android time zone update APEX file that can be used
9 to update time zone rules on Android devices.
10
11debug_tools
12 - Contains tools useful for debugging time zone issues on Android devices.
13
Neil Fuller3830d702017-08-18 17:03:59 +010014input_data
15 - Contains files that provide inputs to the time zone rules update process.
16 Some files come from external sources and some are mastered in Android.
17 See also download-iana-data.py.
18
Neil Fuller9bfe7122019-04-16 15:11:59 +010019input_tools
20 - Contains tools that generate Android time zone files.
21
Neil Fuller3830d702017-08-18 17:03:59 +010022output_data
23 - Contains some derived files from the time zone rules update process and
Almaz Mingaleev819ac372022-05-26 11:28:33 +010024 used in the Android system image and APEX files. Some files are also held
25 by ICU - see also update-tzdata.py
Neil Fuller3830d702017-08-18 17:03:59 +010026
27testing
28 - Contains tools and scripts related to testing time zone update code. See
29 testing/data/README for details.
30
Neil Fuller3830d702017-08-18 17:03:59 +010031
32
33Data file update tools
34======================
Neil Fuller86e72c52017-06-12 15:36:06 +010035
Neil Fuller9bfe7122019-04-16 15:11:59 +010036download-iana-files.py
Neil Fuller56166d32017-06-12 12:57:10 +010037 - A helper script run before update-tzdata.py.
Neil Fuller9bfe7122019-04-16 15:11:59 +010038 It downloads the latest tzdata and/or tzcode files from IANA and puts them
39 in the input_data/iana and input_tools/iana directories for use by the
40 update-tzdata.py script. See download-iana-files.py --help for more.
Neil Fuller56166d32017-06-12 12:57:10 +010041
Neil Fuller56166d32017-06-12 12:57:10 +010042update-tzdata.py
Neil Fuller35467e12017-06-12 16:55:44 +010043 - Regenerates the external/icu and system/timezone/output_data timezone
44 data files.
Neil Fuller56166d32017-06-12 12:57:10 +010045
Neil Fuller3830d702017-08-18 17:03:59 +010046See update instructions below for how these tools are used.
47
48IANA rules data changes
49=======================
50
51When IANA release new time zone rules, the update process is:
52
Neil Fuller9bfe7122019-04-16 15:11:59 +0100531) Run "download-iana-files.py --data" to update the input_data/iana file.
542) Make manual modifications to input_data/android files as needed.
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +0000553) There are sometimes metadata and/or test changes associated with tzdata updates
56 that should be applied to Android's copy of ICU and CLDR.
57 e.g. see https://unicode-org.atlassian.net/issues/?jql=text%20~%20%222024a%2A%22
Neil Fuller3830d702017-08-18 17:03:59 +0100584) Run update-tzdata.py to regenerate the system/timezone/output_data,
Neil Fuller6a49edb2017-11-24 13:59:32 +000059 system/timezone/testing/data, external/icu runtime files and testing equivalents.
Neil Fuller45b6b1b2017-10-24 12:14:00 +0100605) Build/flash a device image with the changes and run CTS:
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +000061 ```
62 $ m cts
63 $ cts-tradefed
64 cts-tf > run cts --include-filter CtsLibcoreTestCases \
65 --include-filter CtsLibcoreOjTestCases \
66 --include-filter CtsIcuTestCases \
67 --include-filter CtsBionicTestCases \
68 --include-filter CtsTextTestCases \
69 --include-filter CtsIcu4cTestCases \
70 --include-filter CtsIcuTestCases
71 ```
Neil Fuller3830d702017-08-18 17:03:59 +010072 (And any others that you think may have been affected)
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +0000736) Run tests from 5) for every affected Android release.
747) Upload, review, submit the changes from external/icu, external/cldr and system/timezone.
Neil Fuller3830d702017-08-18 17:03:59 +010075
Almaz Mingaleev819ac372022-05-26 11:28:33 +010076REMINDER: Any prebuilt APEX files containing time zone data files will also
77need to be regenerated.
Neil Fuller9bfe7122019-04-16 15:11:59 +010078
79IANA tools changes
80==================
81
82Occasionally it might be necessary / desirable to update the version of zic
83used to generate Android's tzdata file. For example, if IANA introduce new
84syntax to the text rules files (e.g. asia, north_america, etc.) or adds useful
85command-line arguments to zic. This should be needed very rarely.
86
87It is recommended that this is done independently of a data update to help
88isolate unexpected changes to behavior.
89
90Note that updating the version of zic used to create the tzdata file is
91independent of the copy of zic used by ICU. Also, bionic contains
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +000092a copy of tzcode (e.g. localtime.c) which is different from system/timezone copy used to generate
93TZif files. For consistency and compatibility purposes Android tries to keep them in sync. The
94latter is controversial as IANA tries to be careful to make newer TZif files readable and correctly
95interpreted by older tzcode and vice versa.
Neil Fuller9bfe7122019-04-16 15:11:59 +010096
97The steps for updating IANA tools are similar to updating IANA data except
98you can use "download-iana-files.py --tools" instead of "--data" and testing
99should be more rigorous.
100
101REMINDER: As above, having updated the tooling then all binaries that contain
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +0000102tzdata should also be regenerated.
Neil Fuller3830d702017-08-18 17:03:59 +0100103
104
Neil Fuller9bfe7122019-04-16 15:11:59 +0100105Time Zone Data Set Versioning
106=============================
Neil Fuller3830d702017-08-18 17:03:59 +0100107
Neil Fuller9bfe7122019-04-16 15:11:59 +0100108Android needs various files to be updated to take a time zone data update.
109These files come from various sources and we needed a concise shorthand
110to indicate compatibility between a set of files and an Android release. This is
111known as the "Time Zone Data Set Version". Currently we expect to increment this
112version with every dessert release, though this may change in future.
Neil Fuller3830d702017-08-18 17:03:59 +0100113
Neil Fuller9bfe7122019-04-16 15:11:59 +0100114The idea of a single version to describe time zone data updates was first
115introduced in O-MR1 with the concept of a "distro" which could be delivered by
Almaz Mingaleev819ac372022-05-26 11:28:33 +0100116an APK. The Android time zone "distro" was a zip archive containing the files
Neil Fuller9bfe7122019-04-16 15:11:59 +0100117needed to update a device's time zone rules by overlaying files into locations
Almaz Mingaleev819ac372022-05-26 11:28:33 +0100118in /data.
Neil Fuller3830d702017-08-18 17:03:59 +0100119
Almaz Mingaleev819ac372022-05-26 11:28:33 +0100120The "distro" concept has been replaced by an APEX file containing the same data.
121As the APEX contains the same files we continue to use a shorthand version code.
122See apex/ for details.
Neil Fuller3830d702017-08-18 17:03:59 +0100123
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +0000124Starting from Android V the tzdata APEX through the inclusion of tz data set version numbers in the
125file paths can be installed to a range of Android releases.
126
Neil Fuller9bfe7122019-04-16 15:11:59 +0100127Time Zone Data Set Versions have a major and minor version number:
128
129- Major version numbers are mutually incompatible. e.g. v2 is not compatible
130 with a v1 or a v3 device.
Almaz Mingaleev819ac372022-05-26 11:28:33 +0100131- Minor version numbers are backwards compatible. e.g. a v2.2 time zone data set
132 will work on a v2.1 device but not a v2.3 device.
Neil Fuller3830d702017-08-18 17:03:59 +0100133- The minor version is reset to 1 when the major version is incremented.
134
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +0000135Historically, the most obvious/common change that could occur between Android releases was an
136ICU upgrade, which required a major version increment: Android used
137the ICU4C's native file format (.dat file) for both ICU4C and ICU4J time zone code which is
138tied to the ICU major version.
139
140The main .dat file used by ICU is held in external/icu and will naturally be updated when
141ICU is updated. But the time zone data set version code is not necessarily updated as part of ICU
142upgrade any more as from V tzdata now ships .res files which are compatible with older ICU releases.
Neil Fuller3830d702017-08-18 17:03:59 +0100143
144Other examples of changes that affect format versioning:
145
146Major version increment:
147- A non-backwards compatible change to the tzdata or tzlookup.xml files used
Neil Fuller9e7b2d82020-07-20 13:18:47 +0100148 by bionic / com/android/i18n/timezone code.
Almaz Mingaleev819ac372022-05-26 11:28:33 +0100149- Removal of an existing file from the time zone data set.
Neil Fuller3830d702017-08-18 17:03:59 +0100150
151Minor version increment:
152- Backwards compatible changes:
Almaz Mingaleev819ac372022-05-26 11:28:33 +0100153 - A new file in the time zone data set.
Neil Fuller3830d702017-08-18 17:03:59 +0100154 - Additional required data in an existing file (e.g. a backwards compatible
155 change to tzdata / tzlookup.xml).
156
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +0000157Versions mapping
158----------------
159
160|Android release|Major version|
161|---------------|-------------|
Almaz Mingaleev0eea93a2024-12-13 17:46:29 +0000162|Android B | 9 |
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +0000163|Android V | 8 |
164|Android U | 7 |
165|Android T | 6 |
166|Android SC v2 | 5 |
167|Android S | 5 |
168|Android R | 4 |
169|Android Q | 3 |
170
171In SC v2 neither ICU nor tzcode-s were updated, hence no major version bump.
172
Neil Fuller3830d702017-08-18 17:03:59 +0100173
Neil Fuller9bfe7122019-04-16 15:11:59 +0100174Changing the Time Zone Data Set Version
175---------------------------------------
Neil Fuller3830d702017-08-18 17:03:59 +0100176
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +00001771) Modify following files:
178 * external/icu/android_icu4j/libcore_bridge/src/java/com/android/i18n/timezone/TzDataSetVersion.java
179 * CURRENT_FORMAT_MAJOR_VERSION and CURRENT_FORMAT_MINOR_VERSION fields.
180 * external/icu/android_icu4j/src/main/java/android/icu/platform/AndroidDataFiles.java
181 * CURRENT_MAJOR_VERSION field.
Almaz Mingaleeva75dc922025-02-13 11:16:53 +0000182 * external/icu/libandroidicuinit/IcuRegistration.cpp
183 * CURRENT_MAJOR_FORMAT_VERSION field.
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +0000184 * Version mapping table above.
Almaz Mingaleev75100972024-06-14 09:52:51 +0100185 * system/timezone/output_data/icu_overlay/Android.bp and system/timezone/output_data/android/Android.bp.
186 * Update `relative_install_path` in `prebuilt_root_host` targets.
Neil Fuller231c68c2018-11-28 22:37:30 +00001872) Run update-tzdata.py to regenerate the system/timezone/output_data,
Neil Fuller9bfe7122019-04-16 15:11:59 +0100188 system/timezone/testing/data, external/icu runtime files and testing equivalents.
Almaz Mingaleev37c2ea92024-06-05 09:13:02 +00001893) Build/flash a device image with the changes and run tests from "IANA rules data changes" section.
1904) Upload, review, submit the changes from system/timezone, external/icu and external/cldr.
Neil Fuller3830d702017-08-18 17:03:59 +0100191
Neil Fuller9bfe7122019-04-16 15:11:59 +0100192REMINDER: Any prebuilt apks / apex files (i.e. ones that that contain time zone files)
193will also need to be regenerated after this change.
Neil Fuller86e72c52017-06-12 15:36:06 +0100194