Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Habersack <grendel@twistedcode.net>2020-09-04 16:55:16 +0300
committerGitHub <noreply@github.com>2020-09-04 16:55:16 +0300
commit413dcc9292a181be607514fba765028428423dac (patch)
treedeabfd446cd0cb24ae39aca7fce010eca34be205
parent5756e65a5c23784e68b494eb4b332e0eb647f40c (diff)
[Android] Enable access to up-to-date tzdata on Android 10+ (#20349)
Context: https://source.android.com/devices/architecture/modular-system/runtime#time-zone-data-interactions Context: https://source.android.com/devices/tech/config/timezone-rules#timezone-apex Context: https://android.googlesource.com/platform/frameworks/base/+/a1ae02519d6fb5de636fc8728dec7cb9b14de356 Maybe helps with: https://github.com/xamarin/xamarin-android/issues/5080 Add support to read ICANN timezone data from two new locations found on devices running Android 10+. The data in the previously searched location still exists but it's most likely out of date. On Android 10+ tzdata updates will be derived via an APEX TimeData package update, whose data directory this commit sets as the first location to be searched. This commit potentially fixes the Xamarin.Android issue mentioned above. "Potentially" because I can't be sure this is what's causing it since I'm unable to reproduce the issue locally. However, out-of-date tz database seems to be the most probable cause.
-rw-r--r--mcs/class/corlib/System/TimeZoneInfo.Android.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/mcs/class/corlib/System/TimeZoneInfo.Android.cs b/mcs/class/corlib/System/TimeZoneInfo.Android.cs
index fa9f73a4dc6..792a9fe2bc3 100644
--- a/mcs/class/corlib/System/TimeZoneInfo.Android.cs
+++ b/mcs/class/corlib/System/TimeZoneInfo.Android.cs
@@ -58,10 +58,16 @@ namespace System {
* https://android.googlesource.com/platform/libcore/+/master/luni/src/main/java/libcore/util/ZoneInfoDB.java
*
* This is needed in order to read Android v4.3 tzdata files.
+ *
+ * Android 10+ moved the up-to-date tzdata location to a module updatable via the Google Play Store and the
+ * database location changed (https://source.android.com/devices/architecture/modular-system/runtime#time-zone-data-interactions)
+ * The older locations still exist (at least the `/system/usr/share/zoneinfo` one) but they won't be updated.
*/
sealed class AndroidTzData : IAndroidTimeZoneDB {
internal static readonly string[] Paths = new string[]{
+ GetApexTimeDataRoot () + "/etc/tz/tzdata", // Android 10+, TimeData module where the updates land
+ GetApexRuntimeRoot () + "/etc/tz/tzdata", // Android 10+, Fallback location if the above isn't found or corrupted
Environment.GetEnvironmentVariable ("ANDROID_DATA") + "/misc/zoneinfo/tzdata",
Environment.GetEnvironmentVariable ("ANDROID_ROOT") + "/usr/share/zoneinfo/tzdata",
};
@@ -98,6 +104,26 @@ namespace System {
get {return zoneTab;}
}
+ static string GetApexTimeDataRoot ()
+ {
+ string ret = Environment.GetEnvironmentVariable ("ANDROID_TZDATA_ROOT");
+ if (!String.IsNullOrEmpty (ret)) {
+ return ret;
+ }
+
+ return "/apex/com.android.tzdata";
+ }
+
+ static string GetApexRuntimeRoot ()
+ {
+ string ret = Environment.GetEnvironmentVariable ("ANDROID_RUNTIME_ROOT");
+ if (!String.IsNullOrEmpty (ret)) {
+ return ret;
+ }
+
+ return "/apex/com.android.runtime";
+ }
+
bool LoadData (string path)
{
if (!File.Exists (path))