summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aishwarya Mallampati <amallampati@google.com> 2025-03-17 18:57:44 +0000
committer Aishwarya Mallampati <amallampati@google.com> 2025-03-19 17:50:15 +0000
commit67411ed9fc6aa97d68ce66f67c82c71838ee1173 (patch)
treea166fc33f52b35d32ea372d1d338c37a3e03223e
parent7896552b218b958c82656e627a57a407d7f96601 (diff)
Check data registration state in isCellularAvailable
Bug: 403826786 Test: atest SatelliteServiceUtilsTest Test: b/404360253 Flag: EXEMPT bugfix Change-Id: I3416255e8a5b0363ebefba62dfe53f7561eff008
-rw-r--r--src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java11
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java6
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java2
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java19
4 files changed, 37 insertions, 1 deletions
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java b/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java
index 3e77bd9d38..318e8cf65e 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteServiceUtils.java
@@ -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;
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
index ded67d72ff..55a44caf32 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
@@ -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);
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java
index 0a60b856c0..9d4a6e4e7e 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSOSMessageRecommenderTest.java
@@ -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,
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java
index 7bf8ab46a7..9185dcec24 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteServiceUtilsTest.java
@@ -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