From 1fd78ea8fcbadc5360239a8d9cd76aea859b0b44 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Wed, 3 Aug 2022 15:00:27 +0800 Subject: [PATCH] Only dispatch onMove event to BackAnimation in one place. Decouple the BackAnimation from EdgeBackPlugin, the motion events would be dispatched by EdgeBackGestureHandler, other back event would be passed by Plugin.BackCallback. Bug: 241110428 Test: switch navigation mode from gesture => 3btn => gesture, touch screen and monitor that BackAnimationController won't receive double onMotionEvent for the same key. Test: enable back affordance, verify above test. Test: atest NexusLauncherTests:com.android.quickstep.TaplTestsQuickstep Change-Id: Ib71030ab0e4147ff04924b2c1a5dce6b460a4b97 --- .../gestural/BackPanelController.kt | 3 +- .../gestural/EdgeBackGestureHandler.java | 4 +-- .../gestural/NavigationBarEdgePanel.java | 28 +------------------ 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt index b05e75ea1c974..d8a1eba256cbd 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/BackPanelController.kt @@ -42,7 +42,6 @@ import com.android.systemui.plugins.NavigationEdgeBackPlugin import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.util.ViewController -import com.android.wm.shell.back.BackAnimation import java.io.PrintWriter import javax.inject.Inject import kotlin.math.abs @@ -119,7 +118,7 @@ class BackPanelController private constructor( private val latencyTracker: LatencyTracker ) { /** Construct a [BackPanelController]. */ - fun create(context: Context, backAnimation: BackAnimation?): BackPanelController { + fun create(context: Context): BackPanelController { val backPanelController = BackPanelController( context, windowManager, diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java index 057ed2439df35..7f12192ed4afa 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java @@ -568,10 +568,10 @@ public class EdgeBackGestureHandler extends CurrentUserTracker private void resetEdgeBackPlugin() { if (mIsNewBackAffordanceEnabled) { setEdgeBackPlugin( - mBackPanelControllerFactory.create(mContext, mBackAnimation)); + mBackPanelControllerFactory.create(mContext)); } else { setEdgeBackPlugin( - new NavigationBarEdgePanel(mContext, mBackAnimation, mLatencyTracker)); + new NavigationBarEdgePanel(mContext, mLatencyTracker)); } } diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java index eba9d3fdcab8e..122852f7d07ab 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/gestural/NavigationBarEdgePanel.java @@ -43,7 +43,6 @@ import android.view.View; import android.view.WindowManager; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; -import android.window.BackEvent; import androidx.core.graphics.ColorUtils; import androidx.dynamicanimation.animation.DynamicAnimation; @@ -59,7 +58,6 @@ import com.android.systemui.animation.Interpolators; import com.android.systemui.plugins.NavigationEdgeBackPlugin; import com.android.systemui.shared.navigationbar.RegionSamplingHelper; import com.android.systemui.statusbar.VibratorHelper; -import com.android.wm.shell.back.BackAnimation; import java.io.PrintWriter; import java.util.concurrent.Executor; @@ -283,14 +281,11 @@ public class NavigationBarEdgePanel extends View implements NavigationEdgeBackPl } }; private BackCallback mBackCallback; - private BackAnimation mBackAnimation; - public NavigationBarEdgePanel(Context context, - BackAnimation backAnimation, LatencyTracker latencyTracker) { + public NavigationBarEdgePanel(Context context, LatencyTracker latencyTracker) { super(context); mWindowManager = context.getSystemService(WindowManager.class); - mBackAnimation = backAnimation; mVibratorHelper = Dependency.get(VibratorHelper.class); mDensity = context.getResources().getDisplayMetrics().density; @@ -360,7 +355,6 @@ public class NavigationBarEdgePanel extends View implements NavigationEdgeBackPl .getDimension(R.dimen.navigation_edge_action_drag_threshold); mSwipeProgressThreshold = context.getResources() .getDimension(R.dimen.navigation_edge_action_progress_threshold); - initializeBackAnimation(); setVisibility(GONE); @@ -388,17 +382,6 @@ public class NavigationBarEdgePanel extends View implements NavigationEdgeBackPl mLatencyTracker = latencyTracker; } - public void setBackAnimation(BackAnimation backAnimation) { - mBackAnimation = backAnimation; - initializeBackAnimation(); - } - - private void initializeBackAnimation() { - if (mBackAnimation != null) { - mBackAnimation.setSwipeThresholds(mSwipeTriggerThreshold, mSwipeProgressThreshold); - } - } - @Override public void onDestroy() { cancelFailsafe(); @@ -484,12 +467,6 @@ public class NavigationBarEdgePanel extends View implements NavigationEdgeBackPl @Override public void onMotionEvent(MotionEvent event) { - if (mBackAnimation != null) { - mBackAnimation.onBackMotion( - event.getX(), event.getY(), - event.getActionMasked(), - mIsLeftPanel ? BackEvent.EDGE_LEFT : BackEvent.EDGE_RIGHT); - } if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } @@ -903,9 +880,6 @@ public class NavigationBarEdgePanel extends View implements NavigationEdgeBackPl // Whenever the trigger back state changes the existing translation animation should be // cancelled mTranslationAnimation.cancel(); - if (mBackAnimation != null) { - mBackAnimation.setTriggerBack(triggerBack); - } } }