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

Commit 5f0c77d1 authored by Daniel Banta's avatar Daniel Banta Committed by Android Build Coastguard Worker
Browse files

MtSmsPolling messages to be sent the first time the satellite modem is connected.

Bug: 385011293
Test: atest DatagramDispatcherTest
FLAG: com.android.internal.telephony.flags.carrier_roaming_nb_iot_ntn
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:34a416810a7f726eff8b42adfcc45e5074739be4)
Merged-In: I089b8184ac18c70a7b9db6ee0681197be96efea4
Change-Id: I089b8184ac18c70a7b9db6ee0681197be96efea4
parent 526614f3
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -143,6 +143,8 @@ public class DatagramDispatcher extends Handler {
    private boolean mShouldPollMtSms = false;
    @GuardedBy("mLock")
    private boolean mIsMtSmsPollingThrottled = false;
    @GuardedBy("mLock")
    private int mConnectedStateCounter = 0;

    /**
     * Create the DatagramDispatcher singleton instance.
@@ -806,6 +808,12 @@ public class DatagramDispatcher extends Handler {

            if (state == SATELLITE_MODEM_STATE_CONNECTED) {
                mHasEnteredConnectedState = true;

                mConnectedStateCounter++;
                if (isFirstConnected()) {
                    mShouldPollMtSms = shouldPollMtSms();
                }

                if (isDatagramWaitForConnectedStateTimerStarted()) {
                    stopDatagramWaitForConnectedStateTimer();
                    sendPendingMessages();
@@ -825,6 +833,11 @@ public class DatagramDispatcher extends Handler {
        }
    }

    /** Returns true if this is the first time the satellite modem is connected. */
    private boolean isFirstConnected() {
        return mConnectedStateCounter == 1;
    }

    @GuardedBy("mLock")
    private void cleanUpResources() {
        plogd("cleanUpResources");
@@ -856,6 +869,7 @@ public class DatagramDispatcher extends Handler {
        mModemState = SATELLITE_MODEM_STATE_UNKNOWN;
        mHasEnteredConnectedState = false;
        mShouldPollMtSms = false;
        mConnectedStateCounter = 0;
        stopMtSmsPollingThrottle();
    }

+15 −0
Original line number Diff line number Diff line
@@ -1269,6 +1269,21 @@ public class DatagramDispatcherTest extends TelephonyTest {
        verify(mMockSmsDispatchersController, times(0)).sendMtSmsPollingMessage();
    }

    @Test
    public void testOnSatelliteModemStateChanged_onFirstConnected_sendsMtSmsPoll() {
        mDatagramDispatcherUT.setDeviceAlignedWithSatellite(true);
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
        // Set the following so shouldPollMtSms returns true
        mContextFixture.putBooleanResource(R.bool.config_enabled_mt_sms_polling, true);
        when(mMockSatelliteController.shouldSendSmsToDatagramDispatcher(any(Phone.class)))
                .thenReturn(true);

        mDatagramDispatcherUT.onSatelliteModemStateChanged(
                SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED);

        verify(mMockSmsDispatchersController, times(1)).sendMtSmsPollingMessage();
    }

    private void setModemState(int state) {
        mDatagramDispatcherUT.onSatelliteModemStateChanged(state);
    }