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

Commit d6c120ff authored by Geoffrey Boullanger's avatar Geoffrey Boullanger
Browse files

Fix usage of TelephonyNetworkFinder after making it a SystemApi

This changes the way TelephonyNetworkFinder is accessed. Instead of accessing TelephonyLookup and requesting the finder from there it is accessed directly from the finder itself via the static getInstance() method.

Flag: android.timezone.flags.expose_time_zone_system_api
Test: atest FrameworksTelephonyTests
Bug: 432239933
Bug: 432471550
Change-Id: I70a1973d82b92b1bf2f915d3644a131972d655b3
parent 46fcbb1a
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.timezone.MobileCountries;
import android.timezone.TelephonyLookup;
import android.timezone.TelephonyNetworkFinder;
import android.util.LocalLog;

@@ -837,8 +836,7 @@ public class LocaleTracker extends Handler {
        synchronized (LocaleTracker.class) {
            if ((telephonyNetworkFinder = sTelephonyNetworkFinder) == null) {
                sTelephonyNetworkFinder =
                        telephonyNetworkFinder =
                                TelephonyLookup.getInstance().getTelephonyNetworkFinder();
                        telephonyNetworkFinder = TelephonyNetworkFinder.getInstance();
            }
        }

@@ -860,8 +858,7 @@ public class LocaleTracker extends Handler {
        synchronized (LocaleTracker.class) {
            if ((telephonyNetworkFinder = sTelephonyNetworkFinder) == null) {
                sTelephonyNetworkFinder =
                        telephonyNetworkFinder =
                                TelephonyLookup.getInstance().getTelephonyNetworkFinder();
                        telephonyNetworkFinder = TelephonyNetworkFinder.getInstance();
            }
        }

+3 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.os.Build;
import android.os.SystemProperties;
import android.text.TextUtils;
import android.timezone.MobileCountries;
import android.timezone.TelephonyLookup;
import android.timezone.TelephonyNetworkFinder;

import com.android.internal.annotations.GuardedBy;
@@ -204,8 +203,8 @@ public final class MccTable {

        synchronized (MccTable.class) {
            if ((telephonyNetworkFinder = sTelephonyNetworkFinder) == null) {
                sTelephonyNetworkFinder = telephonyNetworkFinder =
                        TelephonyLookup.getInstance().getTelephonyNetworkFinder();
                sTelephonyNetworkFinder =
                        telephonyNetworkFinder = TelephonyNetworkFinder.getInstance();
            }
        }

@@ -252,7 +251,7 @@ public final class MccTable {
    private static String countryCodeForMccMncNoFallback(MccMnc mccMnc) {
        synchronized (MccTable.class) {
            if (sTelephonyNetworkFinder == null) {
                sTelephonyNetworkFinder = TelephonyLookup.getInstance().getTelephonyNetworkFinder();
                sTelephonyNetworkFinder = TelephonyNetworkFinder.getInstance();
            }
        }
        if (sTelephonyNetworkFinder == null) {
+4 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.internal.telephony.NitzData;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.Locale;
import java.util.Objects;

/**
@@ -161,7 +162,6 @@ public final class TimeZoneLookupHelper {
        if (dstAdjustmentMillis == null) {
            return countryTimeZones.lookupByOffsetWithBias(nitzData.getCurrentTimeInMillis(), bias,
                    nitzData.getLocalOffsetMillis());

        } else {
            // We don't try to match the exact DST offset given, we just use it to work out if
            // the country is in DST.
@@ -436,7 +436,9 @@ public final class TimeZoneLookupHelper {
        // be strong consistency across calls.
        synchronized (this) {
            if (mLastCountryTimeZones != null) {
                if (mLastCountryTimeZones.matchesCountryCode(isoCountryCode)) {
                if (mLastCountryTimeZones
                        .getCountryIso()
                        .equals(isoCountryCode.toLowerCase(Locale.US))) {
                    return mLastCountryTimeZones;
                }
            }
+1 −3
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.platform.test.annotations.UsesFlags;
import android.platform.test.flag.junit.FlagsParameterization;
import android.platform.test.flag.junit.SetFlagsRule;
import android.timezone.MobileCountries;
import android.timezone.TelephonyLookup;
import android.timezone.TelephonyNetworkFinder;

import androidx.test.InstrumentationRegistry;
@@ -154,8 +153,7 @@ public class MccTableTest {
    public void telephonyFinder_shouldBeIdenticalToTelephonyMccTable() {
        assumeTrue(Flags.useI18nForMccMapping());

        TelephonyNetworkFinder telephonyNetworkFinder =
                TelephonyLookup.getInstance().getTelephonyNetworkFinder();
        TelephonyNetworkFinder telephonyNetworkFinder = TelephonyNetworkFinder.getInstance();

        MccTable.getAllMccEntries().forEach(mccEntry -> {
                MobileCountries telephonyCountry =