summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Selim Cinek <cinek@google.com> 2017-05-02 20:02:30 -0700
committer Selim Cinek <cinek@google.com> 2017-05-08 15:49:20 -0700
commit48a92a5dbbf98d9f0235554e2bea3c969f7f2cee (patch)
tree40dc55709fe5549f983ed4171fcb4289674d3949
parentf323e3a5435ac21c6a5684e0aeba5f26ea699f9d (diff)
Handling the touch better when the screen turns off
Previously we were only cancelling touches when showing keyguard, but this is not enough, since a user might be touching it while on the keyguard (e.g with falsing) Fixes: 37287962 Fixes: 36416066 Fixes: 37696557 Test: manual, turn of screen while interacting Merged-In: I572ade2380986ef087468dff721b1d1dfa7a48ab Change-Id: I572ade2380986ef087468dff721b1d1dfa7a48ab
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java26
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java31
5 files changed, 65 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
index 1a9a40b24332..674a61cd1d30 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardAffordanceHelper.java
@@ -168,7 +168,8 @@ public class KeyguardAffordanceHelper {
distance = mTranslationOnDown + distance;
distance = Math.max(0, distance);
}
- setTranslation(distance, false /* isReset */, false /* animateReset */);
+ setTranslation(distance, false /* isReset */, false /* animateReset */,
+ false /* force */);
}
break;
@@ -373,11 +374,12 @@ public class KeyguardAffordanceHelper {
targetView.finishAnimation(velocity, mAnimationEndRunnable);
}
- private void setTranslation(float translation, boolean isReset, boolean animateReset) {
+ private void setTranslation(float translation, boolean isReset, boolean animateReset,
+ boolean force) {
translation = rightSwipePossible() ? translation : Math.max(0, translation);
translation = leftSwipePossible() ? translation : Math.min(0, translation);
float absTranslation = Math.abs(translation);
- if (translation != mTranslation || isReset) {
+ if (translation != mTranslation || isReset || force) {
KeyguardAffordanceView targetView = translation > 0 ? mLeftIcon : mRightIcon;
KeyguardAffordanceView otherView = translation > 0 ? mRightIcon : mLeftIcon;
float alpha = absTranslation / getMinTranslationAmount();
@@ -392,15 +394,15 @@ public class KeyguardAffordanceHelper {
boolean slowAnimation = isReset && isBelowFalsingThreshold();
if (!isReset) {
updateIcon(targetView, radius, alpha + fadeOutAlpha * targetView.getRestingAlpha(),
- false, false, false, false);
+ false, false, force, false);
} else {
updateIcon(targetView, 0.0f, fadeOutAlpha * targetView.getRestingAlpha(),
- animateIcons, slowAnimation, false, forceNoCircleAnimation);
+ animateIcons, slowAnimation, force, forceNoCircleAnimation);
}
updateIcon(otherView, 0.0f, fadeOutAlpha * otherView.getRestingAlpha(),
- animateIcons, slowAnimation, false, forceNoCircleAnimation);
+ animateIcons, slowAnimation, force, forceNoCircleAnimation);
updateIcon(mCenterIcon, 0.0f, fadeOutAlpha * mCenterIcon.getRestingAlpha(),
- animateIcons, slowAnimation, false, forceNoCircleAnimation);
+ animateIcons, slowAnimation, force, forceNoCircleAnimation);
mTranslation = translation;
}
@@ -508,8 +510,12 @@ public class KeyguardAffordanceHelper {
}
public void reset(boolean animate) {
+ reset(animate, false /* force */);
+ }
+
+ public void reset(boolean animate, boolean force) {
cancelAnimation();
- setTranslation(0.0f, true, animate);
+ setTranslation(0.0f, true, animate, force);
mMotionCancelled = true;
if (mSwipingInProgress) {
mCallback.onSwipingAborted();
@@ -517,6 +523,10 @@ public class KeyguardAffordanceHelper {
}
}
+ public void resetImmediately() {
+ reset(false /* animate */, true /* force */);
+ }
+
public boolean isSwipingInProgress() {
return mSwipingInProgress;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 8a97be5864d1..6e41ef4bb849 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -46,7 +46,6 @@ import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.keyguard.KeyguardStatusView;
import com.android.systemui.DejankUtils;
-import com.android.systemui.EventLogTags;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.classifier.FalsingManager;
@@ -2463,6 +2462,14 @@ public class NotificationPanelView extends PanelView implements
}
};
+ @Override
+ public void setTouchDisabled(boolean disabled) {
+ super.setTouchDisabled(disabled);
+ if (disabled && mAffordanceHelper.isSwipingInProgress() && !mIsLaunchTransitionRunning) {
+ mAffordanceHelper.resetImmediately();
+ }
+ }
+
public void setDark(boolean dark) {
mDark = dark;
mKeyguardStatusView.setDark(dark);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index e86fd4849fec..d342635775dc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -221,8 +221,11 @@ public abstract class PanelView extends FrameLayout {
public void setTouchDisabled(boolean disabled) {
mTouchDisabled = disabled;
- if (mTouchDisabled && mTracking) {
- onTrackingStopped(true /* expanded */);
+ if (mTouchDisabled) {
+ cancelHeightAnimator();
+ if (mTracking) {
+ onTrackingStopped(true /* expanded */);
+ }
}
}
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 c1859fe43e01..daa52e3b1870 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -4056,13 +4056,6 @@ public class StatusBar extends SystemUI implements DemoMode,
setBarState(StatusBarState.KEYGUARD);
}
updateKeyguardState(false /* goingToFullShade */, false /* fromShadeLocked */);
- if (!mDeviceInteractive) {
-
- // If the screen is off already, we need to disable touch events because these might
- // collapse the panel after we expanded it, and thus we would end up with a blank
- // Keyguard.
- mNotificationPanel.setTouchDisabled(true);
- }
if (mState == StatusBarState.KEYGUARD) {
instantExpandNotificationsPanel();
} else if (mState == StatusBarState.FULLSCREEN_USER_SWITCHER) {
@@ -4861,6 +4854,12 @@ public class StatusBar extends SystemUI implements DemoMode,
mStackScroller.setAnimationsEnabled(false);
mVisualStabilityManager.setScreenOn(false);
updateVisibleToUser();
+
+ // We need to disable touch events because these might
+ // collapse the panel after we expanded it, and thus we would end up with a blank
+ // Keyguard.
+ mNotificationPanel.setTouchDisabled(true);
+ mStatusBarWindow.cancelCurrentTouch();
if (mLaunchCameraOnFinishedGoingToSleep) {
mLaunchCameraOnFinishedGoingToSleep = false;
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 1a09d75be632..26e007c42df8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -37,6 +37,7 @@ import android.os.IBinder;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.view.ActionMode;
+import android.view.InputDevice;
import android.view.InputQueue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -84,6 +85,8 @@ public class StatusBarWindowView extends FrameLayout {
private ActionMode mFloatingActionMode;
private FloatingToolbar mFloatingToolbar;
private ViewTreeObserver.OnPreDrawListener mFloatingToolbarPreDrawListener;
+ private boolean mTouchCancelled;
+ private boolean mTouchActive;
public StatusBarWindowView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -239,10 +242,20 @@ public class StatusBarWindowView extends FrameLayout {
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
- if (ev.getActionMasked() == MotionEvent.ACTION_DOWN
- && mNotificationPanel.isFullyCollapsed()) {
+ boolean isDown = ev.getActionMasked() == MotionEvent.ACTION_DOWN;
+ if (isDown && mNotificationPanel.isFullyCollapsed()) {
mNotificationPanel.startExpandLatencyTracking();
}
+ if (isDown) {
+ mTouchActive = true;
+ mTouchCancelled = false;
+ } else if (ev.getActionMasked() == MotionEvent.ACTION_UP
+ || ev.getActionMasked() == MotionEvent.ACTION_CANCEL) {
+ mTouchActive = false;
+ }
+ if (mTouchCancelled) {
+ return false;
+ }
mFalsingManager.onTouchEvent(ev, getWidth(), getHeight());
if (mBrightnessMirror != null && mBrightnessMirror.getVisibility() == VISIBLE) {
// Disallow new pointers while the brightness mirror is visible. This is so that you
@@ -252,7 +265,7 @@ public class StatusBarWindowView extends FrameLayout {
return false;
}
}
- if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
+ if (isDown) {
mStackScrollLayout.closeControlsIfOutsideTouch(ev);
}
if (mService.isDozing()) {
@@ -349,6 +362,18 @@ public class StatusBarWindowView extends FrameLayout {
}
}
+ public void cancelCurrentTouch() {
+ if (mTouchActive) {
+ final long now = SystemClock.uptimeMillis();
+ MotionEvent event = MotionEvent.obtain(now, now,
+ MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0);
+ event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
+ dispatchTouchEvent(event);
+ event.recycle();
+ mTouchCancelled = true;
+ }
+ }
+
public class LayoutParams extends FrameLayout.LayoutParams {
public boolean ignoreRightInset;