From d7269bf8b6d47835c7cbe631b4d6a04339d4ffe7 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 4 Oct 2019 11:30:10 -0700 Subject: [PATCH] 8/ Rename ActivityControlHelper - ActivityControlHelper -> BaseActivityInterface LauncherActivityControlHelper -> LauncherActivityInterface FallbackActivityControlHelper -> FallbackActivityInterface QuickCaptureTouchConsumer -> QuickCaptureInputConsumer - Move gestures to use the activity interface from the gesture state Bug: 141886704 Change-Id: I6f12daeb03d564143404767dfe4576e3e5da2a1d --- .../AppToOverviewAnimationProvider.java | 8 +- ...er.java => FallbackActivityInterface.java} | 12 +- ...olHelper.java => GoActivityInterface.java} | 4 +- ...er.java => LauncherActivityInterface.java} | 7 +- .../quickstep/OverviewCommandHelper.java | 4 +- .../AppToOverviewAnimationProvider.java | 8 +- .../android/quickstep/BaseSwipeUpHandler.java | 20 +-- ...er.java => FallbackActivityInterface.java} | 12 +- ...er.java => LauncherActivityInterface.java} | 10 +- .../quickstep/OverviewCommandHelper.java | 22 +-- .../QuickstepTestInformationHandler.java | 2 +- .../android/quickstep/SwipeSharedState.java | 4 +- .../quickstep/TouchInteractionService.java | 127 +++++++++--------- .../WindowTransformSwipeHandler.java | 36 ++--- .../AssistantInputConsumer.java | 12 +- .../DeviceLockedInputConsumer.java | 7 +- .../FallbackNoButtonInputConsumer.java | 8 +- .../OtherActivityInputConsumer.java | 23 ++-- .../inputconsumers/OverviewInputConsumer.java | 14 +- .../OverviewWithoutFocusInputConsumer.java | 13 +- .../QuickCaptureInputConsumer.java | 11 +- .../ScreenPinnedInputConsumer.java | 7 +- ...Helper.java => BaseActivityInterface.java} | 4 +- .../com/android/quickstep/GestureState.java | 36 +++++ .../quickstep/OverviewComponentObserver.java | 16 +-- 25 files changed, 238 insertions(+), 189 deletions(-) rename go/quickstep/src/com/android/quickstep/{FallbackActivityControllerHelper.java => FallbackActivityInterface.java} (91%) rename go/quickstep/src/com/android/quickstep/{GoActivityControlHelper.java => GoActivityInterface.java} (93%) rename go/quickstep/src/com/android/quickstep/{LauncherActivityControllerHelper.java => LauncherActivityInterface.java} (94%) rename quickstep/recents_ui_overrides/src/com/android/quickstep/{FallbackActivityControllerHelper.java => FallbackActivityInterface.java} (95%) rename quickstep/recents_ui_overrides/src/com/android/quickstep/{LauncherActivityControllerHelper.java => LauncherActivityInterface.java} (98%) rename quickstep/src/com/android/quickstep/{ActivityControlHelper.java => BaseActivityInterface.java} (97%) create mode 100644 quickstep/src/com/android/quickstep/GestureState.java diff --git a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java index f31cf37d0f..6b50088221 100644 --- a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java +++ b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java @@ -46,12 +46,12 @@ final class AppToOverviewAnimationProvider imple RemoteAnimationProvider { private static final String TAG = "AppToOverviewAnimationProvider"; - private final ActivityControlHelper mHelper; + private final BaseActivityInterface mHelper; private final int mTargetTaskId; private IconRecentsView mRecentsView; private AppToOverviewAnimationListener mAnimationReadyListener; - AppToOverviewAnimationProvider(ActivityControlHelper helper, int targetTaskId) { + AppToOverviewAnimationProvider(BaseActivityInterface helper, int targetTaskId) { mHelper = helper; mTargetTaskId = targetTaskId; } @@ -75,7 +75,7 @@ final class AppToOverviewAnimationProvider imple if (mAnimationReadyListener != null) { mAnimationReadyListener.onActivityReady(activity); } - ActivityControlHelper.AnimationFactory factory = + BaseActivityInterface.AnimationFactory factory = mHelper.prepareRecentsUI(activity, wasVisible, false /* animate activity */, (controller) -> { controller.dispatchOnStart(); @@ -85,7 +85,7 @@ final class AppToOverviewAnimationProvider imple anim.start(); }); factory.onRemoteAnimationReceived(null); - factory.createActivityController(getRecentsLaunchDuration()); + factory.createActivityInterface(getRecentsLaunchDuration()); mRecentsView = activity.getOverviewPanel(); return false; } diff --git a/go/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java b/go/quickstep/src/com/android/quickstep/FallbackActivityInterface.java similarity index 91% rename from go/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java rename to go/quickstep/src/com/android/quickstep/FallbackActivityInterface.java index ee860ab2cd..2af8441853 100644 --- a/go/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java +++ b/go/quickstep/src/com/android/quickstep/FallbackActivityInterface.java @@ -33,14 +33,14 @@ import java.util.function.BiPredicate; import java.util.function.Consumer; /** - * {@link ActivityControlHelper} for recents when the default launcher is different than the + * {@link BaseActivityInterface} for recents when the default launcher is different than the * currently running one and apps should interact with the {@link RecentsActivity} as opposed * to the in-launcher one. */ -public final class FallbackActivityControllerHelper extends - GoActivityControlHelper { +public final class FallbackActivityInterface extends + GoActivityInterface { - public FallbackActivityControllerHelper() { } + public FallbackActivityInterface() { } @Override public AnimationFactory prepareRecentsUI(RecentsActivity activity, boolean activityVisible, @@ -63,12 +63,12 @@ public final class FallbackActivityControllerHelper extends if (!isAnimatingToRecents) { rv.setAlpha(1); } - createActivityController(getSwipeUpDestinationAndLength( + createActivityInterface(getSwipeUpDestinationAndLength( activity.getDeviceProfile(), activity, new Rect())); } @Override - public void createActivityController(long transitionLength) { + public void createActivityInterface(long transitionLength) { if (!isAnimatingToRecents) { return; } diff --git a/go/quickstep/src/com/android/quickstep/GoActivityControlHelper.java b/go/quickstep/src/com/android/quickstep/GoActivityInterface.java similarity index 93% rename from go/quickstep/src/com/android/quickstep/GoActivityControlHelper.java rename to go/quickstep/src/com/android/quickstep/GoActivityInterface.java index 274a347cbb..5ce0f4cdf5 100644 --- a/go/quickstep/src/com/android/quickstep/GoActivityControlHelper.java +++ b/go/quickstep/src/com/android/quickstep/GoActivityInterface.java @@ -13,8 +13,8 @@ import com.android.systemui.shared.system.RemoteAnimationTargetCompat; * * @param activity that contains the overview */ -public abstract class GoActivityControlHelper implements - ActivityControlHelper { +public abstract class GoActivityInterface implements + BaseActivityInterface { @Override public void onTransitionCancelled(T activity, boolean activityVisible) { diff --git a/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java b/go/quickstep/src/com/android/quickstep/LauncherActivityInterface.java similarity index 94% rename from go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java rename to go/quickstep/src/com/android/quickstep/LauncherActivityInterface.java index 8993b67005..5bff8e8060 100644 --- a/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/go/quickstep/src/com/android/quickstep/LauncherActivityInterface.java @@ -30,10 +30,10 @@ import java.util.function.BiPredicate; import java.util.function.Consumer; /** - * {@link ActivityControlHelper} for the in-launcher recents. + * {@link BaseActivityInterface} for the in-launcher recents. * TODO: Implement the app to overview animation functionality */ -public final class LauncherActivityControllerHelper extends GoActivityControlHelper { +public final class LauncherActivityInterface extends GoActivityInterface { @Override public AnimationFactory prepareRecentsUI(Launcher activity, @@ -43,8 +43,7 @@ public final class LauncherActivityControllerHelper extends GoActivityControlHel activity.getOverviewPanel().setUsingRemoteAnimation(true); //TODO: Implement this based off where the recents view needs to be for app => recents anim. return new AnimationFactory() { - @Override - public void createActivityController(long transitionLength) { + public void createActivityInterface(long transitionLength) { callback.accept(activity.getStateManager().createAnimationToNewWorkspace( fromState, OVERVIEW, transitionLength)); } diff --git a/go/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/go/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index f65109afde..a436ce7033 100644 --- a/go/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/go/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -101,7 +101,7 @@ public class OverviewCommandHelper { private class RecentsActivityCommand implements Runnable { - protected final ActivityControlHelper mHelper; + protected final BaseActivityInterface mHelper; private final long mCreateTime; private final long mToggleClickedTime = SystemClock.uptimeMillis(); @@ -109,7 +109,7 @@ public class OverviewCommandHelper { private ActivityInitListener mListener; public RecentsActivityCommand() { - mHelper = mOverviewComponentObserver.getActivityControlHelper(); + mHelper = mOverviewComponentObserver.getActivityInterface(); mCreateTime = SystemClock.elapsedRealtime(); // Preload the plan diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java index 3eab5ac873..8a11ac80aa 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/AppToOverviewAnimationProvider.java @@ -48,14 +48,14 @@ final class AppToOverviewAnimationProvider imple private static final long RECENTS_LAUNCH_DURATION = 250; private static final String TAG = "AppToOverviewAnimationProvider"; - private final ActivityControlHelper mHelper; + private final BaseActivityInterface mHelper; // The id of the currently running task that is transitioning to overview. private final int mTargetTaskId; private T mActivity; private RecentsView mRecentsView; - AppToOverviewAnimationProvider(ActivityControlHelper helper, int targetTaskId) { + AppToOverviewAnimationProvider(BaseActivityInterface helper, int targetTaskId) { mHelper = helper; mTargetTaskId = targetTaskId; } @@ -69,7 +69,7 @@ final class AppToOverviewAnimationProvider imple boolean onActivityReady(T activity, Boolean wasVisible) { activity.getOverviewPanel().showCurrentTask(mTargetTaskId); AbstractFloatingView.closeAllOpenViews(activity, wasVisible); - ActivityControlHelper.AnimationFactory factory = + BaseActivityInterface.AnimationFactory factory = mHelper.prepareRecentsUI(activity, wasVisible, false /* animate activity */, (controller) -> { controller.dispatchOnStart(); @@ -79,7 +79,7 @@ final class AppToOverviewAnimationProvider imple anim.start(); }); factory.onRemoteAnimationReceived(null); - factory.createActivityController(RECENTS_LAUNCH_DURATION); + factory.createActivityInterface(RECENTS_LAUNCH_DURATION); factory.setRecentsAttachedToAppWindow(true, false); mActivity = activity; mRecentsView = mActivity.getOverviewPanel(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index 9eb2d4c919..e1e994c6a6 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -56,7 +56,7 @@ import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.graphics.RotationMode; import com.android.launcher3.views.FloatingIconView; -import com.android.quickstep.ActivityControlHelper.HomeAnimationFactory; +import com.android.quickstep.BaseActivityInterface.HomeAnimationFactory; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.ActivityInitListener; @@ -97,7 +97,7 @@ public abstract class BaseSwipeUpHandler mActivityControlHelper; + protected final BaseActivityInterface mActivityInterface; protected final RecentsModel mRecentsModel; protected final int mRunningTaskId; @@ -135,15 +135,15 @@ public abstract class BaseSwipeUpHandler { resultCallback.accept(success); if (!success) { - mActivityControlHelper.onLaunchTaskFailed(mActivity); + mActivityInterface.onLaunchTaskFailed(mActivity); nextTask.notifyTaskLaunchFailed(TAG); } else { - mActivityControlHelper.onLaunchTaskSuccess(mActivity); + mActivityInterface.onLaunchTaskSuccess(mActivity); } }, mMainThreadHandler); } @@ -291,7 +291,7 @@ public abstract class BaseSwipeUpHandler { +public final class FallbackActivityInterface implements + BaseActivityInterface { - public FallbackActivityControllerHelper() { } + public FallbackActivityInterface() { } @Override public void onTransitionCancelled(RecentsActivity activity, boolean activityVisible) { @@ -142,12 +142,12 @@ public final class FallbackActivityControllerHelper implements if (!isAnimatingToRecents) { rv.setContentAlpha(1); } - createActivityController(getSwipeUpDestinationAndLength( + createActivityInterface(getSwipeUpDestinationAndLength( activity.getDeviceProfile(), activity, new Rect())); } @Override - public void createActivityController(long transitionLength) { + public void createActivityInterface(long transitionLength) { AnimatorSet animatorSet = new AnimatorSet(); if (isAnimatingToRecents) { ObjectAnimator anim = ObjectAnimator.ofFloat(rv, CONTENT_ALPHA, 0, 1); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java similarity index 98% rename from quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java rename to quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java index c749761eb9..f6b3654e69 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java @@ -73,9 +73,9 @@ import java.util.function.BiPredicate; import java.util.function.Consumer; /** - * {@link ActivityControlHelper} for the in-launcher recents. + * {@link BaseActivityInterface} for the in-launcher recents. */ -public final class LauncherActivityControllerHelper implements ActivityControlHelper { +public final class LauncherActivityInterface implements BaseActivityInterface { private Runnable mAdjustInterpolatorsRunnable; @@ -214,8 +214,8 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe private boolean mIsAttachedToWindow; @Override - public void createActivityController(long transitionLength) { - createActivityControllerInternal(activity, fromState, transitionLength, callback); + public void createActivityInterface(long transitionLength) { + createActivityInterfaceInternal(activity, fromState, transitionLength, callback); // Creating the activity controller animation sometimes reapplies the launcher state // (because we set the animation as the current state animation), so we reapply the // attached state here as well to ensure recents is shown/hidden appropriately. @@ -312,7 +312,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe }; } - private void createActivityControllerInternal(Launcher activity, LauncherState fromState, + private void createActivityInterfaceInternal(Launcher activity, LauncherState fromState, long transitionLength, Consumer callback) { LauncherState endState = OVERVIEW; if (fromState == endState) { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java index 6cdcb39f7d..150c44d264 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewCommandHelper.java @@ -98,14 +98,14 @@ public class OverviewCommandHelper { @Override protected boolean handleCommand(long elapsedTime) { // TODO: Go to the next page if started from alt-tab. - return mHelper.getVisibleRecentsView() != null; + return mActivityInterface.getVisibleRecentsView() != null; } @Override protected void onTransitionComplete() { // TODO(b/138729100) This doesn't execute first time launcher is run if (mTriggeredFromAltTab) { - RecentsView rv = (RecentsView) mHelper.getVisibleRecentsView(); + RecentsView rv = (RecentsView) mActivityInterface.getVisibleRecentsView(); if (rv == null) { return; } @@ -130,7 +130,7 @@ public class OverviewCommandHelper { @Override protected boolean handleCommand(long elapsedTime) { - RecentsView recents = (RecentsView) mHelper.getVisibleRecentsView(); + RecentsView recents = (RecentsView) mActivityInterface.getVisibleRecentsView(); if (recents == null) { return false; } @@ -146,7 +146,7 @@ public class OverviewCommandHelper { private class RecentsActivityCommand implements Runnable { - protected final ActivityControlHelper mHelper; + protected final BaseActivityInterface mActivityInterface; private final long mCreateTime; private final AppToOverviewAnimationProvider mAnimationProvider; @@ -155,10 +155,10 @@ public class OverviewCommandHelper { private ActivityInitListener mListener; public RecentsActivityCommand() { - mHelper = mOverviewComponentObserver.getActivityControlHelper(); + mActivityInterface = mOverviewComponentObserver.getActivityInterface(); mCreateTime = SystemClock.elapsedRealtime(); - mAnimationProvider = - new AppToOverviewAnimationProvider<>(mHelper, RecentsModel.getRunningTaskId()); + mAnimationProvider = new AppToOverviewAnimationProvider<>(mActivityInterface, + RecentsModel.getRunningTaskId()); // Preload the plan mRecentsModel.getTasks(null); @@ -174,13 +174,13 @@ public class OverviewCommandHelper { return; } - if (mHelper.switchToRecentsIfVisible(this::onTransitionComplete)) { + if (mActivityInterface.switchToRecentsIfVisible(this::onTransitionComplete)) { // If successfully switched, then return return; } // Otherwise, start overview. - mListener = mHelper.createActivityInitListener(this::onActivityReady); + mListener = mActivityInterface.createActivityInitListener(this::onActivityReady); mListener.registerAndStartActivity(mOverviewComponentObserver.getOverviewIntent(), this::createWindowAnimation, mContext, MAIN_EXECUTOR.getHandler(), mAnimationProvider.getRecentsLaunchDuration()); @@ -190,7 +190,7 @@ public class OverviewCommandHelper { // TODO: We need to fix this case with PIP, when an activity first enters PIP, it shows // the menu activity which takes window focus, preventing the right condition from // being run below - RecentsView recents = mHelper.getVisibleRecentsView(); + RecentsView recents = mActivityInterface.getVisibleRecentsView(); if (recents != null) { // Launch the next task recents.showNextTask(); @@ -207,7 +207,7 @@ public class OverviewCommandHelper { if (!mUserEventLogged) { activity.getUserEventDispatcher().logActionCommand( LauncherLogProto.Action.Command.RECENTS_BUTTON, - mHelper.getContainerType(), + mActivityInterface.getContainerType(), LauncherLogProto.ContainerType.TASKSWITCHER); mUserEventLogged = true; } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java index 6ac75465a3..1bbeca47f1 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -83,7 +83,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { OverviewComponentObserver observer = new OverviewComponentObserver(mContext, new RecentsAnimationDeviceState(mContext)); try { - return observer.getActivityControlHelper().getCreatedActivity().getOverviewPanel(); + return observer.getActivityInterface().getCreatedActivity().getOverviewPanel(); } finally { observer.onDestroy(); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/SwipeSharedState.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/SwipeSharedState.java index 7beab5bae1..cd8e1a406b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/SwipeSharedState.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/SwipeSharedState.java @@ -65,7 +65,7 @@ public class SwipeSharedState implements RecentsAnimationListener { @Override public final void onRecentsAnimationCanceled(ThumbnailData thumbnailData) { if (thumbnailData != null) { - mOverviewComponentObserver.getActivityControlHelper().switchToScreenshot(thumbnailData, + mOverviewComponentObserver.getActivityInterface().switchToScreenshot(thumbnailData, () -> { mLastRecentsAnimationController.cleanupScreenshot(); clearAnimationState(); @@ -129,7 +129,7 @@ public class SwipeSharedState implements RecentsAnimationListener { clearListenerState(false /* finishAnimation */); boolean shouldMinimiseSplitScreen = mOverviewComponentObserver == null ? false - : mOverviewComponentObserver.getActivityControlHelper().shouldMinimizeSplitScreen(); + : mOverviewComponentObserver.getActivityInterface().shouldMinimizeSplitScreen(); mRecentsAnimationListener = new RecentsAnimationCallbacks(shouldMinimiseSplitScreen); mRecentsAnimationListener.addListener(this); return mRecentsAnimationListener; 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 2616d0dff9..4b7ae6f426 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -182,10 +182,10 @@ public class TouchInteractionService extends Service implements return; } - final ActivityControlHelper activityControl = - mOverviewComponentObserver.getActivityControlHelper(); + final BaseActivityInterface activityInterface = + mOverviewComponentObserver.getActivityInterface(); UserEventDispatcher.newInstance(getBaseContext()).logActionBack(completed, downX, downY, - isButton, gestureSwipeLeft, activityControl.getContainerType()); + isButton, gestureSwipeLeft, activityInterface.getContainerType()); if (completed && !isButton && shouldNotifyBackGesture()) { UI_HELPER_EXECUTOR.execute(TouchInteractionService.this::tryNotifyBackGesture); @@ -373,7 +373,7 @@ public class TouchInteractionService extends Service implements @UiThread private void onAssistantVisibilityChanged() { if (mDeviceState.isUserUnlocked()) { - mOverviewComponentObserver.getActivityControlHelper().onAssistantVisibilityChanged( + mOverviewComponentObserver.getActivityInterface().onAssistantVisibilityChanged( mDeviceState.getAssistantVisibility()); } } @@ -412,13 +412,16 @@ public class TouchInteractionService extends Service implements MotionEvent event = (MotionEvent) ev; if (event.getAction() == ACTION_DOWN) { + GestureState newGestureState = new GestureState( + mOverviewComponentObserver.getActivityInterface()); + mLogId = ActiveGestureLog.INSTANCE.generateAndSetLogId(); sSwipeSharedState.setLogTraceId(mLogId); if (mDeviceState.isInSwipeUpTouchRegion(event)) { boolean useSharedState = mConsumer.useSharedSwipeState(); mConsumer.onConsumerAboutToBeSwitched(); - mConsumer = newConsumer(useSharedState, event); + mConsumer = newConsumer(newGestureState, useSharedState, event); ActiveGestureLog.INSTANCE.addLog("setInputConsumer", mConsumer.getType()); mUncheckedConsumer = mConsumer; } else if (mDeviceState.isUserUnlocked() && mMode == Mode.NO_BUTTON @@ -426,8 +429,7 @@ public class TouchInteractionService extends Service implements // 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. - mUncheckedConsumer = new AssistantInputConsumer(this, - mOverviewComponentObserver.getActivityControlHelper(), + mUncheckedConsumer = new AssistantInputConsumer(this, newGestureState, InputConsumer.NO_OP, mInputMonitorCompat); } else { mUncheckedConsumer = InputConsumer.NO_OP; @@ -439,14 +441,16 @@ public class TouchInteractionService extends Service implements DejankBinderTracker.disallowBinderTrackingInTests(); } - private InputConsumer newConsumer(boolean useSharedState, MotionEvent event) { + private InputConsumer newConsumer(GestureState gestureState, boolean useSharedState, + MotionEvent event) { boolean canStartSystemGesture = mDeviceState.canStartSystemGesture(); if (!mDeviceState.isUserUnlocked()) { if (canStartSystemGesture) { // This handles apps launched in direct boot mode (e.g. dialer) as well as apps // launched while device is locked even after exiting direct boot mode (e.g. camera). - return createDeviceLockedInputConsumer(mAM.getRunningTask(ACTIVITY_TYPE_ASSISTANT)); + return createDeviceLockedInputConsumer(gestureState, + mAM.getRunningTask(ACTIVITY_TYPE_ASSISTANT)); } else { return mResetGestureInputConsumer; } @@ -455,24 +459,21 @@ public class TouchInteractionService extends Service implements // When using sharedState, bypass systemState check as this is a followup gesture and the // first gesture started in a valid system state. InputConsumer base = canStartSystemGesture || useSharedState - ? newBaseConsumer(useSharedState, event) : mResetGestureInputConsumer; + ? newBaseConsumer(gestureState, useSharedState, event) : mResetGestureInputConsumer; if (mMode == Mode.NO_BUTTON) { - final ActivityControlHelper activityControl = - mOverviewComponentObserver.getActivityControlHelper(); if (mDeviceState.canTriggerAssistantAction(event)) { - base = new AssistantInputConsumer(this, activityControl, base, mInputMonitorCompat); + base = new AssistantInputConsumer(this, gestureState, base, mInputMonitorCompat); } if (FeatureFlags.ENABLE_QUICK_CAPTURE_GESTURE.get()) { // Put the Compose gesture as higher priority than the Assistant or base gestures - base = new QuickCaptureInputConsumer(this, base, mInputMonitorCompat, - activityControl); + base = new QuickCaptureInputConsumer(this, gestureState, base, mInputMonitorCompat); } if (mDeviceState.isScreenPinningActive()) { // Note: we only allow accessibility to wrap this, and it replaces the previous // base input consumer (which should be NO_OP anyway since topTaskLocked == true). - base = new ScreenPinnedInputConsumer(this, activityControl); + base = new ScreenPinnedInputConsumer(this, gestureState); } if (mDeviceState.isAccessibilityMenuAvailable()) { @@ -487,7 +488,8 @@ public class TouchInteractionService extends Service implements return base; } - private InputConsumer newBaseConsumer(boolean useSharedState, MotionEvent event) { + private InputConsumer newBaseConsumer(GestureState gestureState, boolean useSharedState, + MotionEvent event) { RunningTaskInfo runningTaskInfo = DejankBinderTracker.whitelistIpcs( () -> mAM.getRunningTask(0)); if (!useSharedState) { @@ -495,12 +497,9 @@ public class TouchInteractionService extends Service implements } if (mDeviceState.isKeyguardShowingOccluded()) { // This handles apps showing over the lockscreen (e.g. camera) - return createDeviceLockedInputConsumer(runningTaskInfo); + return createDeviceLockedInputConsumer(gestureState, runningTaskInfo); } - final ActivityControlHelper activityControl = - mOverviewComponentObserver.getActivityControlHelper(); - boolean forceOverviewInputConsumer = false; if (isExcludedAssistant(runningTaskInfo)) { // In the case where we are in the excluded assistant state, ignore it and treat the @@ -523,16 +522,18 @@ public class TouchInteractionService extends Service implements // consumer but with the next task as the running task RunningTaskInfo info = new ActivityManager.RunningTaskInfo(); info.id = sSwipeSharedState.nextRunningTaskId; - return createOtherActivityInputConsumer(event, info); - } else if (sSwipeSharedState.goingToLauncher || activityControl.isResumed() + return createOtherActivityInputConsumer(gestureState, event, info); + } else if (sSwipeSharedState.goingToLauncher + || gestureState.getActivityInterface().isResumed() || forceOverviewInputConsumer) { - return createOverviewInputConsumer(event); - } else if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityControl.isInLiveTileMode()) { - return createOverviewInputConsumer(event); + return createOverviewInputConsumer(gestureState, event); + } else if (ENABLE_QUICKSTEP_LIVE_TILE.get() + && gestureState.getActivityInterface().isInLiveTileMode()) { + return createOverviewInputConsumer(gestureState, event); } else if (mDeviceState.isGestureBlockedActivity(runningTaskInfo)) { return mResetGestureInputConsumer; } else { - return createOtherActivityInputConsumer(event, runningTaskInfo); + return createOtherActivityInputConsumer(gestureState, event, runningTaskInfo); } } @@ -542,52 +543,50 @@ public class TouchInteractionService extends Service implements && (info.baseIntent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) != 0; } - private InputConsumer createOtherActivityInputConsumer(MotionEvent event, - RunningTaskInfo runningTaskInfo) { + private InputConsumer createOtherActivityInputConsumer(GestureState gestureState, + MotionEvent event, RunningTaskInfo runningTaskInfo) { final boolean shouldDefer; final BaseSwipeUpHandler.Factory factory; - ActivityControlHelper activityControlHelper = - mOverviewComponentObserver.getActivityControlHelper(); if (mMode == Mode.NO_BUTTON && !mOverviewComponentObserver.isHomeAndOverviewSame()) { shouldDefer = !sSwipeSharedState.recentsAnimationFinishInterrupted; factory = mFallbackNoButtonFactory; } else { - shouldDefer = activityControlHelper.deferStartingActivity(mDeviceState, event); + shouldDefer = gestureState.getActivityInterface().deferStartingActivity(mDeviceState, + event); factory = mWindowTreansformFactory; } final boolean disableHorizontalSwipe = mDeviceState.isInExclusionRegion(event); - return new OtherActivityInputConsumer(this, mDeviceState, runningTaskInfo, shouldDefer, - this::onConsumerInactive, sSwipeSharedState, mInputMonitorCompat, - disableHorizontalSwipe, activityControlHelper, factory, mLogId); + return new OtherActivityInputConsumer(this, mDeviceState, gestureState, runningTaskInfo, + shouldDefer, this::onConsumerInactive, sSwipeSharedState, mInputMonitorCompat, + disableHorizontalSwipe, factory, mLogId); } - private InputConsumer createDeviceLockedInputConsumer(RunningTaskInfo taskInfo) { + private InputConsumer createDeviceLockedInputConsumer(GestureState gestureState, + RunningTaskInfo taskInfo) { if (mMode == Mode.NO_BUTTON && taskInfo != null) { - return new DeviceLockedInputConsumer(this, mDeviceState, sSwipeSharedState, - mInputMonitorCompat, taskInfo.taskId, mLogId); + return new DeviceLockedInputConsumer(this, mDeviceState, gestureState, + sSwipeSharedState, mInputMonitorCompat, taskInfo.taskId, mLogId); } else { return mResetGestureInputConsumer; } } - public InputConsumer createOverviewInputConsumer(MotionEvent event) { - final ActivityControlHelper activityControl = - mOverviewComponentObserver.getActivityControlHelper(); - BaseDraggingActivity activity = activityControl.getCreatedActivity(); + public InputConsumer createOverviewInputConsumer(GestureState gestureState, MotionEvent event) { + BaseDraggingActivity activity = gestureState.getActivityInterface().getCreatedActivity(); if (activity == null) { return mResetGestureInputConsumer; } if (activity.getRootView().hasWindowFocus() || sSwipeSharedState.goingToLauncher) { - return new OverviewInputConsumer(activity, mInputMonitorCompat, - false /* startingInActivityBounds */, activityControl); + return new OverviewInputConsumer(gestureState, activity, mInputMonitorCompat, + false /* startingInActivityBounds */); } else { final boolean disableHorizontalSwipe = mDeviceState.isInExclusionRegion(event); - return new OverviewWithoutFocusInputConsumer(activity, mInputMonitorCompat, - activityControl, disableHorizontalSwipe); + return new OverviewWithoutFocusInputConsumer(activity, gestureState, + mInputMonitorCompat, disableHorizontalSwipe); } } @@ -616,11 +615,11 @@ public class TouchInteractionService extends Service implements return; } - final ActivityControlHelper activityControl = - mOverviewComponentObserver.getActivityControlHelper(); - if (activityControl.getCreatedActivity() == null) { + final BaseActivityInterface activityInterface = + mOverviewComponentObserver.getActivityInterface(); + if (activityInterface.getCreatedActivity() == null) { // Make sure that UI states will be initialized. - activityControl.createActivityInitListener((activity, wasVisible) -> { + activityInterface.createActivityInitListener((activity, wasVisible) -> { AppLaunchTracker.INSTANCE.get(activity); return false; }).register(); @@ -641,9 +640,9 @@ public class TouchInteractionService extends Service implements if (!mDeviceState.isUserUnlocked()) { return; } - final ActivityControlHelper activityControl = - mOverviewComponentObserver.getActivityControlHelper(); - final BaseDraggingActivity activity = activityControl.getCreatedActivity(); + final BaseActivityInterface activityInterface = + mOverviewComponentObserver.getActivityInterface(); + final BaseDraggingActivity activity = activityInterface.getCreatedActivity(); if (activity == null || activity.isStarted()) { // We only care about the existing background activity. return; @@ -675,7 +674,7 @@ public class TouchInteractionService extends Service implements pw.println("TouchState:"); pw.println(" navMode=" + mMode); boolean resumed = mOverviewComponentObserver != null - && mOverviewComponentObserver.getActivityControlHelper().isResumed(); + && mOverviewComponentObserver.getActivityInterface().isResumed(); pw.println(" resumed=" + resumed); pw.println(" useSharedState=" + mConsumer.useSharedSwipeState()); if (mConsumer.useSharedSwipeState()) { @@ -706,16 +705,20 @@ public class TouchInteractionService extends Service implements } } - private BaseSwipeUpHandler createWindowTransformSwipeHandler(RunningTaskInfo runningTask, - long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) { - return new WindowTransformSwipeHandler(mDeviceState, runningTask, this, touchTimeMs, - mOverviewComponentObserver, continuingLastGesture, mInputConsumer, mRecentsModel); + private BaseSwipeUpHandler createWindowTransformSwipeHandler(GestureState gestureState, + RunningTaskInfo runningTask, long touchTimeMs, boolean continuingLastGesture, + boolean isLikelyToStartNewTask) { + return new WindowTransformSwipeHandler(this, mDeviceState, gestureState, runningTask, + touchTimeMs, mOverviewComponentObserver, continuingLastGesture, mInputConsumer, + mRecentsModel); } - private BaseSwipeUpHandler createFallbackNoButtonSwipeHandler(RunningTaskInfo runningTask, - long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) { - return new FallbackNoButtonInputConsumer(this, mOverviewComponentObserver, runningTask, - mRecentsModel, mInputConsumer, isLikelyToStartNewTask, continuingLastGesture); + private BaseSwipeUpHandler createFallbackNoButtonSwipeHandler(GestureState gestureState, + RunningTaskInfo runningTask, long touchTimeMs, boolean continuingLastGesture, + boolean isLikelyToStartNewTask) { + return new FallbackNoButtonInputConsumer(this, gestureState, mOverviewComponentObserver, + runningTask, mRecentsModel, mInputConsumer, isLikelyToStartNewTask, + continuingLastGesture); } protected boolean shouldNotifyBackGesture() { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index ccc41e3de0..e3b12cb79c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -26,8 +26,8 @@ import static com.android.launcher3.util.DefaultDisplay.getSingleFrameMs; import static com.android.launcher3.util.RaceConditionTracker.ENTER; import static com.android.launcher3.util.RaceConditionTracker.EXIT; import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW; -import static com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState.HIDE; -import static com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState.PEEK; +import static com.android.quickstep.BaseActivityInterface.AnimationFactory.ShelfAnimState.HIDE; +import static com.android.quickstep.BaseActivityInterface.AnimationFactory.ShelfAnimState.PEEK; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.HOME; import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.LAST_TASK; @@ -71,9 +71,9 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.RaceConditionTracker; import com.android.launcher3.util.TraceHelper; -import com.android.quickstep.ActivityControlHelper.AnimationFactory; -import com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState; -import com.android.quickstep.ActivityControlHelper.HomeAnimationFactory; +import com.android.quickstep.BaseActivityInterface.AnimationFactory; +import com.android.quickstep.BaseActivityInterface.AnimationFactory.ShelfAnimState; +import com.android.quickstep.BaseActivityInterface.HomeAnimationFactory; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.inputconsumers.OverviewInputConsumer; import com.android.quickstep.util.ActiveGestureLog; @@ -195,7 +195,8 @@ public class WindowTransformSwipeHandler */ private static final int LOG_NO_OP_PAGE_INDEX = -1; - private RecentsAnimationDeviceState mDeviceState; + private final RecentsAnimationDeviceState mDeviceState; + private final GestureState mGestureState; private GestureEndTarget mGestureEndTarget; // Either RectFSpringAnim (if animating home) or ObjectAnimator (from mCurrentShift) otherwise @@ -228,12 +229,13 @@ public class WindowTransformSwipeHandler private final long mTouchTimeMs; private long mLauncherFrameDrawnTime; - public WindowTransformSwipeHandler(RecentsAnimationDeviceState deviceState, - RunningTaskInfo runningTaskInfo, Context context, long touchTimeMs, + public WindowTransformSwipeHandler(Context context, RecentsAnimationDeviceState deviceState, + GestureState gestureState, RunningTaskInfo runningTaskInfo, long touchTimeMs, OverviewComponentObserver overviewComponentObserver, boolean continuingLastGesture, InputConsumerController inputConsumer, RecentsModel recentsModel) { - super(context, overviewComponentObserver, recentsModel, inputConsumer, runningTaskInfo.id); + super(context, gestureState, overviewComponentObserver, recentsModel, inputConsumer, runningTaskInfo.id); mDeviceState = deviceState; + mGestureState = gestureState; mTouchTimeMs = touchTimeMs; mContinuingLastGesture = continuingLastGesture; initStateCallbacks(); @@ -349,7 +351,7 @@ public class WindowTransformSwipeHandler // as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL. if (mGestureEndTarget != HOME) { Runnable initAnimFactory = () -> { - mAnimationFactory = mActivityControlHelper.prepareRecentsUI(mActivity, + mAnimationFactory = mActivityInterface.prepareRecentsUI(mActivity, mWasLauncherAlreadyVisible, true, this::onAnimatorPlaybackControllerCreated); maybeUpdateRecentsAttachedState(false /* animate */); @@ -518,7 +520,7 @@ public class WindowTransformSwipeHandler return; } initTransitionEndpoints(mActivity.getDeviceProfile()); - mAnimationFactory.createActivityController(mTransitionDragLength); + mAnimationFactory.createActivityInterface(mTransitionDragLength); } @Override @@ -688,9 +690,9 @@ public class WindowTransformSwipeHandler setTargetAlphaProvider(WindowTransformSwipeHandler::getHiddenTargetAlpha); } - BaseDraggingActivity activity = mActivityControlHelper.getCreatedActivity(); + BaseDraggingActivity activity = mActivityInterface.getCreatedActivity(); return activity == null ? InputConsumer.NO_OP - : new OverviewInputConsumer(activity, null, true, mActivityControlHelper); + : new OverviewInputConsumer(mGestureState, activity, null, true); } private void endRunningWindowAnim(boolean cancel) { @@ -882,7 +884,7 @@ public class WindowTransformSwipeHandler if (mGestureEndTarget == HOME) { HomeAnimationFactory homeAnimFactory; if (mActivity != null) { - homeAnimFactory = mActivityControlHelper.prepareHomeUI(mActivity); + homeAnimFactory = mActivityInterface.prepareHomeUI(mActivity); } else { homeAnimFactory = new HomeAnimationFactory() { @NonNull @@ -994,7 +996,7 @@ public class WindowTransformSwipeHandler } // Make sure recents is in its final state maybeUpdateRecentsAttachedState(false); - mActivityControlHelper.onSwipeUpToHomeComplete(mActivity); + mActivityInterface.onSwipeUpToHomeComplete(mActivity); } }); return anim; @@ -1103,7 +1105,7 @@ public class WindowTransformSwipeHandler private void resetStateForAnimationCancel() { boolean wasVisible = mWasLauncherAlreadyVisible || mGestureStarted; - mActivityControlHelper.onTransitionCancelled(mActivity, wasVisible); + mActivityInterface.onTransitionCancelled(mActivity, wasVisible); // Leave the pending invisible flag, as it may be used by wallpaper open animation. mActivity.clearForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER); @@ -1180,7 +1182,7 @@ public class WindowTransformSwipeHandler private void setupLauncherUiAfterSwipeUpToRecentsAnimation() { endLauncherTransitionController(); - mActivityControlHelper.onSwipeUpToRecentsComplete(mActivity); + mActivityInterface.onSwipeUpToRecentsComplete(mActivity); if (mRecentsAnimationController != null) { mRecentsAnimationController.setDeferCancelUntilNextTransition(true /* defer */, true /* screenshot */); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java index d60b92718a..94126ff6ee 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantInputConsumer.java @@ -48,7 +48,8 @@ import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.R; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.logging.UserEventDispatcher; -import com.android.quickstep.ActivityControlHelper; +import com.android.quickstep.BaseActivityInterface; +import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.SystemUiProxy; import com.android.systemui.shared.system.InputMonitorCompat; @@ -80,7 +81,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer { private long mDragTime; private float mLastProgress; private int mDirection; - private ActivityControlHelper mActivityControlHelper; + private BaseActivityInterface mActivityInterface; private final float mDragDistThreshold; private final float mFlingDistThreshold; @@ -90,7 +91,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer { private final Context mContext; private final GestureDetector mGestureDetector; - public AssistantInputConsumer(Context context, ActivityControlHelper activityControlHelper, + public AssistantInputConsumer(Context context, GestureState gestureState, InputConsumer delegate, InputMonitorCompat inputMonitor) { super(delegate, inputMonitor); final Resources res = context.getResources(); @@ -103,7 +104,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer { float slop = ViewConfiguration.get(context).getScaledTouchSlop(); mSquaredSlop = slop * slop; - mActivityControlHelper = activityControlHelper; + mActivityInterface = gestureState.getActivityInterface(); mGestureDetector = new GestureDetector(context, new AssistantGestureListener()); } @@ -233,8 +234,7 @@ public class AssistantInputConsumer extends DelegateInputConsumer { UserEventDispatcher.newInstance(mContext) .logActionOnContainer(gestureType, mDirection, NAVBAR); - BaseDraggingActivity launcherActivity = mActivityControlHelper - .getCreatedActivity(); + BaseDraggingActivity launcherActivity = mActivityInterface.getCreatedActivity(); if (launcherActivity != null) { launcherActivity.getRootView().performHapticFeedback( 13, // HapticFeedbackConstants.GESTURE_END diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java index cdf2e26bc5..12b7c2622d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java @@ -39,6 +39,7 @@ import android.view.ViewConfiguration; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.util.DefaultDisplay; +import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.LockScreenRecentsActivity; import com.android.quickstep.MultiStateCallback; @@ -75,6 +76,7 @@ public class DeviceLockedInputConsumer implements InputConsumer, private final Context mContext; private final RecentsAnimationDeviceState mDeviceState; + private final GestureState mGestureState; private final float mTouchSlopSquared; private final SwipeSharedState mSwipeSharedState; private final InputMonitorCompat mInputMonitorCompat; @@ -96,10 +98,11 @@ public class DeviceLockedInputConsumer implements InputConsumer, private RecentsAnimationTargets mRecentsAnimationTargets; public DeviceLockedInputConsumer(Context context, RecentsAnimationDeviceState deviceState, - SwipeSharedState swipeSharedState, InputMonitorCompat inputMonitorCompat, - int runningTaskId, int logId) { + GestureState gestureState, SwipeSharedState swipeSharedState, + InputMonitorCompat inputMonitorCompat, int runningTaskId, int logId) { mContext = context; mDeviceState = deviceState; + mGestureState = gestureState; mTouchSlopSquared = squaredTouchSlop(context); mSwipeSharedState = swipeSharedState; mAppWindowAnimationHelper = new AppWindowAnimationHelper(context); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/FallbackNoButtonInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/FallbackNoButtonInputConsumer.java index 29357f237d..370b48793c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/FallbackNoButtonInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/FallbackNoButtonInputConsumer.java @@ -39,9 +39,10 @@ import com.android.launcher3.R; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.util.ObjectWrapper; -import com.android.quickstep.ActivityControlHelper.HomeAnimationFactory; +import com.android.quickstep.BaseActivityInterface.HomeAnimationFactory; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.BaseSwipeUpHandler; +import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.MultiStateCallback; import com.android.quickstep.OverviewComponentObserver; @@ -114,12 +115,13 @@ public class FallbackNoButtonInputConsumer extends private final PointF mEndVelocityPxPerMs = new PointF(0, 0.5f); private RunningWindowAnim mFinishAnimation; - public FallbackNoButtonInputConsumer(Context context, + public FallbackNoButtonInputConsumer(Context context, GestureState gestureState, OverviewComponentObserver overviewComponentObserver, RunningTaskInfo runningTaskInfo, RecentsModel recentsModel, InputConsumerController inputConsumer, boolean isLikelyToStartNewTask, boolean continuingLastGesture) { - super(context, overviewComponentObserver, recentsModel, inputConsumer, runningTaskInfo.id); + super(context, gestureState, overviewComponentObserver, recentsModel, inputConsumer, + runningTaskInfo.id); mLauncherAlpha.value = 1; mRunningTaskInfo = runningTaskInfo; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index d5a18043ab..fbedc0f812 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -50,9 +50,10 @@ import com.android.launcher3.R; import com.android.launcher3.util.Preconditions; import com.android.launcher3.util.RaceConditionTracker; import com.android.launcher3.util.TraceHelper; -import com.android.quickstep.ActivityControlHelper; +import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.BaseSwipeUpHandler; import com.android.quickstep.BaseSwipeUpHandler.Factory; +import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.RecentsAnimationDeviceState; import com.android.quickstep.SwipeSharedState; @@ -81,12 +82,13 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC public static final float QUICKSTEP_TOUCH_SLOP_RATIO = 3; private final RecentsAnimationDeviceState mDeviceState; + private final GestureState mGestureState; private final CachedEventDispatcher mRecentsViewDispatcher = new CachedEventDispatcher(); private final RunningTaskInfo mRunningTask; private final SwipeSharedState mSwipeSharedState; private final InputMonitorCompat mInputMonitorCompat; private final SysUINavigationMode.Mode mMode; - private final ActivityControlHelper mActivityControlHelper; + private final BaseActivityInterface mActivityInterface; private final BaseSwipeUpHandler.Factory mHandlerFactory; @@ -126,20 +128,19 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC private int mLogId; public OtherActivityInputConsumer(Context base, RecentsAnimationDeviceState deviceState, - RunningTaskInfo runningTaskInfo, boolean isDeferredDownTarget, - Consumer onCompleteCallback, + GestureState gestureState, RunningTaskInfo runningTaskInfo, + boolean isDeferredDownTarget, Consumer onCompleteCallback, SwipeSharedState swipeSharedState, InputMonitorCompat inputMonitorCompat, - boolean disableHorizontalSwipe, ActivityControlHelper activityControlHelper, - Factory handlerFactory, int logId) { + boolean disableHorizontalSwipe, Factory handlerFactory, int logId) { super(base); mLogId = logId; - mDeviceState = deviceState; + mGestureState = gestureState; mMainThreadHandler = new Handler(Looper.getMainLooper()); mRunningTask = runningTaskInfo; mMode = SysUINavigationMode.getMode(base); mHandlerFactory = handlerFactory; - mActivityControlHelper = activityControlHelper; + mActivityInterface = mGestureState.getActivityInterface(); mMotionPauseDetector = new MotionPauseDetector(base); mMotionPauseMinDisplacement = base.getResources().getDimension( @@ -318,7 +319,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC } mInputMonitorCompat.pilferPointers(); - mActivityControlHelper.closeOverlay(); + mActivityInterface.closeOverlay(); ActivityManagerWrapper.getInstance().closeSystemWindows( CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); @@ -331,8 +332,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC ActiveGestureLog.INSTANCE.addLog("startRecentsAnimation"); RecentsAnimationCallbacks listenerSet = mSwipeSharedState.getActiveListener(); - final BaseSwipeUpHandler handler = mHandlerFactory.newHandler(mRunningTask, touchTimeMs, - listenerSet != null, isLikelyToStartNewTask); + final BaseSwipeUpHandler handler = mHandlerFactory.newHandler(mGestureState, mRunningTask, + touchTimeMs, listenerSet != null, isLikelyToStartNewTask); mInteractionHandler = handler; handler.setGestureEndCallback(this::onInteractionGestureFinished); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java index b09a5ac1c1..c19754fa56 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java @@ -26,7 +26,8 @@ import androidx.annotation.Nullable; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.Utilities; import com.android.launcher3.views.BaseDragLayer; -import com.android.quickstep.ActivityControlHelper; +import com.android.quickstep.BaseActivityInterface; +import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.util.ActiveGestureLog; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -41,7 +42,7 @@ public class OverviewInputConsumer implements InputConsumer { private final T mActivity; - private final ActivityControlHelper mActivityControlHelper; + private final BaseActivityInterface mActivityInterface; private final BaseDragLayer mTarget; private final InputMonitorCompat mInputMonitor; @@ -52,13 +53,12 @@ public class OverviewInputConsumer private final boolean mStartingInActivityBounds; private boolean mTargetHandledTouch; - public OverviewInputConsumer(T activity, @Nullable InputMonitorCompat inputMonitor, - boolean startingInActivityBounds, - ActivityControlHelper activityControlHelper) { + public OverviewInputConsumer(GestureState gestureState, T activity, + @Nullable InputMonitorCompat inputMonitor, boolean startingInActivityBounds) { mActivity = activity; mInputMonitor = inputMonitor; mStartingInActivityBounds = startingInActivityBounds; - mActivityControlHelper = activityControlHelper; + mActivityInterface = gestureState.getActivityInterface(); mTarget = activity.getDragLayer(); if (startingInActivityBounds) { @@ -100,7 +100,7 @@ public class OverviewInputConsumer if (!mTargetHandledTouch && handled) { mTargetHandledTouch = true; if (!mStartingInActivityBounds) { - mActivityControlHelper.closeOverlay(); + mActivityInterface.closeOverlay(); ActivityManagerWrapper.getInstance() .closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); ActiveGestureLog.INSTANCE.addLog("startQuickstep"); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java index c2560946c3..50069ea05c 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java @@ -35,8 +35,9 @@ import com.android.launcher3.Utilities; import com.android.launcher3.logging.StatsLogUtils; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; -import com.android.quickstep.ActivityControlHelper; +import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.InputConsumer; +import com.android.quickstep.GestureState; import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.NavBarPosition; import com.android.systemui.shared.system.ActivityManagerWrapper; @@ -50,17 +51,17 @@ public class OverviewWithoutFocusInputConsumer implements InputConsumer { private final float mSquaredTouchSlop; private final Context mContext; private final NavBarPosition mNavBarPosition; - private final ActivityControlHelper mActivityControlHelper; + private final BaseActivityInterface mActivityInterface; private boolean mInterceptedTouch; private VelocityTracker mVelocityTracker; - public OverviewWithoutFocusInputConsumer(Context context, InputMonitorCompat inputMonitor, - ActivityControlHelper activityControlHelper, boolean disableHorizontalSwipe) { + public OverviewWithoutFocusInputConsumer(Context context, GestureState gestureState, + InputMonitorCompat inputMonitor, boolean disableHorizontalSwipe) { mInputMonitor = inputMonitor; mDisableHorizontalSwipe = disableHorizontalSwipe; mContext = context; - mActivityControlHelper = activityControlHelper; + mActivityInterface = gestureState.getActivityInterface(); mSquaredTouchSlop = Utilities.squaredTouchSlop(context); mNavBarPosition = new NavBarPosition(context); @@ -149,7 +150,7 @@ public class OverviewWithoutFocusInputConsumer implements InputConsumer { } if (triggerQuickstep) { - mActivityControlHelper.closeOverlay(); + mActivityInterface.closeOverlay(); ActivityManagerWrapper.getInstance() .closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); ActiveGestureLog.INSTANCE.addLog("startQuickstep"); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureInputConsumer.java index ea80a383bd..97ca730402 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/QuickCaptureInputConsumer.java @@ -35,7 +35,7 @@ import android.view.ViewConfiguration; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.R; -import com.android.quickstep.ActivityControlHelper; +import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.system.InputMonitorCompat; @@ -73,15 +73,16 @@ public class QuickCaptureInputConsumer private RecentsView mRecentsView; - public QuickCaptureInputConsumer(Context context, InputConsumer delegate, - InputMonitorCompat inputMonitor, ActivityControlHelper activityControlHelper) { + public QuickCaptureInputConsumer(Context context, GestureState gestureState, + InputConsumer delegate, InputMonitorCompat inputMonitor) { super(delegate, inputMonitor); mContext = context; float slop = ViewConfiguration.get(context).getScaledTouchSlop(); mSquaredSlop = slop * slop; - activityControlHelper.createActivityInitListener(this::onActivityInit).register(); + gestureState.getActivityInterface().createActivityInitListener(this::onActivityInit) + .register(); } @Override @@ -89,7 +90,7 @@ public class QuickCaptureInputConsumer return TYPE_QUICK_CAPTURE | mDelegate.getType(); } - private boolean onActivityInit(final T activity, Boolean alreadyOnHome) { + private boolean onActivityInit(final BaseDraggingActivity activity, Boolean alreadyOnHome) { mRecentsView = activity.getOverviewPanel(); return true; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java index d8b1bfdcfd..d5ed321e08 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java @@ -21,7 +21,7 @@ import android.view.MotionEvent; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.R; -import com.android.quickstep.ActivityControlHelper; +import com.android.quickstep.GestureState; import com.android.quickstep.InputConsumer; import com.android.quickstep.util.MotionPauseDetector; import com.android.quickstep.SystemUiProxy; @@ -38,14 +38,15 @@ public class ScreenPinnedInputConsumer implements InputConsumer { private float mTouchDownY; - public ScreenPinnedInputConsumer(Context context, ActivityControlHelper activityControl) { + public ScreenPinnedInputConsumer(Context context, GestureState gestureState) { mMotionPauseMinDisplacement = context.getResources().getDimension( R.dimen.motion_pause_detector_min_displacement_from_app); mMotionPauseDetector = new MotionPauseDetector(context, true /* makePauseHarderToTrigger*/); mMotionPauseDetector.setOnMotionPauseListener(isPaused -> { if (isPaused) { SystemUiProxy.INSTANCE.get(context).stopScreenPinning(); - BaseDraggingActivity launcherActivity = activityControl.getCreatedActivity(); + BaseDraggingActivity launcherActivity = gestureState.getActivityInterface() + .getCreatedActivity(); if (launcherActivity != null) { launcherActivity.getRootView().performHapticFeedback( HapticFeedbackConstants.LONG_PRESS, diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java similarity index 97% rename from quickstep/src/com/android/quickstep/ActivityControlHelper.java rename to quickstep/src/com/android/quickstep/BaseActivityInterface.java index 382232cda2..409bec6c70 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -42,7 +42,7 @@ import java.util.function.Consumer; * Utility class which abstracts out the logical differences between Launcher and RecentsActivity. */ @TargetApi(Build.VERSION_CODES.P) -public interface ActivityControlHelper { +public interface BaseActivityInterface { void onTransitionCancelled(T activity, boolean activityVisible); @@ -112,7 +112,7 @@ public interface ActivityControlHelper { default void onRemoteAnimationReceived(RemoteAnimationTargets targets) { } - void createActivityController(long transitionLength); + void createActivityInterface(long transitionLength); default void adjustActivityControllerInterpolators() { } diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java new file mode 100644 index 0000000000..de64227c26 --- /dev/null +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.quickstep; + +import com.android.launcher3.BaseDraggingActivity; + +/** + * Manages the state for an active system gesture, listens for events from the system and Launcher, + * and fires events when the states change. + */ +public class GestureState { + + // Needed to interact with the current activity + private BaseActivityInterface mActivityInterface; + + public GestureState(BaseActivityInterface activityInterface) { + mActivityInterface = activityInterface; + } + + public BaseActivityInterface getActivityInterface() { + return mActivityInterface; + } +} diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java index 331183a512..73b78db6cd 100644 --- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java +++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java @@ -62,7 +62,7 @@ public final class OverviewComponentObserver { private final Intent mFallbackIntent; private final SparseIntArray mConfigChangesMap = new SparseIntArray(); private String mUpdateRegisteredPackage; - private ActivityControlHelper mActivityControlHelper; + private BaseActivityInterface mActivityInterface; private Intent mOverviewIntent; private boolean mIsHomeAndOverviewSame; private boolean mIsDefaultHome; @@ -106,7 +106,7 @@ public final class OverviewComponentObserver { } /** - * Update overview intent and {@link ActivityControlHelper} based off the current launcher home + * Update overview intent and {@link BaseActivityInterface} based off the current launcher home * component. */ private void updateOverviewTargets() { @@ -119,13 +119,13 @@ public final class OverviewComponentObserver { // Set assistant visibility to 0 from launcher's perspective, ensures any elements that // launcher made invisible become visible again before the new activity control helper // becomes active. - if (mActivityControlHelper != null) { - mActivityControlHelper.onAssistantVisibilityChanged(0.f); + if (mActivityInterface != null) { + mActivityInterface.onAssistantVisibilityChanged(0.f); } if (!mDeviceState.isHomeDisabled() && (defaultHome == null || mIsDefaultHome)) { // User default home is same as out home app. Use Overview integrated in Launcher. - mActivityControlHelper = new LauncherActivityControllerHelper(); + mActivityInterface = new LauncherActivityInterface(); mIsHomeAndOverviewSame = true; mOverviewIntent = mMyHomeIntent; mCurrentHomeIntent.setComponent(mMyHomeIntent.getComponent()); @@ -138,7 +138,7 @@ public final class OverviewComponentObserver { } else { // The default home app is a different launcher. Use the fallback Overview instead. - mActivityControlHelper = new FallbackActivityControllerHelper(); + mActivityInterface = new FallbackActivityInterface(); mIsHomeAndOverviewSame = false; mOverviewIntent = mFallbackIntent; mCurrentHomeIntent.setComponent(defaultHome); @@ -230,7 +230,7 @@ public final class OverviewComponentObserver { * * @return the current activity control helper */ - public ActivityControlHelper getActivityControlHelper() { - return mActivityControlHelper; + public BaseActivityInterface getActivityInterface() { + return mActivityInterface; } }