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

Commit bc0d1aa2 authored by Ling Ma's avatar Ling Ma
Browse files

Init data reg state with the current state

Init the data registration state with the current data state, to prevent the case where data become in service earlier than the controller initialization.

Fix: 312878347
Test: basic voice + data browsing
Flag: Trivial fix

Change-Id: I0810ab0b3b02d971f4c62dd884540a86358cfbc9
parent 3cb9b30c
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -191,8 +191,7 @@ public class AutoDataSwitchController extends Handler {
        /** The phone */
        @NonNull private final Phone mPhone;
        /** Data registration state of the phone */
        @RegistrationState private int mDataRegState = NetworkRegistrationInfo
                .REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING;
        @RegistrationState private int mDataRegState;
        /** Current Telephony display info of the phone */
        @NonNull private TelephonyDisplayInfo mDisplayInfo;
        /** Signal strength of the phone */
@@ -201,6 +200,10 @@ public class AutoDataSwitchController extends Handler {
        private boolean mListeningForEvents;
        private PhoneSignalStatus(@NonNull Phone phone) {
            this.mPhone = phone;
            this.mDataRegState = phone.getServiceState().getNetworkRegistrationInfo(
                            NetworkRegistrationInfo.DOMAIN_PS,
                            AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .getRegistrationState();
            this.mDisplayInfo = phone.getDisplayInfoController().getTelephonyDisplayInfo();
            this.mSignalStrength = phone.getSignalStrength();
        }
+11 −0
Original line number Diff line number Diff line
@@ -106,6 +106,17 @@ public class AutoDataSwitchControllerTest extends TelephonyTest {

        mPhones = new Phone[]{mPhone, mPhone2};
        for (Phone phone : mPhones) {
            ServiceState ss = new ServiceState();

            ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .setRegistrationState(
                            NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING)
                    .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                    .setIsNonTerrestrialNetwork(mIsNonTerrestrialNetwork)
                    .build());

            doReturn(ss).when(phone).getServiceState();
            doReturn(mSST).when(phone).getServiceStateTracker();
            doReturn(mDisplayInfoController).when(phone).getDisplayInfoController();
            doReturn(mSignalStrengthController).when(phone).getSignalStrengthController();
+11 −0
Original line number Diff line number Diff line
@@ -1936,6 +1936,17 @@ public class PhoneSwitcherTest extends TelephonyTest {
        }

        replaceInstance(PhoneFactory.class, "sPhones", null, mPhones);
        for (Phone phone : mPhones) {
            ServiceState ss = new ServiceState();

            ss.addNetworkRegistrationInfo(new NetworkRegistrationInfo.Builder()
                    .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                    .setRegistrationState(
                            NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING)
                    .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                    .build());
            doReturn(ss).when(phone).getServiceState();
        }
    }

    private void initializeCommandInterfacesMock() {