Merge "AOD: When prox covered disable touch during pulse instead of aborting" into oc-dr1-dev
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java b/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java
index 57fb14e..9b97634 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeHost.java
@@ -44,6 +44,8 @@
void setDozeScreenBrightness(int value);
+ void onIgnoreTouchWhilePulsing(boolean ignore);
+
interface Callback {
default void onNotificationHeadsUp() {}
default void onPowerSaveChanged(boolean active) {}
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
index 0993ace..79de48a 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeLog.java
@@ -164,6 +164,11 @@
}
}
+ public static void traceState(DozeMachine.State state) {
+ if (!ENABLED) return;
+ log("state " + state);
+ }
+
public static void traceProximityResult(Context context, boolean near, long millis,
int pulseReason) {
if (!ENABLED) return;
@@ -233,10 +238,10 @@
+ state + " blocked=" + blocked);
}
- public static void tracePulseCanceledByProx(Context context) {
+ public static void tracePulseTouchDisabledByProx(Context context, boolean disabled) {
if (!ENABLED) return;
init(context);
- log("pulseCanceledByProx");
+ log("pulseTouchDisabledByProx " + disabled);
}
public static void setRegisterKeyguardCallback(boolean registerKeyguardCallback) {
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java b/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
index a1dfeb3..8ec6afc 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
@@ -17,6 +17,7 @@
package com.android.systemui.doze;
import android.annotation.MainThread;
+import android.os.Trace;
import android.os.UserHandle;
import android.util.Log;
import android.view.Display;
@@ -225,6 +226,9 @@
State oldState = mState;
mState = newState;
+ DozeLog.traceState(newState);
+ Trace.traceCounter(Trace.TRACE_TAG_APP, "doze_machine_state", newState.ordinal());
+
updatePulseReason(newState, oldState, pulseReason);
performTransitionOnComponents(oldState, newState);
updateWakeLockState(newState);
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java b/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java
index ea06479..15981e5 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java
@@ -162,10 +162,10 @@
final boolean pausing = (state == DozeMachine.State.DOZE_AOD_PAUSING);
final boolean aod = (state == DozeMachine.State.DOZE_AOD);
- if (near && state == DozeMachine.State.DOZE_PULSING) {
- if (DEBUG) Log.i(TAG, "Prox NEAR, ending pulse");
- DozeLog.tracePulseCanceledByProx(mContext);
- mMachine.requestState(DozeMachine.State.DOZE_PULSE_DONE);
+ if (state == DozeMachine.State.DOZE_PULSING) {
+ boolean ignoreTouch = near;
+ if (DEBUG) Log.i(TAG, "Prox changed, ignore touch = " + ignoreTouch);
+ mDozeHost.onIgnoreTouchWhilePulsing(ignoreTouch);
}
if (far && (paused || pausing)) {
if (DEBUG) Log.i(TAG, "Prox FAR, unpausing AOD");
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 0b57e7c..b08f056 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -5384,6 +5384,7 @@
private final class DozeServiceHost implements DozeHost {
private final ArrayList<Callback> mCallbacks = new ArrayList<Callback>();
private boolean mAnimateWakeup;
+ private boolean mIgnoreTouchWhilePulsing;
@Override
public String toString() {
@@ -5454,6 +5455,7 @@
mStackScroller.setPulsing(pulsing);
mNotificationPanel.setPulsing(pulsing != null);
mVisualStabilityManager.setPulsing(pulsing != null);
+ mIgnoreTouchWhilePulsing = false;
}
}, reason);
}
@@ -5468,6 +5470,17 @@
}
@Override
+ public void onIgnoreTouchWhilePulsing(boolean ignore) {
+ if (ignore != mIgnoreTouchWhilePulsing) {
+ DozeLog.tracePulseTouchDisabledByProx(mContext, ignore);
+ }
+ mIgnoreTouchWhilePulsing = ignore;
+ if (isDozing() && ignore) {
+ mStatusBarWindow.cancelCurrentTouch();
+ }
+ }
+
+ @Override
public void dozeTimeTick() {
mNotificationPanel.refreshTime();
}
@@ -5564,6 +5577,10 @@
}
}
+ public boolean shouldIgnoreTouch() {
+ return isDozing() && mDozeServiceHost.mIgnoreTouchWhilePulsing;
+ }
+
// Begin Extra BaseStatusBar methods.
protected CommandQueue mCommandQueue;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index adc33a1..3d24bd0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -249,6 +249,10 @@
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
boolean isDown = ev.getActionMasked() == MotionEvent.ACTION_DOWN;
+ boolean isCancel = ev.getActionMasked() == MotionEvent.ACTION_CANCEL;
+ if (!isCancel && mService.shouldIgnoreTouch()) {
+ return false;
+ }
if (isDown && mNotificationPanel.isFullyCollapsed()) {
mNotificationPanel.startExpandLatencyTracking();
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeHostFake.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeHostFake.java
index 641f263..333e73d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeHostFake.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeHostFake.java
@@ -87,6 +87,10 @@
}
@Override
+ public void onIgnoreTouchWhilePulsing(boolean ignore) {
+ }
+
+ @Override
public void abortPulsing() {
pulseAborted = true;
}