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

Commit 8015be90 authored by Aishwarya Mallampati's avatar Aishwarya Mallampati
Browse files

Exit from satellite mode on p2p sms inactivity time out.

Bug: 385357642
Test: atest SatelliteSessionControllerTest
Test: 385397820
Flag: EXEMPT bugfix

Change-Id: I977a6894aad6a3af4f74c59fad2e3faf8f68385f
parent 32acd6d8
Loading
Loading
Loading
Loading
+42 −14
Original line number Diff line number Diff line
@@ -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);
@@ -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);
@@ -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.
@@ -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());

@@ -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) {
+42 −0
Original line number Diff line number Diff line
@@ -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(),