Loading src/java/com/android/internal/telephony/nitz/NewNitzStateMachineImpl.java +11 −11 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { */ @NonNull PhoneTimeZoneSuggestion getTimeZoneSuggestion( int phoneId, @Nullable String countryIsoCode, int slotIndex, @Nullable String countryIsoCode, @Nullable TimestampedValue<NitzData> nitzSignal); } Loading @@ -99,7 +99,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { static final boolean DBG = true; // Miscellaneous dependencies and helpers not related to detection state. private final int mPhoneId; private final int mSlotIndex; /** Applied to NITZ signals during input filtering. */ private final NitzSignalInputFilterPredicate mNitzSignalInputFilter; /** Creates {@link PhoneTimeZoneSuggestion} for passing to the time zone detection service. */ Loading Loading @@ -132,7 +132,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { public static NewNitzStateMachineImpl createInstance(@NonNull Phone phone) { Objects.requireNonNull(phone); int phoneId = phone.getPhoneId(); int slotIndex = phone.getPhoneId(); DeviceState deviceState = new DeviceStateImpl(phone); TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper(); TimeZoneSuggester timeZoneSuggester = Loading @@ -141,7 +141,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { NitzSignalInputFilterPredicate nitzSignalFilter = NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState); return new NewNitzStateMachineImpl( phoneId, nitzSignalFilter, timeZoneSuggester, newTimeServiceHelper); slotIndex, nitzSignalFilter, timeZoneSuggester, newTimeServiceHelper); } /** Loading @@ -149,11 +149,11 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { * See {@link #createInstance(Phone)} */ @VisibleForTesting public NewNitzStateMachineImpl(int phoneId, public NewNitzStateMachineImpl(int slotIndex, @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter, @NonNull TimeZoneSuggester timeZoneSuggester, @NonNull NewTimeServiceHelper newTimeServiceHelper) { mPhoneId = phoneId; mSlotIndex = slotIndex; mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester); mNewTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper); mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter); Loading Loading @@ -284,8 +284,8 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { try { Objects.requireNonNull(reason); PhoneTimeZoneSuggestion suggestion = mTimeZoneSuggester.getTimeZoneSuggestion(mPhoneId, countryIsoCode, nitzSignal); PhoneTimeZoneSuggestion suggestion = mTimeZoneSuggester.getTimeZoneSuggestion( mSlotIndex, countryIsoCode, nitzSignal); suggestion.addDebugInfo("Detection reason=" + reason); if (DBG) { Loading @@ -296,7 +296,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { mNewTimeServiceHelper.maybeSuggestDeviceTimeZone(suggestion); } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "doTimeZoneDetection: Exception thrown" + " mPhoneId=" + mPhoneId + " mSlotIndex=" + mSlotIndex + ", countryIsoCode=" + countryIsoCode + ", nitzSignal=" + nitzSignal + ", reason=" + reason Loading @@ -312,7 +312,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { try { Objects.requireNonNull(reason); PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(mPhoneId); PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(mSlotIndex); if (nitzSignal == null) { builder.addDebugInfo("Clearing time suggestion" + " reason=" + reason); Loading @@ -328,7 +328,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { mNewTimeServiceHelper.suggestDeviceTime(builder.build()); } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "doTimeDetection: Exception thrown" + " mPhoneId=" + mPhoneId + " mSlotIndex=" + mSlotIndex + ", nitzSignal=" + nitzSignal + ", reason=" + reason + ", ex=" + ex, ex); Loading src/java/com/android/internal/telephony/nitz/TimeZoneSuggesterImpl.java +9 −9 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { @Override @NonNull public PhoneTimeZoneSuggestion getTimeZoneSuggestion(int phoneId, public PhoneTimeZoneSuggestion getTimeZoneSuggestion(int slotIndex, @Nullable String countryIsoCode, @Nullable TimestampedValue<NitzData> nitzSignal) { try { // Check for overriding NITZ-based signals from Android running in an emulator. Loading @@ -64,7 +64,7 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { NitzData nitzData = nitzSignal.getValue(); if (nitzData.getEmulatorHostTimeZone() != null) { PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(phoneId) new PhoneTimeZoneSuggestion.Builder(slotIndex) .setZoneId(nitzData.getEmulatorHostTimeZone().getID()) .setMatchType(PhoneTimeZoneSuggestion.MATCH_TYPE_EMULATOR_ZONE_ID) .setQuality(PhoneTimeZoneSuggestion.QUALITY_SINGLE_ZONE) Loading @@ -78,23 +78,23 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { suggestion = overridingSuggestion; } else if (countryIsoCode == null) { if (nitzSignal == null) { suggestion = createEmptySuggestion(phoneId, suggestion = createEmptySuggestion(slotIndex, "getTimeZoneSuggestion: nitzSignal=null, countryIsoCode=null"); } else { // NITZ only - wait until we have a country. suggestion = createEmptySuggestion(phoneId, "getTimeZoneSuggestion:" suggestion = createEmptySuggestion(slotIndex, "getTimeZoneSuggestion:" + " nitzSignal=" + nitzSignal + ", countryIsoCode=null"); } } else { // countryIsoCode != null if (nitzSignal == null) { if (countryIsoCode.isEmpty()) { // This is assumed to be a test network with no NITZ data to go on. suggestion = createEmptySuggestion(phoneId, suggestion = createEmptySuggestion(slotIndex, "getTimeZoneSuggestion: nitzSignal=null, countryIsoCode=\"\""); } else { // Country only suggestion = findTimeZoneFromNetworkCountryCode( phoneId, countryIsoCode, mDeviceState.currentTimeMillis()); slotIndex, countryIsoCode, mDeviceState.currentTimeMillis()); } } else { // nitzSignal != null if (countryIsoCode.isEmpty()) { Loading @@ -103,11 +103,11 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { // (eg, "001"). Obtain a TimeZone based only on the NITZ parameters: without // a country it will be arbitrary, but it should at least have the correct // offset. suggestion = findTimeZoneForTestNetwork(phoneId, nitzSignal); suggestion = findTimeZoneForTestNetwork(slotIndex, nitzSignal); } else { // We have both NITZ and Country code. suggestion = findTimeZoneFromCountryAndNitz( phoneId, countryIsoCode, nitzSignal); slotIndex, countryIsoCode, nitzSignal); } } } Loading @@ -123,7 +123,7 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { + " countryIsoCode=" + countryIsoCode + ", nitzSignal=" + nitzSignal + ", e=" + e.getMessage(); PhoneTimeZoneSuggestion errorSuggestion = createEmptySuggestion(phoneId, message); PhoneTimeZoneSuggestion errorSuggestion = createEmptySuggestion(slotIndex, message); Rlog.w(LOG_TAG, message, e); return errorSuggestion; } Loading tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineTestSupport.java +6 −6 Original line number Diff line number Diff line Loading @@ -271,21 +271,21 @@ public final class NitzStateMachineTestSupport { return cal.getTimeInMillis(); } public static PhoneTimeZoneSuggestion createEmptyTimeZoneSuggestion(int phoneId) { return new PhoneTimeZoneSuggestion.Builder(phoneId) public static PhoneTimeZoneSuggestion createEmptyTimeZoneSuggestion(int slotIndex) { return new PhoneTimeZoneSuggestion.Builder(slotIndex) .addDebugInfo("Test") .build(); } public static PhoneTimeSuggestion createEmptyTimeSuggestion(int phoneId) { return new PhoneTimeSuggestion.Builder(phoneId) public static PhoneTimeSuggestion createEmptyTimeSuggestion(int slotIndex) { return new PhoneTimeSuggestion.Builder(slotIndex) .addDebugInfo("Test") .build(); } public static PhoneTimeSuggestion createTimeSuggestionFromNitzSignal( int phoneId, TimestampedValue<NitzData> nitzSignal) { return new PhoneTimeSuggestion.Builder(phoneId) int slotIndex, TimestampedValue<NitzData> nitzSignal) { return new PhoneTimeSuggestion.Builder(slotIndex) .setUtcTime(createTimeSignalFromNitzSignal(nitzSignal)) .addDebugInfo("Test") .build(); Loading tests/telephonytests/src/com/android/internal/telephony/nitz/NewNitzStateMachineImplTest.java +27 −27 Original line number Diff line number Diff line Loading @@ -55,11 +55,11 @@ import java.util.concurrent.TimeUnit; public class NewNitzStateMachineImplTest extends TelephonyTest { private static final int PHONE_ID = 99999; private static final int SLOT_INDEX = 99999; private static final PhoneTimeZoneSuggestion EMPTY_TIME_ZONE_SUGGESTION = createEmptyTimeZoneSuggestion(PHONE_ID); createEmptyTimeZoneSuggestion(SLOT_INDEX); private static final PhoneTimeSuggestion EMPTY_TIME_SUGGESTION = createEmptyTimeSuggestion(PHONE_ID); createEmptyTimeSuggestion(SLOT_INDEX); private FakeNewTimeServiceHelper mFakeNewTimeServiceHelper; private FakeDeviceState mFakeDeviceState; Loading Loading @@ -91,7 +91,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { mRealTimeZoneSuggester = new TimeZoneSuggesterImpl(mFakeDeviceState, timeZoneLookupHelper); mNitzStateMachineImpl = new NewNitzStateMachineImpl( PHONE_ID, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, SLOT_INDEX, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, mFakeNewTimeServiceHelper); TelephonyTest.logd("NewNitzStateMachineImplTest -Setup!"); Loading @@ -113,10 +113,10 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // between them. PhoneTimeZoneSuggestion expectedTimeZoneSuggestion1 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, networkCountryIsoCode, null /* nitzSignal */); SLOT_INDEX, networkCountryIsoCode, null /* nitzSignal */); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion2 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, networkCountryIsoCode, nitzSignal); SLOT_INDEX, networkCountryIsoCode, nitzSignal); assertNotNull(expectedTimeZoneSuggestion2); assertNotEquals(expectedTimeZoneSuggestion1, expectedTimeZoneSuggestion2); Loading @@ -136,7 +136,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { script.nitzReceived(nitzSignal); PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedTimeSuggestion, expectedTimeZoneSuggestion2); Loading @@ -156,10 +156,10 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // between them. PhoneTimeZoneSuggestion expectedTimeZoneSuggestion1 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, null /* countryIsoCode */, nitzSignal); SLOT_INDEX, null /* countryIsoCode */, nitzSignal); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion2 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, networkCountryIsoCode, nitzSignal); SLOT_INDEX, networkCountryIsoCode, nitzSignal); assertNotEquals(expectedTimeZoneSuggestion1, expectedTimeZoneSuggestion2); Script script = new Script() Loading @@ -171,7 +171,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedTimeSuggestion, expectedTimeZoneSuggestion1); Loading Loading @@ -209,12 +209,12 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { script.nitzReceived(nitzSignal); PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); // Capture output from the real suggester and confirm it meets the test's needs / // expectations. PhoneTimeZoneSuggestion expectedTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, "" /* countryIsoCode */, nitzSignal); SLOT_INDEX, "" /* countryIsoCode */, nitzSignal); assertEquals(MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY, expectedTimeZoneSuggestion.getMatchType()); assertEquals(QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET, Loading Loading @@ -244,7 +244,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. // No time zone should be set. A NITZ signal by itself is not enough. PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedTimeSuggestion, EMPTY_TIME_ZONE_SUGGESTION); Loading @@ -258,7 +258,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // expectations. PhoneTimeZoneSuggestion expectedTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, "" /* countryIsoCode */, nitzSignal); SLOT_INDEX, "" /* countryIsoCode */, nitzSignal); assertEquals(MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY, expectedTimeZoneSuggestion.getMatchType()); assertEquals(QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET, Loading @@ -285,7 +285,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { TimestampedValue<NitzData> preFlightNitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime()); PhoneTimeSuggestion expectedPreFlightTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, preFlightNitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, preFlightNitzSignal); String preFlightCountryIsoCode = scenario.getNetworkCountryIsoCode(); // Simulate receiving the NITZ signal and country. Loading @@ -295,7 +295,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeZoneSuggestion expectedPreFlightTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, preFlightCountryIsoCode, preFlightNitzSignal); SLOT_INDEX, preFlightCountryIsoCode, preFlightNitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedPreFlightTimeSuggestion, expectedPreFlightTimeZoneSuggestion); Loading Loading @@ -356,10 +356,10 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeSuggestion expectedPostFlightTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, postFlightNitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, postFlightNitzSignal); PhoneTimeZoneSuggestion expectedPostFlightTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, postFlightCountryCode, postFlightNitzSignal); SLOT_INDEX, postFlightCountryCode, postFlightNitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedPostFlightTimeSuggestion, expectedPostFlightTimeZoneSuggestion); Loading @@ -384,7 +384,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { TimestampedValue<NitzData> initialNitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime()); PhoneTimeSuggestion expectedInitialTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, initialNitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, initialNitzSignal); // Simulate receiving the NITZ signal and country. script.nitzReceived(initialNitzSignal) Loading @@ -393,7 +393,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeZoneSuggestion expectedInitialTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, countryIsoCode, initialNitzSignal); SLOT_INDEX, countryIsoCode, initialNitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedInitialTimeSuggestion, expectedInitialTimeZoneSuggestion); Loading @@ -410,7 +410,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Check the "no NITZ" time and time zone suggestions are made. PhoneTimeZoneSuggestion expectedMiddleTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, countryIsoCode, null /* nitzSignal */); SLOT_INDEX, countryIsoCode, null /* nitzSignal */); script.verifyTimeAndTimeZoneSuggestedAndReset( EMPTY_TIME_SUGGESTION, expectedMiddleTimeZoneSuggestion); Loading Loading @@ -440,10 +440,10 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeSuggestion expectedFinalTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, finalNitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, finalNitzSignal); PhoneTimeZoneSuggestion expectedFinalTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, countryIsoCode, finalNitzSignal); SLOT_INDEX, countryIsoCode, finalNitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedFinalTimeSuggestion, expectedFinalTimeZoneSuggestion); Loading @@ -465,16 +465,16 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { script.countryReceived(scenario.getNetworkCountryIsoCode()); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion1 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, scenario.getNetworkCountryIsoCode(), null /* nitzSignal */); SLOT_INDEX, scenario.getNetworkCountryIsoCode(), null /* nitzSignal */); script.verifyOnlyTimeZoneWasSuggestedAndReset(expectedTimeZoneSuggestion1); // Simulate receiving an NITZ signal and verify the state machine does the right thing. script.nitzReceived(nitzSignal); PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion2 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, scenario.getNetworkCountryIsoCode(), nitzSignal); SLOT_INDEX, scenario.getNetworkCountryIsoCode(), nitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedTimeSuggestion, expectedTimeZoneSuggestion2); Loading @@ -486,7 +486,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { script.countryUnavailable(); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion3 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, null /* countryIsoCode */, nitzSignal); SLOT_INDEX, null /* countryIsoCode */, nitzSignal); script.verifyOnlyTimeZoneWasSuggestedAndReset(expectedTimeZoneSuggestion3); // Check state that NitzStateMachine must expose. Loading tests/telephonytests/src/com/android/internal/telephony/nitz/TimeZoneSuggesterImplTest.java +62 −62 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/java/com/android/internal/telephony/nitz/NewNitzStateMachineImpl.java +11 −11 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { */ @NonNull PhoneTimeZoneSuggestion getTimeZoneSuggestion( int phoneId, @Nullable String countryIsoCode, int slotIndex, @Nullable String countryIsoCode, @Nullable TimestampedValue<NitzData> nitzSignal); } Loading @@ -99,7 +99,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { static final boolean DBG = true; // Miscellaneous dependencies and helpers not related to detection state. private final int mPhoneId; private final int mSlotIndex; /** Applied to NITZ signals during input filtering. */ private final NitzSignalInputFilterPredicate mNitzSignalInputFilter; /** Creates {@link PhoneTimeZoneSuggestion} for passing to the time zone detection service. */ Loading Loading @@ -132,7 +132,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { public static NewNitzStateMachineImpl createInstance(@NonNull Phone phone) { Objects.requireNonNull(phone); int phoneId = phone.getPhoneId(); int slotIndex = phone.getPhoneId(); DeviceState deviceState = new DeviceStateImpl(phone); TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper(); TimeZoneSuggester timeZoneSuggester = Loading @@ -141,7 +141,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { NitzSignalInputFilterPredicate nitzSignalFilter = NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState); return new NewNitzStateMachineImpl( phoneId, nitzSignalFilter, timeZoneSuggester, newTimeServiceHelper); slotIndex, nitzSignalFilter, timeZoneSuggester, newTimeServiceHelper); } /** Loading @@ -149,11 +149,11 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { * See {@link #createInstance(Phone)} */ @VisibleForTesting public NewNitzStateMachineImpl(int phoneId, public NewNitzStateMachineImpl(int slotIndex, @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter, @NonNull TimeZoneSuggester timeZoneSuggester, @NonNull NewTimeServiceHelper newTimeServiceHelper) { mPhoneId = phoneId; mSlotIndex = slotIndex; mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester); mNewTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper); mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter); Loading Loading @@ -284,8 +284,8 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { try { Objects.requireNonNull(reason); PhoneTimeZoneSuggestion suggestion = mTimeZoneSuggester.getTimeZoneSuggestion(mPhoneId, countryIsoCode, nitzSignal); PhoneTimeZoneSuggestion suggestion = mTimeZoneSuggester.getTimeZoneSuggestion( mSlotIndex, countryIsoCode, nitzSignal); suggestion.addDebugInfo("Detection reason=" + reason); if (DBG) { Loading @@ -296,7 +296,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { mNewTimeServiceHelper.maybeSuggestDeviceTimeZone(suggestion); } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "doTimeZoneDetection: Exception thrown" + " mPhoneId=" + mPhoneId + " mSlotIndex=" + mSlotIndex + ", countryIsoCode=" + countryIsoCode + ", nitzSignal=" + nitzSignal + ", reason=" + reason Loading @@ -312,7 +312,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { try { Objects.requireNonNull(reason); PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(mPhoneId); PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(mSlotIndex); if (nitzSignal == null) { builder.addDebugInfo("Clearing time suggestion" + " reason=" + reason); Loading @@ -328,7 +328,7 @@ public final class NewNitzStateMachineImpl implements NitzStateMachine { mNewTimeServiceHelper.suggestDeviceTime(builder.build()); } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "doTimeDetection: Exception thrown" + " mPhoneId=" + mPhoneId + " mSlotIndex=" + mSlotIndex + ", nitzSignal=" + nitzSignal + ", reason=" + reason + ", ex=" + ex, ex); Loading
src/java/com/android/internal/telephony/nitz/TimeZoneSuggesterImpl.java +9 −9 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { @Override @NonNull public PhoneTimeZoneSuggestion getTimeZoneSuggestion(int phoneId, public PhoneTimeZoneSuggestion getTimeZoneSuggestion(int slotIndex, @Nullable String countryIsoCode, @Nullable TimestampedValue<NitzData> nitzSignal) { try { // Check for overriding NITZ-based signals from Android running in an emulator. Loading @@ -64,7 +64,7 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { NitzData nitzData = nitzSignal.getValue(); if (nitzData.getEmulatorHostTimeZone() != null) { PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(phoneId) new PhoneTimeZoneSuggestion.Builder(slotIndex) .setZoneId(nitzData.getEmulatorHostTimeZone().getID()) .setMatchType(PhoneTimeZoneSuggestion.MATCH_TYPE_EMULATOR_ZONE_ID) .setQuality(PhoneTimeZoneSuggestion.QUALITY_SINGLE_ZONE) Loading @@ -78,23 +78,23 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { suggestion = overridingSuggestion; } else if (countryIsoCode == null) { if (nitzSignal == null) { suggestion = createEmptySuggestion(phoneId, suggestion = createEmptySuggestion(slotIndex, "getTimeZoneSuggestion: nitzSignal=null, countryIsoCode=null"); } else { // NITZ only - wait until we have a country. suggestion = createEmptySuggestion(phoneId, "getTimeZoneSuggestion:" suggestion = createEmptySuggestion(slotIndex, "getTimeZoneSuggestion:" + " nitzSignal=" + nitzSignal + ", countryIsoCode=null"); } } else { // countryIsoCode != null if (nitzSignal == null) { if (countryIsoCode.isEmpty()) { // This is assumed to be a test network with no NITZ data to go on. suggestion = createEmptySuggestion(phoneId, suggestion = createEmptySuggestion(slotIndex, "getTimeZoneSuggestion: nitzSignal=null, countryIsoCode=\"\""); } else { // Country only suggestion = findTimeZoneFromNetworkCountryCode( phoneId, countryIsoCode, mDeviceState.currentTimeMillis()); slotIndex, countryIsoCode, mDeviceState.currentTimeMillis()); } } else { // nitzSignal != null if (countryIsoCode.isEmpty()) { Loading @@ -103,11 +103,11 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { // (eg, "001"). Obtain a TimeZone based only on the NITZ parameters: without // a country it will be arbitrary, but it should at least have the correct // offset. suggestion = findTimeZoneForTestNetwork(phoneId, nitzSignal); suggestion = findTimeZoneForTestNetwork(slotIndex, nitzSignal); } else { // We have both NITZ and Country code. suggestion = findTimeZoneFromCountryAndNitz( phoneId, countryIsoCode, nitzSignal); slotIndex, countryIsoCode, nitzSignal); } } } Loading @@ -123,7 +123,7 @@ public class TimeZoneSuggesterImpl implements TimeZoneSuggester { + " countryIsoCode=" + countryIsoCode + ", nitzSignal=" + nitzSignal + ", e=" + e.getMessage(); PhoneTimeZoneSuggestion errorSuggestion = createEmptySuggestion(phoneId, message); PhoneTimeZoneSuggestion errorSuggestion = createEmptySuggestion(slotIndex, message); Rlog.w(LOG_TAG, message, e); return errorSuggestion; } Loading
tests/telephonytests/src/com/android/internal/telephony/NitzStateMachineTestSupport.java +6 −6 Original line number Diff line number Diff line Loading @@ -271,21 +271,21 @@ public final class NitzStateMachineTestSupport { return cal.getTimeInMillis(); } public static PhoneTimeZoneSuggestion createEmptyTimeZoneSuggestion(int phoneId) { return new PhoneTimeZoneSuggestion.Builder(phoneId) public static PhoneTimeZoneSuggestion createEmptyTimeZoneSuggestion(int slotIndex) { return new PhoneTimeZoneSuggestion.Builder(slotIndex) .addDebugInfo("Test") .build(); } public static PhoneTimeSuggestion createEmptyTimeSuggestion(int phoneId) { return new PhoneTimeSuggestion.Builder(phoneId) public static PhoneTimeSuggestion createEmptyTimeSuggestion(int slotIndex) { return new PhoneTimeSuggestion.Builder(slotIndex) .addDebugInfo("Test") .build(); } public static PhoneTimeSuggestion createTimeSuggestionFromNitzSignal( int phoneId, TimestampedValue<NitzData> nitzSignal) { return new PhoneTimeSuggestion.Builder(phoneId) int slotIndex, TimestampedValue<NitzData> nitzSignal) { return new PhoneTimeSuggestion.Builder(slotIndex) .setUtcTime(createTimeSignalFromNitzSignal(nitzSignal)) .addDebugInfo("Test") .build(); Loading
tests/telephonytests/src/com/android/internal/telephony/nitz/NewNitzStateMachineImplTest.java +27 −27 Original line number Diff line number Diff line Loading @@ -55,11 +55,11 @@ import java.util.concurrent.TimeUnit; public class NewNitzStateMachineImplTest extends TelephonyTest { private static final int PHONE_ID = 99999; private static final int SLOT_INDEX = 99999; private static final PhoneTimeZoneSuggestion EMPTY_TIME_ZONE_SUGGESTION = createEmptyTimeZoneSuggestion(PHONE_ID); createEmptyTimeZoneSuggestion(SLOT_INDEX); private static final PhoneTimeSuggestion EMPTY_TIME_SUGGESTION = createEmptyTimeSuggestion(PHONE_ID); createEmptyTimeSuggestion(SLOT_INDEX); private FakeNewTimeServiceHelper mFakeNewTimeServiceHelper; private FakeDeviceState mFakeDeviceState; Loading Loading @@ -91,7 +91,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { mRealTimeZoneSuggester = new TimeZoneSuggesterImpl(mFakeDeviceState, timeZoneLookupHelper); mNitzStateMachineImpl = new NewNitzStateMachineImpl( PHONE_ID, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, SLOT_INDEX, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, mFakeNewTimeServiceHelper); TelephonyTest.logd("NewNitzStateMachineImplTest -Setup!"); Loading @@ -113,10 +113,10 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // between them. PhoneTimeZoneSuggestion expectedTimeZoneSuggestion1 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, networkCountryIsoCode, null /* nitzSignal */); SLOT_INDEX, networkCountryIsoCode, null /* nitzSignal */); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion2 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, networkCountryIsoCode, nitzSignal); SLOT_INDEX, networkCountryIsoCode, nitzSignal); assertNotNull(expectedTimeZoneSuggestion2); assertNotEquals(expectedTimeZoneSuggestion1, expectedTimeZoneSuggestion2); Loading @@ -136,7 +136,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { script.nitzReceived(nitzSignal); PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedTimeSuggestion, expectedTimeZoneSuggestion2); Loading @@ -156,10 +156,10 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // between them. PhoneTimeZoneSuggestion expectedTimeZoneSuggestion1 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, null /* countryIsoCode */, nitzSignal); SLOT_INDEX, null /* countryIsoCode */, nitzSignal); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion2 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, networkCountryIsoCode, nitzSignal); SLOT_INDEX, networkCountryIsoCode, nitzSignal); assertNotEquals(expectedTimeZoneSuggestion1, expectedTimeZoneSuggestion2); Script script = new Script() Loading @@ -171,7 +171,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedTimeSuggestion, expectedTimeZoneSuggestion1); Loading Loading @@ -209,12 +209,12 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { script.nitzReceived(nitzSignal); PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); // Capture output from the real suggester and confirm it meets the test's needs / // expectations. PhoneTimeZoneSuggestion expectedTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, "" /* countryIsoCode */, nitzSignal); SLOT_INDEX, "" /* countryIsoCode */, nitzSignal); assertEquals(MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY, expectedTimeZoneSuggestion.getMatchType()); assertEquals(QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET, Loading Loading @@ -244,7 +244,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. // No time zone should be set. A NITZ signal by itself is not enough. PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedTimeSuggestion, EMPTY_TIME_ZONE_SUGGESTION); Loading @@ -258,7 +258,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // expectations. PhoneTimeZoneSuggestion expectedTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, "" /* countryIsoCode */, nitzSignal); SLOT_INDEX, "" /* countryIsoCode */, nitzSignal); assertEquals(MATCH_TYPE_TEST_NETWORK_OFFSET_ONLY, expectedTimeZoneSuggestion.getMatchType()); assertEquals(QUALITY_MULTIPLE_ZONES_WITH_SAME_OFFSET, Loading @@ -285,7 +285,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { TimestampedValue<NitzData> preFlightNitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime()); PhoneTimeSuggestion expectedPreFlightTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, preFlightNitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, preFlightNitzSignal); String preFlightCountryIsoCode = scenario.getNetworkCountryIsoCode(); // Simulate receiving the NITZ signal and country. Loading @@ -295,7 +295,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeZoneSuggestion expectedPreFlightTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, preFlightCountryIsoCode, preFlightNitzSignal); SLOT_INDEX, preFlightCountryIsoCode, preFlightNitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedPreFlightTimeSuggestion, expectedPreFlightTimeZoneSuggestion); Loading Loading @@ -356,10 +356,10 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeSuggestion expectedPostFlightTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, postFlightNitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, postFlightNitzSignal); PhoneTimeZoneSuggestion expectedPostFlightTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, postFlightCountryCode, postFlightNitzSignal); SLOT_INDEX, postFlightCountryCode, postFlightNitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedPostFlightTimeSuggestion, expectedPostFlightTimeZoneSuggestion); Loading @@ -384,7 +384,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { TimestampedValue<NitzData> initialNitzSignal = scenario.createNitzSignal(mFakeDeviceState.elapsedRealtime()); PhoneTimeSuggestion expectedInitialTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, initialNitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, initialNitzSignal); // Simulate receiving the NITZ signal and country. script.nitzReceived(initialNitzSignal) Loading @@ -393,7 +393,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeZoneSuggestion expectedInitialTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, countryIsoCode, initialNitzSignal); SLOT_INDEX, countryIsoCode, initialNitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedInitialTimeSuggestion, expectedInitialTimeZoneSuggestion); Loading @@ -410,7 +410,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Check the "no NITZ" time and time zone suggestions are made. PhoneTimeZoneSuggestion expectedMiddleTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, countryIsoCode, null /* nitzSignal */); SLOT_INDEX, countryIsoCode, null /* nitzSignal */); script.verifyTimeAndTimeZoneSuggestedAndReset( EMPTY_TIME_SUGGESTION, expectedMiddleTimeZoneSuggestion); Loading Loading @@ -440,10 +440,10 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { // Verify the state machine did the right thing. PhoneTimeSuggestion expectedFinalTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, finalNitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, finalNitzSignal); PhoneTimeZoneSuggestion expectedFinalTimeZoneSuggestion = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, countryIsoCode, finalNitzSignal); SLOT_INDEX, countryIsoCode, finalNitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedFinalTimeSuggestion, expectedFinalTimeZoneSuggestion); Loading @@ -465,16 +465,16 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { script.countryReceived(scenario.getNetworkCountryIsoCode()); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion1 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, scenario.getNetworkCountryIsoCode(), null /* nitzSignal */); SLOT_INDEX, scenario.getNetworkCountryIsoCode(), null /* nitzSignal */); script.verifyOnlyTimeZoneWasSuggestedAndReset(expectedTimeZoneSuggestion1); // Simulate receiving an NITZ signal and verify the state machine does the right thing. script.nitzReceived(nitzSignal); PhoneTimeSuggestion expectedTimeSuggestion = createTimeSuggestionFromNitzSignal(PHONE_ID, nitzSignal); createTimeSuggestionFromNitzSignal(SLOT_INDEX, nitzSignal); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion2 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, scenario.getNetworkCountryIsoCode(), nitzSignal); SLOT_INDEX, scenario.getNetworkCountryIsoCode(), nitzSignal); script.verifyTimeAndTimeZoneSuggestedAndReset( expectedTimeSuggestion, expectedTimeZoneSuggestion2); Loading @@ -486,7 +486,7 @@ public class NewNitzStateMachineImplTest extends TelephonyTest { script.countryUnavailable(); PhoneTimeZoneSuggestion expectedTimeZoneSuggestion3 = mRealTimeZoneSuggester.getTimeZoneSuggestion( PHONE_ID, null /* countryIsoCode */, nitzSignal); SLOT_INDEX, null /* countryIsoCode */, nitzSignal); script.verifyOnlyTimeZoneWasSuggestedAndReset(expectedTimeZoneSuggestion3); // Check state that NitzStateMachine must expose. Loading
tests/telephonytests/src/com/android/internal/telephony/nitz/TimeZoneSuggesterImplTest.java +62 −62 File changed.Preview size limit exceeded, changes collapsed. Show changes