Commit graph

18 commits

Author SHA1 Message Date
Elliott Hughes
31fc69f67f Fix tzalloc(nullptr) and add a test.
This works (by reading /etc/localtime) on NetBSD, but not on Android
since we have no such file. Fix that by using our equivalent system
property instead.

Also s/time zone/timezone/ in documentation and comments. We've always
been inconsistent about this (as is upstream in code comments and
documentation) but it seems especially odd now we expose a _type_ that
spells it "timezone" to talk of "time zone" even as we're describing
that type and its associated functions.

Bug: https://github.com/chronotope/chrono/issues/499
Test: treehugger
Change-Id: I142995a3ab4deff1073a0aa9e63ce8eac850b93d
2023-06-22 09:51:01 -07:00
Almaz Mingaleev
da75bb637d Revert "Revert "Do not look for tzdata file in /data.""
This reverts commit 4e013233b8.

Issue was in unexpected returned fd and errno value combination.
See comments in bionic.cpp and time_test.cpp.

Bug: 236967833
Fix: 236967833

Test: atest CtsBionicTestCases
Test: atest toybox-tests

Change-Id: I51b3e1527ff16b2a6ea4d6fedf8102019f7fd896
2022-06-30 09:39:53 +01:00
Almaz Mingaleev
4e013233b8 Revert "Do not look for tzdata file in /data."
This reverts commit e9a20895ea.

Reason for revert: b/236967833. Breaks toybox tests

Change-Id: Ia9832ff62b6d700673f41f0c1c013090a21fe5ec
2022-06-23 16:41:24 +00:00
Almaz Mingaleev
e9a20895ea Do not look for tzdata file in /data.
That was place where APK update mechanism placed tzdata file. Now
the mechanism is removed, so no need to look for tzdata there.

Bug: 148144561

Test: atest CtsBionicTestCases
Test: atest BionicTzdbConsistencyTest
Change-Id: I584400a75651cf24a25df74c7007fcd584838395
2022-06-15 10:02:44 +01:00
Neil Fuller
9b7338c6bb Merge "Track name changes in the tzdata format" 2020-07-22 09:50:10 +00:00
Elliott Hughes
528e29d91c Simplify tzdata fallback logic.
It's a historical accident that we try all the other files even if a
higher-priority file doesn't contain the sought-for olson id. Stop
doing that.

Also remove a TODO that has never been warranted, and add one that it
will be many years before anyone can do anything about it, but by that
time the historical knowledge may have been lost.

Bug: http://b/159613340
Test: treehugger
Change-Id: I873579268753c84b0bb721ea56f71ba64506d45a
2020-06-22 12:55:12 -07:00
Neil Fuller
2b76a94c68 Track name changes in the tzdata format
The tzdata format has changed:

Firstly, there is now a "final_offset", which serves as a pointer to the
beginning of the section after the last known section. The pointer means
that file size is no longer a factor when reading the last section and
new sections could be added to the end of the file in future in a
backwards compatible way.

Secondly, since nothing uses zone.tab on Android it is being removed and
the zonetab_offset is replaced by final_offset.

The net effect for bionic is zero besides some comment / name changes.

Test: build only
Change-Id: Ia315083879c891f2d3fc84cf48e304c323ca89f2
2020-05-21 14:59:19 +01:00
Neil Fuller
41636ca1ac Remove bionic refs to runtime module tz files
The tzdata file is being removed from the runtime mainline module
in an upcoming commit. This commit removes the bionic references
to it.

This commit also contains general comment tidy-ups.

Bug: 132168458
Test: build only
Change-Id: I83cd9ff756b36e1d1222b7830f97c8bde2885ce4
2019-06-10 15:09:15 +01:00
Neil Fuller
81b3bdd681 Use the ANDROID_TZDATA_ROOT environment variable
To mirror device code more closely, look for time zone data using
ANDROID_TZDATA_ROOT on host. For device usecases the path is still
hardcoded.

Bug: 128422035
Test: build only
Change-Id: I5762745349338bcc3e3a173c1c9b18ea5a3324dd
2019-03-13 15:22:47 +00:00
Neil Fuller
2e967fcbab 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
2019-01-07 21:08:37 +00:00
Neil Fuller
a50e51ac96 Find tzdata in the runtime module before /system
Look for the tzdata file in the runtime module before looking
in /system. It is still an open question how the removal of
tzdata will be handled, if at all. Until it is worked out it
will be duplicated.

Bug: 119293618
Bug: 119390260
Test: build / boot
Change-Id: I7e14ef41d0ec226caa595c56be61df5ecf50c382
2018-12-07 09:14:03 +00:00
Neil Fuller
9268977f2d Track move of APEX module tz files under etc/tz
The same prebuilts will be used in both runtime and time zone
modules. Having the rules put the files in etc/tz/ will make
them more appropriate for the runtime module.

Bug: 119026403
Test: build /boot only
Change-Id: Ia1370457e9d1547b35ed56bb385213d3727c8b9a
2018-12-06 14:33:12 +00:00
Neil Fuller
fd522d0132 Finalize the name of the apex package
The package name in the manifest.json is changing to
remove apex so the hardcoded path must change.

Bug: 119026403
Test: build
Change-Id: I906b595a1325b40f8af8c37d7d08cd543c988cc8
2018-11-07 15:42:43 +00:00
Neil Fuller
7dfeaf896d Changes to support loading tz data from APEX
The changes needed to pick up time zone data files from
a mounted APEX directory. Code that looks for time zone
data now looks in a new location after checking for
data installed by the time zone updates via APK feature.

This hasn't been tested in combination with a real APEX but
it shouldn't do anything bad if the new path does not exist.

Bug: 115612964
Test: CTS: run cts-dev -m CtsBionicTests
Test: Build / boot without APEX support
Change-Id: I56ae50e26f2cbfa0e537029a0e6f679fa2394327
2018-10-30 20:19:35 +00:00
Dan Albert
1c78cb0fee Add missing includes.
Test: mma
Bug: None
Change-Id: I0221b213e08d07cc5ac0b704a86e98ae8c0f456f
2017-10-11 11:25:52 -07:00
Christopher Ferris
35dfaa89de Fix incorrect check.
Bug: 37347846

Test: No error on data +%s
Change-Id: I7e88ea842af29ce4a366c25a3f79c09b63a25004
2017-04-14 12:58:56 -07:00
Elliott Hughes
a01cbaa87d Address review comments on the bionic tzdata loader.
Bug: N/A
Test: ran tests
Change-Id: Ia7e27a2f93fe814e46b0912ce358b72651192173
2017-04-12 14:06:29 -07:00
Elliott Hughes
0e8616a37a Move localtime.c over to CachedProperty.
Since localtime.c is C, this entails pulling our code out into its own
C++ file, which we should probably have done years ago anyway.

Bug: N/A
Test: ran tests, and manually tested via Settings
Change-Id: Ifc787a553e8f739a87641a2d35321aca40a47286
2017-04-11 14:44:51 -07:00