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

Commit 2d23690e authored by TYM Tsai's avatar TYM Tsai
Browse files

Protects query pulse reason exception

Checks the machine is currently in one of the pulse states before
query the current pulse reason. Avoid incorrect undocked event cause
DozeService crash. And refines test case and javadoc.

Bug: 120464108
Test: atest SystemUITests
Test: manual
Change-Id: I3595217984ec7982de1f0f53765e7ae0a9d80fcf
parent aef19af3
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ package com.android.systemui.dock;
public interface DockManager {

    /**
     * Uninitialized / unknow dock states
     * Uninitialized / unknown dock states
     */
    int STATE_NONE = 0;
    /**
@@ -37,14 +37,14 @@ public interface DockManager {
    /**
     * Add a dock event listener into manager
     *
     * @param callback A  {@link #DockEventListener} which want to add
     * @param callback A  {@link DockEventListener} which want to add
     */
    void addListener(DockEventListener callback);

    /**
     * Remove the added listener from dock manager
     *
     * @param callback A {@link #DockEventListener} which want to remove
     * @param callback A {@link DockEventListener} which want to remove
     */
    void removeListener(DockEventListener callback);

@@ -52,8 +52,6 @@ public interface DockManager {
    interface DockEventListener {
        /**
         * Override to handle dock events
         *
         * Events reference: {@link #DockState}
         */
        void onEvent(int event);
    }
+6 −6
Original line number Diff line number Diff line
@@ -86,14 +86,14 @@ public class DozeDockHandler implements DozeMachine.Part {

    private void requestPulseOutNow() {
        final DozeMachine.State state = mMachine.getState();
        if (state == DozeMachine.State.DOZE_PULSING
                || state == DozeMachine.State.DOZE_REQUEST_PULSE) {
            final int pulseReason = mMachine.getPulseReason();

        if ((state == DozeMachine.State.DOZE_PULSING
                || state == DozeMachine.State.DOZE_REQUEST_PULSE)
                && pulseReason == DozeLog.PULSE_REASON_DOCKING) {
            if (pulseReason == DozeLog.PULSE_REASON_DOCKING) {
                mDozeHost.stopPulsing();
            }
        }
    }

    @Override
    public void dump(PrintWriter pw) {
+1 −1
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ public class DozeDockHandlerTest extends SysuiTestCase {
    @Test
    public void testOnEvent_undockedWhenDoze_neverRequestPulseOut() throws Exception {
        mDockHandler.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.INITIALIZED);
        when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE_PULSING);
        when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);

        mDockManagerFake.setDockEvent(DockManager.STATE_UNDOCKING);