Loading src/java/com/android/internal/telephony/NitzStateMachine.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -134,11 +134,11 @@ public interface NitzStateMachine { private static final int NITZ_UPDATE_DIFF_DEFAULT = 2000; private static final int NITZ_UPDATE_DIFF_DEFAULT = 2000; private final int mNitzUpdateDiff; private final int mNitzUpdateDiff; private final GsmCdmaPhone mPhone; private final Phone mPhone; private final TelephonyManager mTelephonyManager; private final TelephonyManager mTelephonyManager; private final ContentResolver mCr; private final ContentResolver mCr; public DeviceStateImpl(GsmCdmaPhone phone) { public DeviceStateImpl(Phone phone) { mPhone = phone; mPhone = phone; Context context = phone.getContext(); Context context = phone.getContext(); Loading src/java/com/android/internal/telephony/NitzStateMachineImpl.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -91,7 +91,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // Miscellaneous dependencies and helpers not related to detection state. // Miscellaneous dependencies and helpers not related to detection state. private final LocalLog mTimeLog = new LocalLog(30); private final LocalLog mTimeLog = new LocalLog(30); private final LocalLog mTimeZoneLog = new LocalLog(30); private final LocalLog mTimeZoneLog = new LocalLog(30); private final GsmCdmaPhone mPhone; private final Phone mPhone; private final DeviceState mDeviceState; private final DeviceState mDeviceState; private final TimeServiceHelper mTimeServiceHelper; private final TimeServiceHelper mTimeServiceHelper; private final TimeZoneLookupHelper mTimeZoneLookupHelper; private final TimeZoneLookupHelper mTimeZoneLookupHelper; Loading @@ -99,7 +99,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { private final PowerManager.WakeLock mWakeLock; private final PowerManager.WakeLock mWakeLock; private static final String WAKELOCK_TAG = "NitzStateMachine"; private static final String WAKELOCK_TAG = "NitzStateMachine"; public NitzStateMachineImpl(GsmCdmaPhone phone) { public NitzStateMachineImpl(Phone phone) { this(phone, this(phone, new TimeServiceHelperImpl(phone.getContext()), new TimeServiceHelperImpl(phone.getContext()), new DeviceStateImpl(phone), new DeviceStateImpl(phone), Loading @@ -107,7 +107,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { } } @VisibleForTesting @VisibleForTesting public NitzStateMachineImpl(GsmCdmaPhone phone, TimeServiceHelper timeServiceHelper, public NitzStateMachineImpl(Phone phone, TimeServiceHelper timeServiceHelper, DeviceState deviceState, TimeZoneLookupHelper timeZoneLookupHelper) { DeviceState deviceState, TimeZoneLookupHelper timeZoneLookupHelper) { mPhone = phone; mPhone = phone; Loading src/java/com/android/internal/telephony/TimeZoneLookupHelper.java +32 −16 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,8 @@ import static com.android.internal.telephony.TimeZoneLookupHelper.CountryResult. import static com.android.internal.telephony.TimeZoneLookupHelper.CountryResult.QUALITY_MULTIPLE_ZONES_SAME_OFFSET; import static com.android.internal.telephony.TimeZoneLookupHelper.CountryResult.QUALITY_MULTIPLE_ZONES_SAME_OFFSET; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.icu.util.TimeZone; import android.icu.util.TimeZone; import android.text.TextUtils; import android.text.TextUtils; Loading @@ -44,12 +46,13 @@ public class TimeZoneLookupHelper { public static final class OffsetResult { public static final class OffsetResult { /** A zone that matches the supplied criteria. See also {@link #mIsOnlyMatch}. */ /** A zone that matches the supplied criteria. See also {@link #mIsOnlyMatch}. */ @NonNull private final TimeZone mTimeZone; private final TimeZone mTimeZone; /** True if there is only one matching time zone for the supplied criteria. */ /** True if there is only one matching time zone for the supplied criteria. */ private final boolean mIsOnlyMatch; private final boolean mIsOnlyMatch; public OffsetResult(TimeZone timeZone, boolean isOnlyMatch) { public OffsetResult(@NonNull TimeZone timeZone, boolean isOnlyMatch) { mTimeZone = Objects.requireNonNull(timeZone); mTimeZone = Objects.requireNonNull(timeZone); mIsOnlyMatch = isOnlyMatch; mIsOnlyMatch = isOnlyMatch; } } Loading @@ -57,6 +60,7 @@ public class TimeZoneLookupHelper { /** /** * Returns a time zone that matches the supplied criteria. * Returns a time zone that matches the supplied criteria. */ */ @NonNull public TimeZone getTimeZone() { public TimeZone getTimeZone() { return mTimeZone; return mTimeZone; } } Loading Loading @@ -89,7 +93,7 @@ public class TimeZoneLookupHelper { @Override @Override public String toString() { public String toString() { return "OffsetResult{" return "OffsetResult{" + "mTimeZone=" + mTimeZone + "mTimeZone(Id)=" + mTimeZone.getID() + ", mIsOnlyMatch=" + mIsOnlyMatch + ", mIsOnlyMatch=" + mIsOnlyMatch + '}'; + '}'; } } Loading @@ -111,6 +115,7 @@ public class TimeZoneLookupHelper { public static final int QUALITY_MULTIPLE_ZONES_DIFFERENT_OFFSETS = 4; public static final int QUALITY_MULTIPLE_ZONES_DIFFERENT_OFFSETS = 4; /** A time zone to use for the country. */ /** A time zone to use for the country. */ @NonNull public final String zoneId; public final String zoneId; /** /** Loading @@ -125,8 +130,8 @@ public class TimeZoneLookupHelper { */ */ private final String mDebugInfo; private final String mDebugInfo; public CountryResult(String zoneId, @Quality int quality, String debugInfo) { public CountryResult(@NonNull String zoneId, @Quality int quality, String debugInfo) { this.zoneId = zoneId; this.zoneId = Objects.requireNonNull(zoneId); this.quality = quality; this.quality = quality; mDebugInfo = debugInfo; mDebugInfo = debugInfo; } } Loading Loading @@ -160,6 +165,7 @@ public class TimeZoneLookupHelper { } } /** The last CountryTimeZones object retrieved. */ /** The last CountryTimeZones object retrieved. */ @Nullable private CountryTimeZones mLastCountryTimeZones; private CountryTimeZones mLastCountryTimeZones; public TimeZoneLookupHelper() {} public TimeZoneLookupHelper() {} Loading @@ -172,7 +178,9 @@ public class TimeZoneLookupHelper { * returned in preference to other candidates. This method can return {@code null} if no * returned in preference to other candidates. This method can return {@code null} if no * matching time zones are found. * matching time zones are found. */ */ public OffsetResult lookupByNitzCountry(NitzData nitzData, String isoCountryCode) { @Nullable public OffsetResult lookupByNitzCountry( @NonNull NitzData nitzData, @NonNull String isoCountryCode) { CountryTimeZones countryTimeZones = getCountryTimeZones(isoCountryCode); CountryTimeZones countryTimeZones = getCountryTimeZones(isoCountryCode); if (countryTimeZones == null) { if (countryTimeZones == null) { return null; return null; Loading Loading @@ -204,7 +212,8 @@ public class TimeZoneLookupHelper { * information provided by NITZ is incorrect. This method can return {@code null} if no matching * information provided by NITZ is incorrect. This method can return {@code null} if no matching * time zones are found. * time zones are found. */ */ public OffsetResult lookupByNitz(NitzData nitzData) { @Nullable public OffsetResult lookupByNitz(@NonNull NitzData nitzData) { return lookupByNitzStatic(nitzData); return lookupByNitzStatic(nitzData); } } Loading @@ -214,7 +223,8 @@ public class TimeZoneLookupHelper { * {@code null} can be returned if a problem occurs during lookup, e.g. if the country code is * {@code null} can be returned if a problem occurs during lookup, e.g. if the country code is * unrecognized, if the country is uninhabited, or if there is a problem with the data. * unrecognized, if the country is uninhabited, or if there is a problem with the data. */ */ public CountryResult lookupByCountry(String isoCountryCode, long whenMillis) { @Nullable public CountryResult lookupByCountry(@NonNull String isoCountryCode, long whenMillis) { CountryTimeZones countryTimeZones = getCountryTimeZones(isoCountryCode); CountryTimeZones countryTimeZones = getCountryTimeZones(isoCountryCode); if (countryTimeZones == null) { if (countryTimeZones == null) { // Unknown country code. // Unknown country code. Loading Loading @@ -257,8 +267,8 @@ public class TimeZoneLookupHelper { } } private static boolean countryUsesDifferentOffsets( private static boolean countryUsesDifferentOffsets( long whenMillis, List<TimeZoneMapping> effectiveTimeZoneMappings, long whenMillis, @NonNull List<TimeZoneMapping> effectiveTimeZoneMappings, TimeZone countryDefaultZone) { @NonNull TimeZone countryDefaultZone) { String countryDefaultId = countryDefaultZone.getID(); String countryDefaultId = countryDefaultZone.getID(); int countryDefaultOffset = countryDefaultZone.getOffset(whenMillis); int countryDefaultOffset = countryDefaultZone.getOffset(whenMillis); for (TimeZoneMapping timeZoneMapping : effectiveTimeZoneMappings) { for (TimeZoneMapping timeZoneMapping : effectiveTimeZoneMappings) { Loading Loading @@ -286,13 +296,16 @@ public class TimeZoneLookupHelper { * if a problem occurs during lookup, e.g. if the country code is unrecognized, if the country * if a problem occurs during lookup, e.g. if the country code is unrecognized, if the country * is uninhabited, or if there is a problem with the data. * is uninhabited, or if there is a problem with the data. */ */ public String lookupDefaultTimeZoneIdByCountry(String isoCountryCode) { @Nullable public String lookupDefaultTimeZoneIdByCountry(@NonNull String isoCountryCode) { Objects.requireNonNull(isoCountryCode); CountryTimeZones countryTimeZones = CountryTimeZones countryTimeZones = TimeZoneFinder.getInstance().lookupCountryTimeZones(isoCountryCode); TimeZoneFinder.getInstance().lookupCountryTimeZones(isoCountryCode); return countryTimeZones == null ? null : countryTimeZones.getDefaultTimeZoneId(); return countryTimeZones == null ? null : countryTimeZones.getDefaultTimeZoneId(); } } private static OffsetResult lookupByNitzStatic(NitzData nitzData) { @Nullable private static OffsetResult lookupByNitzStatic(@NonNull NitzData nitzData) { int utcOffsetMillis = nitzData.getLocalOffsetMillis(); int utcOffsetMillis = nitzData.getLocalOffsetMillis(); long timeMillis = nitzData.getCurrentTimeInMillis(); long timeMillis = nitzData.getCurrentTimeInMillis(); Loading @@ -316,7 +329,7 @@ public class TimeZoneLookupHelper { } } private static OffsetResult lookupByInstantOffsetDst(long timeMillis, int utcOffsetMillis, private static OffsetResult lookupByInstantOffsetDst(long timeMillis, int utcOffsetMillis, Boolean isDst) { @Nullable Boolean isDst) { String[] zones = TimeZone.getAvailableIDs(); String[] zones = TimeZone.getAvailableIDs(); TimeZone match = null; TimeZone match = null; Loading Loading @@ -345,8 +358,8 @@ public class TimeZoneLookupHelper { * If {@code isDst} is {@code null} this means the DST state is unknown so DST state is ignored. * If {@code isDst} is {@code null} this means the DST state is unknown so DST state is ignored. * If {@code isDst} is not {@code null} then it is also matched. * If {@code isDst} is not {@code null} then it is also matched. */ */ private static boolean offsetMatchesAtTime(TimeZone timeZone, int totalOffsetMillis, private static boolean offsetMatchesAtTime(@NonNull TimeZone timeZone, int totalOffsetMillis, Boolean isDst, long whenMillis) { @Nullable Boolean isDst, long whenMillis) { int[] offsets = new int[2]; int[] offsets = new int[2]; timeZone.getOffset(whenMillis, false /* local */, offsets); timeZone.getOffset(whenMillis, false /* local */, offsets); Loading @@ -361,7 +374,7 @@ public class TimeZoneLookupHelper { * Returns {@code true} if the supplied (lower-case) ISO country code is for a country known to * Returns {@code true} if the supplied (lower-case) ISO country code is for a country known to * use a raw offset of zero from UTC at the time specified. * use a raw offset of zero from UTC at the time specified. */ */ public boolean countryUsesUtc(String isoCountryCode, long whenMillis) { public boolean countryUsesUtc(@NonNull String isoCountryCode, long whenMillis) { if (TextUtils.isEmpty(isoCountryCode)) { if (TextUtils.isEmpty(isoCountryCode)) { return false; return false; } } Loading @@ -370,7 +383,10 @@ public class TimeZoneLookupHelper { return countryTimeZones != null && countryTimeZones.hasUtcZone(whenMillis); return countryTimeZones != null && countryTimeZones.hasUtcZone(whenMillis); } } private CountryTimeZones getCountryTimeZones(String isoCountryCode) { @Nullable private CountryTimeZones getCountryTimeZones(@NonNull String isoCountryCode) { Objects.requireNonNull(isoCountryCode); // A single entry cache of the last CountryTimeZones object retrieved since there should // A single entry cache of the last CountryTimeZones object retrieved since there should // be strong consistency across calls. // be strong consistency across calls. synchronized (this) { synchronized (this) { Loading Loading
src/java/com/android/internal/telephony/NitzStateMachine.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -134,11 +134,11 @@ public interface NitzStateMachine { private static final int NITZ_UPDATE_DIFF_DEFAULT = 2000; private static final int NITZ_UPDATE_DIFF_DEFAULT = 2000; private final int mNitzUpdateDiff; private final int mNitzUpdateDiff; private final GsmCdmaPhone mPhone; private final Phone mPhone; private final TelephonyManager mTelephonyManager; private final TelephonyManager mTelephonyManager; private final ContentResolver mCr; private final ContentResolver mCr; public DeviceStateImpl(GsmCdmaPhone phone) { public DeviceStateImpl(Phone phone) { mPhone = phone; mPhone = phone; Context context = phone.getContext(); Context context = phone.getContext(); Loading
src/java/com/android/internal/telephony/NitzStateMachineImpl.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -91,7 +91,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { // Miscellaneous dependencies and helpers not related to detection state. // Miscellaneous dependencies and helpers not related to detection state. private final LocalLog mTimeLog = new LocalLog(30); private final LocalLog mTimeLog = new LocalLog(30); private final LocalLog mTimeZoneLog = new LocalLog(30); private final LocalLog mTimeZoneLog = new LocalLog(30); private final GsmCdmaPhone mPhone; private final Phone mPhone; private final DeviceState mDeviceState; private final DeviceState mDeviceState; private final TimeServiceHelper mTimeServiceHelper; private final TimeServiceHelper mTimeServiceHelper; private final TimeZoneLookupHelper mTimeZoneLookupHelper; private final TimeZoneLookupHelper mTimeZoneLookupHelper; Loading @@ -99,7 +99,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { private final PowerManager.WakeLock mWakeLock; private final PowerManager.WakeLock mWakeLock; private static final String WAKELOCK_TAG = "NitzStateMachine"; private static final String WAKELOCK_TAG = "NitzStateMachine"; public NitzStateMachineImpl(GsmCdmaPhone phone) { public NitzStateMachineImpl(Phone phone) { this(phone, this(phone, new TimeServiceHelperImpl(phone.getContext()), new TimeServiceHelperImpl(phone.getContext()), new DeviceStateImpl(phone), new DeviceStateImpl(phone), Loading @@ -107,7 +107,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { } } @VisibleForTesting @VisibleForTesting public NitzStateMachineImpl(GsmCdmaPhone phone, TimeServiceHelper timeServiceHelper, public NitzStateMachineImpl(Phone phone, TimeServiceHelper timeServiceHelper, DeviceState deviceState, TimeZoneLookupHelper timeZoneLookupHelper) { DeviceState deviceState, TimeZoneLookupHelper timeZoneLookupHelper) { mPhone = phone; mPhone = phone; Loading
src/java/com/android/internal/telephony/TimeZoneLookupHelper.java +32 −16 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,8 @@ import static com.android.internal.telephony.TimeZoneLookupHelper.CountryResult. import static com.android.internal.telephony.TimeZoneLookupHelper.CountryResult.QUALITY_MULTIPLE_ZONES_SAME_OFFSET; import static com.android.internal.telephony.TimeZoneLookupHelper.CountryResult.QUALITY_MULTIPLE_ZONES_SAME_OFFSET; import android.annotation.IntDef; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.icu.util.TimeZone; import android.icu.util.TimeZone; import android.text.TextUtils; import android.text.TextUtils; Loading @@ -44,12 +46,13 @@ public class TimeZoneLookupHelper { public static final class OffsetResult { public static final class OffsetResult { /** A zone that matches the supplied criteria. See also {@link #mIsOnlyMatch}. */ /** A zone that matches the supplied criteria. See also {@link #mIsOnlyMatch}. */ @NonNull private final TimeZone mTimeZone; private final TimeZone mTimeZone; /** True if there is only one matching time zone for the supplied criteria. */ /** True if there is only one matching time zone for the supplied criteria. */ private final boolean mIsOnlyMatch; private final boolean mIsOnlyMatch; public OffsetResult(TimeZone timeZone, boolean isOnlyMatch) { public OffsetResult(@NonNull TimeZone timeZone, boolean isOnlyMatch) { mTimeZone = Objects.requireNonNull(timeZone); mTimeZone = Objects.requireNonNull(timeZone); mIsOnlyMatch = isOnlyMatch; mIsOnlyMatch = isOnlyMatch; } } Loading @@ -57,6 +60,7 @@ public class TimeZoneLookupHelper { /** /** * Returns a time zone that matches the supplied criteria. * Returns a time zone that matches the supplied criteria. */ */ @NonNull public TimeZone getTimeZone() { public TimeZone getTimeZone() { return mTimeZone; return mTimeZone; } } Loading Loading @@ -89,7 +93,7 @@ public class TimeZoneLookupHelper { @Override @Override public String toString() { public String toString() { return "OffsetResult{" return "OffsetResult{" + "mTimeZone=" + mTimeZone + "mTimeZone(Id)=" + mTimeZone.getID() + ", mIsOnlyMatch=" + mIsOnlyMatch + ", mIsOnlyMatch=" + mIsOnlyMatch + '}'; + '}'; } } Loading @@ -111,6 +115,7 @@ public class TimeZoneLookupHelper { public static final int QUALITY_MULTIPLE_ZONES_DIFFERENT_OFFSETS = 4; public static final int QUALITY_MULTIPLE_ZONES_DIFFERENT_OFFSETS = 4; /** A time zone to use for the country. */ /** A time zone to use for the country. */ @NonNull public final String zoneId; public final String zoneId; /** /** Loading @@ -125,8 +130,8 @@ public class TimeZoneLookupHelper { */ */ private final String mDebugInfo; private final String mDebugInfo; public CountryResult(String zoneId, @Quality int quality, String debugInfo) { public CountryResult(@NonNull String zoneId, @Quality int quality, String debugInfo) { this.zoneId = zoneId; this.zoneId = Objects.requireNonNull(zoneId); this.quality = quality; this.quality = quality; mDebugInfo = debugInfo; mDebugInfo = debugInfo; } } Loading Loading @@ -160,6 +165,7 @@ public class TimeZoneLookupHelper { } } /** The last CountryTimeZones object retrieved. */ /** The last CountryTimeZones object retrieved. */ @Nullable private CountryTimeZones mLastCountryTimeZones; private CountryTimeZones mLastCountryTimeZones; public TimeZoneLookupHelper() {} public TimeZoneLookupHelper() {} Loading @@ -172,7 +178,9 @@ public class TimeZoneLookupHelper { * returned in preference to other candidates. This method can return {@code null} if no * returned in preference to other candidates. This method can return {@code null} if no * matching time zones are found. * matching time zones are found. */ */ public OffsetResult lookupByNitzCountry(NitzData nitzData, String isoCountryCode) { @Nullable public OffsetResult lookupByNitzCountry( @NonNull NitzData nitzData, @NonNull String isoCountryCode) { CountryTimeZones countryTimeZones = getCountryTimeZones(isoCountryCode); CountryTimeZones countryTimeZones = getCountryTimeZones(isoCountryCode); if (countryTimeZones == null) { if (countryTimeZones == null) { return null; return null; Loading Loading @@ -204,7 +212,8 @@ public class TimeZoneLookupHelper { * information provided by NITZ is incorrect. This method can return {@code null} if no matching * information provided by NITZ is incorrect. This method can return {@code null} if no matching * time zones are found. * time zones are found. */ */ public OffsetResult lookupByNitz(NitzData nitzData) { @Nullable public OffsetResult lookupByNitz(@NonNull NitzData nitzData) { return lookupByNitzStatic(nitzData); return lookupByNitzStatic(nitzData); } } Loading @@ -214,7 +223,8 @@ public class TimeZoneLookupHelper { * {@code null} can be returned if a problem occurs during lookup, e.g. if the country code is * {@code null} can be returned if a problem occurs during lookup, e.g. if the country code is * unrecognized, if the country is uninhabited, or if there is a problem with the data. * unrecognized, if the country is uninhabited, or if there is a problem with the data. */ */ public CountryResult lookupByCountry(String isoCountryCode, long whenMillis) { @Nullable public CountryResult lookupByCountry(@NonNull String isoCountryCode, long whenMillis) { CountryTimeZones countryTimeZones = getCountryTimeZones(isoCountryCode); CountryTimeZones countryTimeZones = getCountryTimeZones(isoCountryCode); if (countryTimeZones == null) { if (countryTimeZones == null) { // Unknown country code. // Unknown country code. Loading Loading @@ -257,8 +267,8 @@ public class TimeZoneLookupHelper { } } private static boolean countryUsesDifferentOffsets( private static boolean countryUsesDifferentOffsets( long whenMillis, List<TimeZoneMapping> effectiveTimeZoneMappings, long whenMillis, @NonNull List<TimeZoneMapping> effectiveTimeZoneMappings, TimeZone countryDefaultZone) { @NonNull TimeZone countryDefaultZone) { String countryDefaultId = countryDefaultZone.getID(); String countryDefaultId = countryDefaultZone.getID(); int countryDefaultOffset = countryDefaultZone.getOffset(whenMillis); int countryDefaultOffset = countryDefaultZone.getOffset(whenMillis); for (TimeZoneMapping timeZoneMapping : effectiveTimeZoneMappings) { for (TimeZoneMapping timeZoneMapping : effectiveTimeZoneMappings) { Loading Loading @@ -286,13 +296,16 @@ public class TimeZoneLookupHelper { * if a problem occurs during lookup, e.g. if the country code is unrecognized, if the country * if a problem occurs during lookup, e.g. if the country code is unrecognized, if the country * is uninhabited, or if there is a problem with the data. * is uninhabited, or if there is a problem with the data. */ */ public String lookupDefaultTimeZoneIdByCountry(String isoCountryCode) { @Nullable public String lookupDefaultTimeZoneIdByCountry(@NonNull String isoCountryCode) { Objects.requireNonNull(isoCountryCode); CountryTimeZones countryTimeZones = CountryTimeZones countryTimeZones = TimeZoneFinder.getInstance().lookupCountryTimeZones(isoCountryCode); TimeZoneFinder.getInstance().lookupCountryTimeZones(isoCountryCode); return countryTimeZones == null ? null : countryTimeZones.getDefaultTimeZoneId(); return countryTimeZones == null ? null : countryTimeZones.getDefaultTimeZoneId(); } } private static OffsetResult lookupByNitzStatic(NitzData nitzData) { @Nullable private static OffsetResult lookupByNitzStatic(@NonNull NitzData nitzData) { int utcOffsetMillis = nitzData.getLocalOffsetMillis(); int utcOffsetMillis = nitzData.getLocalOffsetMillis(); long timeMillis = nitzData.getCurrentTimeInMillis(); long timeMillis = nitzData.getCurrentTimeInMillis(); Loading @@ -316,7 +329,7 @@ public class TimeZoneLookupHelper { } } private static OffsetResult lookupByInstantOffsetDst(long timeMillis, int utcOffsetMillis, private static OffsetResult lookupByInstantOffsetDst(long timeMillis, int utcOffsetMillis, Boolean isDst) { @Nullable Boolean isDst) { String[] zones = TimeZone.getAvailableIDs(); String[] zones = TimeZone.getAvailableIDs(); TimeZone match = null; TimeZone match = null; Loading Loading @@ -345,8 +358,8 @@ public class TimeZoneLookupHelper { * If {@code isDst} is {@code null} this means the DST state is unknown so DST state is ignored. * If {@code isDst} is {@code null} this means the DST state is unknown so DST state is ignored. * If {@code isDst} is not {@code null} then it is also matched. * If {@code isDst} is not {@code null} then it is also matched. */ */ private static boolean offsetMatchesAtTime(TimeZone timeZone, int totalOffsetMillis, private static boolean offsetMatchesAtTime(@NonNull TimeZone timeZone, int totalOffsetMillis, Boolean isDst, long whenMillis) { @Nullable Boolean isDst, long whenMillis) { int[] offsets = new int[2]; int[] offsets = new int[2]; timeZone.getOffset(whenMillis, false /* local */, offsets); timeZone.getOffset(whenMillis, false /* local */, offsets); Loading @@ -361,7 +374,7 @@ public class TimeZoneLookupHelper { * Returns {@code true} if the supplied (lower-case) ISO country code is for a country known to * Returns {@code true} if the supplied (lower-case) ISO country code is for a country known to * use a raw offset of zero from UTC at the time specified. * use a raw offset of zero from UTC at the time specified. */ */ public boolean countryUsesUtc(String isoCountryCode, long whenMillis) { public boolean countryUsesUtc(@NonNull String isoCountryCode, long whenMillis) { if (TextUtils.isEmpty(isoCountryCode)) { if (TextUtils.isEmpty(isoCountryCode)) { return false; return false; } } Loading @@ -370,7 +383,10 @@ public class TimeZoneLookupHelper { return countryTimeZones != null && countryTimeZones.hasUtcZone(whenMillis); return countryTimeZones != null && countryTimeZones.hasUtcZone(whenMillis); } } private CountryTimeZones getCountryTimeZones(String isoCountryCode) { @Nullable private CountryTimeZones getCountryTimeZones(@NonNull String isoCountryCode) { Objects.requireNonNull(isoCountryCode); // A single entry cache of the last CountryTimeZones object retrieved since there should // A single entry cache of the last CountryTimeZones object retrieved since there should // be strong consistency across calls. // be strong consistency across calls. synchronized (this) { synchronized (this) { Loading