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 | 7a69971 | 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 | distro |
| 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 | |
| 18 | input_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 Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 23 | input_tools |
| 24 | - Contains tools that generate Android time zone files. |
| 25 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 26 | output_data |
| 27 | - Contains some derived files from the time zone rules update process and |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 28 | used in the Android system image, distros and APEX files. Some files are |
| 29 | also held by ICU - see also update-tzdata.py |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 30 | |
| 31 | testing |
| 32 | - Contains tools and scripts related to testing time zone update code. See |
| 33 | testing/data/README for details. |
| 34 | |
| 35 | tzdatacheck |
| 36 | - Source code for a binary executed during boot and used to ensure that a |
| 37 | device doesn't boot with incompatible/outdated time zone data installed |
| 38 | /data (as could happen if the device has just received an OTA upgrade). |
| 39 | It is also responsible for committing staged install/uninstalls. |
| 40 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 41 | |
| 42 | |
| 43 | Data file update tools |
| 44 | ====================== |
Neil Fuller | 86e72c5 | 2017-06-12 15:36:06 +0100 | [diff] [blame] | 45 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 46 | download-iana-files.py |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 47 | - A helper script run before update-tzdata.py. |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 48 | It downloads the latest tzdata and/or tzcode files from IANA and puts them |
| 49 | in the input_data/iana and input_tools/iana directories for use by the |
| 50 | update-tzdata.py script. See download-iana-files.py --help for more. |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 51 | |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 52 | update-tzdata.py |
Neil Fuller | 35467e1 | 2017-06-12 16:55:44 +0100 | [diff] [blame] | 53 | - Regenerates the external/icu and system/timezone/output_data timezone |
| 54 | data files. |
Neil Fuller | 56166d3 | 2017-06-12 12:57:10 +0100 | [diff] [blame] | 55 | |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 56 | See update instructions below for how these tools are used. |
| 57 | |
| 58 | IANA rules data changes |
| 59 | ======================= |
| 60 | |
| 61 | When IANA release new time zone rules, the update process is: |
| 62 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 63 | 1) Run "download-iana-files.py --data" to update the input_data/iana file. |
| 64 | 2) Make manual modifications to input_data/android files as needed. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 65 | 3) There are sometimes code and metadata changes associated with tzdata updates |
| 66 | that should be applied to Android's copy of ICU. |
| 67 | e.g. see http://bugs.icu-project.org/trac/search?q=2015d |
| 68 | 4) Run update-tzdata.py to regenerate the system/timezone/output_data, |
Neil Fuller | 6a49edb | 2017-11-24 13:59:32 +0000 | [diff] [blame] | 69 | system/timezone/testing/data, external/icu runtime files and testing equivalents. |
Neil Fuller | 45b6b1b | 2017-10-24 12:14:00 +0100 | [diff] [blame] | 70 | 5) Build/flash a device image with the changes and run CTS: |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 71 | cts-tradefed |
| 72 | run cts -m CtsLibcoreTestCases |
| 73 | run cts -m CtsIcuTestCases |
| 74 | (And any others that you think may have been affected) |
Neil Fuller | 45b6b1b | 2017-10-24 12:14:00 +0100 | [diff] [blame] | 75 | 6) Upload, review, submit the changes from external/icu and system/timezone. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 76 | |
| 77 | REMINDER: Any prebuilt apks of OEM-specific time zone data apps .apk files |
| 78 | (i.e. ones that that contain distro files) will also need to be regenerated |
| 79 | with a new version code / string and any OEM-specific tests should be run. |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 80 | APEX files containing time zone data files will also need to be regenerated. |
| 81 | |
| 82 | IANA tools changes |
| 83 | ================== |
| 84 | |
| 85 | Occasionally it might be necessary / desirable to update the version of zic |
| 86 | used to generate Android's tzdata file. For example, if IANA introduce new |
| 87 | syntax to the text rules files (e.g. asia, north_america, etc.) or adds useful |
| 88 | command-line arguments to zic. This should be needed very rarely. |
| 89 | |
| 90 | It is recommended that this is done independently of a data update to help |
| 91 | isolate unexpected changes to behavior. |
| 92 | |
| 93 | Note that updating the version of zic used to create the tzdata file is |
| 94 | independent of the copy of zic used by ICU. Also, bionic contains |
| 95 | a copy of tzcode (e.g. localtime.c) which is based on yet another IANA |
| 96 | release so compatibility and consistency is a consideration. |
| 97 | |
| 98 | The steps for updating IANA tools are similar to updating IANA data except |
| 99 | you can use "download-iana-files.py --tools" instead of "--data" and testing |
| 100 | should be more rigorous. |
| 101 | |
| 102 | REMINDER: As above, having updated the tooling then all binaries that contain |
| 103 | tzdata should also be regenerated. e.g. APK and APEX files. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 104 | |
| 105 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 106 | Time Zone Data Set Versioning |
| 107 | ============================= |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 108 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 109 | Android needs various files to be updated to take a time zone data update. |
| 110 | These files come from various sources and we needed a concise shorthand |
| 111 | to indicate compatibility between a set of files and an Android release. This is |
| 112 | known as the "Time Zone Data Set Version". Currently we expect to increment this |
| 113 | version with every dessert release, though this may change in future. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 114 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 115 | The idea of a single version to describe time zone data updates was first |
| 116 | introduced in O-MR1 with the concept of a "distro" which could be delivered by |
| 117 | an APK. The Android time zone "distro" is a zip archive containing the files |
| 118 | needed to update a device's time zone rules by overlaying files into locations |
| 119 | in /data. See distro/ for details. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 120 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 121 | The "distro" concept will be removed in a future release of Android as it is |
| 122 | being replaced by an APEX file containing the same data. As the APEX contains |
| 123 | the same files we continue to use a shorthand version code. See apex/ for |
| 124 | details. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 125 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 126 | Time Zone Data Set Versions have a major and minor version number: |
| 127 | |
| 128 | - Major version numbers are mutually incompatible. e.g. v2 is not compatible |
| 129 | with a v1 or a v3 device. |
| 130 | - Minor version numbers are backwards compatible. e.g. a v2.2 distro will work |
| 131 | on a v2.1 device but not a v2.3 device. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 132 | - The minor version is reset to 1 when the major version is incremented. |
| 133 | |
| 134 | The most obvious/common change that can occur between Android releases is an |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 135 | ICU upgrade, which currently requires a major version increment: Android uses |
| 136 | the ICU4C's native file format for both ICU4C and ICU4J time zone code which is |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 137 | tied to the ICU major version. The main .dat file used by ICU is held in |
| 138 | external/icu and will naturally be updated when ICU is updated. Less obviously, |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 139 | the time zone data set version code and files must be updated as well. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 140 | |
| 141 | Other examples of changes that affect format versioning: |
| 142 | |
| 143 | Major version increment: |
| 144 | - A non-backwards compatible change to the tzdata or tzlookup.xml files used |
| 145 | by bionic / libcore. |
| 146 | - Removal of an existing file from the distro. |
| 147 | |
| 148 | Minor version increment: |
| 149 | - Backwards compatible changes: |
| 150 | - A new file in the distro. |
| 151 | - Additional required data in an existing file (e.g. a backwards compatible |
| 152 | change to tzdata / tzlookup.xml). |
| 153 | |
| 154 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 155 | Changing the Time Zone Data Set Version |
| 156 | --------------------------------------- |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 157 | |
Neil Fuller | 231c68c | 2018-11-28 22:37:30 +0000 | [diff] [blame] | 158 | 1) Modify libcore/luni/src/main/java/libcore/timezone/TzDataSetVersion.java |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 159 | - CURRENT_FORMAT_MAJOR_VERSION, CURRENT_FORMAT_MINOR_VERSION |
Neil Fuller | 231c68c | 2018-11-28 22:37:30 +0000 | [diff] [blame] | 160 | 2) Run update-tzdata.py to regenerate the system/timezone/output_data, |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 161 | system/timezone/testing/data, external/icu runtime files and testing equivalents. |
| 162 | 3) Build/flash a device image with the changes and run CTS tests: |
| 163 | atest CtsHostTzDataTests |
| 164 | atest CtsLibcoreTestCases |
Neil Fuller | 231c68c | 2018-11-28 22:37:30 +0000 | [diff] [blame] | 165 | 4) Run non-CTS test cases: |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 166 | atest FrameworksServicesTests:com.android.server.timezone |
| 167 | 5) Upload, review, submit the changes from system/timezone and libcore. |
| 168 | Note: you may have changes in external/icu/ but usually there is no need to update |
| 169 | external/icu as only a timestamp in zoneinfo64.txt should have changed. |
Neil Fuller | 3830d70 | 2017-08-18 17:03:59 +0100 | [diff] [blame] | 170 | |
Neil Fuller | 7a69971 | 2019-04-16 15:11:59 +0100 | [diff] [blame] | 171 | REMINDER: Any prebuilt apks / apex files (i.e. ones that that contain time zone files) |
| 172 | will also need to be regenerated after this change. |
Neil Fuller | 86e72c5 | 2017-06-12 15:36:06 +0100 | [diff] [blame] | 173 | |