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

Commit 963c98ad authored by Neil Fuller's avatar Neil Fuller
Browse files

Create a new implementation of NitzStateMachine

Create a new implementation of NitzStateMachine by copying
OldNitzStateMachine and calling it NewNitzStateMachine.
The associated TimeServiceHelper is also being renamed
OldTimeServiceHelper, and a NewTimeServiceHelper is being
created.

In this initial commit NewNitzStateMachine is a copy of
OldNitzStateMachine with no logic changes.

The old version is kept for now in case we need to switch
back due to a bug and for reference.

Test: build
Test: (internal) atest FrameworksTelephonyTests:com.android.internal.telephony.NewNitzStateMachineTest
Test: (internal) atest FrameworksTelephonyTests:com.android.internal.telephony.OldNitzStateMachineTest
Bug: 78217059

Change-Id: I84d3a3247c6b4982b886e6232ca4c09748eadcb6
parent c47b54d8
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -350,14 +350,27 @@ 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) {
        if (!TimeServiceHelper.isTimeZoneSettingInitializedStatic()) {
        // 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()) {
                String zoneId = defaultTimeZoneForMcc(mcc);
                if (zoneId != null && zoneId.length() > 0) {
                    // Set time zone based on MCC
                TimeServiceHelper.setDeviceTimeZoneStatic(context, zoneId);
                    NewTimeServiceHelper.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);
                }
            }
        }
    }

    /**
+533 −0

File added.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import android.provider.Settings;
 * new service.
 */
// Non-final to allow mocking.
public class TimeServiceHelper {
public class NewTimeServiceHelper {

    /**
     * Callback interface for automatic detection enable/disable changes.
@@ -57,7 +57,7 @@ public class TimeServiceHelper {
    private Listener mListener;

    /** Creates a TimeServiceHelper */
    public TimeServiceHelper(Context context) {
    public NewTimeServiceHelper(Context context) {
        mContext = context;
        mCr = context.getContentResolver();
    }
+4 −4

File changed.

Preview size limit exceeded, changes collapsed.

+193 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading