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

Commit 86644f1e authored by Jack Yu's avatar Jack Yu
Browse files

Fixed that out of service in latest service state

The service state instance broadcasted to clients
through onServiceStateChanged callback could get modified
to out of service unexpectedly. The long term solution would
be making ServiceState an immutable object.

Fix: 174306612
Test: manual
Change-Id: I7c834c2b14d1aaf9e8474c9812f97643bf79b833
parent 756f94e7
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -583,13 +583,14 @@ public class GsmCdmaPhone extends Phone {
    public ServiceState getServiceState() {
        if (mSST == null || mSST.mSS.getState() != ServiceState.STATE_IN_SERVICE) {
            if (mImsPhone != null) {
                return mergeServiceStates((mSST == null) ? new ServiceState() : mSST.mSS,
                return mergeServiceStates((mSST == null)
                                ? new ServiceState() : mSST.getServiceState(),
                        mImsPhone.getServiceState());
            }
        }

        if (mSST != null) {
            return mSST.mSS;
            return mSST.getServiceState();
        } else {
            // avoid potential NPE in EmergencyCallHelper during Phone switch
            return new ServiceState();
+1 −1
Original line number Diff line number Diff line
@@ -514,7 +514,7 @@ public class ImsPhone extends ImsPhoneBase {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @Override
    public ServiceState getServiceState() {
        return mSS;
        return new ServiceState(mSS);
    }

    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
+3 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
    public void testGetServiceState() {
        ServiceState serviceState = new ServiceState();
        mSST.mSS = serviceState;
        doReturn(serviceState).when(mSST).getServiceState();
        assertEquals(serviceState, mPhoneUT.getServiceState());
    }

@@ -238,6 +239,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        serviceState.setIwlanPreferred(true);

        mSST.mSS = serviceState;
        doReturn(serviceState).when(mSST).getServiceState();
        mPhoneUT.mSST = mSST;

        ServiceState mergedServiceState = mPhoneUT.getServiceState();
@@ -320,6 +322,7 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        serviceState.setIwlanPreferred(true);

        mSST.mSS = serviceState;
        doReturn(serviceState).when(mSST).getServiceState();
        mPhoneUT.mSST = mSST;

        ServiceState mergedServiceState = mPhoneUT.getServiceState();