From 005fa3f5a789c77765845feab58a572142b26c13 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 24 Mar 2020 12:01:14 -0700 Subject: [PATCH] Remove extra binder calls when not detecting gestures - Previous refactoring meant that we were always fetching the running task to update the gesture state, even when you touch down in an area that is not in the gesture region (which is unnecessary). Also only transforming touch events (currently causes allocations) when we are actually handling a gesture. Change-Id: I32e21c3e4d7113a782afce593711d9df62551bc8 --- .../quickstep/TouchInteractionService.java | 28 +++++++++++++++---- .../com/android/quickstep/GestureState.java | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) 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 eb5c7f9f69..496a3d858a 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -22,6 +22,7 @@ import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; +import static com.android.quickstep.GestureState.DEFAULT_STATE; import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_INPUT_MONITOR; import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SYSUI_PROXY; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TRACING_ENABLED; @@ -124,6 +125,7 @@ public class TouchInteractionService extends Service implements PluginListener mAM.getRunningTask(0))); + mDeviceState.setOrientationTransformIfNeeded(event); + GestureState newGestureState; if (mDeviceState.isInSwipeUpTouchRegion(event)) { + newGestureState = createGestureState(); mConsumer.onConsumerAboutToBeSwitched(); mConsumer = newConsumer(mGestureState, newGestureState, event); @@ -453,6 +453,7 @@ public class TouchInteractionService extends Service implements PluginListener mAM.getRunningTask(0))); + return gestureState; + } + private InputConsumer newConsumer(GestureState previousGestureState, GestureState newGestureState, MotionEvent event) { boolean canStartSystemGesture = mDeviceState.canStartSystemGesture(); diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index 501c6f0b74..f7e40cace5 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -64,6 +64,8 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL private static final String TAG = "GestureState"; private static final ArrayList STATE_NAMES = new ArrayList<>(); + public static final GestureState DEFAULT_STATE = new GestureState(); + private static int FLAG_COUNT = 0; private static int getFlagForIndex(String name) { if (DEBUG_STATES) {