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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ public class DozeDockHandler implements DozeMachine.Part {
|
||||
|
||||
private void requestPulseOutNow() {
|
||||
final DozeMachine.State state = mMachine.getState();
|
||||
final int pulseReason = mMachine.getPulseReason();
|
||||
|
||||
if ((state == DozeMachine.State.DOZE_PULSING
|
||||
|| state == DozeMachine.State.DOZE_REQUEST_PULSE)
|
||||
&& pulseReason == DozeLog.PULSE_REASON_DOCKING) {
|
||||
mDozeHost.stopPulsing();
|
||||
if (state == DozeMachine.State.DOZE_PULSING
|
||||
|| state == DozeMachine.State.DOZE_REQUEST_PULSE) {
|
||||
final int pulseReason = mMachine.getPulseReason();
|
||||
if (pulseReason == DozeLog.PULSE_REASON_DOCKING) {
|
||||
mDozeHost.stopPulsing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user