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

Commit 95026040 authored by Hakjun Choi's avatar Hakjun Choi
Browse files

Reject enabling satellite when emergency call is in progress

There is a case when user attempts emergency call, satellite is still getting the location information then enable it later this causes scenario conflict.
Therefore it is needed to block enabling satellite when user is attempting emergency call and let application to know the reason.

Bug: 355740633
Flag: EXEMPT bugfix
Test: manually e2e test whether satellite is enabled when user is attempting emergency call
      atest SatelliteControllerTest
Change-Id: Ie04b54dde698ef501ec343dd576187621f61d939
parent fafd207e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Telephony;
import android.telecom.TelecomManager;
import android.telephony.AccessNetworkConstants;
import android.telephony.CarrierConfigManager;
import android.telephony.DropBoxManagerLoggerBackend;
@@ -254,6 +255,7 @@ public class SatelliteController extends Handler {
    @NonNull private CarrierRoamingSatelliteControllerStats mCarrierRoamingSatelliteControllerStats;
    @NonNull private final SubscriptionManagerService mSubscriptionManagerService;
    @NonNull private final TelephonyCountryDetector mCountryDetector;
    @NonNull private final TelecomManager mTelecomManager;
    private final CommandsInterface mCi;
    private ContentResolver mContentResolver;
    private final DeviceStateMonitor mDSM;
@@ -557,6 +559,7 @@ public class SatelliteController extends Handler {
        mCountryDetector = TelephonyCountryDetector.getInstance(context);
        mCountryDetector.registerForWifiConnectivityStateChanged(this,
                EVENT_WIFI_CONNECTIVITY_STATE_CHANGED, null);
        mTelecomManager = mContext.getSystemService(TelecomManager.class);

        // Create the PointingUIController singleton,
        // which is used to manage interactions with PointingUI app.
@@ -1691,6 +1694,13 @@ public class SatelliteController extends Handler {
                    return;
                }
            }

            if (mTelecomManager.isInEmergencyCall()) {
                plogd("requestSatelliteEnabled: reject as emergency call is ongoing.");
                sendErrorAndReportSessionMetrics(
                        SatelliteManager.SATELLITE_RESULT_EMERGENCY_CALL_IN_PROGRESS, result);
                return;
            }
        } else {
            /* if disable satellite, always assume demo is also disabled */
            enableDemoMode = false;
+19 −3
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import static android.telephony.satellite.SatelliteManager.SATELLITE_COMMUNICATI
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_CONNECTED;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_OFF;
import static android.telephony.satellite.SatelliteManager.SATELLITE_MODEM_STATE_UNAVAILABLE;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_EMERGENCY_CALL_IN_PROGRESS;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_ERROR;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS;
import static android.telephony.satellite.SatelliteManager.SATELLITE_RESULT_INVALID_MODEM_STATE;
@@ -807,6 +808,21 @@ public class SatelliteControllerTest extends TelephonyTest {
        processAllMessages();
        verifySatelliteProvisioned(true, SATELLITE_RESULT_SUCCESS);

        // Fail to enable satellite when the emergency call is in progress
        mIIntegerConsumerResults.clear();
        mSatelliteControllerUT.setSettingsKeyForSatelliteModeCalled = false;
        mSatelliteControllerUT.setSettingsKeyToAllowDeviceRotationCalled = false;
        setUpResponseForRequestSatelliteEnabled(true, false, false, SATELLITE_RESULT_SUCCESS);
        doReturn(true).when(mTelecomManager).isInEmergencyCall();
        mSatelliteControllerUT.requestSatelliteEnabled(SUB_ID, true, false, false,
                mIIntegerConsumer);
        mSatelliteControllerUT.setSatelliteSessionController(mMockSatelliteSessionController);
        processAllMessages();
        assertTrue(waitForIIntegerConsumerResult(1));
        assertEquals(SATELLITE_RESULT_EMERGENCY_CALL_IN_PROGRESS,
                (long) mIIntegerConsumerResults.get(0));
        doReturn(false).when(mTelecomManager).isInEmergencyCall();

        // Successfully enable satellite
        mIIntegerConsumerResults.clear();
        mSatelliteControllerUT.setSettingsKeyForSatelliteModeCalled = false;
@@ -989,13 +1005,13 @@ public class SatelliteControllerTest extends TelephonyTest {
        assertTrue(waitForIIntegerConsumerResult(1));
        assertEquals(SATELLITE_RESULT_INVALID_MODEM_STATE, (long) mIIntegerConsumerResults.get(0));

        verify(mMockSessionMetricsStats, times(15)).setInitializationResult(anyInt());
        verify(mMockSessionMetricsStats, times(15)).setSatelliteTechnology(anyInt());
        verify(mMockSessionMetricsStats, times(16)).setInitializationResult(anyInt());
        verify(mMockSessionMetricsStats, times(16)).setSatelliteTechnology(anyInt());
        verify(mMockSessionMetricsStats, times(3)).setInitializationProcessingTime(anyLong());
        verify(mMockSessionMetricsStats, times(2)).setTerminationResult(anyInt());
        verify(mMockSessionMetricsStats, times(2)).setTerminationProcessingTime(anyLong());
        verify(mMockSessionMetricsStats, times(2)).setSessionDurationSec(anyInt());
        verify(mMockSessionMetricsStats, times(15)).reportSessionMetrics();
        verify(mMockSessionMetricsStats, times(16)).reportSessionMetrics();

        /**
         * Make areAllRadiosDisabled return false and move mWaitingForRadioDisabled to true, which