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

Commit 186095dd authored by Rukun Mao's avatar Rukun Mao
Browse files

Allow dynamically shutdown radio and turn it back on

1. Reset the flag mDeviceShuttingDown after radio becomes unavailable
2. Allow setting radio power to ON when current radio power is
RADIO_POWER_UNAVAILABLE

Bug: 416563298
Test: atest
Manual test: with simulator, request to shutdown radio then set radio power to ON
Flag: com.android.internal.telephony.flags.dynamic_modem_shutdown

Change-Id: I046d8ba33549029bcc2b3e237b13df7a4b198121
parent b4d5b259
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -179,3 +179,14 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

# OWNER=rmao TARGET=26Q1
flag {
    name: "dynamic_modem_shutdown"
    namespace: "telephony"
    description: "Allow shutdown and turn on the modem while the overall system is on"
    bug:"416563298"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+9 −1
Original line number Diff line number Diff line
@@ -3271,7 +3271,12 @@ public class ServiceStateTracker extends Handler {

        // If we want it on and it's off, turn it on
        if (mDesiredPowerState && mRadioPowerOffReasons.isEmpty()
                && (forceApply || mCi.getRadioState() == TelephonyManager.RADIO_POWER_OFF)) {
                && (forceApply || mCi.getRadioState() == TelephonyManager.RADIO_POWER_OFF
                  // When dynamic_modem_shutdown feature is enabled, allow turn on the modem at
                  // RADIO_POWER_UNAVAILABLE state.
                     || (mFeatureFlags.dynamicModemShutdown()
                             && mCi.getRadioState()
                                     == TelephonyManager.RADIO_POWER_UNAVAILABLE))) {
            mCi.setRadioPower(true, forEmergencyCall, isSelectedPhoneForEmergencyCall, null);
        } else if ((!mDesiredPowerState || !mRadioPowerOffReasons.isEmpty()) && mCi.getRadioState()
                == TelephonyManager.RADIO_POWER_ON) {
@@ -3466,6 +3471,9 @@ public class ServiceStateTracker extends Handler {
        switch (mCi.getRadioState()) {
            case TelephonyManager.RADIO_POWER_UNAVAILABLE:
                handlePollStateInternalForRadioOffOrUnavailable(false);
                if (mFeatureFlags.dynamicModemShutdown()) {
                    mDeviceShuttingDown = false;
                }
                pollStateDone();
                break;

+15 −0
Original line number Diff line number Diff line
@@ -421,6 +421,21 @@ public class ServiceStateTrackerTest extends TelephonyTest {
                != (mSimulatedCommands.getRadioState() == TelephonyManager.RADIO_POWER_ON));
    }

    @Test
    public void testSetRadioPowerAfterShuttingDownRequest() throws Exception {
        sst.setRadioPower(true);
        processAllMessages();

        sst.requestShutdown();
        processAllMessages();
        assertTrue(mSimulatedCommands.getRadioState() == TelephonyManager.RADIO_POWER_UNAVAILABLE);
        assertEquals(TelephonyManager.RADIO_POWER_UNAVAILABLE, mSimulatedCommands.getRadioState());

        sst.setRadioPower(true);
        processAllMessages();
        assertEquals(TelephonyManager.RADIO_POWER_ON, mSimulatedCommands.getRadioState());
    }

    @Test
    public void testSetRadioPowerWaitForAllDataDisconnected() throws Exception {
        // Set up DSDS environment
+1 −0
Original line number Diff line number Diff line
@@ -566,6 +566,7 @@ public abstract class TelephonyTest {
        lenient().doReturn(true).when(mFeatureFlags).phoneTypeCleanup();
        lenient().doReturn(true).when(mFeatureFlags).cleanupCdma();
        lenient().doReturn(true).when(mFeatureFlags).threadShred();
        lenient().doReturn(true).when(mFeatureFlags).dynamicModemShutdown();

        WorkerThread.reset();
        TelephonyManager.disableServiceHandleCaching();