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

Commit 67411ed9 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Check data registration state in isCellularAvailable

Bug: 403826786
Test: atest SatelliteServiceUtilsTest
Test: b/404360253
Flag: EXEMPT bugfix
Change-Id: I3416255e8a5b0363ebefba62dfe53f7561eff008
parent 7896552b
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -533,8 +533,17 @@ public class SatelliteServiceUtils {
            ServiceState serviceState = phone.getServiceState();
            if (serviceState != null) {
                int state = serviceState.getState();
                NetworkRegistrationInfo dataNri = serviceState.getNetworkRegistrationInfo(
                        NetworkRegistrationInfo.DOMAIN_PS,
                        AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
                boolean isCellularDataInService = dataNri != null && dataNri.isInService();
                logd("isCellularAvailable: phoneId=" + phone.getPhoneId() + " state=" + state
                        + " isEmergencyOnly=" + serviceState.isEmergencyOnly()
                        + " isCellularDataInService=" + isCellularDataInService);

                if ((state == STATE_IN_SERVICE || state == STATE_EMERGENCY_ONLY
                        || serviceState.isEmergencyOnly())
                        || serviceState.isEmergencyOnly()
                        || isCellularDataInService)
                        && !isSatellitePlmn(phone.getSubId(), serviceState)) {
                    logd("isCellularAvailable true");
                    return true;
+6 −0
Original line number Diff line number Diff line
@@ -3941,6 +3941,8 @@ public class SatelliteControllerTest extends TelephonyTest {
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
        when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState2.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        when(mServiceState2.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        mSatelliteControllerUT.mIsApplicationSupportsP2P = true;
        mCarrierConfigBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
        mCarrierConfigBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT, 1);
@@ -4004,6 +4006,8 @@ public class SatelliteControllerTest extends TelephonyTest {
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
        when(mServiceState2.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        when(mServiceState2.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        mSatelliteControllerUT.mIsApplicationSupportsP2P = true;
        mSatelliteControllerUT.setIsSatelliteSupported(true);
        mCarrierConfigBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
@@ -6866,6 +6870,8 @@ public class SatelliteControllerTest extends TelephonyTest {
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
        when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState2.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        when(mServiceState2.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        mSatelliteControllerUT.mIsApplicationSupportsP2P = true;
        mCarrierConfigBundle.putBoolean(KEY_SATELLITE_ATTACH_SUPPORTED_BOOL, true);
        mCarrierConfigBundle.putInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT, 1);
+2 −0
Original line number Diff line number Diff line
@@ -175,6 +175,8 @@ public class SatelliteSOSMessageRecommenderTest extends TelephonyTest {
                mTestSatelliteController, mTestImsManager);
        when(mServiceState.getState()).thenReturn(STATE_OUT_OF_SERVICE);
        when(mServiceState2.getState()).thenReturn(STATE_OUT_OF_SERVICE);
        when(mServiceState.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        when(mServiceState2.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        when(mPhone.isImsRegistered()).thenReturn(false);
        when(mPhone2.isImsRegistered()).thenReturn(false);
        replaceInstance(SatelliteStats.class, "sInstance", null,
+19 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.internal.telephony.satellite;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;

@@ -144,6 +145,8 @@ public class SatelliteServiceUtilsTest extends TelephonyTest {
    public void testIsCellularAvailable() {
        when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState2.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        when(mServiceState2.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(null);
        assertFalse(SatelliteServiceUtils.isCellularAvailable());

        when(mServiceState.getState()).thenReturn(ServiceState.STATE_EMERGENCY_ONLY);
@@ -157,6 +160,22 @@ public class SatelliteServiceUtilsTest extends TelephonyTest {
        when(mServiceState2.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState2.isEmergencyOnly()).thenReturn(true);
        assertTrue(SatelliteServiceUtils.isCellularAvailable());

        NetworkRegistrationInfo dataNri = new NetworkRegistrationInfo.Builder()
                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME)
                .build();
        when(mServiceState.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(dataNri);
        when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState2.isEmergencyOnly()).thenReturn(false);
        assertTrue(SatelliteServiceUtils.isCellularAvailable());

        dataNri = new NetworkRegistrationInfo.Builder()
                .setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_EMERGENCY)
                .build();
        when(mServiceState.getNetworkRegistrationInfo(anyInt(), anyInt())).thenReturn(dataNri);
        when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
        when(mServiceState2.isEmergencyOnly()).thenReturn(false);
        assertFalse(SatelliteServiceUtils.isCellularAvailable());
    }

    @Test