Loading src/java/com/android/internal/telephony/nitz/NitzStateMachineImpl.java +10 −10 Original line number Original line Diff line number Diff line Loading @@ -104,7 +104,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { */ */ private final TimeZoneSuggester mTimeZoneSuggester; private final TimeZoneSuggester mTimeZoneSuggester; /** A facade to the time / time zone detection services. */ /** A facade to the time / time zone detection services. */ private final NewTimeServiceHelper mNewTimeServiceHelper; private final TimeServiceHelper mTimeServiceHelper; // Shared detection state. // Shared detection state. Loading Loading @@ -136,7 +136,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper(); TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper(); TimeZoneSuggester timeZoneSuggester = TimeZoneSuggester timeZoneSuggester = new TimeZoneSuggesterImpl(deviceState, timeZoneLookupHelper); new TimeZoneSuggesterImpl(deviceState, timeZoneLookupHelper); NewTimeServiceHelper newTimeServiceHelper = new NewTimeServiceHelperImpl(phone); TimeServiceHelper newTimeServiceHelper = new TimeServiceHelperImpl(phone); NitzSignalInputFilterPredicate nitzSignalFilter = NitzSignalInputFilterPredicate nitzSignalFilter = NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState); NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState); return new NitzStateMachineImpl( return new NitzStateMachineImpl( Loading @@ -151,10 +151,10 @@ public final class NitzStateMachineImpl implements NitzStateMachine { public NitzStateMachineImpl(int slotIndex, public NitzStateMachineImpl(int slotIndex, @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter, @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter, @NonNull TimeZoneSuggester timeZoneSuggester, @NonNull TimeZoneSuggester timeZoneSuggester, @NonNull NewTimeServiceHelper newTimeServiceHelper) { @NonNull TimeServiceHelper newTimeServiceHelper) { mSlotIndex = slotIndex; mSlotIndex = slotIndex; mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester); mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester); mNewTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper); mTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper); mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter); mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter); } } Loading Loading @@ -292,7 +292,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { + ", nitzSignal=" + nitzSignal + ", suggestion=" + suggestion + ", nitzSignal=" + nitzSignal + ", suggestion=" + suggestion + ", reason=" + reason); + ", reason=" + reason); } } mNewTimeServiceHelper.maybeSuggestDeviceTimeZone(suggestion); mTimeServiceHelper.maybeSuggestDeviceTimeZone(suggestion); } catch (RuntimeException ex) { } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "doTimeZoneDetection: Exception thrown" Rlog.e(LOG_TAG, "doTimeZoneDetection: Exception thrown" + " mSlotIndex=" + mSlotIndex + " mSlotIndex=" + mSlotIndex Loading Loading @@ -325,7 +325,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { + " nitzSignal=" + nitzSignal + " nitzSignal=" + nitzSignal + ", reason=" + reason); + ", reason=" + reason); } } mNewTimeServiceHelper.suggestDeviceTime(builder.build()); mTimeServiceHelper.suggestDeviceTime(builder.build()); } catch (RuntimeException ex) { } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "doTimeDetection: Exception thrown" Rlog.e(LOG_TAG, "doTimeDetection: Exception thrown" + " mSlotIndex=" + mSlotIndex + " mSlotIndex=" + mSlotIndex Loading @@ -337,15 +337,15 @@ public final class NitzStateMachineImpl implements NitzStateMachine { @Override @Override public void dumpState(PrintWriter pw) { public void dumpState(PrintWriter pw) { pw.println(" NewNitzStateMachineImpl.mLatestNitzSignal=" + mLatestNitzSignal); pw.println(" NitzStateMachineImpl.mLatestNitzSignal=" + mLatestNitzSignal); pw.println(" NewNitzStateMachineImpl.mCountryIsoCode=" + mCountryIsoCode); pw.println(" NitzStateMachineImpl.mCountryIsoCode=" + mCountryIsoCode); mNewTimeServiceHelper.dumpState(pw); mTimeServiceHelper.dumpState(pw); pw.flush(); pw.flush(); } } @Override @Override public void dumpLogs(FileDescriptor fd, IndentingPrintWriter ipw, String[] args) { public void dumpLogs(FileDescriptor fd, IndentingPrintWriter ipw, String[] args) { mNewTimeServiceHelper.dumpLogs(ipw); mTimeServiceHelper.dumpLogs(ipw); } } @Nullable @Nullable Loading src/java/com/android/internal/telephony/nitz/NewTimeServiceHelper.java→src/java/com/android/internal/telephony/nitz/TimeServiceHelper.java +10 −8 Original line number Original line Diff line number Diff line Loading @@ -18,34 +18,36 @@ package com.android.internal.telephony.nitz; import android.annotation.NonNull; import android.annotation.NonNull; import android.app.timedetector.TelephonyTimeSuggestion; import android.app.timedetector.TelephonyTimeSuggestion; import android.app.timedetector.TimeDetector; import android.app.timezonedetector.TelephonyTimeZoneSuggestion; import android.app.timezonedetector.TelephonyTimeZoneSuggestion; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.IndentingPrintWriter; import java.io.PrintWriter; import java.io.PrintWriter; /** /** * An interface to various time / time zone detection behaviors that should be centralized into * An interface to various time / time zone detection behaviors that are centralized into services. * new services. * This interface exists to separate out behavior to enable easier testing of the * {@link NitzStateMachineImpl}. */ */ public interface NewTimeServiceHelper { @VisibleForTesting public interface TimeServiceHelper { /** /** * Suggests the time to the {@link TimeDetector}. * Suggests the time to the time detector service. * * * @param suggestion the time * @param suggestion the time suggestion */ */ void suggestDeviceTime(@NonNull TelephonyTimeSuggestion suggestion); void suggestDeviceTime(@NonNull TelephonyTimeSuggestion suggestion); /** /** * Suggests the time zone to the time zone detector. * Suggests the time zone to the time zone detector service. * * * <p>NOTE: The {@link TelephonyTimeZoneSuggestion} cannot be null. The zoneId it contains can * <p>NOTE: The {@link TelephonyTimeZoneSuggestion} cannot be null. The zoneId it contains can * be null to indicate there is no active suggestion; this can be used to clear a previous * be null to indicate there is no active suggestion; this can be used to clear a previous * suggestion. * suggestion. * * * @param suggestion the time zone * @param suggestion the time zone suggestion */ */ void maybeSuggestDeviceTimeZone(@NonNull TelephonyTimeZoneSuggestion suggestion); void maybeSuggestDeviceTimeZone(@NonNull TelephonyTimeZoneSuggestion suggestion); Loading src/java/com/android/internal/telephony/nitz/NewTimeServiceHelperImpl.java→src/java/com/android/internal/telephony/nitz/TimeServiceHelperImpl.java +5 −5 Original line number Original line Diff line number Diff line Loading @@ -34,9 +34,9 @@ import java.io.PrintWriter; import java.util.Objects; import java.util.Objects; /** /** * The real implementation of {@link NewTimeServiceHelper}. * The real implementation of {@link TimeServiceHelper}. */ */ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper { public final class TimeServiceHelperImpl implements TimeServiceHelper { private final int mSlotIndex; private final int mSlotIndex; private final TimeDetector mTimeDetector; private final TimeDetector mTimeDetector; Loading @@ -53,7 +53,7 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper { @NonNull @NonNull private TelephonyTimeZoneSuggestion mLastSuggestedTimeZone; private TelephonyTimeZoneSuggestion mLastSuggestedTimeZone; public NewTimeServiceHelperImpl(@NonNull Phone phone) { public TimeServiceHelperImpl(@NonNull Phone phone) { mSlotIndex = phone.getPhoneId(); mSlotIndex = phone.getPhoneId(); Context context = Objects.requireNonNull(phone.getContext()); Context context = Objects.requireNonNull(phone.getContext()); mTimeDetector = Objects.requireNonNull(context.getSystemService(TimeDetector.class)); mTimeDetector = Objects.requireNonNull(context.getSystemService(TimeDetector.class)); Loading Loading @@ -99,7 +99,7 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper { @Override @Override public void dumpLogs(IndentingPrintWriter ipw) { public void dumpLogs(IndentingPrintWriter ipw) { ipw.println("NewTimeServiceHelperImpl:"); ipw.println("TimeServiceHelperImpl:"); ipw.increaseIndent(); ipw.increaseIndent(); ipw.println("Time Logs:"); ipw.println("Time Logs:"); ipw.increaseIndent(); ipw.increaseIndent(); Loading @@ -115,6 +115,6 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper { @Override @Override public void dumpState(PrintWriter pw) { public void dumpState(PrintWriter pw) { pw.println(" NewTimeServiceHelperImpl.mLastSuggestedTimeZone=" + mLastSuggestedTimeZone); pw.println(" TimeServiceHelperImpl.mLastSuggestedTimeZone=" + mLastSuggestedTimeZone); } } } } tests/telephonytests/src/com/android/internal/telephony/nitz/NitzStateMachineImplTest.java +14 −14 Original line number Original line Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { private static final TelephonyTimeSuggestion EMPTY_TIME_SUGGESTION = private static final TelephonyTimeSuggestion EMPTY_TIME_SUGGESTION = createEmptyTimeSuggestion(SLOT_INDEX); createEmptyTimeSuggestion(SLOT_INDEX); private FakeNewTimeServiceHelper mFakeNewTimeServiceHelper; private FakeTimeServiceHelper mFakeTimeServiceHelper; private FakeDeviceState mFakeDeviceState; private FakeDeviceState mFakeDeviceState; private TimeZoneSuggesterImpl mRealTimeZoneSuggester; private TimeZoneSuggesterImpl mRealTimeZoneSuggester; Loading @@ -69,12 +69,12 @@ public class NitzStateMachineImplTest extends TelephonyTest { @Before @Before public void setUp() throws Exception { public void setUp() throws Exception { TelephonyTest.logd("NewNitzStateMachineImplTest +Setup!"); TelephonyTest.logd("NitzStateMachineImplTest +Setup!"); super.setUp("NewNitzStateMachineImplTest"); super.setUp("NitzStateMachineImplTest"); // In tests we use a fake impls for NewTimeServiceHelper and DeviceState. // In tests we use a fake impls for NewTimeServiceHelper and DeviceState. mFakeDeviceState = new FakeDeviceState(); mFakeDeviceState = new FakeDeviceState(); mFakeNewTimeServiceHelper = new FakeNewTimeServiceHelper(mFakeDeviceState); mFakeTimeServiceHelper = new FakeTimeServiceHelper(mFakeDeviceState); // In tests we disable NITZ signal input filtering. The real NITZ signal filter is tested // In tests we disable NITZ signal input filtering. The real NITZ signal filter is tested // independently. This makes constructing test data simpler: we can be sure the signals // independently. This makes constructing test data simpler: we can be sure the signals Loading @@ -91,7 +91,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { mNitzStateMachineImpl = new NitzStateMachineImpl( mNitzStateMachineImpl = new NitzStateMachineImpl( SLOT_INDEX, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, SLOT_INDEX, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, mFakeNewTimeServiceHelper); mFakeTimeServiceHelper); TelephonyTest.logd("NewNitzStateMachineImplTest -Setup!"); TelephonyTest.logd("NewNitzStateMachineImplTest -Setup!"); } } Loading Loading @@ -574,22 +574,22 @@ public class NitzStateMachineImplTest extends TelephonyTest { } } private void justVerifyTimeWasNotSuggested() { private void justVerifyTimeWasNotSuggested() { mFakeNewTimeServiceHelper.suggestedTimes.assertHasNotBeenSet(); mFakeTimeServiceHelper.suggestedTimes.assertHasNotBeenSet(); } } private void justVerifyTimeZoneWasSuggested( private void justVerifyTimeZoneWasSuggested( TelephonyTimeZoneSuggestion timeZoneSuggestion) { TelephonyTimeZoneSuggestion timeZoneSuggestion) { mFakeNewTimeServiceHelper.suggestedTimeZones.assertHasBeenSet(); mFakeTimeServiceHelper.suggestedTimeZones.assertHasBeenSet(); mFakeNewTimeServiceHelper.suggestedTimeZones.assertLatestEquals(timeZoneSuggestion); mFakeTimeServiceHelper.suggestedTimeZones.assertLatestEquals(timeZoneSuggestion); } } private void justVerifyTimeWasSuggested(TelephonyTimeSuggestion timeSuggestion) { private void justVerifyTimeWasSuggested(TelephonyTimeSuggestion timeSuggestion) { mFakeNewTimeServiceHelper.suggestedTimes.assertChangeCount(1); mFakeTimeServiceHelper.suggestedTimes.assertChangeCount(1); mFakeNewTimeServiceHelper.suggestedTimes.assertLatestEquals(timeSuggestion); mFakeTimeServiceHelper.suggestedTimes.assertLatestEquals(timeSuggestion); } } private void commitStateChanges() { private void commitStateChanges() { mFakeNewTimeServiceHelper.commitState(); mFakeTimeServiceHelper.commitState(); } } } } Loading Loading @@ -643,10 +643,10 @@ public class NitzStateMachineImplTest extends TelephonyTest { } } /** /** * A fake implementation of {@link NewTimeServiceHelper} that enables tests to detect what * A fake implementation of {@link TimeServiceHelper} that enables tests to detect what * {@link NitzStateMachineImpl} would do to a real device's state. * {@link NitzStateMachineImpl} would do to a real device's state. */ */ private static class FakeNewTimeServiceHelper implements NewTimeServiceHelper { private static class FakeTimeServiceHelper implements TimeServiceHelper { private final FakeDeviceState mFakeDeviceState; private final FakeDeviceState mFakeDeviceState; Loading @@ -654,7 +654,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { public final TestState<TelephonyTimeSuggestion> suggestedTimes = new TestState<>(); public final TestState<TelephonyTimeSuggestion> suggestedTimes = new TestState<>(); public final TestState<TelephonyTimeZoneSuggestion> suggestedTimeZones = new TestState<>(); public final TestState<TelephonyTimeZoneSuggestion> suggestedTimeZones = new TestState<>(); FakeNewTimeServiceHelper(FakeDeviceState fakeDeviceState) { FakeTimeServiceHelper(FakeDeviceState fakeDeviceState) { mFakeDeviceState = fakeDeviceState; mFakeDeviceState = fakeDeviceState; } } Loading Loading
src/java/com/android/internal/telephony/nitz/NitzStateMachineImpl.java +10 −10 Original line number Original line Diff line number Diff line Loading @@ -104,7 +104,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { */ */ private final TimeZoneSuggester mTimeZoneSuggester; private final TimeZoneSuggester mTimeZoneSuggester; /** A facade to the time / time zone detection services. */ /** A facade to the time / time zone detection services. */ private final NewTimeServiceHelper mNewTimeServiceHelper; private final TimeServiceHelper mTimeServiceHelper; // Shared detection state. // Shared detection state. Loading Loading @@ -136,7 +136,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper(); TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper(); TimeZoneSuggester timeZoneSuggester = TimeZoneSuggester timeZoneSuggester = new TimeZoneSuggesterImpl(deviceState, timeZoneLookupHelper); new TimeZoneSuggesterImpl(deviceState, timeZoneLookupHelper); NewTimeServiceHelper newTimeServiceHelper = new NewTimeServiceHelperImpl(phone); TimeServiceHelper newTimeServiceHelper = new TimeServiceHelperImpl(phone); NitzSignalInputFilterPredicate nitzSignalFilter = NitzSignalInputFilterPredicate nitzSignalFilter = NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState); NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState); return new NitzStateMachineImpl( return new NitzStateMachineImpl( Loading @@ -151,10 +151,10 @@ public final class NitzStateMachineImpl implements NitzStateMachine { public NitzStateMachineImpl(int slotIndex, public NitzStateMachineImpl(int slotIndex, @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter, @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter, @NonNull TimeZoneSuggester timeZoneSuggester, @NonNull TimeZoneSuggester timeZoneSuggester, @NonNull NewTimeServiceHelper newTimeServiceHelper) { @NonNull TimeServiceHelper newTimeServiceHelper) { mSlotIndex = slotIndex; mSlotIndex = slotIndex; mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester); mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester); mNewTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper); mTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper); mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter); mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter); } } Loading Loading @@ -292,7 +292,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { + ", nitzSignal=" + nitzSignal + ", suggestion=" + suggestion + ", nitzSignal=" + nitzSignal + ", suggestion=" + suggestion + ", reason=" + reason); + ", reason=" + reason); } } mNewTimeServiceHelper.maybeSuggestDeviceTimeZone(suggestion); mTimeServiceHelper.maybeSuggestDeviceTimeZone(suggestion); } catch (RuntimeException ex) { } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "doTimeZoneDetection: Exception thrown" Rlog.e(LOG_TAG, "doTimeZoneDetection: Exception thrown" + " mSlotIndex=" + mSlotIndex + " mSlotIndex=" + mSlotIndex Loading Loading @@ -325,7 +325,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine { + " nitzSignal=" + nitzSignal + " nitzSignal=" + nitzSignal + ", reason=" + reason); + ", reason=" + reason); } } mNewTimeServiceHelper.suggestDeviceTime(builder.build()); mTimeServiceHelper.suggestDeviceTime(builder.build()); } catch (RuntimeException ex) { } catch (RuntimeException ex) { Rlog.e(LOG_TAG, "doTimeDetection: Exception thrown" Rlog.e(LOG_TAG, "doTimeDetection: Exception thrown" + " mSlotIndex=" + mSlotIndex + " mSlotIndex=" + mSlotIndex Loading @@ -337,15 +337,15 @@ public final class NitzStateMachineImpl implements NitzStateMachine { @Override @Override public void dumpState(PrintWriter pw) { public void dumpState(PrintWriter pw) { pw.println(" NewNitzStateMachineImpl.mLatestNitzSignal=" + mLatestNitzSignal); pw.println(" NitzStateMachineImpl.mLatestNitzSignal=" + mLatestNitzSignal); pw.println(" NewNitzStateMachineImpl.mCountryIsoCode=" + mCountryIsoCode); pw.println(" NitzStateMachineImpl.mCountryIsoCode=" + mCountryIsoCode); mNewTimeServiceHelper.dumpState(pw); mTimeServiceHelper.dumpState(pw); pw.flush(); pw.flush(); } } @Override @Override public void dumpLogs(FileDescriptor fd, IndentingPrintWriter ipw, String[] args) { public void dumpLogs(FileDescriptor fd, IndentingPrintWriter ipw, String[] args) { mNewTimeServiceHelper.dumpLogs(ipw); mTimeServiceHelper.dumpLogs(ipw); } } @Nullable @Nullable Loading
src/java/com/android/internal/telephony/nitz/NewTimeServiceHelper.java→src/java/com/android/internal/telephony/nitz/TimeServiceHelper.java +10 −8 Original line number Original line Diff line number Diff line Loading @@ -18,34 +18,36 @@ package com.android.internal.telephony.nitz; import android.annotation.NonNull; import android.annotation.NonNull; import android.app.timedetector.TelephonyTimeSuggestion; import android.app.timedetector.TelephonyTimeSuggestion; import android.app.timedetector.TimeDetector; import android.app.timezonedetector.TelephonyTimeZoneSuggestion; import android.app.timezonedetector.TelephonyTimeZoneSuggestion; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.IndentingPrintWriter; import java.io.PrintWriter; import java.io.PrintWriter; /** /** * An interface to various time / time zone detection behaviors that should be centralized into * An interface to various time / time zone detection behaviors that are centralized into services. * new services. * This interface exists to separate out behavior to enable easier testing of the * {@link NitzStateMachineImpl}. */ */ public interface NewTimeServiceHelper { @VisibleForTesting public interface TimeServiceHelper { /** /** * Suggests the time to the {@link TimeDetector}. * Suggests the time to the time detector service. * * * @param suggestion the time * @param suggestion the time suggestion */ */ void suggestDeviceTime(@NonNull TelephonyTimeSuggestion suggestion); void suggestDeviceTime(@NonNull TelephonyTimeSuggestion suggestion); /** /** * Suggests the time zone to the time zone detector. * Suggests the time zone to the time zone detector service. * * * <p>NOTE: The {@link TelephonyTimeZoneSuggestion} cannot be null. The zoneId it contains can * <p>NOTE: The {@link TelephonyTimeZoneSuggestion} cannot be null. The zoneId it contains can * be null to indicate there is no active suggestion; this can be used to clear a previous * be null to indicate there is no active suggestion; this can be used to clear a previous * suggestion. * suggestion. * * * @param suggestion the time zone * @param suggestion the time zone suggestion */ */ void maybeSuggestDeviceTimeZone(@NonNull TelephonyTimeZoneSuggestion suggestion); void maybeSuggestDeviceTimeZone(@NonNull TelephonyTimeZoneSuggestion suggestion); Loading
src/java/com/android/internal/telephony/nitz/NewTimeServiceHelperImpl.java→src/java/com/android/internal/telephony/nitz/TimeServiceHelperImpl.java +5 −5 Original line number Original line Diff line number Diff line Loading @@ -34,9 +34,9 @@ import java.io.PrintWriter; import java.util.Objects; import java.util.Objects; /** /** * The real implementation of {@link NewTimeServiceHelper}. * The real implementation of {@link TimeServiceHelper}. */ */ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper { public final class TimeServiceHelperImpl implements TimeServiceHelper { private final int mSlotIndex; private final int mSlotIndex; private final TimeDetector mTimeDetector; private final TimeDetector mTimeDetector; Loading @@ -53,7 +53,7 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper { @NonNull @NonNull private TelephonyTimeZoneSuggestion mLastSuggestedTimeZone; private TelephonyTimeZoneSuggestion mLastSuggestedTimeZone; public NewTimeServiceHelperImpl(@NonNull Phone phone) { public TimeServiceHelperImpl(@NonNull Phone phone) { mSlotIndex = phone.getPhoneId(); mSlotIndex = phone.getPhoneId(); Context context = Objects.requireNonNull(phone.getContext()); Context context = Objects.requireNonNull(phone.getContext()); mTimeDetector = Objects.requireNonNull(context.getSystemService(TimeDetector.class)); mTimeDetector = Objects.requireNonNull(context.getSystemService(TimeDetector.class)); Loading Loading @@ -99,7 +99,7 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper { @Override @Override public void dumpLogs(IndentingPrintWriter ipw) { public void dumpLogs(IndentingPrintWriter ipw) { ipw.println("NewTimeServiceHelperImpl:"); ipw.println("TimeServiceHelperImpl:"); ipw.increaseIndent(); ipw.increaseIndent(); ipw.println("Time Logs:"); ipw.println("Time Logs:"); ipw.increaseIndent(); ipw.increaseIndent(); Loading @@ -115,6 +115,6 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper { @Override @Override public void dumpState(PrintWriter pw) { public void dumpState(PrintWriter pw) { pw.println(" NewTimeServiceHelperImpl.mLastSuggestedTimeZone=" + mLastSuggestedTimeZone); pw.println(" TimeServiceHelperImpl.mLastSuggestedTimeZone=" + mLastSuggestedTimeZone); } } } }
tests/telephonytests/src/com/android/internal/telephony/nitz/NitzStateMachineImplTest.java +14 −14 Original line number Original line Diff line number Diff line Loading @@ -60,7 +60,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { private static final TelephonyTimeSuggestion EMPTY_TIME_SUGGESTION = private static final TelephonyTimeSuggestion EMPTY_TIME_SUGGESTION = createEmptyTimeSuggestion(SLOT_INDEX); createEmptyTimeSuggestion(SLOT_INDEX); private FakeNewTimeServiceHelper mFakeNewTimeServiceHelper; private FakeTimeServiceHelper mFakeTimeServiceHelper; private FakeDeviceState mFakeDeviceState; private FakeDeviceState mFakeDeviceState; private TimeZoneSuggesterImpl mRealTimeZoneSuggester; private TimeZoneSuggesterImpl mRealTimeZoneSuggester; Loading @@ -69,12 +69,12 @@ public class NitzStateMachineImplTest extends TelephonyTest { @Before @Before public void setUp() throws Exception { public void setUp() throws Exception { TelephonyTest.logd("NewNitzStateMachineImplTest +Setup!"); TelephonyTest.logd("NitzStateMachineImplTest +Setup!"); super.setUp("NewNitzStateMachineImplTest"); super.setUp("NitzStateMachineImplTest"); // In tests we use a fake impls for NewTimeServiceHelper and DeviceState. // In tests we use a fake impls for NewTimeServiceHelper and DeviceState. mFakeDeviceState = new FakeDeviceState(); mFakeDeviceState = new FakeDeviceState(); mFakeNewTimeServiceHelper = new FakeNewTimeServiceHelper(mFakeDeviceState); mFakeTimeServiceHelper = new FakeTimeServiceHelper(mFakeDeviceState); // In tests we disable NITZ signal input filtering. The real NITZ signal filter is tested // In tests we disable NITZ signal input filtering. The real NITZ signal filter is tested // independently. This makes constructing test data simpler: we can be sure the signals // independently. This makes constructing test data simpler: we can be sure the signals Loading @@ -91,7 +91,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { mNitzStateMachineImpl = new NitzStateMachineImpl( mNitzStateMachineImpl = new NitzStateMachineImpl( SLOT_INDEX, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, SLOT_INDEX, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester, mFakeNewTimeServiceHelper); mFakeTimeServiceHelper); TelephonyTest.logd("NewNitzStateMachineImplTest -Setup!"); TelephonyTest.logd("NewNitzStateMachineImplTest -Setup!"); } } Loading Loading @@ -574,22 +574,22 @@ public class NitzStateMachineImplTest extends TelephonyTest { } } private void justVerifyTimeWasNotSuggested() { private void justVerifyTimeWasNotSuggested() { mFakeNewTimeServiceHelper.suggestedTimes.assertHasNotBeenSet(); mFakeTimeServiceHelper.suggestedTimes.assertHasNotBeenSet(); } } private void justVerifyTimeZoneWasSuggested( private void justVerifyTimeZoneWasSuggested( TelephonyTimeZoneSuggestion timeZoneSuggestion) { TelephonyTimeZoneSuggestion timeZoneSuggestion) { mFakeNewTimeServiceHelper.suggestedTimeZones.assertHasBeenSet(); mFakeTimeServiceHelper.suggestedTimeZones.assertHasBeenSet(); mFakeNewTimeServiceHelper.suggestedTimeZones.assertLatestEquals(timeZoneSuggestion); mFakeTimeServiceHelper.suggestedTimeZones.assertLatestEquals(timeZoneSuggestion); } } private void justVerifyTimeWasSuggested(TelephonyTimeSuggestion timeSuggestion) { private void justVerifyTimeWasSuggested(TelephonyTimeSuggestion timeSuggestion) { mFakeNewTimeServiceHelper.suggestedTimes.assertChangeCount(1); mFakeTimeServiceHelper.suggestedTimes.assertChangeCount(1); mFakeNewTimeServiceHelper.suggestedTimes.assertLatestEquals(timeSuggestion); mFakeTimeServiceHelper.suggestedTimes.assertLatestEquals(timeSuggestion); } } private void commitStateChanges() { private void commitStateChanges() { mFakeNewTimeServiceHelper.commitState(); mFakeTimeServiceHelper.commitState(); } } } } Loading Loading @@ -643,10 +643,10 @@ public class NitzStateMachineImplTest extends TelephonyTest { } } /** /** * A fake implementation of {@link NewTimeServiceHelper} that enables tests to detect what * A fake implementation of {@link TimeServiceHelper} that enables tests to detect what * {@link NitzStateMachineImpl} would do to a real device's state. * {@link NitzStateMachineImpl} would do to a real device's state. */ */ private static class FakeNewTimeServiceHelper implements NewTimeServiceHelper { private static class FakeTimeServiceHelper implements TimeServiceHelper { private final FakeDeviceState mFakeDeviceState; private final FakeDeviceState mFakeDeviceState; Loading @@ -654,7 +654,7 @@ public class NitzStateMachineImplTest extends TelephonyTest { public final TestState<TelephonyTimeSuggestion> suggestedTimes = new TestState<>(); public final TestState<TelephonyTimeSuggestion> suggestedTimes = new TestState<>(); public final TestState<TelephonyTimeZoneSuggestion> suggestedTimeZones = new TestState<>(); public final TestState<TelephonyTimeZoneSuggestion> suggestedTimeZones = new TestState<>(); FakeNewTimeServiceHelper(FakeDeviceState fakeDeviceState) { FakeTimeServiceHelper(FakeDeviceState fakeDeviceState) { mFakeDeviceState = fakeDeviceState; mFakeDeviceState = fakeDeviceState; } } Loading