Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae581cdf authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove extra binder calls when not detecting gestures" into ub-launcher3-master

parents 25486212 005fa3f5
Loading
Loading
Loading
Loading
+22 −6
Original line number Diff line number Diff line
@@ -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<O
    private static final String NOTIFY_ACTION_BACK = "com.android.quickstep.action.BACK_GESTURE";
    private static final String HAS_ENABLED_QUICKSTEP_ONCE = "launcher.has_enabled_quickstep_once";
    private static final int MAX_BACK_NOTIFICATION_COUNT = 3;

    private int mBackGestureNotificationCounter = -1;
    @Nullable
    private OverscrollPlugin mOverscrollPlugin;
@@ -263,7 +265,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
    private InputConsumer mConsumer = InputConsumer.NO_OP;
    private Choreographer mMainChoreographer;
    private InputConsumer mResetGestureInputConsumer;
    private GestureState mGestureState = new GestureState();
    private GestureState mGestureState = DEFAULT_STATE;

    private InputMonitorCompat mInputMonitorCompat;
    private InputEventReceiver mInputEventReceiver;
@@ -435,16 +437,14 @@ public class TouchInteractionService extends Service implements PluginListener<O

        Object traceToken = TraceHelper.INSTANCE.beginFlagsOverride(
                TraceHelper.FLAG_ALLOW_BINDER_TRACKING);
        mDeviceState.setOrientationTransformIfNeeded(event);

        final int action = event.getAction();
        if (action == ACTION_DOWN) {
            GestureState newGestureState = new GestureState(mOverviewComponentObserver,
                    ActiveGestureLog.INSTANCE.generateAndSetLogId());
            newGestureState.updateRunningTask(TraceHelper.whitelistIpcs("getRunningTask.0",
                    () -> 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<O
            } else if (mDeviceState.isUserUnlocked()
                    && mDeviceState.isFullyGesturalNavMode()
                    && mDeviceState.canTriggerAssistantAction(event)) {
                newGestureState = createGestureState();
                // Do not change mConsumer as if there is an ongoing QuickSwitch gesture, we should
                // not interrupt it. QuickSwitch assumes that interruption can only happen if the
                // next gesture is also quick switch.
@@ -462,11 +463,18 @@ public class TouchInteractionService extends Service implements PluginListener<O
                    InputConsumer.NO_OP, mInputMonitorCompat,
                    mOverviewComponentObserver.assistantGestureIsConstrained());
            } else {
                newGestureState = DEFAULT_STATE;
                mUncheckedConsumer = InputConsumer.NO_OP;
            }

            // Save the current gesture state
            mGestureState = newGestureState;
        } else {
            // Other events
            if (mUncheckedConsumer != InputConsumer.NO_OP) {
                // Only transform the event if we are handling it in a proper consumer
                mDeviceState.setOrientationTransformIfNeeded(event);
            }
        }

        ActiveGestureLog.INSTANCE.addLog("onMotionEvent", event.getActionMasked());
@@ -481,6 +489,14 @@ public class TouchInteractionService extends Service implements PluginListener<O
        TraceHelper.INSTANCE.endFlagsOverride(traceToken);
    }

    private GestureState createGestureState() {
        GestureState gestureState = new GestureState(mOverviewComponentObserver,
                ActiveGestureLog.INSTANCE.generateAndSetLogId());
        gestureState.updateRunningTask(TraceHelper.whitelistIpcs("getRunningTask.0",
                () -> mAM.getRunningTask(0)));
        return gestureState;
    }

    private InputConsumer newConsumer(GestureState previousGestureState,
            GestureState newGestureState, MotionEvent event) {
        boolean canStartSystemGesture = mDeviceState.canStartSystemGesture();
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
    private static final String TAG = "GestureState";

    private static final ArrayList<String> 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) {