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

Commit 008dd343 authored by Wileen Chiu's avatar Wileen Chiu Committed by takeshi tanigawa
Browse files

Send shutdown command to modem

- The shutdown command is not sent to
the modem for a graceful shutdown when
the modem is in offline state in which,
the RADIO_POWER off request is rejected
- Send the shutdown command as soon as
the device has been given a chance to
power down the radio

Test: manual - Checked that shutdown command is sent
even if modem is in offline state.
Bug: 38397402

Change-Id: I2fc2eae04918f3927e93924f6ae7b3e19f920de2
parent 4a2a7516
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -212,6 +212,7 @@ public class ServiceStateTracker extends Handler {
    protected static final int EVENT_RADIO_POWER_FROM_CARRIER          = 51;
    protected static final int EVENT_SIM_NOT_INSERTED                  = 52;
    protected static final int EVENT_IMS_SERVICE_STATE_CHANGED         = 53;
    protected static final int EVENT_RADIO_POWER_OFF_DONE              = 54;

    protected static final String TIMEZONE_PROPERTY = "persist.sys.timezone";

@@ -1134,6 +1135,16 @@ public class ServiceStateTracker extends Handler {
                }
                break;

            case EVENT_RADIO_POWER_OFF_DONE:
                if (DBG) log("EVENT_RADIO_POWER_OFF_DONE");
                if (mDeviceShuttingDown && mCi.getRadioState().isAvailable()) {
                    // during shutdown the modem may not send radio state changed event
                    // as a result of radio power request
                    // Hence, issuing shut down regardless of radio power response
                    mCi.requestShutdown(null);
                }
                break;

            // GSM
            case EVENT_SIM_READY:
                // Reset the mPreviousSubId so we treat a SIM power bounce
@@ -4460,7 +4471,7 @@ public class ServiceStateTracker extends Handler {
            mPhone.mCT.mForegroundCall.hangupIfAlive();
        }

        mCi.setRadioPower(false, null);
        mCi.setRadioPower(false, obtainMessage(EVENT_RADIO_POWER_OFF_DONE));

    }

+11 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ public class SimulatedCommands extends BaseCommands

    private boolean mDcSuccess = true;
    private DataCallResponse mDcResponse;
    private boolean mIsRadioPowerFailResponse = false;

    //***** Constructor
    public
@@ -1188,11 +1189,17 @@ public class SimulatedCommands extends BaseCommands

    @Override
    public void setRadioPower(boolean on, Message result) {
        if (mIsRadioPowerFailResponse) {
            resultFail(result, null, new RuntimeException("setRadioPower failed!"));
            return;
        }

        if(on) {
            setRadioState(RadioState.RADIO_ON);
        } else {
            setRadioState(RadioState.RADIO_OFF);
        }
        resultSuccess(result, null);
    }


@@ -2151,4 +2158,8 @@ public class SimulatedCommands extends BaseCommands
        super.setOnRestrictedStateChanged(h, what, obj);
        SimulatedCommandsVerifier.getInstance().setOnRestrictedStateChanged(h, what, obj);
    }

    public void setRadioPowerFailResponse(boolean fail) {
        mIsRadioPowerFailResponse = fail;
    }
}
+27 −0
Original line number Diff line number Diff line
@@ -1112,6 +1112,33 @@ public class ServiceStateTrackerTest extends TelephonyTest {
        assertEquals(true, sst.isDeviceShuttingDown());
    }

    @Test
    @SmallTest
    public void testShuttingDownRequest() throws Exception {
        sst.setRadioPower(true);
        waitForMs(100);

        sst.requestShutdown();
        waitForMs(100);
        assertFalse(mSimulatedCommands.getRadioState().isAvailable());
    }

    @Test
    @SmallTest
    public void testShuttingDownRequestWithRadioPowerFailResponse() throws Exception {
        sst.setRadioPower(true);
        waitForMs(100);

        // Simulate RIL fails the radio power settings.
        mSimulatedCommands.setRadioPowerFailResponse(true);
        sst.setRadioPower(false);
        waitForMs(100);
        assertTrue(mSimulatedCommands.getRadioState().isOn());
        sst.requestShutdown();
        waitForMs(100);
        assertFalse(mSimulatedCommands.getRadioState().isAvailable());
    }

    @Test
    @SmallTest
    public void testSetTimeFromNITZStr() throws Exception {