blob: 72652f4f50b6196725e62b2db315109db51468c6 [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 +010014distro
15 - Code related to "distros", the collection of files that can be used to
16 update time zone rules on Android devices. See distro/README for details.
17
18input_data
19 - Contains files that provide inputs to the time zone rules update process.
20 Some files come from external sources and some are mastered in Android.
21 See also download-iana-data.py.
22
Neil Fuller9bfe7122019-04-16 15:11:59 +010023input_tools
24 - Contains tools that generate Android time zone files.
25
Neil Fuller3830d702017-08-18 17:03:59 +010026output_data
27 - Contains some derived files from the time zone rules update process and
Neil Fuller9bfe7122019-04-16 15:11:59 +010028 used in the Android system image, distros and APEX files. Some files are
29 also held by ICU - see also update-tzdata.py
Neil Fuller3830d702017-08-18 17:03:59 +010030
31testing
32 - Contains tools and scripts related to testing time zone update code. See
33 testing/data/README for details.
34
35tzdatacheck
Neil Fuller9e7b2d82020-07-20 13:18:47 +010036 - This is for the "time zone updates via APK" feature.
37 Source code for a binary executed during boot and used to ensure that a
Neil Fuller3830d702017-08-18 17:03:59 +010038 device doesn't boot with incompatible/outdated time zone data installed
Neil Fuller9e7b2d82020-07-20 13:18:47 +010039 in /data (as could happen if the device has just received an OTA upgrade).
Neil Fuller3830d702017-08-18 17:03:59 +010040 It is also responsible for committing staged install/uninstalls.
41
Neil Fuller3830d702017-08-18 17:03:59 +010042
43
44Data file update tools
45======================
Neil Fuller86e72c52017-06-12 15:36:06 +010046
Neil Fuller9bfe7122019-04-16 15:11:59 +010047download-iana-files.py
Neil Fuller56166d32017-06-12 12:57:10 +010048 - A helper script run before update-tzdata.py.
Neil Fuller9bfe7122019-04-16 15:11:59 +010049 It downloads the latest tzdata and/or tzcode files from IANA and puts them
50 in the input_data/iana and input_tools/iana directories for use by the
51 update-tzdata.py script. See download-iana-files.py --help for more.
Neil Fuller56166d32017-06-12 12:57:10 +010052
Neil Fuller56166d32017-06-12 12:57:10 +010053update-tzdata.py
Neil Fuller35467e12017-06-12 16:55:44 +010054 - Regenerates the external/icu and system/timezone/output_data timezone
55 data files.
Neil Fuller56166d32017-06-12 12:57:10 +010056
Neil Fuller3830d702017-08-18 17:03:59 +010057See update instructions below for how these tools are used.
58
59IANA rules data changes
60=======================
61
62When IANA release new time zone rules, the update process is:
63
Neil Fuller9bfe7122019-04-16 15:11:59 +0100641) Run "download-iana-files.py --data" to update the input_data/iana file.
652) Make manual modifications to input_data/android files as needed.
Neil Fuller3830d702017-08-18 17:03:59 +0100663) There are sometimes code and metadata changes associated with tzdata updates
67 that should be applied to Android's copy of ICU.
68 e.g. see http://bugs.icu-project.org/trac/search?q=2015d
694) Run update-tzdata.py to regenerate the system/timezone/output_data,
Neil Fuller6a49edb2017-11-24 13:59:32 +000070 system/timezone/testing/data, external/icu runtime files and testing equivalents.
Neil Fuller45b6b1b2017-10-24 12:14:00 +0100715) Build/flash a device image with the changes and run CTS:
Neil Fuller3830d702017-08-18 17:03:59 +010072 cts-tradefed
73 run cts -m CtsLibcoreTestCases
74 run cts -m CtsIcuTestCases
75 (And any others that you think may have been affected)
Neil Fuller45b6b1b2017-10-24 12:14:00 +0100766) Upload, review, submit the changes from external/icu and system/timezone.
Neil Fuller3830d702017-08-18 17:03:59 +010077
78REMINDER: Any prebuilt apks of OEM-specific time zone data apps .apk files
79(i.e. ones that that contain distro files) will also need to be regenerated
80with a new version code / string and any OEM-specific tests should be run.
Neil Fuller9bfe7122019-04-16 15:11:59 +010081APEX files containing time zone data files will also need to be regenerated.
82
83IANA tools changes
84==================
85
86Occasionally it might be necessary / desirable to update the version of zic
87used to generate Android's tzdata file. For example, if IANA introduce new
88syntax to the text rules files (e.g. asia, north_america, etc.) or adds useful
89command-line arguments to zic. This should be needed very rarely.
90
91It is recommended that this is done independently of a data update to help
92isolate unexpected changes to behavior.
93
94Note that updating the version of zic used to create the tzdata file is
95independent of the copy of zic used by ICU. Also, bionic contains
96a copy of tzcode (e.g. localtime.c) which is based on yet another IANA
97release so compatibility and consistency is a consideration.
98
99The steps for updating IANA tools are similar to updating IANA data except
100you can use "download-iana-files.py --tools" instead of "--data" and testing
101should be more rigorous.
102
103REMINDER: As above, having updated the tooling then all binaries that contain
104tzdata should also be regenerated. e.g. APK and APEX files.
Neil Fuller3830d702017-08-18 17:03:59 +0100105
106
Neil Fuller9bfe7122019-04-16 15:11:59 +0100107Time Zone Data Set Versioning
108=============================
Neil Fuller3830d702017-08-18 17:03:59 +0100109
Neil Fuller9bfe7122019-04-16 15:11:59 +0100110Android needs various files to be updated to take a time zone data update.
111These files come from various sources and we needed a concise shorthand
112to indicate compatibility between a set of files and an Android release. This is
113known as the "Time Zone Data Set Version". Currently we expect to increment this
114version with every dessert release, though this may change in future.
Neil Fuller3830d702017-08-18 17:03:59 +0100115
Neil Fuller9bfe7122019-04-16 15:11:59 +0100116The idea of a single version to describe time zone data updates was first
117introduced in O-MR1 with the concept of a "distro" which could be delivered by
118an APK. The Android time zone "distro" is a zip archive containing the files
119needed to update a device's time zone rules by overlaying files into locations
120in /data. See distro/ for details.
Neil Fuller3830d702017-08-18 17:03:59 +0100121
Neil Fuller9bfe7122019-04-16 15:11:59 +0100122The "distro" concept will be removed in a future release of Android as it is
123being replaced by an APEX file containing the same data. As the APEX contains
124the same files we continue to use a shorthand version code. See apex/ for
125details.
Neil Fuller3830d702017-08-18 17:03:59 +0100126
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.
131- Minor version numbers are backwards compatible. e.g. a v2.2 distro will work
132 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
135The most obvious/common change that can occur between Android releases is an
Neil Fuller9bfe7122019-04-16 15:11:59 +0100136ICU upgrade, which currently requires a major version increment: Android uses
137the ICU4C's native file format for both ICU4C and ICU4J time zone code which is
Neil Fuller3830d702017-08-18 17:03:59 +0100138tied to the ICU major version. The main .dat file used by ICU is held in
139external/icu and will naturally be updated when ICU is updated. Less obviously,
Neil Fuller9bfe7122019-04-16 15:11:59 +0100140the time zone data set version code and files must be updated as well.
Neil Fuller3830d702017-08-18 17:03:59 +0100141
142Other examples of changes that affect format versioning:
143
144Major version increment:
145- A non-backwards compatible change to the tzdata or tzlookup.xml files used
Neil Fuller9e7b2d82020-07-20 13:18:47 +0100146 by bionic / com/android/i18n/timezone code.
Neil Fuller3830d702017-08-18 17:03:59 +0100147- Removal of an existing file from the distro.
148
149Minor version increment:
150- Backwards compatible changes:
151 - A new file in the distro.
152 - Additional required data in an existing file (e.g. a backwards compatible
153 change to tzdata / tzlookup.xml).
154
155
Neil Fuller9bfe7122019-04-16 15:11:59 +0100156Changing the Time Zone Data Set Version
157---------------------------------------
Neil Fuller3830d702017-08-18 17:03:59 +0100158
Neil Fuller9e7b2d82020-07-20 13:18:47 +01001591) Modify android_icu4j/libcore_bridge/src/java/com/android/i18n/timezone/TzDataSetVersion.java
Neil Fuller3830d702017-08-18 17:03:59 +0100160 - CURRENT_FORMAT_MAJOR_VERSION, CURRENT_FORMAT_MINOR_VERSION
Neil Fuller231c68c2018-11-28 22:37:30 +00001612) Run update-tzdata.py to regenerate the system/timezone/output_data,
Neil Fuller9bfe7122019-04-16 15:11:59 +0100162 system/timezone/testing/data, external/icu runtime files and testing equivalents.
1633) Build/flash a device image with the changes and run CTS tests:
164 atest CtsHostTzDataTests
Neil Fuller9e7b2d82020-07-20 13:18:47 +0100165 atest CtsIcuTestCases
Neil Fuller231c68c2018-11-28 22:37:30 +00001664) Run non-CTS test cases:
Neil Fuller9bfe7122019-04-16 15:11:59 +0100167 atest FrameworksServicesTests:com.android.server.timezone
Neil Fuller9e7b2d82020-07-20 13:18:47 +01001685) Upload, review, submit the changes from system/timezone and external/icu/.
Neil Fuller3830d702017-08-18 17:03:59 +0100169
Neil Fuller9bfe7122019-04-16 15:11:59 +0100170REMINDER: Any prebuilt apks / apex files (i.e. ones that that contain time zone files)
171will also need to be regenerated after this change.
Neil Fuller86e72c52017-06-12 15:36:06 +0100172