Fix issue with delegate consumers being overwritten
- Whenever the delegate consumer sets itself as active, it will cancel
the base consumers which can cause onConsumerInactive() which will
clear the active consumer. Instead, we should only clear the active
consumer, and in the case where isConsumerDetachedFromGesture() is
checked, only check the active consumer before resetting.
ie.
base ic (detached) -> on touch up (do nothing) -> onConsumerInactive (active == base) -> reset
base ic (detached), wrapped ic (active) -> onConsumerInactive (active != base) -> on touch up (active == wrapped) -> reset
base ic (detached, active), wrapped ic -> on touch up (do nothing) -> onConsumerInactive (active == base) -> reset
base ic (not detached) -> on touch up (active == base) -> reset
base ic (not detached), wrapped ic (active) -> onConsumerInactive (active != base) -> on touch up (active == wrapped) -> reset
base ic (not detached, active), wrapped ic -> on touch up (active == base) -> reset
Change-Id: I2d623c501d9c9799dadcf2005f34e1e0062c113f
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index 61fe6cb..0c4cd43 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -481,14 +481,14 @@
}
ActiveGestureLog.INSTANCE.addLog("onMotionEvent", event.getActionMasked());
+ boolean cleanUpConsumer = (action == ACTION_UP || action == ACTION_CANCEL)
+ && mConsumer != null
+ && !mConsumer.getActiveConsumerInHierarchy().isConsumerDetachedFromGesture();
mUncheckedConsumer.onMotionEvent(event);
- if (action == ACTION_UP || action == ACTION_CANCEL) {
- if (mConsumer != null && !mConsumer.isConsumerDetachedFromGesture()) {
- onConsumerInactive(mConsumer);
- }
+ if (cleanUpConsumer) {
+ reset();
}
-
TraceHelper.INSTANCE.endFlagsOverride(traceToken);
}
@@ -686,15 +686,21 @@
}
/**
- * To be called by the consumer when it's no longer active.
+ * To be called by the consumer when it's no longer active. This can be called by any consumer
+ * in the hierarchy at any point during the gesture (ie. if a delegate consumer starts
+ * intercepting touches, the base consumer can try to call this).
*/
private void onConsumerInactive(InputConsumer caller) {
- if (mConsumer != null && mConsumer.isInConsumerHierarchy(caller)) {
- mConsumer = mUncheckedConsumer = mResetGestureInputConsumer;
- mGestureState = new GestureState();
+ if (mConsumer != null && mConsumer.getActiveConsumerInHierarchy() == caller) {
+ reset();
}
}
+ private void reset() {
+ mConsumer = mUncheckedConsumer = mResetGestureInputConsumer;
+ mGestureState = new GestureState();
+ }
+
private void preloadOverview(boolean fromInit) {
if (!mDeviceState.isUserUnlocked()) {
return;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
index bcc9707..67a15a7 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
@@ -25,13 +25,11 @@
}
@Override
- public boolean isConsumerDetachedFromGesture() {
- return mDelegate.isConsumerDetachedFromGesture();
- }
-
- @Override
- public boolean isInConsumerHierarchy(InputConsumer candidate) {
- return this == candidate || mDelegate.isInConsumerHierarchy(candidate);
+ public InputConsumer getActiveConsumerInHierarchy() {
+ if (mState == STATE_ACTIVE) {
+ return this;
+ }
+ return mDelegate.getActiveConsumerInHierarchy();
}
@Override
diff --git a/quickstep/src/com/android/quickstep/InputConsumer.java b/quickstep/src/com/android/quickstep/InputConsumer.java
index 818d836..aa80c96 100644
--- a/quickstep/src/com/android/quickstep/InputConsumer.java
+++ b/quickstep/src/com/android/quickstep/InputConsumer.java
@@ -70,10 +70,10 @@
}
/**
- * Returns true if the given input consumer is in the hierarchy of this input consumer.
+ * Returns the active input consumer is in the hierarchy of this input consumer.
*/
- default boolean isInConsumerHierarchy(InputConsumer candidate) {
- return this == candidate;
+ default InputConsumer getActiveConsumerInHierarchy() {
+ return this;
}
/**