Loading src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java +42 −14 Original line number Diff line number Diff line Loading @@ -875,8 +875,7 @@ public class SatelliteSessionController extends StateMachine { //Enable Cellular Modem scanning boolean configSatelliteAllowTnScanningDuringSatelliteSession = mContext.getResources().getBoolean( R.bool.config_satellite_allow_tn_scanning_during_satellite_session); isTnScanningAllowedDuringSatelliteSession(); if (configSatelliteAllowTnScanningDuringSatelliteSession) { Message onCompleted = obtainMessage(EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE); Loading Loading @@ -1217,12 +1216,7 @@ public class SatelliteSessionController extends StateMachine { } break; case EVENT_P2P_SMS_INACTIVITY_TIMER_TIMED_OUT: if (isEsosInActivityTimerStarted()) { plogd("NotConnectedState: processing: ESOS inactivity timer running " + "can not move to IDLE"); } else { transitionTo(mIdleState); } handleEventP2pSmsInactivityTimerTimedOut(); break; case EVENT_NB_IOT_INACTIVITY_TIMER_TIMED_OUT: transitionTo(mIdleState); Loading Loading @@ -1345,12 +1339,7 @@ public class SatelliteSessionController extends StateMachine { } break; case EVENT_P2P_SMS_INACTIVITY_TIMER_TIMED_OUT: if (isEsosInActivityTimerStarted()) { plogd("ConnectedState: processing: ESOS inactivity timer running " + "can not move to IDLE"); } else { transitionTo(mIdleState); } handleEventP2pSmsInactivityTimerTimedOut(); break; } // Ignore all unexpected events. Loading Loading @@ -1690,6 +1679,35 @@ public class SatelliteSessionController extends StateMachine { } } private void handleEventP2pSmsInactivityTimerTimedOut() { if (isEsosInActivityTimerStarted()) { plogd("handleEventP2pSmsInactivityTimerTimedOut: processing: ESOS inactivity timer " + "running can not move to IDLE"); } else { if (isTnScanningAllowedDuringSatelliteSession()) { plogd("handleEventP2pSmsInactivityTimerTimedOut: Transition to IDLE state"); transitionTo(mIdleState); } else { if (mSatelliteController.getRequestIsEmergency()) { plogd("handleEventP2pSmsInactivityTimerTimedOut: Emergency mode"); return; } plogd("handleEventP2pSmsInactivityTimerTimedOut: request disable satellite"); mSatelliteController.requestSatelliteEnabled( false /*enableSatellite*/, false /*enableDemoMode*/, mSatelliteController.getRequestIsEmergency() /*isEmergency*/, new IIntegerConsumer.Stub() { @Override public void accept(int result) { plogd("requestSatelliteEnabled result=" + result); } }); } } } private int getScreenOffInactivityTimeoutDurationSec() { PersistableBundle config = mSatelliteController.getPersistableBundle(getSubId()); Loading Loading @@ -1963,6 +1981,16 @@ public class SatelliteSessionController extends StateMachine { } } private boolean isTnScanningAllowedDuringSatelliteSession() { try { return mContext.getResources().getBoolean( R.bool.config_satellite_allow_tn_scanning_during_satellite_session); } catch (RuntimeException e) { plogd("isTnScanningAllowedDuringSatelliteSession: ex=" + e); return false; } } private void plogd(@NonNull String log) { logd(log); if (mPersistentLogger != null) { Loading tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java +42 −0 Original line number Diff line number Diff line Loading @@ -2124,6 +2124,48 @@ public class SatelliteSessionControllerTest extends TelephonyTest { clearInvocations(mMockDatagramController); } @Test public void testP2pSmsInactivityTimerTimedOut_tnScanningNotSupported() { when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true); when(mMockSatelliteController.isSatelliteAttachRequired()).thenReturn(true); when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(false); when(mMockSatelliteController.isSatelliteRoamingP2pSmSSupported( anyInt())).thenReturn(true); when(mMockSatelliteController.getSupportedServicesOnCarrierRoamingNtn(anyInt())) .thenReturn(new int[]{ NetworkRegistrationInfo.SERVICE_TYPE_SMS, NetworkRegistrationInfo.SERVICE_TYPE_EMERGENCY}); when(mMockSatelliteController.isInCarrierRoamingNbIotNtn()).thenReturn(true); Resources resources = mContext.getResources(); when(resources.getBoolean( R.bool.config_satellite_allow_tn_scanning_during_satellite_session)) .thenReturn(false); PersistableBundle bundle = new PersistableBundle(); bundle.putInt(KEY_SATELLITE_ROAMING_P2P_SMS_INACTIVITY_TIMEOUT_SEC_INT, P2P_SMS_INACTIVITY_TIMEOUT_SEC); when(mMockSatelliteController.getPersistableBundle(anyInt())).thenReturn(bundle); // Since satellite is supported, SatelliteSessionController should move to POWER_OFF state. assertNotNull(mTestSatelliteSessionController); mTestSatelliteSessionController.setSatelliteEnabledForNtnOnlySubscription(false); assertEquals(STATE_POWER_OFF, mTestSatelliteSessionController.getCurrentStateName()); setupDatagramTransferringState(true); moveToNotConnectedState(); // Verify that the P2P SMS inactivity timer is started. assertTrue(mTestSatelliteSessionController.isP2pSmsInActivityTimerStarted()); // Time shift to cause timeout moveTimeForward(P2P_SMS_INACTIVITY_TIMEOUT_SEC * 1000); processAllMessages(); // Should disable satellite verify(mMockSatelliteController).requestSatelliteEnabled( eq(false), eq(false), eq(false), any(IIntegerConsumer.Stub.class)); } private void verifyEsosP2pSmsInactivityTimer(boolean esosTimer, boolean p2pSmsTimer) { assertEquals(mTestSatelliteSessionController.isEsosInActivityTimerStarted(), esosTimer); assertEquals(mTestSatelliteSessionController.isP2pSmsInActivityTimerStarted(), Loading Loading
src/java/com/android/internal/telephony/satellite/SatelliteSessionController.java +42 −14 Original line number Diff line number Diff line Loading @@ -875,8 +875,7 @@ public class SatelliteSessionController extends StateMachine { //Enable Cellular Modem scanning boolean configSatelliteAllowTnScanningDuringSatelliteSession = mContext.getResources().getBoolean( R.bool.config_satellite_allow_tn_scanning_during_satellite_session); isTnScanningAllowedDuringSatelliteSession(); if (configSatelliteAllowTnScanningDuringSatelliteSession) { Message onCompleted = obtainMessage(EVENT_ENABLE_CELLULAR_MODEM_WHILE_SATELLITE_MODE_IS_ON_DONE); Loading Loading @@ -1217,12 +1216,7 @@ public class SatelliteSessionController extends StateMachine { } break; case EVENT_P2P_SMS_INACTIVITY_TIMER_TIMED_OUT: if (isEsosInActivityTimerStarted()) { plogd("NotConnectedState: processing: ESOS inactivity timer running " + "can not move to IDLE"); } else { transitionTo(mIdleState); } handleEventP2pSmsInactivityTimerTimedOut(); break; case EVENT_NB_IOT_INACTIVITY_TIMER_TIMED_OUT: transitionTo(mIdleState); Loading Loading @@ -1345,12 +1339,7 @@ public class SatelliteSessionController extends StateMachine { } break; case EVENT_P2P_SMS_INACTIVITY_TIMER_TIMED_OUT: if (isEsosInActivityTimerStarted()) { plogd("ConnectedState: processing: ESOS inactivity timer running " + "can not move to IDLE"); } else { transitionTo(mIdleState); } handleEventP2pSmsInactivityTimerTimedOut(); break; } // Ignore all unexpected events. Loading Loading @@ -1690,6 +1679,35 @@ public class SatelliteSessionController extends StateMachine { } } private void handleEventP2pSmsInactivityTimerTimedOut() { if (isEsosInActivityTimerStarted()) { plogd("handleEventP2pSmsInactivityTimerTimedOut: processing: ESOS inactivity timer " + "running can not move to IDLE"); } else { if (isTnScanningAllowedDuringSatelliteSession()) { plogd("handleEventP2pSmsInactivityTimerTimedOut: Transition to IDLE state"); transitionTo(mIdleState); } else { if (mSatelliteController.getRequestIsEmergency()) { plogd("handleEventP2pSmsInactivityTimerTimedOut: Emergency mode"); return; } plogd("handleEventP2pSmsInactivityTimerTimedOut: request disable satellite"); mSatelliteController.requestSatelliteEnabled( false /*enableSatellite*/, false /*enableDemoMode*/, mSatelliteController.getRequestIsEmergency() /*isEmergency*/, new IIntegerConsumer.Stub() { @Override public void accept(int result) { plogd("requestSatelliteEnabled result=" + result); } }); } } } private int getScreenOffInactivityTimeoutDurationSec() { PersistableBundle config = mSatelliteController.getPersistableBundle(getSubId()); Loading Loading @@ -1963,6 +1981,16 @@ public class SatelliteSessionController extends StateMachine { } } private boolean isTnScanningAllowedDuringSatelliteSession() { try { return mContext.getResources().getBoolean( R.bool.config_satellite_allow_tn_scanning_during_satellite_session); } catch (RuntimeException e) { plogd("isTnScanningAllowedDuringSatelliteSession: ex=" + e); return false; } } private void plogd(@NonNull String log) { logd(log); if (mPersistentLogger != null) { Loading
tests/telephonytests/src/com/android/internal/telephony/satellite/SatelliteSessionControllerTest.java +42 −0 Original line number Diff line number Diff line Loading @@ -2124,6 +2124,48 @@ public class SatelliteSessionControllerTest extends TelephonyTest { clearInvocations(mMockDatagramController); } @Test public void testP2pSmsInactivityTimerTimedOut_tnScanningNotSupported() { when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true); when(mMockSatelliteController.isSatelliteAttachRequired()).thenReturn(true); when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(false); when(mMockSatelliteController.isSatelliteRoamingP2pSmSSupported( anyInt())).thenReturn(true); when(mMockSatelliteController.getSupportedServicesOnCarrierRoamingNtn(anyInt())) .thenReturn(new int[]{ NetworkRegistrationInfo.SERVICE_TYPE_SMS, NetworkRegistrationInfo.SERVICE_TYPE_EMERGENCY}); when(mMockSatelliteController.isInCarrierRoamingNbIotNtn()).thenReturn(true); Resources resources = mContext.getResources(); when(resources.getBoolean( R.bool.config_satellite_allow_tn_scanning_during_satellite_session)) .thenReturn(false); PersistableBundle bundle = new PersistableBundle(); bundle.putInt(KEY_SATELLITE_ROAMING_P2P_SMS_INACTIVITY_TIMEOUT_SEC_INT, P2P_SMS_INACTIVITY_TIMEOUT_SEC); when(mMockSatelliteController.getPersistableBundle(anyInt())).thenReturn(bundle); // Since satellite is supported, SatelliteSessionController should move to POWER_OFF state. assertNotNull(mTestSatelliteSessionController); mTestSatelliteSessionController.setSatelliteEnabledForNtnOnlySubscription(false); assertEquals(STATE_POWER_OFF, mTestSatelliteSessionController.getCurrentStateName()); setupDatagramTransferringState(true); moveToNotConnectedState(); // Verify that the P2P SMS inactivity timer is started. assertTrue(mTestSatelliteSessionController.isP2pSmsInActivityTimerStarted()); // Time shift to cause timeout moveTimeForward(P2P_SMS_INACTIVITY_TIMEOUT_SEC * 1000); processAllMessages(); // Should disable satellite verify(mMockSatelliteController).requestSatelliteEnabled( eq(false), eq(false), eq(false), any(IIntegerConsumer.Stub.class)); } private void verifyEsosP2pSmsInactivityTimer(boolean esosTimer, boolean p2pSmsTimer) { assertEquals(mTestSatelliteSessionController.isEsosInActivityTimerStarted(), esosTimer); assertEquals(mTestSatelliteSessionController.isP2pSmsInActivityTimerStarted(), Loading