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
This commit is contained in:
wilsonshih
2022-08-03 15:00:27 +08:00
parent 117bab591c
commit 1fd78ea8fc
3 changed files with 4 additions and 31 deletions

View File

@@ -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,

View File

@@ -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));
}
}

View File

@@ -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);
}
}
}