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

Commit ac52fd9b authored by joonhunshin's avatar joonhunshin Committed by Joonhun Shin
Browse files

update to block sending check message when p2p is disabled.

Bug: 393912447
Test: atest DatagramDispatcherTest
      live network test b/395493343
Flag: EXEMPT (bug fix)
Change-Id: I46d5fc0d72e8893204f7c813b7703528685b684e
parent 21133d63
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1378,7 +1378,14 @@ public class DatagramDispatcher extends Handler {
    private boolean allowMtSmsPolling() {
        if (!mFeatureFlags.carrierRoamingNbIotNtn()) return false;

        if (mIsMtSmsPollingThrottled) return false;
        SatelliteController satelliteController = SatelliteController.getInstance();
        int subId = satelliteController.getSelectedSatelliteSubId();
        boolean isP2PSmsDisallowed =
                satelliteController.isP2PSmsDisallowedOnCarrierRoamingNtn(subId);
        if (isP2PSmsDisallowed) {
            plogd("allowMtSmsPolling: P2P SMS disallowed, subId = " + subId);
            return false;
        }

        if (!mIsAligned) return false;

+0 −1
Original line number Diff line number Diff line
@@ -8410,7 +8410,6 @@ public class SatelliteController extends Handler {
     * return {@code true} when the phone does not support P2P SMS over carrier roaming satellite
     *        {@code false} otherwise
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public boolean isP2PSmsDisallowedOnCarrierRoamingNtn(int subId) {
        int carrierRoamingNtnConnectType = getCarrierRoamingNtnConnectType(subId);
        if (carrierRoamingNtnConnectType == CARRIER_ROAMING_NTN_CONNECT_MANUAL) {
+27 −3
Original line number Diff line number Diff line
@@ -1265,9 +1265,6 @@ public class DatagramDispatcherTest extends TelephonyTest {
        mContextFixture.putBooleanResource(
                R.bool.config_satellite_allow_check_message_in_not_connected, true);

        mDatagramDispatcherUT.onSatelliteModemStateChanged(
                SatelliteManager.SATELLITE_MODEM_STATE_NOT_CONNECTED);

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

@@ -1286,6 +1283,31 @@ public class DatagramDispatcherTest extends TelephonyTest {
        verify(mMockSmsDispatchersController, times(1)).sendMtSmsPollingMessage();
    }

    @Test
    public void testSendsMtSmsPoll_P2PSmsAllowed() {
        mDatagramDispatcherUT.setDeviceAlignedWithSatellite(true);
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
        mContextFixture.putBooleanResource(R.bool.config_enabled_mt_sms_polling, true);
        when(mMockSatelliteController.shouldSendSmsToDatagramDispatcher(any(Phone.class)))
                .thenReturn(true);

        // Set P2P SMS disallowed
        when(mMockSatelliteController.isP2PSmsDisallowedOnCarrierRoamingNtn(anyInt()))
                .thenReturn(true);
        mDatagramDispatcherUT.onSatelliteModemStateChanged(
                SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED);

        verify(mMockSmsDispatchersController, times(0)).sendMtSmsPollingMessage();

        // Set P2P SMS allowed
        when(mMockSatelliteController.isP2PSmsDisallowedOnCarrierRoamingNtn(anyInt()))
                .thenReturn(false);
        mDatagramDispatcherUT.onSatelliteModemStateChanged(
                SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED);

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

    private void setModemState(int state) {
        mDatagramDispatcherUT.onSatelliteModemStateChanged(state);
    }
@@ -1297,6 +1319,8 @@ public class DatagramDispatcherTest extends TelephonyTest {
        mContextFixture.putBooleanResource(R.bool.config_enabled_mt_sms_polling, true);
        when(mMockSatelliteController.shouldSendSmsToDatagramDispatcher(any(Phone.class)))
                .thenReturn(true);
        when(mMockSatelliteController.isP2PSmsDisallowedOnCarrierRoamingNtn(anyInt()))
                .thenReturn(false);
        // This will trigger mShouldPollMtSms = shouldPollMtSms
        setModemState(SatelliteManager.SATELLITE_MODEM_STATE_NOT_CONNECTED);
    }