Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36bc1ea8 authored by Neil Fuller's avatar Neil Fuller
Browse files

Use Android data for MCC-based time zone lookup

Instead of using IANA's time zone ordering from zone.tab,
use Android data for MCC-based time zone lookup.

This allows us to remove a code hack for Australia (
which was forcing the use of Australia/Sydney over the
Australia/Lord_Howe given in the IANA data) and
improves a few others. It also means that the selection
is controlled in files mastered by Android and not files
taken directly from IANA.

With 2017b rules data it means the following
differences from prior behavior:

[ISO code]: Old answer, New answer.

[fm]:  Old: Pacific/Chuuk, New: Pacific/Pohnpei
[ru]:  Old: Europe/Kaliningrad, New: Europe/Moscow
[um]:  Old: Pacific/Midway, New: Pacific/Wake
[uz]:  Old: Asia/Samarkand, New: Asia/Tashkent

In all cases these are the zone IDs understood to cover the
region's capital.

This change only affects time zone lookups when only
the MCC is known (i.e. in the absence of NITZ).

Bug: 36971201
Bug: 62418027
Test: All known country ISO codes (and some unknown) tried
Change-Id: I7ee2d133802d2d91f36b247b05974c77abb957dc
parent adec655b
Loading
Loading
Loading
Loading
+3 −19
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import com.android.internal.app.LocaleStore;
import com.android.internal.app.LocaleStore.LocaleInfo;

import libcore.icu.ICU;
import libcore.icu.TimeZoneNames;
import libcore.util.TimeZoneFinder;

import java.util.ArrayList;
import java.util.Arrays;
@@ -94,24 +94,8 @@ public final class MccTable {
        if (entry == null) {
            return null;
        }
        Locale locale = new Locale("", entry.mIso);
        String[] tz = TimeZoneNames.forLocale(locale);
        if (tz.length == 0) return null;

        String zoneName = tz[0];

        /* Use Australia/Sydney instead of Australia/Lord_Howe for Australia.
         * http://b/33228250
         * Todo: remove the code, see b/62418027
         */
        if (mcc == 505  /* Australia / Norfolk Island */) {
            for (String zone : tz) {
                if (zone.contains("Sydney")) {
                    zoneName = zone;
                }
            }
        }
        return zoneName;
        final String lowerCaseCountryCode = entry.mIso;
        return TimeZoneFinder.getInstance().lookupDefaultTimeZoneIdByCountry(lowerCaseCountryCode);
    }

    /**