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

Commit 585848bc authored by Joonhun Shin's avatar Joonhun Shin Committed by Android (Google) Code Review
Browse files

Merge "Allow TN scanning by ESOS/P2P SMS timer, even if the device is in...

Merge "Allow TN scanning by ESOS/P2P SMS timer,  even if the device is in CONNECTED state" into main
parents 2a48ab74 c49ba93f
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -1314,11 +1314,16 @@ public class SatelliteSessionController extends StateMachine {
            mCurrentState = SATELLITE_MODEM_STATE_CONNECTED;
            notifyStateChangedEvent(SATELLITE_MODEM_STATE_CONNECTED);
            startNbIotInactivityTimer();
            evaluateStartingEsosInactivityTimer();
            evaluateStartingP2pSmsInactivityTimer();
        }

        @Override
        public void exit() {
            if (DBG) plogd("Exiting ConnectedState");

            stopEsosInactivityTimer();
            stopP2pSmsInactivityTimer();
        }

        @Override
@@ -1347,6 +1352,22 @@ public class SatelliteSessionController extends StateMachine {
                case EVENT_SCREEN_OFF_INACTIVITY_TIMER_TIMED_OUT:
                    handleEventScreenOffInactivityTimerTimedOut();
                    break;
                case EVENT_ESOS_INACTIVITY_TIMER_TIMED_OUT:
                    if (isP2pSmsInActivityTimerStarted()) {
                        plogd("ConnectedState: processing: P2P_SMS inactivity timer running "
                                + "can not move to IDLE");
                    } else {
                        transitionTo(mIdleState);
                    }
                    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);
                    }
                    break;
            }
            // Ignore all unexpected events.
            return HANDLED;
+73 −0
Original line number Diff line number Diff line
@@ -755,6 +755,79 @@ public class SatelliteSessionControllerTest extends TelephonyTest {
                eq(false), eq(false), eq(true), any(IIntegerConsumer.Stub.class));
    }

    @Test
    public void testEsosP2pSmsInactivityTimerInConnectedState() {
        // Send eSOS and SMS
        // After 10 minutes SatelliteSessionController moves to idle
        // TN network reports IN_SERVICE
        // Report the callback only and don't auto exit

        long passedTime = 0;
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
        when(mMockSatelliteController.isSatelliteAttachRequired()).thenReturn(true);
        // Support ESOS
        when(mMockSatelliteController.isSatelliteEsosSupported(anyInt())).thenReturn(true);
        when(mMockSatelliteController.getRequestIsEmergency()).thenReturn(true);
        // Support P2P_SMS
        when(mMockSatelliteController.isSatelliteRoamingP2pSmSSupported(
                anyInt())).thenReturn(true);

        // Setup carrier config for timer values
        PersistableBundle bundle = new PersistableBundle();
        bundle.putInt(KEY_SATELLITE_ROAMING_ESOS_INACTIVITY_TIMEOUT_SEC_INT,
                ESOS_INACTIVITY_TIMEOUT_SEC);
        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());
        // Set up Datagram SATELLITE_DATAGRAM_TRANSFER_STATE_IDLE
        setupDatagramTransferringState(true);

        moveToNotConnectedState();
        moveNotConnectedToConnectedState();

        // Verify that ESOS, P2P_SMS timer are started.
        verifyEsosP2pSmsInactivityTimer(true, true);

        // Sent ESOS
        // CONNECTED -> TRANSFERRING -> CONNECTED
        sendMessage(DATAGRAM_TYPE_SOS_MESSAGE);

        // Verify that ESOS, P2P_SMS timer are restarted.
        verifyEsosP2pSmsInactivityTimer(true, true);

        // Sent SMS
        // CONNECTED -> TRANSFERRING -> CONNECTED
        sendMessage(DATAGRAM_TYPE_SMS);

        // Verify that ESOS, P2P_SMS timer are restarted.
        verifyEsosP2pSmsInactivityTimer(true, true);

        // Time shift to cause P2P_SMS timeout
        passedTime = P2P_SMS_INACTIVITY_TIMEOUT_SEC * 1000;
        moveTimeForward(P2P_SMS_INACTIVITY_TIMEOUT_SEC * 1000);
        processAllMessages();

        // Verify that keep ESOS timer, expired P2P_SMS timer.
        // CONNECTED state
        verifyEsosP2pSmsInactivityTimer(true, false);
        assertEquals(STATE_CONNECTED, mTestSatelliteSessionController.getCurrentStateName());

        // Time shift to cause ESOS timeout
        moveTimeForward(ESOS_INACTIVITY_TIMEOUT_SEC * 1000 - passedTime);
        processAllMessages();

        // Verify that expired ESOS and P2P_SMS timer
        // reported IDLE state.
        verifyEsosP2pSmsInactivityTimer(false, false);
        assertSuccessfulModemStateChangedCallback(
                mTestSatelliteModemStateCallback, SatelliteManager.SATELLITE_MODEM_STATE_IDLE);
    }

    @Test
    public void testDisableSatelliteWhenCellularModemEnabledInIdleMode() {
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);