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

Commit 40e8f7af authored by Neil Fuller's avatar Neil Fuller
Browse files

Make NewNitzStateMachine the only impl

Make NewNitzStateMachine the only impl by deleting
OldNitzStateMachine and associated classes and renaming
'New' classes. The "Old" code was kept around in case
the changes in the "New" code turned out to cause problems
in the Q cycle. Now we can embed the new behavior and
remove the maintenance overhead of having two classes.

Bug: 133492648
Test: build only
Change-Id: I81ad0c324dab64913b943a20b3e9e30e344b0c92
parent dbf928d3
Loading
Loading
Loading
Loading
+6 −19
Original line number Diff line number Diff line
@@ -358,27 +358,14 @@ public final class MccTable {
     * @param mcc Mobile Country Code of the SIM or SIM-like entity (build prop on CDMA)
     */
    private static void setTimezoneFromMccIfNeeded(Context context, int mcc) {
        // Switch to use the time service helper associated with the NitzStateMachine impl
        // being used. This logic will be removed once the old implementation is removed.
        if (TelephonyComponentFactory.USE_NEW_NITZ_STATE_MACHINE) {
            if (!NewTimeServiceHelper.isTimeZoneSettingInitializedStatic()) {
        if (!TimeServiceHelper.isTimeZoneSettingInitializedStatic()) {
            String zoneId = defaultTimeZoneForMcc(mcc);
            if (zoneId != null && zoneId.length() > 0) {
                // Set time zone based on MCC
                    NewTimeServiceHelper.setDeviceTimeZoneStatic(context, zoneId);
                TimeServiceHelper.setDeviceTimeZoneStatic(context, zoneId);
                Slog.d(LOG_TAG, "timezone set to " + zoneId);
            }
        }
        } else {
            if (!OldTimeServiceHelper.isTimeZoneSettingInitializedStatic()) {
                String zoneId = defaultTimeZoneForMcc(mcc);
                if (zoneId != null && zoneId.length() > 0) {
                    // Set time zone based on MCC
                    OldTimeServiceHelper.setDeviceTimeZoneStatic(context, zoneId);
                    Slog.d(LOG_TAG, "timezone set to " + zoneId);
                }
            }
        }
    }

    /**
+6 −6
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ import java.io.PrintWriter;
/**
 * {@hide}
 */
public final class NewNitzStateMachine implements NitzStateMachine {
public final class NitzStateMachineImpl implements NitzStateMachine {

    private static final String LOG_TAG = ServiceStateTracker.LOG_TAG;
    private static final boolean DBG = ServiceStateTracker.DBG;
@@ -84,21 +84,21 @@ public final class NewNitzStateMachine implements NitzStateMachine {
    private final LocalLog mTimeZoneLog = new LocalLog(15);
    private final GsmCdmaPhone mPhone;
    private final DeviceState mDeviceState;
    private final NewTimeServiceHelper mTimeServiceHelper;
    private final TimeServiceHelper mTimeServiceHelper;
    private final TimeZoneLookupHelper mTimeZoneLookupHelper;
    /** Wake lock used while setting time of day. */
    private final PowerManager.WakeLock mWakeLock;
    private static final String WAKELOCK_TAG = "NitzStateMachine";

    public NewNitzStateMachine(GsmCdmaPhone phone) {
    public NitzStateMachineImpl(GsmCdmaPhone phone) {
        this(phone,
                new NewTimeServiceHelper(phone.getContext()),
                new TimeServiceHelper(phone.getContext()),
                new DeviceState(phone),
                new TimeZoneLookupHelper());
    }

    @VisibleForTesting
    public NewNitzStateMachine(GsmCdmaPhone phone, NewTimeServiceHelper timeServiceHelper,
    public NitzStateMachineImpl(GsmCdmaPhone phone, TimeServiceHelper timeServiceHelper,
            DeviceState deviceState, TimeZoneLookupHelper timeZoneLookupHelper) {
        mPhone = phone;

@@ -110,7 +110,7 @@ public final class NewNitzStateMachine implements NitzStateMachine {
        mDeviceState = deviceState;
        mTimeZoneLookupHelper = timeZoneLookupHelper;
        mTimeServiceHelper = timeServiceHelper;
        mTimeServiceHelper.setListener(new NewTimeServiceHelper.Listener() {
        mTimeServiceHelper.setListener(new TimeServiceHelper.Listener() {
            @Override
            public void onTimeZoneDetectionChange(boolean enabled) {
                if (enabled) {
Loading