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

Commit c7bf4833 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role)
Browse files

[automerger] Various quickscrub fixes am: 9bb8ffb5

Change-Id: Id9f1cb83795b3164dd8bc67c879a3b3d8b8fd91f
parents 8ccf581d 9bb8ffb5
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherInitListener;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.allapps.DiscoveryBounce;
import com.android.launcher3.anim.AnimatorPlaybackController;
@@ -82,7 +83,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
    void onQuickInteractionStart(T activity, @Nullable RunningTaskInfo taskInfo,
            boolean activityVisible);

    float getTranslationYForQuickScrub(T activity);
    float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp,
            Context context);

    void executeOnWindowAvailable(T activity, Runnable action);

@@ -151,10 +153,15 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
        }

        @Override
        public float getTranslationYForQuickScrub(Launcher activity) {
            LauncherRecentsView recentsView = activity.getOverviewPanel();
            return recentsView.computeTranslationYForFactor(
                    FastOverviewState.OVERVIEW_TRANSLATION_FACTOR);
        public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp,
                Context context) {
            // The padding calculations are exactly same as that of RecentsView.setInsets
            int topMargin = context.getResources()
                    .getDimensionPixelSize(R.dimen.task_thumbnail_top_margin);
            int paddingTop = targetRect.rect.top - topMargin - dp.getInsets().top;
            int paddingBottom = dp.availableHeightPx + dp.getInsets().top - targetRect.rect.bottom;

            return FastOverviewState.OVERVIEW_TRANSLATION_FACTOR * (paddingBottom - paddingTop);
        }

        @Override
@@ -380,7 +387,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
        }

        @Override
        public float getTranslationYForQuickScrub(RecentsActivity activity) {
        public float getTranslationYForQuickScrub(TransformedRect targetRect, DeviceProfile dp,
                Context context) {
            return 0;
        }

+15 −0
Original line number Diff line number Diff line
@@ -63,6 +63,16 @@ public class DeferredTouchConsumer implements TouchConsumer {
        mTarget.onQuickScrubProgress(progress);
    }

    @Override
    public void onQuickStep(MotionEvent ev) {
        mTarget.onQuickStep(ev);
    }

    @Override
    public void onCommand(int command) {
        mTarget.onCommand(command);
    }

    @Override
    public void preProcessMotionEvent(MotionEvent ev) {
        mVelocityTracker.addMovement(ev);
@@ -92,6 +102,11 @@ public class DeferredTouchConsumer implements TouchConsumer {
        return target == null ? true : target.deferNextEventToMainThread();
    }

    @Override
    public void onShowOverviewFromAltTab() {
        mTarget.onShowOverviewFromAltTab();
    }

    public interface DeferredTouchProvider {

        TouchConsumer createTouchConsumer(VelocityTracker tracker);
+11 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ public class MotionEventQueue {
            ACTION_VIRTUAL | (6 << ACTION_POINTER_INDEX_SHIFT);
    private static final int ACTION_QUICK_STEP =
            ACTION_VIRTUAL | (7 << ACTION_POINTER_INDEX_SHIFT);
    private static final int ACTION_COMMAND =
            ACTION_VIRTUAL | (8 << ACTION_POINTER_INDEX_SHIFT);

    private final EventArray mEmptyArray = new EventArray();
    private final Object mExecutionLock = new Object();
@@ -165,6 +167,9 @@ public class MotionEventQueue {
                        case ACTION_QUICK_STEP:
                            mConsumer.onQuickStep(event);
                            break;
                        case ACTION_COMMAND:
                            mConsumer.onCommand(event.getSource());
                            break;
                        default:
                            Log.e(TAG, "Invalid virtual event: " + event.getAction());
                    }
@@ -222,6 +227,12 @@ public class MotionEventQueue {
        queueVirtualAction(ACTION_DEFER_INIT, 0);
    }

    public void onCommand(int command) {
        MotionEvent ev = MotionEvent.obtain(0, 0, ACTION_COMMAND, 0, 0, 0);
        ev.setSource(command);
        queueNoPreProcess(ev);
    }

    public TouchConsumer getConsumer() {
        return mConsumer;
    }
+64 −26
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.os.SystemClock;
import android.util.SparseArray;
import android.view.Choreographer;
import android.view.Display;
import android.view.MotionEvent;
@@ -69,6 +70,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC

    private static final long LAUNCHER_DRAW_TIMEOUT_MS = 150;

    private final SparseArray<RecentsAnimationState> mAnimationStates = new SparseArray<>();
    private final RunningTaskInfo mRunningTask;
    private final RecentsModel mRecentsModel;
    private final Intent mHomeIntent;
@@ -212,8 +214,9 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC

    private void startTouchTrackingForWindowAnimation(long touchTimeMs) {
        // Create the shared handler
        RecentsAnimationState animationState = new RecentsAnimationState();
        final WindowTransformSwipeHandler handler = new WindowTransformSwipeHandler(
                mRunningTask, this, touchTimeMs, mActivityControlHelper);
                animationState.id, mRunningTask, this, touchTimeMs, mActivityControlHelper);

        // Preload the plan
        mRecentsModel.loadTasks(mRunningTask.id, null);
@@ -237,31 +240,7 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
                    public void onHandleAssistData(Bundle bundle) {
                        mRecentsModel.preloadAssistData(mRunningTask.id, bundle);
                    }
                },
                new RecentsAnimationListener() {
                    public void onAnimationStart(
                            RecentsAnimationControllerCompat controller,
                            RemoteAnimationTargetCompat[] apps, Rect homeContentInsets,
                            Rect minimizedHomeBounds) {
                        if (mInteractionHandler == handler) {
                            TraceHelper.partitionSection("RecentsController", "Received");
                            handler.onRecentsAnimationStart(controller,
                                    new RemoteAnimationTargetSet(apps, MODE_CLOSING),
                                    homeContentInsets, minimizedHomeBounds);
                        } else {
                            TraceHelper.endSection("RecentsController", "Finishing no handler");
                            controller.finish(false /* toHome */);
                        }
                    }

                    public void onAnimationCanceled() {
                        TraceHelper.endSection("RecentsController",
                                "Cancelled: " + mInteractionHandler);
                        if (mInteractionHandler == handler) {
                            handler.onRecentsAnimationCanceled();
                        }
                    }
                }, null, null);
                }, animationState, null, null);

        if (Looper.myLooper() != Looper.getMainLooper()) {
            startActivity.run();
@@ -277,6 +256,14 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
        }
    }

    @Override
    public void onCommand(int command) {
        RecentsAnimationState state = mAnimationStates.get(command);
        if (state != null) {
            state.execute();
        }
    }

    /**
     * Called when the gesture has ended. Does not correlate to the completion of the interaction as
     * the animation can still be running.
@@ -398,4 +385,55 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
        // TODO: Consider also check if the eventQueue is using mainThread of not.
        return mInteractionHandler != null;
    }

    private class RecentsAnimationState implements RecentsAnimationListener {

        private final int id;

        private RecentsAnimationControllerCompat mController;
        private RemoteAnimationTargetSet mTargets;
        private Rect mHomeContentInsets;
        private Rect mMinimizedHomeBounds;
        private boolean mCancelled;

        public RecentsAnimationState() {
            id = mAnimationStates.size();
            mAnimationStates.put(id, this);
        }

        @Override
        public void onAnimationStart(
                RecentsAnimationControllerCompat controller,
                RemoteAnimationTargetCompat[] apps, Rect homeContentInsets,
                Rect minimizedHomeBounds) {
            mController = controller;
            mTargets = new RemoteAnimationTargetSet(apps, MODE_CLOSING);
            mHomeContentInsets = homeContentInsets;
            mMinimizedHomeBounds = minimizedHomeBounds;
            mEventQueue.onCommand(id);
        }

        @Override
        public void onAnimationCanceled() {
            mCancelled = true;
            mEventQueue.onCommand(id);
        }

        public void execute() {
            if (mInteractionHandler == null || mInteractionHandler.id != id) {
                if (!mCancelled && mController != null) {
                    TraceHelper.endSection("RecentsController", "Finishing no handler");
                    mController.finish(false /* toHome */);
                }
            } else if (mCancelled) {
                TraceHelper.endSection("RecentsController",
                        "Cancelled: " + mInteractionHandler);
                mInteractionHandler.onRecentsAnimationCanceled();
            } else {
                TraceHelper.partitionSection("RecentsController", "Received");
                mInteractionHandler.onRecentsAnimationStart(mController, mTargets,
                        mHomeContentInsets, mMinimizedHomeBounds);
            }
        }
    }
}
+21 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;

import java.util.ArrayList;
import java.util.concurrent.ExecutorService;

/**
@@ -27,6 +29,10 @@ import java.util.concurrent.ExecutorService;
 */
public class RecentsAnimationWrapper {

    // A list of callbacks to run when we receive the recents animation target. There are different
    // than the state callbacks as these run on the current worker thread.
    private final ArrayList<Runnable> mCallbacks = new ArrayList<>();

    public RemoteAnimationTargetSet targetSet;

    private RecentsAnimationControllerCompat mController;
@@ -46,6 +52,21 @@ public class RecentsAnimationWrapper {
        if (mInputConsumerEnabled) {
            enableInputConsumer();
        }

        if (!mCallbacks.isEmpty()) {
            for (Runnable action : new ArrayList<>(mCallbacks)) {
                action.run();
            }
            mCallbacks.clear();
        }
    }

    public synchronized void runOnInit(Runnable action) {
        if (targetSet == null) {
            mCallbacks.add(action);
        } else {
            action.run();
        }
    }

    /**
Loading