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

Commit cf8993fa authored by Neil Fuller's avatar Neil Fuller
Browse files

Rename NewTimeServiceHelper: it is no longer new

The original TimeServiceHelper / TimeServiceHelperImpl were deleted in
commit a4011139.  This commit also changes log messages/tests to
correct remaining references to NewNitzStateMachineImpl.

Bug: 149014708
Test: build only
Merged-In: I35854e853ded5be9ba129a970279e8ef122e2eb2
Change-Id: I35854e853ded5be9ba129a970279e8ef122e2eb2
(cherry picked from commit 46ed5cdc)
parent 1591e841
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine {
     */
    private final TimeZoneSuggester mTimeZoneSuggester;
    /** A facade to the time / time zone detection services. */
    private final NewTimeServiceHelper mNewTimeServiceHelper;
    private final TimeServiceHelper mTimeServiceHelper;

    // Shared detection state.

@@ -136,7 +136,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine {
        TimeZoneLookupHelper timeZoneLookupHelper = new TimeZoneLookupHelper();
        TimeZoneSuggester timeZoneSuggester =
                new TimeZoneSuggesterImpl(deviceState, timeZoneLookupHelper);
        NewTimeServiceHelper newTimeServiceHelper = new NewTimeServiceHelperImpl(phone);
        TimeServiceHelper newTimeServiceHelper = new TimeServiceHelperImpl(phone);
        NitzSignalInputFilterPredicate nitzSignalFilter =
                NitzSignalInputFilterPredicateFactory.create(phone.getContext(), deviceState);
        return new NitzStateMachineImpl(
@@ -151,10 +151,10 @@ public final class NitzStateMachineImpl implements NitzStateMachine {
    public NitzStateMachineImpl(int slotIndex,
            @NonNull NitzSignalInputFilterPredicate nitzSignalInputFilter,
            @NonNull TimeZoneSuggester timeZoneSuggester,
            @NonNull NewTimeServiceHelper newTimeServiceHelper) {
            @NonNull TimeServiceHelper newTimeServiceHelper) {
        mSlotIndex = slotIndex;
        mTimeZoneSuggester = Objects.requireNonNull(timeZoneSuggester);
        mNewTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper);
        mTimeServiceHelper = Objects.requireNonNull(newTimeServiceHelper);
        mNitzSignalInputFilter = Objects.requireNonNull(nitzSignalInputFilter);
    }

@@ -292,7 +292,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine {
                        + ", nitzSignal=" + nitzSignal + ", suggestion=" + suggestion
                        + ", reason=" + reason);
            }
            mNewTimeServiceHelper.maybeSuggestDeviceTimeZone(suggestion);
            mTimeServiceHelper.maybeSuggestDeviceTimeZone(suggestion);
        } catch (RuntimeException ex) {
            Rlog.e(LOG_TAG, "doTimeZoneDetection: Exception thrown"
                    + " mSlotIndex=" + mSlotIndex
@@ -325,7 +325,7 @@ public final class NitzStateMachineImpl implements NitzStateMachine {
                        + " nitzSignal=" + nitzSignal
                        + ", reason=" + reason);
            }
            mNewTimeServiceHelper.suggestDeviceTime(builder.build());
            mTimeServiceHelper.suggestDeviceTime(builder.build());
        } catch (RuntimeException ex) {
            Rlog.e(LOG_TAG, "doTimeDetection: Exception thrown"
                    + " mSlotIndex=" + mSlotIndex
@@ -337,15 +337,15 @@ public final class NitzStateMachineImpl implements NitzStateMachine {

    @Override
    public void dumpState(PrintWriter pw) {
        pw.println(" NewNitzStateMachineImpl.mLatestNitzSignal=" + mLatestNitzSignal);
        pw.println(" NewNitzStateMachineImpl.mCountryIsoCode=" + mCountryIsoCode);
        mNewTimeServiceHelper.dumpState(pw);
        pw.println(" NitzStateMachineImpl.mLatestNitzSignal=" + mLatestNitzSignal);
        pw.println(" NitzStateMachineImpl.mCountryIsoCode=" + mCountryIsoCode);
        mTimeServiceHelper.dumpState(pw);
        pw.flush();
    }

    @Override
    public void dumpLogs(FileDescriptor fd, IndentingPrintWriter ipw, String[] args) {
        mNewTimeServiceHelper.dumpLogs(ipw);
        mTimeServiceHelper.dumpLogs(ipw);
    }

    @Nullable
+10 −8
Original line number Diff line number Diff line
@@ -18,34 +18,36 @@ package com.android.internal.telephony.nitz;

import android.annotation.NonNull;
import android.app.timedetector.TelephonyTimeSuggestion;
import android.app.timedetector.TimeDetector;
import android.app.timezonedetector.TelephonyTimeZoneSuggestion;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;

import java.io.PrintWriter;

/**
 * An interface to various time / time zone detection behaviors that should be centralized into
 * new services.
 * An interface to various time / time zone detection behaviors that are centralized into 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);

    /**
     * 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
     * be null to indicate there is no active suggestion; this can be used to clear a previous
     * suggestion.
     *
     * @param suggestion the time zone
     * @param suggestion the time zone suggestion
     */
    void maybeSuggestDeviceTimeZone(@NonNull TelephonyTimeZoneSuggestion suggestion);

+5 −5
Original line number Diff line number Diff line
@@ -34,9 +34,9 @@ import java.io.PrintWriter;
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 TimeDetector mTimeDetector;
@@ -53,7 +53,7 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper {
    @NonNull
    private TelephonyTimeZoneSuggestion mLastSuggestedTimeZone;

    public NewTimeServiceHelperImpl(@NonNull Phone phone) {
    public TimeServiceHelperImpl(@NonNull Phone phone) {
        mSlotIndex = phone.getPhoneId();
        Context context = Objects.requireNonNull(phone.getContext());
        mTimeDetector = Objects.requireNonNull(context.getSystemService(TimeDetector.class));
@@ -99,7 +99,7 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper {

    @Override
    public void dumpLogs(IndentingPrintWriter ipw) {
        ipw.println("NewTimeServiceHelperImpl:");
        ipw.println("TimeServiceHelperImpl:");
        ipw.increaseIndent();
        ipw.println("Time Logs:");
        ipw.increaseIndent();
@@ -115,6 +115,6 @@ public final class NewTimeServiceHelperImpl implements NewTimeServiceHelper {

    @Override
    public void dumpState(PrintWriter pw) {
        pw.println(" NewTimeServiceHelperImpl.mLastSuggestedTimeZone=" + mLastSuggestedTimeZone);
        pw.println(" TimeServiceHelperImpl.mLastSuggestedTimeZone=" + mLastSuggestedTimeZone);
    }
}
+14 −14
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class NitzStateMachineImplTest extends TelephonyTest {
    private static final TelephonyTimeSuggestion EMPTY_TIME_SUGGESTION =
            createEmptyTimeSuggestion(SLOT_INDEX);

    private FakeNewTimeServiceHelper mFakeNewTimeServiceHelper;
    private FakeTimeServiceHelper mFakeTimeServiceHelper;
    private FakeDeviceState mFakeDeviceState;
    private TimeZoneSuggesterImpl mRealTimeZoneSuggester;

@@ -69,12 +69,12 @@ public class NitzStateMachineImplTest extends TelephonyTest {

    @Before
    public void setUp() throws Exception {
        TelephonyTest.logd("NewNitzStateMachineImplTest +Setup!");
        super.setUp("NewNitzStateMachineImplTest");
        TelephonyTest.logd("NitzStateMachineImplTest +Setup!");
        super.setUp("NitzStateMachineImplTest");

        // In tests we use a fake impls for NewTimeServiceHelper and DeviceState.
        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
        // independently. This makes constructing test data simpler: we can be sure the signals
@@ -91,7 +91,7 @@ public class NitzStateMachineImplTest extends TelephonyTest {

        mNitzStateMachineImpl = new NitzStateMachineImpl(
                SLOT_INDEX, mFakeNitzSignalInputFilter, mRealTimeZoneSuggester,
                mFakeNewTimeServiceHelper);
                mFakeTimeServiceHelper);

        TelephonyTest.logd("NewNitzStateMachineImplTest -Setup!");
    }
@@ -574,22 +574,22 @@ public class NitzStateMachineImplTest extends TelephonyTest {
        }

        private void justVerifyTimeWasNotSuggested() {
            mFakeNewTimeServiceHelper.suggestedTimes.assertHasNotBeenSet();
            mFakeTimeServiceHelper.suggestedTimes.assertHasNotBeenSet();
        }

        private void justVerifyTimeZoneWasSuggested(
                TelephonyTimeZoneSuggestion timeZoneSuggestion) {
            mFakeNewTimeServiceHelper.suggestedTimeZones.assertHasBeenSet();
            mFakeNewTimeServiceHelper.suggestedTimeZones.assertLatestEquals(timeZoneSuggestion);
            mFakeTimeServiceHelper.suggestedTimeZones.assertHasBeenSet();
            mFakeTimeServiceHelper.suggestedTimeZones.assertLatestEquals(timeZoneSuggestion);
        }

        private void justVerifyTimeWasSuggested(TelephonyTimeSuggestion timeSuggestion) {
            mFakeNewTimeServiceHelper.suggestedTimes.assertChangeCount(1);
            mFakeNewTimeServiceHelper.suggestedTimes.assertLatestEquals(timeSuggestion);
            mFakeTimeServiceHelper.suggestedTimes.assertChangeCount(1);
            mFakeTimeServiceHelper.suggestedTimes.assertLatestEquals(timeSuggestion);
        }

        private void commitStateChanges() {
            mFakeNewTimeServiceHelper.commitState();
            mFakeTimeServiceHelper.commitState();
        }
    }

@@ -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.
     */
    private static class FakeNewTimeServiceHelper implements NewTimeServiceHelper {
    private static class FakeTimeServiceHelper implements TimeServiceHelper {

        private final FakeDeviceState mFakeDeviceState;

@@ -654,7 +654,7 @@ public class NitzStateMachineImplTest extends TelephonyTest {
        public final TestState<TelephonyTimeSuggestion> suggestedTimes = new TestState<>();
        public final TestState<TelephonyTimeZoneSuggestion> suggestedTimeZones = new TestState<>();

        FakeNewTimeServiceHelper(FakeDeviceState fakeDeviceState) {
        FakeTimeServiceHelper(FakeDeviceState fakeDeviceState) {
            mFakeDeviceState = fakeDeviceState;
        }