Merge changes from topic "cpt-perf" into main
* changes:
Async Initialize CarrierPrivilegesTracker
Performance Optimizations for CarrierPrivilegesTracker
diff --git a/flags/data.aconfig b/flags/data.aconfig
index 0fd094d..ccd5db4 100644
--- a/flags/data.aconfig
+++ b/flags/data.aconfig
@@ -132,3 +132,10 @@
}
}
+# OWNER=TBD TARGET=TBD
+flag {
+ name: "oem_paid_private"
+ namespace: "telephony"
+ description: "Support OEM_PAID and OEM_PRIVATE networks"
+ bug: "366194627"
+}
diff --git a/src/java/com/android/internal/telephony/CarrierServiceBindHelper.java b/src/java/com/android/internal/telephony/CarrierServiceBindHelper.java
index 55baecc..4f9d84d 100644
--- a/src/java/com/android/internal/telephony/CarrierServiceBindHelper.java
+++ b/src/java/com/android/internal/telephony/CarrierServiceBindHelper.java
@@ -17,6 +17,7 @@
package com.android.internal.telephony;
import android.annotation.NonNull;
+import android.app.ActivityManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -161,7 +162,11 @@
};
public CarrierServiceBindHelper(Context context) {
- mContext = context.createContextAsUser(Process.myUserHandle(), 0);
+ mContext =
+ context.createContextAsUser(
+ Flags.supportCarrierServicesForHsum()
+ ? UserHandle.of(ActivityManager.getCurrentUser())
+ : Process.myUserHandle(), 0);
updateBindingsAndSimStates();
diff --git a/src/java/com/android/internal/telephony/data/DataUtils.java b/src/java/com/android/internal/telephony/data/DataUtils.java
index 20da97f..c88e0b3 100644
--- a/src/java/com/android/internal/telephony/data/DataUtils.java
+++ b/src/java/com/android/internal/telephony/data/DataUtils.java
@@ -287,6 +287,8 @@
case NetworkCapabilities.NET_CAPABILITY_VSIM -> ApnSetting.TYPE_VSIM;
case NetworkCapabilities.NET_CAPABILITY_BIP -> ApnSetting.TYPE_BIP;
case NetworkCapabilities.NET_CAPABILITY_RCS -> ApnSetting.TYPE_RCS;
+ case NetworkCapabilities.NET_CAPABILITY_OEM_PAID -> ApnSetting.TYPE_OEM_PAID;
+ case NetworkCapabilities.NET_CAPABILITY_OEM_PRIVATE -> ApnSetting.TYPE_OEM_PRIVATE;
default -> ApnSetting.TYPE_NONE;
};
}
@@ -315,6 +317,8 @@
case ApnSetting.TYPE_VSIM -> NetworkCapabilities.NET_CAPABILITY_VSIM;
case ApnSetting.TYPE_ENTERPRISE -> NetworkCapabilities.NET_CAPABILITY_ENTERPRISE;
case ApnSetting.TYPE_RCS -> NetworkCapabilities.NET_CAPABILITY_RCS;
+ case ApnSetting.TYPE_OEM_PAID -> NetworkCapabilities.NET_CAPABILITY_OEM_PAID;
+ case ApnSetting.TYPE_OEM_PRIVATE -> NetworkCapabilities.NET_CAPABILITY_OEM_PRIVATE;
default -> -1;
};
}
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
index 8ae6cf4..c89aa65 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
@@ -2930,6 +2930,21 @@
}
/**
+ * This API can be used by only CTS to control ingoring cellular service state event.
+ *
+ * @param enabled Whether to enable boolean config.
+ * @return {@code true} if the value is set successfully, {@code false} otherwise.
+ */
+ public boolean setSatelliteIgnoreCellularServiceState(boolean enabled) {
+ plogd("setSatelliteIgnoreCellularServiceState - " + enabled);
+ if (mSatelliteSessionController == null) {
+ ploge("setSatelliteIgnoreCellularServiceState is not initialized yet");
+ return false;
+ }
+ return mSatelliteSessionController.setSatelliteIgnoreCellularServiceState(enabled);
+ }
+
+ /**
* This API can be used by only CTS to override timeout durations used by DatagramController
* module.
*
@@ -4825,6 +4840,17 @@
return getConfigForSubId(subId).getBoolean(KEY_SATELLITE_ESOS_SUPPORTED_BOOL);
}
+ /**
+ * Return whether the device allows to turn off satellite session for emergency call.
+ *
+ * @param subId Associated subscription ID
+ */
+ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
+ public boolean turnOffSatelliteSessionForEmergencyCall(int subId) {
+ return getConfigForSubId(subId).getBoolean(
+ KEY_SATELLITE_ROAMING_TURN_OFF_SESSION_FOR_EMERGENCY_CALL_BOOL);
+ }
+
private int getCarrierRoamingNtnConnectType(int subId) {
return getConfigForSubId(subId).getInt(KEY_CARRIER_ROAMING_NTN_CONNECT_TYPE_INT);
}
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java b/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
index f4208f7..540d106 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
@@ -52,6 +52,7 @@
import android.os.SystemProperties;
import android.telephony.DropBoxManagerLoggerBackend;
import android.telephony.PersistentLogger;
+import android.telephony.ServiceState;
import android.telephony.satellite.ISatelliteModemStateCallback;
import android.telephony.satellite.SatelliteManager;
import android.telephony.satellite.stub.ISatelliteGateway;
@@ -66,6 +67,7 @@
import com.android.internal.telephony.ExponentialBackoff;
import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.flags.FeatureFlags;
import com.android.internal.telephony.satellite.metrics.SessionMetricsStats;
import com.android.internal.util.State;
@@ -124,6 +126,8 @@
private static final int EVENT_SCREEN_STATE_CHANGED = 9;
protected static final int EVENT_SCREEN_OFF_INACTIVITY_TIMER_TIMED_OUT = 10;
protected static final int EVENT_CARRIER_ROAMING_NB_IOT_INACTIVITY_TIMER_TIMED_OUT = 11;
+ private static final int EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE = 12;
+ private static final int EVENT_SERVICE_STATE_CHANGED = 13;
private static final long REBIND_INITIAL_DELAY = 2 * 1000; // 2 seconds
private static final long REBIND_MAXIMUM_DELAY = 64 * 1000; // 1 minute
@@ -160,6 +164,7 @@
private long mSatelliteStayAtListeningFromSendingMillis;
private long mSatelliteStayAtListeningFromReceivingMillis;
private long mSatelliteNbIotInactivityTimeoutMillis;
+ private boolean mIgnoreCellularServiceState = false;
private final ConcurrentHashMap<IBinder, ISatelliteModemStateCallback> mListeners;
@SatelliteManager.SatelliteModemState private int mCurrentState;
@SatelliteManager.SatelliteModemState private int mPreviousState;
@@ -205,8 +210,10 @@
boolean isSatelliteSupported) {
if (sInstance == null || isSatelliteSupported != sInstance.mIsSatelliteSupported) {
ConcurrentHashMap<IBinder, ISatelliteModemStateCallback> existingListeners = null;
+ boolean existIgnoreCellularServiceState = false;
if (sInstance != null) {
existingListeners = sInstance.mListeners;
+ existIgnoreCellularServiceState = sInstance.mIgnoreCellularServiceState;
sInstance.cleanUpResource();
}
@@ -220,6 +227,10 @@
Log.d(TAG, "make() existingListeners: " + existingListeners.size());
sInstance.mListeners.putAll(existingListeners);
}
+ if (existIgnoreCellularServiceState) {
+ Log.d(TAG, "make() existIgnoreCellularServiceState is true");
+ sInstance.mIgnoreCellularServiceState = true;
+ }
}
return sInstance;
}
@@ -277,13 +288,27 @@
bindService();
});
- Phone phone = mSatelliteController.getSatellitePhone();
- if (phone == null) {
- phone = SatelliteServiceUtils.getPhone();
+ Phone satellitePhone = mSatelliteController.getSatellitePhone();
+ if (satellitePhone == null) {
+ satellitePhone = SatelliteServiceUtils.getPhone();
}
- mDeviceStateMonitor = phone.getDeviceStateMonitor();
+ mDeviceStateMonitor = satellitePhone.getDeviceStateMonitor();
mSessionMetricsStats = SessionMetricsStats.getInstance();
+ if (mFeatureFlags.carrierRoamingNbIotNtn()) {
+ // Register to received Cellular service state
+ for (Phone phone : PhoneFactory.getPhones()) {
+ if (phone == null) continue;
+
+ phone.registerForServiceStateChanged(
+ getHandler(), EVENT_SERVICE_STATE_CHANGED, null);
+ if (DBG) {
+ plogd("SatelliteSessionController: registerForServiceStateChanged phoneId "
+ + phone.getPhoneId());
+ }
+ }
+ }
+
addState(mUnavailableState);
addState(mPowerOffState);
addState(mEnablingState);
@@ -450,6 +475,23 @@
}
/**
+ * This API can be used by only CTS to control ingoring cellular service state event.
+ *
+ * @param enabled Whether to enable boolean config.
+ * @return {@code true} if the value is set successfully, {@code false} otherwise.
+ */
+ public boolean setSatelliteIgnoreCellularServiceState(boolean enabled) {
+ plogd("setSatelliteIgnoreCellularServiceState : "
+ + "old = " + mIgnoreCellularServiceState + " new : " + enabled);
+ if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
+ return false;
+ }
+
+ mIgnoreCellularServiceState = enabled;
+ return true;
+ }
+
+ /**
* This API can be used by only CTS to update satellite gateway service package name.
*
* @param servicePackageName The package name of the satellite gateway service.
@@ -547,9 +589,33 @@
plogd("cleanUpResource");
mIsDeviceAlignedWithSatellite = false;
unregisterForScreenStateChanged();
+
+ if (mFeatureFlags.carrierRoamingNbIotNtn()) {
+ // Register to received Cellular service state
+ for (Phone phone : PhoneFactory.getPhones()) {
+ if (phone == null) continue;
+
+ phone.unregisterForServiceStateChanged(getHandler());
+ if (DBG) {
+ plogd("cleanUpResource: unregisterForServiceStateChanged phoneId "
+ + phone.getPhoneId());
+ }
+ }
+ }
+
quitNow();
}
+ /**
+ * Uses this function to notify that cellular service state has changed
+ *
+ * @param serviceState The state of the cellular service.
+ */
+ @VisibleForTesting
+ public void onCellularServiceStateChanged(ServiceState serviceState) {
+ sendMessage(EVENT_SERVICE_STATE_CHANGED, new AsyncResult(null, serviceState, null));
+ }
+
private boolean isDemoMode() {
return mIsDemoMode;
}
@@ -790,8 +856,11 @@
mCurrentState = SatelliteManager.SATELLITE_MODEM_STATE_IDLE;
mIsSendingTriggeredDuringTransferringState.set(false);
stopNbIotInactivityTimer();
+
//Enable Cellular Modem scanning
- mSatelliteModemInterface.enableCellularModemWhileSatelliteModeIsOn(true, null);
+ Message onCompleted =
+ obtainMessage(EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE);
+ mSatelliteModemInterface.enableCellularModemWhileSatelliteModeIsOn(true, onCompleted);
notifyStateChangedEvent(SatelliteManager.SATELLITE_MODEM_STATE_IDLE);
}
@@ -821,6 +890,27 @@
case EVENT_SATELLITE_MODEM_STATE_CHANGED:
handleSatelliteModemStateChanged(msg);
break;
+ case EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE:
+ if (!mIgnoreCellularServiceState) {
+ handleEventEnableCellularModemWhileSatelliteModeIsOnDone();
+ } else {
+ plogd("IdleState: processing: ignore "
+ + "EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE");
+ }
+ break;
+ case EVENT_SERVICE_STATE_CHANGED:
+ if (!mIgnoreCellularServiceState) {
+ AsyncResult ar = (msg.obj != null) ? (AsyncResult) msg.obj : null;
+ if (ar == null || ar.result == null) {
+ plogd("IdleState: processing: can't access ServiceState");
+ } else {
+ ServiceState newServiceState = (ServiceState) ar.result;
+ handleEventServiceStateChanged(newServiceState);
+ }
+ } else {
+ plogd("IdleState: processing: ignore EVENT_SERVICE_STATE_CHANGED");
+ }
+ break;
}
// Ignore all unexpected events.
return HANDLED;
@@ -848,6 +938,58 @@
}
}
+ private void handleEventEnableCellularModemWhileSatelliteModeIsOnDone() {
+ if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
+ Rlog.d(TAG, "handleEventEnableCellularModemWhileSatelliteModeIsOnDone: "
+ + "carrierRoamingNbIotNtn is disabled");
+ return;
+ }
+
+ ServiceState serviceState = mSatelliteController.getSatellitePhone().getServiceState();
+ if (serviceState == null) {
+ plogd("handleEventEnableCellularModemWhileSatelliteModeIsOnDone: "
+ + "can't access ServiceState");
+ return;
+ }
+ handleEventServiceStateChanged(serviceState);
+ }
+
+ private void handleEventServiceStateChanged(ServiceState serviceState) {
+ boolean isInServiceOrEmergency =
+ serviceState.getVoiceRegState() == ServiceState.STATE_IN_SERVICE
+ || serviceState.getDataRegState() == ServiceState.STATE_IN_SERVICE
+ || serviceState.isEmergencyOnly();
+ if (!isInServiceOrEmergency) {
+ plogd("handleEventServiceStateChanged: is not IN_SERVICE or EMERGENCY_ONLY");
+ return;
+ }
+
+ // In emergency
+ boolean isEmergency = mSatelliteController.getRequestIsEmergency();
+ if (isEmergency) {
+ boolean isEmergencyCommunicationEstablished = (mDatagramController == null)
+ ? false : mDatagramController.isEmergencyCommunicationEstablished();
+ boolean isTurnOffAllowed =
+ mSatelliteController.turnOffSatelliteSessionForEmergencyCall(getSubId());
+ if (isEmergencyCommunicationEstablished || !isTurnOffAllowed) {
+ logd("handleEventServiceStateChanged: "
+ + "can't disable emergency satellite session");
+ return;
+ }
+ }
+
+ mSatelliteController.requestSatelliteEnabled(
+ false /*enableSatellite*/,
+ false /*enableDemoMode*/,
+ isEmergency /*isEmergency*/,
+ new IIntegerConsumer.Stub() {
+ @Override
+ public void accept(int result) {
+ plogd("requestSatelliteEnabled result=" + result);
+ }
+ });
+ }
+
private void handleEventDisableCellularModemWhileSatelliteModeIsOnDone(
@NonNull AsyncResult result) {
synchronized (mLock) {
@@ -1232,6 +1374,12 @@
case EVENT_CARRIER_ROAMING_NB_IOT_INACTIVITY_TIMER_TIMED_OUT:
whatString = "EVENT_CARRIER_ROAMING_NB_IOT_INACTIVITY_TIMER_TIMED_OUT";
break;
+ case EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE:
+ whatString = "EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE";
+ break;
+ case EVENT_SERVICE_STATE_CHANGED:
+ whatString = "EVENT_SERVICE_STATE_CHANGED";
+ break;
default:
whatString = "UNKNOWN EVENT " + what;
}
diff --git a/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java b/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
index a645439..fae5e8b 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java
@@ -981,6 +981,8 @@
mApplicationInfo.targetSdkVersion = Build.VERSION_CODES.TIRAMISU;
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(anyString(), anyInt());
+ doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfoAsUser(
+ anyString(), anyInt(), any(UserHandle.class));
mContextFixture.addCallingOrSelfPermission("");
mContextFixture.addCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE);
mContextFixture.addCallingOrSelfPermission(
@@ -1077,6 +1079,8 @@
mApplicationInfo.targetSdkVersion = Build.VERSION_CODES.TIRAMISU;
doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfo(anyString(), anyInt());
+ doReturn(mApplicationInfo).when(mPackageManager).getApplicationInfoAsUser(
+ anyString(), anyInt(), any(UserHandle.class));
mContextFixture.addCallingOrSelfPermission("");
mContextFixture.addCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE);
mContextFixture.addCallingOrSelfPermission(
diff --git a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java
index b4af458..a617182 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java
@@ -49,6 +49,7 @@
import android.os.Looper;
import android.os.Message;
import android.os.PersistableBundle;
+import android.telephony.ServiceState;
import android.telephony.satellite.ISatelliteModemStateCallback;
import android.telephony.satellite.SatelliteManager;
import android.testing.AndroidTestingRunner;
@@ -104,6 +105,7 @@
@Mock private DatagramReceiver mMockDatagramReceiver;
@Mock private DatagramDispatcher mMockDatagramDispatcher;
@Mock private DatagramController mMockDatagramController;
+ @Mock private ServiceState mMockServiceState;
@Captor ArgumentCaptor<Handler> mHandlerCaptor;
@Captor ArgumentCaptor<Integer> mMsgCaptor;
@@ -216,6 +218,7 @@
// Notify Screen off
sendScreenStateChanged(mHandlerCaptor.getValue(), mMsgCaptor.getValue(), false);
processAllMessages();
+ clearInvocations(mMockSatelliteController);
// Verify that the screen off inactivity timer is started.
assertTrue(mTestSatelliteSessionController.isScreenOffInActivityTimerStarted());
@@ -283,6 +286,8 @@
doNothing().when(mDeviceStateMonitor).registerForScreenStateChanged(
eq(mTestSatelliteSessionController.getHandler()), anyInt(), any());
when(mMockSatelliteController.isSatelliteAttachRequired()).thenReturn(true);
+ when(mMockSatelliteController.turnOffSatelliteSessionForEmergencyCall(
+ anyInt())).thenReturn(false);
when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(false);
when(mMockSatelliteController.isSatelliteRoamingP2pSmSSupported(
@@ -295,6 +300,7 @@
// Since satellite is supported, SatelliteSessionController should move to POWER_OFF state.
assertNotNull(mTestSatelliteSessionController);
+ mTestSatelliteSessionController.setSatelliteEnabledForNtnOnlySubscription(false);
assertEquals(STATE_POWER_OFF, mTestSatelliteSessionController.getCurrentStateName());
setupDatagramTransferringState(true);
@@ -328,6 +334,8 @@
doNothing().when(mDeviceStateMonitor).registerForScreenStateChanged(
eq(mTestSatelliteSessionController.getHandler()), anyInt(), any());
when(mMockSatelliteController.isSatelliteAttachRequired()).thenReturn(true);
+ when(mMockSatelliteController.turnOffSatelliteSessionForEmergencyCall(
+ anyInt())).thenReturn(false);
when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(true);
when(mMockSatelliteController.isSatelliteEsosSupported(anyInt())).thenReturn(true);
@@ -338,6 +346,7 @@
// Since satellite is supported, SatelliteSessionController should move to POWER_OFF state.
assertNotNull(mTestSatelliteSessionController);
+ mTestSatelliteSessionController.setSatelliteEnabledForNtnOnlySubscription(false);
assertEquals(STATE_POWER_OFF, mTestSatelliteSessionController.getCurrentStateName());
setupDatagramTransferringState(true);
@@ -366,6 +375,76 @@
}
@Test
+ public void testDisableSatelliteWhenCellularModemEnabledInIdleMode() {
+ when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
+ doNothing().when(mDeviceStateMonitor).registerForScreenStateChanged(
+ eq(mTestSatelliteSessionController.getHandler()), anyInt(), any());
+ when(mMockSatelliteController.isSatelliteAttachRequired()).thenReturn(false);
+ when(mPhone.getServiceState()).thenReturn(mMockServiceState);
+
+ // Since satellite is supported, SatelliteSessionController should move to POWER_OFF state.
+ assertNotNull(mTestSatelliteSessionController);
+ mTestSatelliteSessionController.setSatelliteEnabledForNtnOnlySubscription(false);
+ assertEquals(STATE_POWER_OFF, mTestSatelliteSessionController.getCurrentStateName());
+
+ // Conditions for operation
+ boolean isEmergency = true;
+ // Cellular network is not IN_SERVICE and emergency only.
+ // Satellite request is emergency and emergency communication was established.
+ // Disabling satellite was not allowed
+ when(mMockServiceState.getVoiceRegState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
+ when(mMockServiceState.getDataRegState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
+ when(mMockServiceState.isEmergencyOnly()).thenReturn(false);
+ when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(isEmergency);
+ when(mMockDatagramController.isEmergencyCommunicationEstablished()).thenReturn(true);
+ when(mMockSatelliteController.turnOffSatelliteSessionForEmergencyCall(
+ anyInt())).thenReturn(false);
+
+ moveToIdleState();
+
+ // Cellular network is not in STATE_IN_SERVICE or emergency only.
+ // Should not disable satellite
+ verify(mMockSatelliteController, never()).requestSatelliteEnabled(
+ eq(false), eq(false), eq(isEmergency), any(IIntegerConsumer.Stub.class));
+
+ // Notify cellular service is in STATE_IN_SERVICE.
+ ServiceState serviceState = new ServiceState();
+ serviceState.setVoiceRegState(ServiceState.STATE_IN_SERVICE);
+ serviceState.setDataRegState(ServiceState.STATE_OUT_OF_SERVICE);
+ serviceState.setEmergencyOnly(false);
+ mTestSatelliteSessionController.onCellularServiceStateChanged(serviceState);
+ processAllMessages();
+
+ // Satellite is in emergency mode and emergency communication was established.
+ // Should not disable satellite
+ verify(mMockSatelliteController, never()).requestSatelliteEnabled(
+ eq(false), eq(false), eq(isEmergency), any(IIntegerConsumer.Stub.class));
+
+ // Satellite is in emergency mode but emergency communication was not established.
+ // Disabling satellite was not allowed
+ when(mMockDatagramController.isEmergencyCommunicationEstablished()).thenReturn(false);
+ when(mMockSatelliteController.turnOffSatelliteSessionForEmergencyCall(
+ anyInt())).thenReturn(false);
+ mTestSatelliteSessionController.onCellularServiceStateChanged(serviceState);
+ processAllMessages();
+
+ // Should not disable satellite
+ verify(mMockSatelliteController, never()).requestSatelliteEnabled(
+ eq(false), eq(false), eq(isEmergency), any(IIntegerConsumer.Stub.class));
+
+ // Satellite is in emergency mode but emergency communication was not established.
+ // Disabling satellite was allowed
+ when(mMockSatelliteController.turnOffSatelliteSessionForEmergencyCall(
+ anyInt())).thenReturn(true);
+ mTestSatelliteSessionController.onCellularServiceStateChanged(serviceState);
+ processAllMessages();
+
+ // Should disable satellite
+ verify(mMockSatelliteController).requestSatelliteEnabled(
+ eq(false), eq(false), eq(isEmergency), any(IIntegerConsumer.Stub.class));
+ }
+
+ @Test
public void testStateTransition() {
/**
* Since satellite is supported, SatelliteSessionController should move to POWER_OFF state.
@@ -1419,6 +1498,8 @@
}
private static class TestSatelliteSessionController extends SatelliteSessionController {
+ boolean mSatelliteEnabledForNtnOnlySubscription = true;
+
TestSatelliteSessionController(Context context, Looper looper, FeatureFlags featureFlags,
boolean isSatelliteSupported,
SatelliteModemInterface satelliteModemInterface) {
@@ -1450,7 +1531,11 @@
}
protected boolean isSatelliteEnabledForNtnOnlySubscription() {
- return true;
+ return mSatelliteEnabledForNtnOnlySubscription;
+ }
+
+ void setSatelliteEnabledForNtnOnlySubscription(boolean enabled) {
+ mSatelliteEnabledForNtnOnlySubscription = false;
}
}