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

Commit 103e42f1 authored by Pengquan Meng's avatar Pengquan Meng
Browse files

resolve merge conflicts of 0a1b7c2b to stage-aosp-master

Test: I solemnly swear I tested this conflict resolution.
Change-Id: Ic4ce6a0cf640ccd7706c66672ee75b716e795bc4
parents 686b9154 0a1b7c2b
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -211,6 +211,7 @@ public class ServiceStateTracker extends Handler {
    protected static final int EVENT_PHONE_TYPE_SWITCHED               = 50;
    protected static final int EVENT_RADIO_POWER_FROM_CARRIER          = 51;
    protected static final int EVENT_SIM_NOT_INSERTED                  = 52;
    protected static final int EVENT_IMS_SERVICE_STATE_CHANGED         = 53;

    protected static final String TIMEZONE_PROPERTY = "persist.sys.timezone";

@@ -1346,6 +1347,15 @@ public class ServiceStateTracker extends Handler {
                updateSpnDisplay();
                break;

            case EVENT_IMS_SERVICE_STATE_CHANGED:
                if (DBG) log("EVENT_IMS_SERVICE_STATE_CHANGED");
                // IMS state will only affect the merged service state if the service state of
                // GsmCdma phone is not STATE_IN_SERVICE.
                if (mSS.getState() != ServiceState.STATE_IN_SERVICE) {
                    mPhone.notifyServiceStateChanged(mPhone.getServiceState());
                }
                break;

            //CDMA
            case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
                handleCdmaSubscriptionSource(mCdmaSSM.getCdmaSubscriptionSource());
@@ -2548,6 +2558,11 @@ public class ServiceStateTracker extends Handler {
        }
    }

    /** Called when the service state of ImsPhone is changed. */
    public void onImsServiceStateChanged() {
        sendMessage(obtainMessage(EVENT_IMS_SERVICE_STATE_CHANGED));
    }

    public void setImsRegistrationState(boolean registered) {
        log("ImsRegistrationState - registered : " + registered);

@@ -2810,6 +2825,8 @@ public class ServiceStateTracker extends Handler {
            mRejectCode = mNewRejectCode;
        }

        ServiceState oldMergedSS = mPhone.getServiceState();

        // swap mSS and mNewSS to put new state in mSS
        ServiceState tss = mSS;
        mSS = mNewSS;
@@ -2921,7 +2938,10 @@ public class ServiceStateTracker extends Handler {
            setRoamingType(mSS);
            log("Broadcasting ServiceState : " + mSS);
            // notify using PhoneStateListener and the legacy intent ACTION_SERVICE_STATE_CHANGED
            mPhone.notifyServiceStateChanged(mSS);
            // notify service state changed only if the merged service state is changed.
            if (!oldMergedSS.equals(mPhone.getServiceState())) {
                mPhone.notifyServiceStateChanged(mPhone.getServiceState());
            }

            // insert into ServiceStateProvider. This will trigger apps to wake through JobScheduler
            mPhone.getContext().getContentResolver()
+3 −3
Original line number Diff line number Diff line
@@ -266,10 +266,10 @@ public class ImsPhone extends ImsPhoneBase {
        }
        updateDataServiceState();

        // Notifies the service state to the listeners. The service state combined from ImsPhone
        // and GsmCdmaPhone, it may be changed when the service state in ImsPhone is changed.
        if (isVoiceRegStateChanged) {
            mNotifier.notifyServiceState(mDefaultPhone);
            if (mDefaultPhone.getServiceStateTracker() != null) {
                mDefaultPhone.getServiceStateTracker().onImsServiceStateChanged();
            }
        }
    }

+25 −0
Original line number Diff line number Diff line
@@ -331,6 +331,31 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertFalse(sst.isImsRegistered());
    }

    @Test
    public void testOnImsServiceStateChanged() {
        // The service state of GsmCdmaPhone is STATE_OUT_OF_SERVICE, and IMS is unregistered.
        ServiceState ss = new ServiceState();
        ss.setVoiceRegState(ServiceState.STATE_OUT_OF_SERVICE);
        sst.mSS = ss;

        sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_IMS_SERVICE_STATE_CHANGED));
        waitForMs(200);

        // The listener will be notified that the service state was changed.
        verify(mPhone).notifyServiceStateChanged(any(ServiceState.class));

        // The service state of GsmCdmaPhone is STATE_IN_SERVICE, and IMS is registered.
        ss = new ServiceState();
        ss.setVoiceRegState(ServiceState.STATE_IN_SERVICE);
        sst.mSS = ss;

        sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_IMS_SERVICE_STATE_CHANGED));
        waitForMs(200);

        // Nothing happened because the IMS service state was not affected the merged service state.
        verify(mPhone, times(1)).notifyServiceStateChanged(any(ServiceState.class));
    }

    @Test
    @MediumTest
    public void testSignalStrength() {
+4 −6
Original line number Diff line number Diff line
@@ -488,23 +488,21 @@ public class ImsPhoneTest extends TelephonyTest {
    }

    @Test
    @SmallTest
    public void testShouldSendNotificationWhenServiceStateIsChanged() {
        mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE);
        reset(mNotifier);
        reset(mSST);

        mImsPhoneUT.setServiceState(ServiceState.STATE_OUT_OF_SERVICE);
        verify(mNotifier).notifyServiceState(mPhone);
        verify(mSST).onImsServiceStateChanged();
    }

    @Test
    @SmallTest
    public void testShouldNotSendNotificationWhenServiceStateIsNotChanged() {
        mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE);
        reset(mNotifier);
        reset(mSST);

        mImsPhoneUT.setServiceState(ServiceState.STATE_IN_SERVICE);
        verify(mNotifier, never()).notifyServiceState(mPhone);
        verify(mSST, never()).onImsServiceStateChanged();
    }

    @Test