Merge cherrypicks of ['googleplex-android-review.googlesource.com/31389860', 'googleplex-android-review.googlesource.com/31389861'] into 25Q1-release.
Change-Id: I2bcd54ea3c3e81b1603233ad48d5659320a46cea
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteController.java b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
index c87011e..bf0d882 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteController.java
@@ -307,6 +307,7 @@
private static final int CMD_UPDATE_SYSTEM_SELECTION_CHANNELS = 58;
private static final int EVENT_UPDATE_SYSTEM_SELECTION_CHANNELS_DONE = 59;
private static final int EVENT_SELECTED_NB_IOT_SATELLITE_SUBSCRIPTION_CHANGED = 60;
+ private static final int CMD_EVALUATE_CARRIER_ROAMING_NTN_ELIGIBILITY_CHANGE = 61;
@NonNull private static SatelliteController sInstance;
@NonNull private final Context mContext;
@@ -2143,6 +2144,19 @@
break;
}
+ case CMD_EVALUATE_CARRIER_ROAMING_NTN_ELIGIBILITY_CHANGE: {
+ plogd("CMD_EVALUATE_CARRIER_ROAMING_NTN_ELIGIBILITY_CHANGE");
+ evaluateCarrierRoamingNtnEligibilityChange();
+ boolean eligible = isCarrierRoamingNtnEligible(getSatellitePhone());
+ plogd("CMD_EVALUATE_CARRIER_ROAMING_NTN_ELIGIBILITY_CHANGE: eligible=" + eligible);
+ int selectedSatelliteSubId = getSelectedSatelliteSubId();
+ Phone phone = SatelliteServiceUtils.getPhone(selectedSatelliteSubId);
+ if (eligible) {
+ phone.notifyCarrierRoamingNtnEligibleStateChanged(eligible);
+ }
+ break;
+ }
+
default:
Log.w(TAG, "SatelliteControllerHandler: unexpected message code: " +
msg.what);
@@ -4509,7 +4523,7 @@
RequestSatelliteEnabledArgument argument =
(RequestSatelliteEnabledArgument) request.argument;
handlePersistentLoggingOnSessionStart(argument);
- selectBindingSatelliteSubscription(argument.enableSatellite);
+ selectBindingSatelliteSubscription(false);
SatelliteModemEnableRequestAttributes enableRequestAttributes =
createModemEnableRequest(argument);
if (enableRequestAttributes == null) {
@@ -5248,6 +5262,10 @@
false, "moveSatelliteToOffStateAndCleanUpResources");
selectBindingSatelliteSubscription(false);
updateLastNotifiedNtnModeAndNotify(getSatellitePhone());
+
+ sendMessage(obtainMessage(CMD_EVALUATE_ESOS_PROFILES_PRIORITIZATION));
+ // Evaluate eligibility after satellite session is disabled
+ sendMessage(obtainMessage(CMD_EVALUATE_CARRIER_ROAMING_NTN_ELIGIBILITY_CHANGE));
}
private void setDemoModeEnabled(boolean enabled) {
@@ -6120,6 +6138,12 @@
registerForSatelliteCommunicationAllowedStateChanged();
+ if (isSatelliteEnabledOrBeingEnabled()) {
+ plogd("evaluateCarrierRoamingNtnEligibilityChange: "
+ + "Skip eligibility check as satellite is enabled or being enabled");
+ return;
+ }
+
boolean eligible = isCarrierRoamingNtnEligible(getSatellitePhone());
plogd("evaluateCarrierRoamingNtnEligibilityChange: "
+ "isCarrierRoamingNtnEligible=" + eligible);
@@ -7063,6 +7087,13 @@
plogd("evaluateESOSProfilesPrioritization: Flag CarrierRoamingNbIotNtn is disabled");
return;
}
+
+ if (isSatelliteEnabledOrBeingEnabled()) {
+ plogd("evaluateESOSProfilesPrioritization: Skip evaluation as satellite is enabled "
+ + "or being enabled");
+ return;
+ }
+
boolean isChanged = false;
List<SubscriptionInfo> allSubInfos = mSubscriptionManagerService.getAllSubInfoList(
mContext.getOpPackageName(), mContext.getAttributionTag());
diff --git a/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java b/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
index a002457..b0c985a 100644
--- a/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
+++ b/src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java
@@ -35,6 +35,7 @@
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_ENABLING_SATELLITE;
+import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_IDLE;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_LISTENING;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_UNKNOWN;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_REQUEST_ABORTED;
@@ -571,13 +572,16 @@
}
mIsDeviceAlignedWithSatellite = isAligned;
+ plogd("setDeviceAlignedWithSatellite: isAligned " + isAligned);
if (mIsDeviceAlignedWithSatellite) {
stopEsosInactivityTimer();
stopP2pSmsInactivityTimer();
endUserInactivity();
} else {
- if (mCurrentState == SatelliteManager.SATELLITE_MODEM_STATE_NOT_CONNECTED) {
+ if (mCurrentState == SatelliteManager.SATELLITE_MODEM_STATE_NOT_CONNECTED
+ || mCurrentState == SATELLITE_MODEM_STATE_CONNECTED
+ || mCurrentState == SATELLITE_MODEM_STATE_IDLE) {
evaluateStartingEsosInactivityTimer();
evaluateStartingP2pSmsInactivityTimer();
}
@@ -705,6 +709,8 @@
mIsSendingTriggeredDuringTransferringState.set(false);
unbindService();
stopNbIotInactivityTimer();
+ stopEsosInactivityTimer();
+ stopNbIotInactivityTimer();
endUserInactivity();
DemoSimulator.getInstance().onSatelliteModeOff();
notifyStateChangedEvent(SatelliteManager.SATELLITE_MODEM_STATE_OFF);
@@ -1060,6 +1066,9 @@
public void enter() {
if (DBG) plogd("Entering TransferringState");
stopNbIotInactivityTimer();
+ stopEsosInactivityTimer();
+ stopNbIotInactivityTimer();
+
mPreviousState = mCurrentState;
mCurrentState = SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING;
notifyStateChangedEvent(SATELLITE_MODEM_STATE_DATAGRAM_TRANSFERRING);
@@ -1219,9 +1228,6 @@
@Override
public void exit() {
if (DBG) plogd("Exiting NotConnectedState");
-
- stopEsosInactivityTimer();
- stopP2pSmsInactivityTimer();
}
@Override
@@ -1327,9 +1333,6 @@
@Override
public void exit() {
if (DBG) plogd("Exiting ConnectedState");
-
- stopEsosInactivityTimer();
- stopP2pSmsInactivityTimer();
}
@Override
@@ -1611,17 +1614,6 @@
return;
}
- if (!mSatelliteController.isInCarrierRoamingNbIotNtn()) {
- logd("registerScreenOnOffChanged: device is not in CarrierRoamingNbIotNtn");
- return;
- }
-
- if (mSatelliteController.getRequestIsEmergency()) {
- logd("registerScreenOnOffChanged: not register, device is in Emergency mode");
- // screen on/off timer is available in not emergency mode
- return;
- }
-
if (!mIsRegisteredScreenStateChanged && mDeviceStateMonitor != null) {
mDeviceStateMonitor.registerForScreenStateChanged(
getHandler(), EVENT_SCREEN_STATE_CHANGED, null);
@@ -1667,6 +1659,11 @@
}
mIsScreenOn = screenOn;
+ if (!mSatelliteController.isInCarrierRoamingNbIotNtn()) {
+ logd("handleEventScreenStateChanged: device is not in CarrierRoamingNbIotNtn");
+ return;
+ }
+
if (mSatelliteController.getRequestIsEmergency()) {
if (DBG) logd("handleEventScreenStateChanged: Emergency mode");
// This is for coexistence
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 bd84ce2..d142386 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteControllerTest.java
@@ -1631,8 +1631,8 @@
@Test
public void testIsSatelliteEnabled() {
logd("testIsSatelliteEnabled: starting");
- setUpResponseForRequestIsSatelliteEnabled(true, SATELLITE_RESULT_SUCCESS);
assertFalse(mSatelliteControllerUT.isSatelliteEnabledOrBeingEnabled());
+ setUpResponseForRequestIsSatelliteEnabled(true, SATELLITE_RESULT_SUCCESS);
mIsSatelliteEnabledSemaphore.drainPermits();
mSatelliteControllerUT.requestIsSatelliteEnabled(mIsSatelliteEnabledReceiver);
processAllMessages();
@@ -5481,6 +5481,7 @@
message.sendToTarget();
return null;
}).when(mMockSatelliteModemInterface).requestIsSatelliteEnabled(any(Message.class));
+ mSatelliteControllerUT.isSatelliteEnabledOrBeingEnabled = isSatelliteEnabled;
}
private void setUpResponseForRequestIsSatelliteSupported(
@@ -5960,6 +5961,11 @@
msg.sendToTarget();
}
+ private void sendCmdEvaluateCarrierRoamingNtnEligibilityChange() {
+ mSatelliteControllerUT.obtainMessage(
+ 61 /* CMD_EVALUATE_CARRIER_ROAMING_NTN_ELIGIBILITY_CHANGE */).sendToTarget();
+ }
+
private void setRadioPower(boolean on) {
mSimulatedCommands.setRadioPower(on, false, false, null);
}
@@ -6175,6 +6181,7 @@
public boolean mIsApplicationSupportsP2P = false;
public int selectedSatelliteSubId = -1;
public boolean isSatelliteProvisioned;
+ public boolean isSatelliteEnabledOrBeingEnabled = false;
TestSatelliteController(
Context context, Looper looper, @NonNull FeatureFlags featureFlags) {
@@ -6260,6 +6267,11 @@
return isSatelliteBeingDisabled;
}
+ @Override
+ public boolean isSatelliteEnabledOrBeingEnabled() {
+ return isSatelliteEnabledOrBeingEnabled;
+ }
+
protected String getConfigSatelliteGatewayServicePackage() {
String packageName = "com.example.app";
return packageName;
@@ -6665,4 +6677,20 @@
.getSatelliteDataServicePolicyForPlmn(SUB_ID, "00101");
assertEquals(SATELLITE_DATA_SUPPORT_BANDWIDTH_CONSTRAINED, dataSupportModeForPlmn);
}
+
+ @Test
+ public void testEvaluateCarrierRoamingNtnEligibilityChange_inSatelliteMode() {
+ when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
+
+ mSatelliteControllerUT.isSatelliteEnabledOrBeingEnabled = true;
+ mSatelliteControllerUT.setSatellitePhone(1);
+ mSatelliteControllerUT.setSelectedSatelliteSubId(SUB_ID);
+ mSatelliteControllerUT.isSatelliteProvisioned = true;
+ mSatelliteControllerUT.isSatelliteAllowedCallback = null;
+ setUpResponseForRequestIsSatelliteSupported(true, SATELLITE_RESULT_SUCCESS);
+ mSatelliteControllerUT.setIsSatelliteAllowedState(true);
+ sendCmdEvaluateCarrierRoamingNtnEligibilityChange();
+ processAllMessages();
+ verify(mPhone, times(0)).notifyCarrierRoamingNtnEligibleStateChanged(anyBoolean());
+ }
}
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 766d1fb..54cf227 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java
@@ -24,14 +24,12 @@
import static android.telephony.satellite.SatelliteManager.DATAGRAM_TYPE_UNKNOWN;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_FAILED;
-import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_NONE;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVE_SUCCESS;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_RECEIVING;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SENDING;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_FAILED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_SEND_SUCCESS;
import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_WAITING_TO_CONNECT;
-import static android.telephony.satellite.SatelliteManager.SATELLITE_DATAGRAM_TRANSFER_STATE_UNKNOWN;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_SUCCESS;
import static org.junit.Assert.assertEquals;
@@ -244,7 +242,7 @@
bundle.putInt(KEY_SATELLITE_ROAMING_SCREEN_OFF_INACTIVITY_TIMEOUT_SEC_INT,
SCREEN_OFF_INACTIVITY_TIMEOUT_SEC);
when(mMockSatelliteController.getPersistableBundle(anyInt())).thenReturn(bundle);
- when(mMockSatelliteController.isInCarrierRoamingNbIotNtn()).thenReturn(true);
+ when(mMockSatelliteController.isInCarrierRoamingNbIotNtn()).thenReturn(false);
// Since satellite is supported, SatelliteSessionController should move to POWER_OFF state.
assertNotNull(mTestSatelliteSessionController);
@@ -252,10 +250,13 @@
moveToIdleState();
+ // Even if the device is not in CarrierRoamingNbIotNtn
// SatelliteSessionController should call registerForScreenStateChanged.
verify(mDeviceStateMonitor).registerForScreenStateChanged(mHandlerCaptor.capture(),
mMsgCaptor.capture(), any());
+ when(mMockSatelliteController.isInCarrierRoamingNbIotNtn()).thenReturn(true);
+
// Notify Screen off
sendScreenStateChanged(mHandlerCaptor.getValue(), mMsgCaptor.getValue(), false);
processAllMessages();
@@ -293,7 +294,7 @@
doNothing().when(mDeviceStateMonitor).registerForScreenStateChanged(
eq(mTestSatelliteSessionController.getHandler()), anyInt(), any());
// Satellite enabling request is for an emergency.
- when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(true);
+ when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(false);
PersistableBundle bundle = new PersistableBundle();
bundle.putInt(KEY_SATELLITE_ROAMING_SCREEN_OFF_INACTIVITY_TIMEOUT_SEC_INT,
SCREEN_OFF_INACTIVITY_TIMEOUT_SEC);
@@ -306,18 +307,7 @@
moveToIdleState();
- // SatelliteSessionController should not call registerForScreenStateChanged.
- verify(mDeviceStateMonitor, never()).registerForScreenStateChanged(
- eq(mTestSatelliteSessionController.getHandler()), anyInt(), any());
-
- moveToPowerOffState();
-
- // Satellite enabling request is not for an emergency.
- when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(false);
-
- moveToIdleState();
-
- // SatelliteSessionController should call registerForScreenStateChanged.
+ // SatelliteSessionController should call registerForScreenStateChanged.
verify(mDeviceStateMonitor).registerForScreenStateChanged(mHandlerCaptor.capture(),
mMsgCaptor.capture(), any());
@@ -378,9 +368,11 @@
// Verify that the P2P SMS inactivity timer is stopped.
assertFalse(mTestSatelliteSessionController.isP2pSmsInActivityTimerStarted());
+ moveNotConnectedToConnectedState();
+
mTestSatelliteSessionController.setDeviceAlignedWithSatellite(false);
- // Verify that the P2P SMS inactivity timer is started.
+ // Verify that the P2P SMS inactivity timer is started in CONNECTED state.
assertTrue(mTestSatelliteSessionController.isP2pSmsInActivityTimerStarted());
// Time shift to cause timeout