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

Commit 87909342 authored by Neil Fuller's avatar Neil Fuller Committed by android-build-merger
Browse files

Merge "More tidy up / test refactoring"

am: c7cb9361

Change-Id: Ibee585013b0d0714d9fcc6b67a9a9efe99ad80fb
parents 536a22fe c7cb9361
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.internal.telephony;
package com.android.internal.telephony;


import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.os.SystemClock;
import android.os.SystemClock;
@@ -60,7 +62,7 @@ public interface NitzStateMachine {
    /**
    /**
     * Handle a new NITZ signal being received.
     * Handle a new NITZ signal being received.
     */
     */
    void handleNitzReceived(TimestampedValue<NitzData> nitzSignal);
    void handleNitzReceived(@NonNull TimestampedValue<NitzData> nitzSignal);


    /**
    /**
     * Handle the user putting the device into or out of airplane mode
     * Handle the user putting the device into or out of airplane mode
@@ -81,6 +83,7 @@ public interface NitzStateMachine {
    /**
    /**
     * Returns the last NITZ data that was cached.
     * Returns the last NITZ data that was cached.
     */
     */
    @Nullable
    NitzData getCachedNitzData();
    NitzData getCachedNitzData();


    /**
    /**
@@ -106,7 +109,7 @@ public interface NitzStateMachine {
         */
         */
        boolean getIgnoreNitz();
        boolean getIgnoreNitz();


        String getNetworkCountryIsoForPhone();
        @Nullable String getNetworkCountryIsoForPhone();


        /**
        /**
         * Returns the same value as {@link SystemClock#elapsedRealtime()}.
         * Returns the same value as {@link SystemClock#elapsedRealtime()}.
@@ -135,7 +138,7 @@ public interface NitzStateMachine {
        private final TelephonyManager mTelephonyManager;
        private final TelephonyManager mTelephonyManager;
        private final ContentResolver mCr;
        private final ContentResolver mCr;


        DeviceStateImpl(GsmCdmaPhone phone) {
        public DeviceStateImpl(GsmCdmaPhone phone) {
            mPhone = phone;
            mPhone = phone;


            Context context = phone.getContext();
            Context context = phone.getContext();
@@ -166,6 +169,7 @@ public interface NitzStateMachine {
        }
        }


        @Override
        @Override
        @Nullable
        public String getNetworkCountryIsoForPhone() {
        public String getNetworkCountryIsoForPhone() {
            return mTelephonyManager.getNetworkCountryIsoForPhone(mPhone.getPhoneId());
            return mTelephonyManager.getNetworkCountryIsoForPhone(mPhone.getPhoneId());
        }
        }
+2 −2
Original line number Original line Diff line number Diff line
@@ -204,8 +204,8 @@ public final class NitzStateMachineImpl implements NitzStateMachine {


                zoneId = null;
                zoneId = null;
            } else {
            } else {
                OffsetResult lookupResult = mTimeZoneLookupHelper.lookupByNitzCountry(
                OffsetResult lookupResult =
                        nitzData, isoCountryCode);
                        mTimeZoneLookupHelper.lookupByNitzCountry(nitzData, isoCountryCode);
                if (DBG) {
                if (DBG) {
                    Rlog.d(LOG_TAG, "updateTimeZoneFromCountryAndNitz: using"
                    Rlog.d(LOG_TAG, "updateTimeZoneFromCountryAndNitz: using"
                            + " lookupByNitzCountry(nitzData, isoCountryCode),"
                            + " lookupByNitzCountry(nitzData, isoCountryCode),"
+0 −17
Original line number Original line Diff line number Diff line
@@ -165,8 +165,6 @@ public class TimeZoneLookupHelper {
        }
        }
    }
    }


    private static final int MS_PER_HOUR = 60 * 60 * 1000;

    /** The last CountryTimeZones object retrieved. */
    /** The last CountryTimeZones object retrieved. */
    private CountryTimeZones mLastCountryTimeZones;
    private CountryTimeZones mLastCountryTimeZones;


@@ -296,21 +294,6 @@ public class TimeZoneLookupHelper {
        return countryTimeZones == null ? null : countryTimeZones.getDefaultTimeZoneId();
        return countryTimeZones == null ? null : countryTimeZones.getDefaultTimeZoneId();
    }
    }


    /**
     * Finds a time zone using only information present in the supplied {@link NitzData} object.
     * This is a static method for use by {@link ServiceStateTracker}.
     *
     * <p><em>Note:</em> Because multiple time zones can have the same offset / DST state at a given
     * time this process is error prone; an arbitrary match is returned when there are multiple
     * candidates. The algorithm can also return a non-exact match by assuming that the DST
     * information provided by NITZ is incorrect. This method can return {@code null} if no matching
     * time zones are found.
     */
    static TimeZone guessZoneByNitzStatic(NitzData nitzData) {
        OffsetResult result = lookupByNitzStatic(nitzData);
        return result != null ? result.getTimeZone() : null;
    }

    private static OffsetResult lookupByNitzStatic(NitzData nitzData) {
    private static OffsetResult lookupByNitzStatic(NitzData nitzData) {
        int utcOffsetMillis = nitzData.getLocalOffsetMillis();
        int utcOffsetMillis = nitzData.getLocalOffsetMillis();
        long timeMillis = nitzData.getCurrentTimeInMillis();
        long timeMillis = nitzData.getCurrentTimeInMillis();
Loading