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

Commit a0d10c1a authored by Jack Yu's avatar Jack Yu Committed by Gerrit Code Review
Browse files

Merge "Fixed incorrect merge service state"

parents f604f167 b328b92a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4083,6 +4083,7 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
        pw.println(" getActiveApnTypes()=" + getActiveApnTypes());
        pw.println(" needsOtaServiceProvisioning=" + needsOtaServiceProvisioning());
        pw.println(" isInEmergencySmsMode=" + isInEmergencySmsMode());
        pw.println(" service state=" + getServiceState());
        pw.flush();
        pw.println("++++++++++++++++++++++++++++++++");

+4 −0
Original line number Diff line number Diff line
@@ -5223,6 +5223,10 @@ public class ServiceStateTracker extends Handler {
                    mNewSS.addNetworkRegistrationInfo(nri);
                }
                mNewSS.setOperatorAlphaLong(operator);
                // Since it's in airplane mode, cellular must be out of service. The only possible
                // transport for data to go through is the IWLAN transport. Setting this to true
                // so that ServiceState.getDataNetworkType can report the right RAT.
                mNewSS.setIwlanPreferred(true);
                log("pollStateDone: mNewSS = " + mNewSS);
            }
            return;
+1 −0
Original line number Diff line number Diff line
@@ -1444,6 +1444,7 @@ public class ImsPhone extends ImsPhoneBase {
                mSS.addNetworkRegistrationInfo(nri);
            }

            mSS.setIwlanPreferred(ss.isIwlanPreferred());
            logd("updateDataServiceState: defSs = " + ss + " imsSs = " + mSS);
        }
    }
+84 −0
Original line number Diff line number Diff line
@@ -167,6 +167,89 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        assertEquals(serviceState, mPhoneUT.getServiceState());
    }

    @Test
    @SmallTest
    public void testGetMergedServiceState() throws Exception {
        ServiceState imsServiceState = new ServiceState();

        NetworkRegistrationInfo imsCsWwanRegInfo = new NetworkRegistrationInfo.Builder()
                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
                .setRegistrationState(
                        NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                .build();

        NetworkRegistrationInfo imsPsWwanRegInfo = new NetworkRegistrationInfo.Builder()
                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
                .setRegistrationState(
                        NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                .build();

        NetworkRegistrationInfo imsPsWlanRegInfo = new NetworkRegistrationInfo.Builder()
                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
                .setRegistrationState(
                        NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                .build();

        imsServiceState.addNetworkRegistrationInfo(imsCsWwanRegInfo);
        imsServiceState.addNetworkRegistrationInfo(imsPsWwanRegInfo);
        imsServiceState.addNetworkRegistrationInfo(imsPsWlanRegInfo);

        imsServiceState.setVoiceRegState(ServiceState.STATE_IN_SERVICE);
        imsServiceState.setDataRegState(ServiceState.STATE_IN_SERVICE);
        imsServiceState.setIwlanPreferred(true);
        doReturn(imsServiceState).when(mImsPhone).getServiceState();

        replaceInstance(Phone.class, "mImsPhone", mPhoneUT, mImsPhone);

        ServiceState serviceState = new ServiceState();

        NetworkRegistrationInfo csWwanRegInfo = new NetworkRegistrationInfo.Builder()
                .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
                .setRegistrationState(
                        NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING)
                .build();

        NetworkRegistrationInfo psWwanRegInfo = new NetworkRegistrationInfo.Builder()
                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_LTE)
                .setRegistrationState(
                        NetworkRegistrationInfo.REGISTRATION_STATE_NOT_REGISTERED_OR_SEARCHING)
                .build();

        NetworkRegistrationInfo psWlanRegInfo = new NetworkRegistrationInfo.Builder()
                .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
                .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WLAN)
                .setAccessNetworkTechnology(TelephonyManager.NETWORK_TYPE_IWLAN)
                .setRegistrationState(
                        NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                .build();

        serviceState.addNetworkRegistrationInfo(csWwanRegInfo);
        serviceState.addNetworkRegistrationInfo(psWwanRegInfo);
        serviceState.addNetworkRegistrationInfo(psWlanRegInfo);
        serviceState.setVoiceRegState(ServiceState.STATE_OUT_OF_SERVICE);
        serviceState.setDataRegState(ServiceState.STATE_IN_SERVICE);
        serviceState.setIwlanPreferred(true);

        mSST.mSS = serviceState;
        mPhoneUT.mSST = mSST;

        ServiceState mergedServiceState = mPhoneUT.getServiceState();

        assertEquals(ServiceState.STATE_IN_SERVICE, mergedServiceState.getVoiceRegState());
        assertEquals(ServiceState.STATE_IN_SERVICE, mergedServiceState.getDataRegState());
        assertEquals(TelephonyManager.NETWORK_TYPE_IWLAN, mergedServiceState.getDataNetworkType());
    }

    @Test
    @SmallTest
    public void testGetSubscriberIdForGsmPhone() {
@@ -1002,3 +1085,4 @@ public class GsmCdmaPhoneTest extends TelephonyTest {
        assertEquals(msisdn, mPhoneUT.getLine1Number());
    }
}