summaryrefslogtreecommitdiff
path: root/libc/tzcode/bionic.cpp
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2019-08-25 12:20:54 -0700
committerScott Lobdell <slobdell@google.com>2019-08-25 12:20:54 -0700
commit4f9bfdcaca2414c8959986f0a4d73f16cb15e1c4 (patch)
tree540bab5498d276cbbfad24c48a7ff989ee8b920a /libc/tzcode/bionic.cpp
parentbfda022dd6fbbcea60e9f52496d90ece514b32da (diff)
parentf77cc9b224c35fa7d1d71e7c374ef19e47b5f6a5 (diff)
Merge RP1A.190822.001
Change-Id: Iaf90835a99d87f6246798efd2cea6fe9f750ea18
Diffstat (limited to 'libc/tzcode/bionic.cpp')
-rw-r--r--libc/tzcode/bionic.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/libc/tzcode/bionic.cpp b/libc/tzcode/bionic.cpp
index 1742d7941..6d84303a4 100644
--- a/libc/tzcode/bionic.cpp
+++ b/libc/tzcode/bionic.cpp
@@ -199,37 +199,36 @@ static int __bionic_open_tzdata_path(const char* path,
int __bionic_open_tzdata(const char* olson_id, int32_t* entry_length) {
int fd;
-#if defined(__ANDROID__)
- // On Android devices, try the four hard-coded locations in order.
- //
+ // Try the three locations for the tzdata file in a strict order:
// 1: The O-MR1 time zone updates via APK update mechanism. This is
- // tried first because it allows us to test that the time zone updates
- // via APK mechanism still works even on devices with the time zone
- // module.
+ // tried first because it allows us to test that the time zone updates
+ // via APK mechanism still works even on devices with the time zone
+ // module.
+ // 2: The time zone data module which contains the main copy. This is the
+ // common case.
+ // 3: The ultimate fallback: the non-updatable copy in /system.
+
+#if defined(__ANDROID__)
+ // On Android devices, bionic has to work even if exec takes place without
+ // environment variables set. So, all paths are hardcoded here.
+
fd = __bionic_open_tzdata_path("/data/misc/zoneinfo/current/tzdata",
olson_id, entry_length);
if (fd >= 0) return fd;
- // 2: The time zone data module which may contain newer data on
- // devices that support module updates.
fd = __bionic_open_tzdata_path("/apex/com.android.tzdata/etc/tz/tzdata",
olson_id, entry_length);
if (fd >= 0) return fd;
- // 3: The runtime module, which should exist even on devices that
- // do not support APEX file updates.
- fd = __bionic_open_tzdata_path("/apex/com.android.runtime/etc/tz/tzdata",
- olson_id, entry_length);
- if (fd >= 0) return fd;
-
- // 4: The ultimate fallback: the non-updatable copy in /system.
fd = __bionic_open_tzdata_path("/system/usr/share/zoneinfo/tzdata",
olson_id, entry_length);
if (fd >= 0) return fd;
#else
- // On the host, we don't expect those locations to exist, and we're not
- // worried about security so we trust $ANDROID_DATA, $ANDROID_RUNTIME_ROOT,
- // $ANDROID_TZDATA_ROOT, and $ANDROID_ROOT to point us in the right direction.
+ // On the host, we don't expect the hard-coded locations above to exist, and
+ // we're not worried about security so we trust $ANDROID_DATA,
+ // $ANDROID_TZDATA_ROOT, and $ANDROID_ROOT to point us in the right direction
+ // instead.
+
char* path = make_path("ANDROID_DATA", "/misc/zoneinfo/current/tzdata");
fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
free(path);
@@ -240,11 +239,6 @@ int __bionic_open_tzdata(const char* olson_id, int32_t* entry_length) {
free(path);
if (fd >= 0) return fd;
- path = make_path("ANDROID_RUNTIME_ROOT", "/etc/tz/tzdata");
- fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
- free(path);
- if (fd >= 0) return fd;
-
path = make_path("ANDROID_ROOT", "/usr/share/zoneinfo/tzdata");
fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
free(path);