Update the "host" bionic code tzdata lookup logic

The "if defined(__ANDROID__)" else branch is there to support
bionic when running on host environments.

The code now checks the
${ANDROID_RUNTIME_ROOT}/etc/tz/tzdata path as well.

This is similar to the current on-device expectations.

Eventually, we may remove the /system / ANDROID_ROOT cases.

Bug: 119293618
Test: build only
Change-Id: I8310f7b5a1c14567a648673970c636c7c84ff818
This commit is contained in:
Neil Fuller 2018-12-14 16:02:07 +00:00
parent c975355066
commit 2e967fcbab
1 changed files with 7 additions and 2 deletions

View File

@ -228,13 +228,18 @@ int __bionic_open_tzdata(const char* olson_id, int32_t* entry_length) {
if (fd >= 0) return fd; if (fd >= 0) return fd;
#else #else
// On the host, we don't expect those locations to exist, and we're not // On the host, we don't expect those locations to exist, and we're not
// worried about security so we trust $ANDROID_DATA and $ANDROID_ROOT to // worried about security so we trust $ANDROID_DATA, $ANDROID_RUNTIME_ROOT
// point us in the right direction. // and $ANDROID_ROOT to point us in the right direction.
char* path = make_path("ANDROID_DATA", "/misc/zoneinfo/current/tzdata"); char* path = make_path("ANDROID_DATA", "/misc/zoneinfo/current/tzdata");
fd = __bionic_open_tzdata_path(path, olson_id, entry_length); fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
free(path); free(path);
if (fd >= 0) return fd; 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"); path = make_path("ANDROID_ROOT", "/usr/share/zoneinfo/tzdata");
fd = __bionic_open_tzdata_path(path, olson_id, entry_length); fd = __bionic_open_tzdata_path(path, olson_id, entry_length);
free(path); free(path);