Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 1 | This directory contains code, tools and data related to time zone rules data |
| 2 | and updates. |
Neil Fuller | 86e72c5 | 2017-06-12 15:36:06 +0100 | [diff] [blame] | 3 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 4 | Directory structure |
| 5 | =================== |
| 6 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 7 | apex |
| 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 | |
| 11 | debug_tools |
| 12 | - Contains tools useful for debugging time zone issues on Android devices. |
| 13 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 14 | input_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 Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 19 | input_tools |
| 20 | - Contains tools that generate Android time zone files. |
| 21 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 22 | output_data |
| 23 | - Contains some derived files from the time zone rules update process and |
Almaz Mingaleev | 819ac37 | 2022-05-26 11:28:33 +0100 | [diff] [blame] | 24 | used in the Android system image and APEX files. Some files are also held |
| 25 | by ICU - see also update-tzdata.py |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 26 | |
| 27 | testing |
| 28 | - Contains tools and scripts related to testing time zone update code. See |
| 29 | testing/data/README for details. |
| 30 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 31 | |
| 32 | |
| 33 | Data file update tools |
| 34 | ====================== |
Neil Fuller | 86e72c5 | 2017-06-12 15:36:06 +0100 | [diff] [blame] | 35 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 36 | download-iana-files.py |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 37 | - A helper script run before update-tzdata.py. |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 38 | 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 Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 41 | |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 42 | update-tzdata.py |
Neil Fuller | 35467e1 | 2017-06-12 16:55:44 +0100 | [diff] [blame] | 43 | - Regenerates the external/icu and system/timezone/output_data timezone |
| 44 | data files. |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 45 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 46 | See update instructions below for how these tools are used. |
| 47 | |
| 48 | IANA rules data changes |
| 49 | ======================= |
| 50 | |
| 51 | When IANA release new time zone rules, the update process is: |
| 52 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 53 | 1) Run "download-iana-files.py --data" to update the input_data/iana file. |
| 54 | 2) Make manual modifications to input_data/android files as needed. |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 55 | 3) 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 Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 58 | 4) Run update-tzdata.py to regenerate the system/timezone/output_data, |
Neil Fuller | 6a49edb | 2017-11-24 13:59:32 +0000 | [diff] [blame] | 59 | system/timezone/testing/data, external/icu runtime files and testing equivalents. |
Neil Fuller | 45b6b1b | 2017-10-24 12:14:00 +0100 | [diff] [blame] | 60 | 5) Build/flash a device image with the changes and run CTS: |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 61 | ``` |
| 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 Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 72 | (And any others that you think may have been affected) |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 73 | 6) Run tests from 5) for every affected Android release. |
| 74 | 7) Upload, review, submit the changes from external/icu, external/cldr and system/timezone. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 75 | |
Almaz Mingaleev | 819ac37 | 2022-05-26 11:28:33 +0100 | [diff] [blame] | 76 | REMINDER: Any prebuilt APEX files containing time zone data files will also |
| 77 | need to be regenerated. |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 78 | |
| 79 | IANA tools changes |
| 80 | ================== |
| 81 | |
| 82 | Occasionally it might be necessary / desirable to update the version of zic |
| 83 | used to generate Android's tzdata file. For example, if IANA introduce new |
| 84 | syntax to the text rules files (e.g. asia, north_america, etc.) or adds useful |
| 85 | command-line arguments to zic. This should be needed very rarely. |
| 86 | |
| 87 | It is recommended that this is done independently of a data update to help |
| 88 | isolate unexpected changes to behavior. |
| 89 | |
| 90 | Note that updating the version of zic used to create the tzdata file is |
| 91 | independent of the copy of zic used by ICU. Also, bionic contains |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 92 | a copy of tzcode (e.g. localtime.c) which is different from system/timezone copy used to generate |
| 93 | TZif files. For consistency and compatibility purposes Android tries to keep them in sync. The |
| 94 | latter is controversial as IANA tries to be careful to make newer TZif files readable and correctly |
| 95 | interpreted by older tzcode and vice versa. |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 96 | |
| 97 | The steps for updating IANA tools are similar to updating IANA data except |
| 98 | you can use "download-iana-files.py --tools" instead of "--data" and testing |
| 99 | should be more rigorous. |
| 100 | |
| 101 | REMINDER: As above, having updated the tooling then all binaries that contain |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 102 | tzdata should also be regenerated. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 103 | |
| 104 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 105 | Time Zone Data Set Versioning |
| 106 | ============================= |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 107 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 108 | Android needs various files to be updated to take a time zone data update. |
| 109 | These files come from various sources and we needed a concise shorthand |
| 110 | to indicate compatibility between a set of files and an Android release. This is |
| 111 | known as the "Time Zone Data Set Version". Currently we expect to increment this |
| 112 | version with every dessert release, though this may change in future. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 113 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 114 | The idea of a single version to describe time zone data updates was first |
| 115 | introduced in O-MR1 with the concept of a "distro" which could be delivered by |
Almaz Mingaleev | 819ac37 | 2022-05-26 11:28:33 +0100 | [diff] [blame] | 116 | an APK. The Android time zone "distro" was a zip archive containing the files |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 117 | needed to update a device's time zone rules by overlaying files into locations |
Almaz Mingaleev | 819ac37 | 2022-05-26 11:28:33 +0100 | [diff] [blame] | 118 | in /data. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 119 | |
Almaz Mingaleev | 819ac37 | 2022-05-26 11:28:33 +0100 | [diff] [blame] | 120 | The "distro" concept has been replaced by an APEX file containing the same data. |
| 121 | As the APEX contains the same files we continue to use a shorthand version code. |
| 122 | See apex/ for details. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 123 | |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 124 | Starting from Android V the tzdata APEX through the inclusion of tz data set version numbers in the |
| 125 | file paths can be installed to a range of Android releases. |
| 126 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 127 | Time 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 Mingaleev | 819ac37 | 2022-05-26 11:28:33 +0100 | [diff] [blame] | 131 | - 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 Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 133 | - The minor version is reset to 1 when the major version is incremented. |
| 134 | |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 135 | Historically, the most obvious/common change that could occur between Android releases was an |
| 136 | ICU upgrade, which required a major version increment: Android used |
| 137 | the ICU4C's native file format (.dat file) for both ICU4C and ICU4J time zone code which is |
| 138 | tied to the ICU major version. |
| 139 | |
| 140 | The main .dat file used by ICU is held in external/icu and will naturally be updated when |
| 141 | ICU is updated. But the time zone data set version code is not necessarily updated as part of ICU |
| 142 | upgrade any more as from V tzdata now ships .res files which are compatible with older ICU releases. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 143 | |
| 144 | Other examples of changes that affect format versioning: |
| 145 | |
| 146 | Major version increment: |
| 147 | - A non-backwards compatible change to the tzdata or tzlookup.xml files used |
Neil Fuller | 9e7b2d8 | 2020-07-20 13:18:47 +0100 | [diff] [blame] | 148 | by bionic / com/android/i18n/timezone code. |
Almaz Mingaleev | 819ac37 | 2022-05-26 11:28:33 +0100 | [diff] [blame] | 149 | - Removal of an existing file from the time zone data set. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 150 | |
| 151 | Minor version increment: |
| 152 | - Backwards compatible changes: |
Almaz Mingaleev | 819ac37 | 2022-05-26 11:28:33 +0100 | [diff] [blame] | 153 | - A new file in the time zone data set. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 154 | - Additional required data in an existing file (e.g. a backwards compatible |
| 155 | change to tzdata / tzlookup.xml). |
| 156 | |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 157 | Versions mapping |
| 158 | ---------------- |
| 159 | |
| 160 | |Android release|Major version| |
| 161 | |---------------|-------------| |
Almaz Mingaleev | 0eea93a | 2024-12-13 17:46:29 +0000 | [diff] [blame] | 162 | |Android B | 9 | |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 163 | |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 | |
| 171 | In SC v2 neither ICU nor tzcode-s were updated, hence no major version bump. |
| 172 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 173 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 174 | Changing the Time Zone Data Set Version |
| 175 | --------------------------------------- |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 176 | |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 177 | 1) 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 Mingaleev | a75dc92 | 2025-02-13 11:16:53 +0000 | [diff] [blame] | 182 | * external/icu/libandroidicuinit/IcuRegistration.cpp |
| 183 | * CURRENT_MAJOR_FORMAT_VERSION field. |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 184 | * Version mapping table above. |
Almaz Mingaleev | 7510097 | 2024-06-14 09:52:51 +0100 | [diff] [blame] | 185 | * 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 Fuller | 231c68c | 2018-11-28 22:37:30 +0000 | [diff] [blame] | 187 | 2) Run update-tzdata.py to regenerate the system/timezone/output_data, |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 188 | system/timezone/testing/data, external/icu runtime files and testing equivalents. |
Almaz Mingaleev | 37c2ea9 | 2024-06-05 09:13:02 +0000 | [diff] [blame] | 189 | 3) Build/flash a device image with the changes and run tests from "IANA rules data changes" section. |
| 190 | 4) Upload, review, submit the changes from system/timezone, external/icu and external/cldr. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 191 | |
Neil Fuller | 9bfe712 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 192 | REMINDER: Any prebuilt apks / apex files (i.e. ones that that contain time zone files) |
| 193 | will also need to be regenerated after this change. |
Neil Fuller | 86e72c5 | 2017-06-12 15:36:06 +0100 | [diff] [blame] | 194 | |