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

Commit 93161351 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati Committed by Android (Google) Code Review
Browse files

Merge "Check data registration state in isCellularAvailable" into main

parents 5b8c2944 67411ed9
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
@@ -3965,6 +3965,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);
@@ -4028,6 +4030,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);
@@ -6890,6 +6894,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