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

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

Merge "14/ Bake the running task info into the gesture state" into ub-launcher3-master

parents b7eedb45 a19a2b75
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATI

import android.animation.Animator;
import android.annotation.TargetApi;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
@@ -96,7 +95,6 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
    protected final OverviewComponentObserver mOverviewComponentObserver;
    protected final BaseActivityInterface<T> mActivityInterface;
    protected final RecentsModel mRecentsModel;
    protected final int mRunningTaskId;

    protected final AppWindowAnimationHelper mAppWindowAnimationHelper;
    protected final TransformParams mTransformParams = new TransformParams();
@@ -130,7 +128,7 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten

    protected BaseSwipeUpHandler(Context context, RecentsAnimationDeviceState deviceState,
            GestureState gestureState, OverviewComponentObserver overviewComponentObserver,
            RecentsModel recentsModel, InputConsumerController inputConsumer, int runningTaskId) {
            RecentsModel recentsModel, InputConsumerController inputConsumer) {
        mContext = context;
        mDeviceState = deviceState;
        mGestureState = gestureState;
@@ -139,7 +137,6 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
        mRecentsModel = recentsModel;
        mActivityInitListener =
                mActivityInterface.createActivityInitListener(this::onActivityInit);
        mRunningTaskId = runningTaskId;
        mInputConsumer = inputConsumer;

        mAppWindowAnimationHelper = new AppWindowAnimationHelper(context);
@@ -261,7 +258,8 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
        mRecentsAnimationTargets = targets;
        DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(mContext).getDeviceProfile(mContext);
        final Rect overviewStackBounds;
        RemoteAnimationTargetCompat runningTaskTarget = targets.findTask(mRunningTaskId);
        RemoteAnimationTargetCompat runningTaskTarget = targets.findTask(
                mGestureState.getRunningTaskId());

        if (targets.minimizedHomeBounds != null && runningTaskTarget != null) {
            overviewStackBounds = mActivityInterface
@@ -490,8 +488,8 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten

    public interface Factory {

        BaseSwipeUpHandler newHandler(GestureState gestureState, RunningTaskInfo runningTask,
                long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask);
        BaseSwipeUpHandler newHandler(GestureState gestureState, long touchTimeMs,
                boolean continuingLastGesture, boolean isLikelyToStartNewTask);
    }

    protected interface RunningWindowAnim {
+26 −33
Original line number Diff line number Diff line
@@ -434,6 +434,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
            GestureState newGestureState = new GestureState(
                    mOverviewComponentObserver.getActivityInterface(),
                    ActiveGestureLog.INSTANCE.generateAndSetLogId());
            newGestureState.updateRunningTask(TraceHelper.whitelistIpcs("getRunningTask.0",
                    () -> mAM.getRunningTask(0)));

            if (mDeviceState.isInSwipeUpTouchRegion(event)) {
                mConsumer.onConsumerAboutToBeSwitched();
@@ -470,8 +472,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
            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(newGestureState,
                        mAM.getRunningTask(ACTIVITY_TYPE_ASSISTANT));
                return createDeviceLockedInputConsumer(newGestureState);
            } else {
                return mResetGestureInputConsumer;
            }
@@ -514,25 +515,22 @@ public class TouchInteractionService extends Service implements PluginListener<O

    private InputConsumer newBaseConsumer(GestureState previousGestureState,
            GestureState gestureState, MotionEvent event) {
        RunningTaskInfo runningTaskInfo = TraceHelper.whitelistIpcs("getRunningTask.0",
                () -> mAM.getRunningTask(0));
        if (mDeviceState.isKeyguardShowingOccluded()) {
            // This handles apps showing over the lockscreen (e.g. camera)
            return createDeviceLockedInputConsumer(gestureState, runningTaskInfo);
            return createDeviceLockedInputConsumer(gestureState);
        }

        boolean forceOverviewInputConsumer = false;
        if (isExcludedAssistant(runningTaskInfo)) {
        if (isExcludedAssistant(gestureState.getRunningTask())) {
            // In the case where we are in the excluded assistant state, ignore it and treat the
            // running activity as the task behind the assistant

            runningTaskInfo = TraceHelper.whitelistIpcs("getRunningTask.assistant",
                    () -> mAM.getRunningTask(ACTIVITY_TYPE_ASSISTANT));
            if (!ActivityManagerWrapper.isHomeTask(runningTaskInfo)) {
            gestureState.updateRunningTask(TraceHelper.whitelistIpcs("getRunningTask.assistant",
                    () -> mAM.getRunningTask(ACTIVITY_TYPE_ASSISTANT)));
            if (!ActivityManagerWrapper.isHomeTask(gestureState.getRunningTask())) {
                final ComponentName homeComponent =
                        mOverviewComponentObserver.getHomeIntent().getComponent();
                forceOverviewInputConsumer =
                        runningTaskInfo.baseIntent.getComponent().equals(homeComponent);
                forceOverviewInputConsumer = gestureState.getRunningTask()
                        .baseIntent.getComponent().equals(homeComponent);
            }
        }

@@ -541,9 +539,9 @@ public class TouchInteractionService extends Service implements PluginListener<O
            // consumer but with the next task as the running task
            RunningTaskInfo info = new ActivityManager.RunningTaskInfo();
            info.id = previousGestureState.getFinishingRecentsAnimationTaskId();
            return createOtherActivityInputConsumer(previousGestureState, gestureState, event,
                    info);
        } else if (runningTaskInfo == null) {
            gestureState.updateRunningTask(info);
            return createOtherActivityInputConsumer(previousGestureState, gestureState, event);
        } else if (gestureState.getRunningTask() == null) {
            return mResetGestureInputConsumer;
        } else if (previousGestureState.isRunningAnimationToLauncher()
                || gestureState.getActivityInterface().isResumed()
@@ -552,11 +550,10 @@ public class TouchInteractionService extends Service implements PluginListener<O
        } else if (ENABLE_QUICKSTEP_LIVE_TILE.get()
                && gestureState.getActivityInterface().isInLiveTileMode()) {
            return createOverviewInputConsumer(previousGestureState, gestureState, event);
        } else if (mDeviceState.isGestureBlockedActivity(runningTaskInfo)) {
        } else if (mDeviceState.isGestureBlockedActivity(gestureState.getRunningTask())) {
            return mResetGestureInputConsumer;
        } else {
            return createOtherActivityInputConsumer(previousGestureState, gestureState, event,
                    runningTaskInfo);
            return createOtherActivityInputConsumer(previousGestureState, gestureState, event);
        }
    }

@@ -567,8 +564,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
    }

    private InputConsumer createOtherActivityInputConsumer(GestureState previousGestureState,
            GestureState gestureState,
            MotionEvent event, RunningTaskInfo runningTaskInfo) {
            GestureState gestureState, MotionEvent event) {

        final boolean shouldDefer;
        final BaseSwipeUpHandler.Factory factory;
@@ -585,15 +581,14 @@ public class TouchInteractionService extends Service implements PluginListener<O

        final boolean disableHorizontalSwipe = mDeviceState.isInExclusionRegion(event);
        return new OtherActivityInputConsumer(this, mDeviceState, mTaskAnimationManager,
                gestureState, runningTaskInfo, shouldDefer, this::onConsumerInactive,
                gestureState, shouldDefer, this::onConsumerInactive,
                mInputMonitorCompat, disableHorizontalSwipe, factory);
    }

    private InputConsumer createDeviceLockedInputConsumer(GestureState gestureState,
            RunningTaskInfo taskInfo) {
        if (mDeviceState.isFullyGesturalNavMode() && taskInfo != null) {
    private InputConsumer createDeviceLockedInputConsumer(GestureState gestureState) {
        if (mDeviceState.isFullyGesturalNavMode() && gestureState.getRunningTask() != null) {
            return new DeviceLockedInputConsumer(this, mDeviceState, mTaskAnimationManager,
                    gestureState, mInputMonitorCompat, taskInfo.taskId);
                    gestureState, mInputMonitorCompat);
        } else {
            return mResetGestureInputConsumer;
        }
@@ -727,19 +722,17 @@ public class TouchInteractionService extends Service implements PluginListener<O
    }

    private BaseSwipeUpHandler createWindowTransformSwipeHandler(GestureState gestureState,
            RunningTaskInfo runningTask, long touchTimeMs, boolean continuingLastGesture,
            boolean isLikelyToStartNewTask) {
            long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) {
        return  new WindowTransformSwipeHandler(this, mDeviceState, mTaskAnimationManager,
                gestureState, runningTask, touchTimeMs, mOverviewComponentObserver,
                continuingLastGesture, mInputConsumer, mRecentsModel);
                gestureState, touchTimeMs, mOverviewComponentObserver, continuingLastGesture,
                mInputConsumer, mRecentsModel);
    }

    private BaseSwipeUpHandler createFallbackNoButtonSwipeHandler(GestureState gestureState,
            RunningTaskInfo runningTask, long touchTimeMs, boolean continuingLastGesture,
            boolean isLikelyToStartNewTask) {
            long touchTimeMs, boolean continuingLastGesture, boolean isLikelyToStartNewTask) {
        return new FallbackNoButtonInputConsumer(this, mDeviceState, gestureState,
                mOverviewComponentObserver, runningTask, mRecentsModel, mInputConsumer,
                isLikelyToStartNewTask, continuingLastGesture);
                mOverviewComponentObserver, mRecentsModel, mInputConsumer, isLikelyToStartNewTask,
                continuingLastGesture);
    }

    protected boolean shouldNotifyBackGesture() {
+20 −17
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.animation.AnimatorSet;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
import android.content.Intent;
import android.graphics.PointF;
@@ -192,11 +191,11 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

    public WindowTransformSwipeHandler(Context context, RecentsAnimationDeviceState deviceState,
            TaskAnimationManager taskAnimationManager, GestureState gestureState,
            RunningTaskInfo runningTaskInfo, long touchTimeMs,
            OverviewComponentObserver overviewComponentObserver, boolean continuingLastGesture,
            InputConsumerController inputConsumer, RecentsModel recentsModel) {
            long touchTimeMs, OverviewComponentObserver overviewComponentObserver,
            boolean continuingLastGesture, InputConsumerController inputConsumer,
            RecentsModel recentsModel) {
        super(context, deviceState, gestureState, overviewComponentObserver, recentsModel,
                inputConsumer, runningTaskInfo.id);
                inputConsumer);
        mTaskAnimationManager = taskAnimationManager;
        mTouchTimeMs = touchTimeMs;
        mContinuingLastGesture = continuingLastGesture;
@@ -290,9 +289,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>

        mStateCallback.setState(STATE_LAUNCHER_PRESENT);
        if (alreadyOnHome) {
            onLauncherStart(activity);
            onLauncherStart();
        } else {
            activity.setOnStartCallback(this::onLauncherStart);
            activity.runOnceOnStart(this::onLauncherStart);
        }

        setupRecentsViewUi();
@@ -304,7 +303,8 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
        return mGestureState.getEndTarget() != HOME;
    }

    private void onLauncherStart(final T activity) {
    private void onLauncherStart() {
        final T activity = mActivityInterface.getCreatedActivity();
        if (mActivity != activity) {
            return;
        }
@@ -393,7 +393,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
            updateSysUiFlags(mCurrentShift.value);
            return;
        }
        mRecentsView.onGestureAnimationStart(mRunningTaskId);
        mRecentsView.onGestureAnimationStart(mGestureState.getRunningTaskId());
    }

    private void launcherFrameDrawn() {
@@ -442,9 +442,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
        if (!mDeviceState.isFullyGesturalNavMode() || mRecentsView == null) {
            return;
        }
        RemoteAnimationTargetCompat runningTaskTarget = mRecentsAnimationTargets == null
                ? null
                : mRecentsAnimationTargets.findTask(mRunningTaskId);
        RemoteAnimationTargetCompat runningTaskTarget = mRecentsAnimationTargets != null
                ? mRecentsAnimationTargets.findTask(mGestureState.getRunningTaskId())
                : null;
        final boolean recentsAttachedToAppWindow;
        if (mGestureState.getEndTarget() != null) {
            recentsAttachedToAppWindow = mGestureState.getEndTarget().recentsAttachedToAppWindow;
@@ -1005,7 +1005,9 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
    @Override
    public void onConsumerAboutToBeSwitched() {
        if (mActivity != null) {
            mActivity.setOnStartCallback(null);
            // In the off chance that the gesture ends before Launcher is started, we should clear
            // the callback here so that it doesn't update with the wrong state
            mActivity.clearRunOnceOnStartCallback();
        }
        if (mGestureState.getEndTarget() != null && !mGestureState.isRunningAnimationToLauncher()) {
            cancelCurrentAnimation();
@@ -1114,13 +1116,14 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
    }

    private void switchToScreenshot() {
        final int runningTaskId = mGestureState.getRunningTaskId();
        if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
            if (mRecentsAnimationController != null) {
                // Update the screenshot of the task
                if (mTaskSnapshot == null) {
                    mTaskSnapshot = mRecentsAnimationController.screenshotTask(mRunningTaskId);
                    mTaskSnapshot = mRecentsAnimationController.screenshotTask(runningTaskId);
                }
                mRecentsView.updateThumbnail(mRunningTaskId, mTaskSnapshot, false /* refreshNow */);
                mRecentsView.updateThumbnail(runningTaskId, mTaskSnapshot, false /* refreshNow */);
            }
            mStateCallback.setStateOnUiThread(STATE_SCREENSHOT_CAPTURED);
        } else if (!hasTargets()) {
@@ -1131,7 +1134,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
            if (mRecentsAnimationController != null) {
                // Update the screenshot of the task
                if (mTaskSnapshot == null) {
                    mTaskSnapshot = mRecentsAnimationController.screenshotTask(mRunningTaskId);
                    mTaskSnapshot = mRecentsAnimationController.screenshotTask(runningTaskId);
                }
                final TaskView taskView;
                if (mGestureState.getEndTarget() == HOME) {
@@ -1139,7 +1142,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity>
                    // taken in the correct orientation, but no need to update the thumbnail.
                    taskView = null;
                } else {
                    taskView = mRecentsView.updateThumbnail(mRunningTaskId, mTaskSnapshot);
                    taskView = mRecentsView.updateThumbnail(runningTaskId, mTaskSnapshot);
                }
                if (taskView != null && !mCanceled) {
                    // Defer finishing the animation until the next launcher frame with the
+3 −4
Original line number Diff line number Diff line
@@ -85,7 +85,6 @@ public class DeviceLockedInputConsumer implements InputConsumer,
    private final AppWindowAnimationHelper.TransformParams mTransformParams;
    private final Point mDisplaySize;
    private final MultiStateCallback mStateCallback;
    public final int mRunningTaskId;

    private VelocityTracker mVelocityTracker;
    private float mProgress;
@@ -97,7 +96,7 @@ public class DeviceLockedInputConsumer implements InputConsumer,

    public DeviceLockedInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
            TaskAnimationManager taskAnimationManager, GestureState gestureState,
            InputMonitorCompat inputMonitorCompat, int runningTaskId) {
            InputMonitorCompat inputMonitorCompat) {
        mContext = context;
        mDeviceState = deviceState;
        mTaskAnimationManager = taskAnimationManager;
@@ -106,7 +105,6 @@ public class DeviceLockedInputConsumer implements InputConsumer,
        mAppWindowAnimationHelper = new AppWindowAnimationHelper(context);
        mTransformParams = new AppWindowAnimationHelper.TransformParams();
        mInputMonitorCompat = inputMonitorCompat;
        mRunningTaskId = runningTaskId;

        // Do not use DeviceProfile as the user data might be locked
        mDisplaySize = DefaultDisplay.INSTANCE.get(context).getInfo().realSize;
@@ -221,7 +219,8 @@ public class DeviceLockedInputConsumer implements InputConsumer,
        mRecentsAnimationTargets = targets;

        Rect displaySize = new Rect(0, 0, mDisplaySize.x, mDisplaySize.y);
        RemoteAnimationTargetCompat targetCompat = targets.findTask(mRunningTaskId);
        RemoteAnimationTargetCompat targetCompat = targets.findTask(
                mGestureState.getRunningTaskId());
        if (targetCompat != null) {
            mAppWindowAnimationHelper.updateSource(displaySize, targetCompat);
        }
+8 −12
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHO

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityOptions;
import android.content.Context;
import android.content.Intent;
@@ -108,24 +107,20 @@ public class FallbackNoButtonInputConsumer extends
    private final boolean mRunningOverHome;
    private final boolean mSwipeUpOverHome;

    private final RunningTaskInfo mRunningTaskInfo;

    private final PointF mEndVelocityPxPerMs = new PointF(0, 0.5f);
    private RunningWindowAnim mFinishAnimation;

    public FallbackNoButtonInputConsumer(Context context, RecentsAnimationDeviceState deviceState,
            GestureState gestureState, OverviewComponentObserver overviewComponentObserver,
            RunningTaskInfo runningTaskInfo, RecentsModel recentsModel,
            InputConsumerController inputConsumer,
            RecentsModel recentsModel, InputConsumerController inputConsumer,
            boolean isLikelyToStartNewTask, boolean continuingLastGesture) {
        super(context, deviceState, gestureState, overviewComponentObserver, recentsModel,
                inputConsumer, runningTaskInfo.id);
                inputConsumer);
        mLauncherAlpha.value = 1;

        mRunningTaskInfo = runningTaskInfo;
        mInQuickSwitchMode = isLikelyToStartNewTask || continuingLastGesture;
        mContinuingLastGesture = continuingLastGesture;
        mRunningOverHome = ActivityManagerWrapper.isHomeTask(runningTaskInfo);
        mRunningOverHome = ActivityManagerWrapper.isHomeTask(mGestureState.getRunningTask());
        mSwipeUpOverHome = mRunningOverHome && !mInQuickSwitchMode;

        if (mSwipeUpOverHome) {
@@ -182,9 +177,9 @@ public class FallbackNoButtonInputConsumer extends

        if (!mContinuingLastGesture) {
            if (mRunningOverHome) {
                mRecentsView.onGestureAnimationStart(mRunningTaskInfo);
                mRecentsView.onGestureAnimationStart(mGestureState.getRunningTask());
            } else {
                mRecentsView.onGestureAnimationStart(mRunningTaskId);
                mRecentsView.onGestureAnimationStart(mGestureState.getRunningTaskId());
            }
        }
        mStateCallback.setStateOnUiThread(STATE_RECENTS_PRESENT);
@@ -344,7 +339,8 @@ public class FallbackNoButtonInputConsumer extends
                    break;
                }

                ThumbnailData thumbnail = mRecentsAnimationController.screenshotTask(mRunningTaskId);
                final int runningTaskId = mGestureState.getRunningTaskId();
                ThumbnailData thumbnail = mRecentsAnimationController.screenshotTask(runningTaskId);
                mRecentsAnimationController.setDeferCancelUntilNextTransition(true /* defer */,
                        false /* screenshot */);

@@ -353,7 +349,7 @@ public class FallbackNoButtonInputConsumer extends

                Bundle extras = new Bundle();
                extras.putBinder(EXTRA_THUMBNAIL, new ObjectWrapper<>(thumbnail));
                extras.putInt(EXTRA_TASK_ID, mRunningTaskId);
                extras.putInt(EXTRA_TASK_ID, runningTaskId);

                Intent intent = new Intent(mOverviewComponentObserver.getOverviewIntent())
                        .putExtras(extras);
Loading