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

Commit e363bb6b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed battery drain after modem reset" into pi-dev

parents 127892a4 371e2140
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ public class DeviceStateMonitor extends Handler {
    private static final int EVENT_POWER_SAVE_MODE_CHANGED      = 3;
    private static final int EVENT_CHARGING_STATE_CHANGED       = 4;
    private static final int EVENT_TETHERING_STATE_CHANGED      = 5;
    private static final int EVENT_RADIO_AVAILABLE              = 6;

    // TODO(b/74006656) load hysteresis values from a property when DeviceStateMonitor starts
    private static final int HYSTERESIS_KBPS = 50;
@@ -200,6 +201,7 @@ public class DeviceStateMonitor extends Handler {
        mPhone.getContext().registerReceiver(mBroadcastReceiver, filter, null, mPhone);

        mPhone.mCi.registerForRilConnected(this, EVENT_RIL_CONNECTED, null);
        mPhone.mCi.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
    }

    /**
@@ -344,7 +346,8 @@ public class DeviceStateMonitor extends Handler {
        log("handleMessage msg=" + msg, false);
        switch (msg.what) {
            case EVENT_RIL_CONNECTED:
                onRilConnected();
            case EVENT_RADIO_AVAILABLE:
                onReset();
                break;
            case EVENT_UPDATE_MODE_CHANGED:
                onSetIndicationUpdateMode(msg.arg1, msg.arg2);
@@ -420,14 +423,14 @@ public class DeviceStateMonitor extends Handler {
    }

    /**
     * Called when RIL is connected during boot up or reconnected after modem restart.
     * Called when RIL is connected during boot up or radio becomes available after modem restart.
     *
     * When modem crashes, if the user turns the screen off before RIL reconnects, device
     * state and filter cannot be sent to modem. Resend the state here so that modem
     * has the correct state (to stop signal strength reporting, etc).
     */
    private void onRilConnected() {
        log("RIL connected.", true);
    private void onReset() {
        log("onReset.", true);
        sendDeviceState(CHARGING_STATE, mIsCharging);
        sendDeviceState(LOW_DATA_EXPECTED, mIsLowDataExpected);
        sendDeviceState(POWER_SAVE_MODE, mIsPowerSaveOn);
+8 −0
Original line number Diff line number Diff line
@@ -124,4 +124,12 @@ public class DeviceStateMonitorTest extends TelephonyTest {
        verify(mSimulatedCommandsVerifier, times(1)).sendDeviceState(eq(CHARGING_STATE),
                eq(false), nullable(Message.class));
    }

    @FlakyTest
    public void testReset() throws Exception {
        mDSM.obtainMessage(6).sendToTarget();

        verify(mSimulatedCommandsVerifier, times(1)).setUnsolResponseFilter(eq(-1),
                nullable(Message.class));
    }
}