Loading src/java/com/android/internal/telephony/nitz/TimeZoneLookupHelper.java +5 −1 Original line number Diff line number Diff line Loading @@ -259,7 +259,11 @@ public final class TimeZoneLookupHelper { private static OffsetResult lookupByInstantOffsetDst(long timeMillis, int utcOffsetMillis, @Nullable Boolean isDst) { String[] zones = TimeZone.getAvailableIDs(); // Use java.util.TimeZone and not android.icu.util.TimeZone to find candidate zone IDs: ICU // references some non-standard zone IDs that can be rejected by java.util.TimeZone. There // is a CTS test (in com.android.i18n.test.timezone.TimeZoneIntegrationTest) that confirms // that ICU can interpret all IDs that are known to java.util.TimeZone. String[] zones = java.util.TimeZone.getAvailableIDs(); TimeZone match = null; boolean isOnlyMatch = true; for (String zone : zones) { Loading tests/telephonytests/src/com/android/internal/telephony/nitz/TimeZoneLookupHelperTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryRe import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; Loading @@ -37,8 +38,10 @@ import com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryResult; import org.junit.Before; import org.junit.Test; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; public class TimeZoneLookupHelperTest { Loading Loading @@ -447,6 +450,18 @@ public class TimeZoneLookupHelperTest { assertTrue(mTimeZoneLookupHelper.countryUsesUtc("gb", NH_WINTER_TIME_MILLIS)); } @Test public void regressionTest_Bug167653885() { // This NITZ caused an error in Android R because lookupByNitz was returning a time zone // known to android.icu.util.TimeZone but not java.util.TimeZone. NitzData nitzData = NitzData.parse("20/05/08,04:15:48+08,00"); OffsetResult offsetResult = mTimeZoneLookupHelper.lookupByNitz(nitzData); assertNotNull(offsetResult); List<String> knownIds = Arrays.asList(java.util.TimeZone.getAvailableIDs()); assertTrue(knownIds.contains(offsetResult.getTimeZone().getID())); } /** * Assert the time zone in the OffsetResult has the expected properties at the specified time. */ Loading Loading
src/java/com/android/internal/telephony/nitz/TimeZoneLookupHelper.java +5 −1 Original line number Diff line number Diff line Loading @@ -259,7 +259,11 @@ public final class TimeZoneLookupHelper { private static OffsetResult lookupByInstantOffsetDst(long timeMillis, int utcOffsetMillis, @Nullable Boolean isDst) { String[] zones = TimeZone.getAvailableIDs(); // Use java.util.TimeZone and not android.icu.util.TimeZone to find candidate zone IDs: ICU // references some non-standard zone IDs that can be rejected by java.util.TimeZone. There // is a CTS test (in com.android.i18n.test.timezone.TimeZoneIntegrationTest) that confirms // that ICU can interpret all IDs that are known to java.util.TimeZone. String[] zones = java.util.TimeZone.getAvailableIDs(); TimeZone match = null; boolean isOnlyMatch = true; for (String zone : zones) { Loading
tests/telephonytests/src/com/android/internal/telephony/nitz/TimeZoneLookupHelperTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryRe import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; Loading @@ -37,8 +38,10 @@ import com.android.internal.telephony.nitz.TimeZoneLookupHelper.CountryResult; import org.junit.Before; import org.junit.Test; import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; public class TimeZoneLookupHelperTest { Loading Loading @@ -447,6 +450,18 @@ public class TimeZoneLookupHelperTest { assertTrue(mTimeZoneLookupHelper.countryUsesUtc("gb", NH_WINTER_TIME_MILLIS)); } @Test public void regressionTest_Bug167653885() { // This NITZ caused an error in Android R because lookupByNitz was returning a time zone // known to android.icu.util.TimeZone but not java.util.TimeZone. NitzData nitzData = NitzData.parse("20/05/08,04:15:48+08,00"); OffsetResult offsetResult = mTimeZoneLookupHelper.lookupByNitz(nitzData); assertNotNull(offsetResult); List<String> knownIds = Arrays.asList(java.util.TimeZone.getAvailableIDs()); assertTrue(knownIds.contains(offsetResult.getTimeZone().getID())); } /** * Assert the time zone in the OffsetResult has the expected properties at the specified time. */ Loading