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

Commit efd263f0 authored by Thomas Nguyen's avatar Thomas Nguyen
Browse files

Guard the handling of multiple enable requests with a feature flag

Flag: com.android.internal.telephony.flags.carrier_roaming_nb_iot_ntn
Bug: 361139260
Test: SatelliteManagerTestOnMockService

Change-Id: I09b59a974e3072bb020376a878a3554e3a909d40
parent 0d4310b1
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -1227,28 +1227,39 @@ public class SatelliteController extends Handler {
                break;
            }

            case EVENT_WAIT_FOR_SATELLITE_ENABLING_RESPONSE_TIMED_OUT:
            case EVENT_WAIT_FOR_SATELLITE_ENABLING_RESPONSE_TIMED_OUT: {
                handleEventWaitForSatelliteEnablingResponseTimedOut(
                        (RequestSatelliteEnabledArgument) msg.obj);
                break;
            }

            case CMD_UPDATE_SATELLITE_ENABLE_ATTRIBUTES: {
                request = (SatelliteControllerHandlerRequest) msg.obj;
                RequestSatelliteEnabledArgument argument =
                        (RequestSatelliteEnabledArgument) request.argument;

                if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
                    plogd("UpdateEnableAttributes: carrierRoamingNbIotNtn flag is disabled");
                    sendErrorAndReportSessionMetrics(
                            SatelliteManager.SATELLITE_RESULT_INVALID_ARGUMENTS, argument.callback);
                    synchronized (mSatelliteEnabledRequestLock) {
                        mSatelliteEnableAttributesUpdateRequest = null;
                    }
                    break;
                }

                synchronized (mSatelliteEnabledRequestLock) {
                    if (mSatelliteEnabledRequest != null) {
                        plogd("UpdateEnableAttributes: Satellite is being enabled. Need to "
                                + "wait until enable complete before updating attributes");
                        return;
                        break;
                    }
                    if (isSatelliteBeingDisabled()) {
                        plogd("UpdateEnableAttributes: Satellite is being disabled. Aborting the "
                                + "enable attributes update request");
                        mSatelliteEnableAttributesUpdateRequest = null;
                        argument.callback.accept(SATELLITE_RESULT_REQUEST_ABORTED);
                        return;
                        break;
                    }
                }
                onCompleted = obtainMessage(EVENT_UPDATE_SATELLITE_ENABLE_ATTRIBUTES_DONE, request);
@@ -1918,6 +1929,12 @@ public class SatelliteController extends Handler {
                     * carriers want to disable satellite for prioritizing emergency calls. Thus,
                     * we need to push the disable request to modem while enable is in progress.
                     */
                    if (!mFeatureFlags.carrierRoamingNbIotNtn()) {
                        plogd("requestSatelliteEnabled: carrierRoamingNbIotNtn flag is disabled");
                        sendErrorAndReportSessionMetrics(
                                SatelliteManager.SATELLITE_RESULT_ENABLE_IN_PROGRESS, result);
                        return;
                    }
                    mSatelliteDisabledRequest = request;
                }
            }
+1 −0
Original line number Diff line number Diff line
@@ -921,6 +921,7 @@ public class SatelliteControllerTest extends TelephonyTest {

    @Test
    public void testRequestSatelliteEnabled() {
        when(mFeatureFlags.carrierRoamingNbIotNtn()).thenReturn(true);
        mIsSatelliteEnabledSemaphore.drainPermits();

        // Fail to enable satellite when SatelliteController is not fully loaded yet.