Search in sources :

Example 1 with ThumbnailData

use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.

the class AbsSwipeUpHandler method onActivityInit.

protected boolean onActivityInit(Boolean alreadyOnHome) {
    if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) {
        return false;
    }
    T createdActivity = mActivityInterface.getCreatedActivity();
    if (createdActivity != null) {
        initTransitionEndpoints(createdActivity.getDeviceProfile());
    }
    final T activity = mActivityInterface.getCreatedActivity();
    if (mActivity == activity) {
        return true;
    }
    if (mActivity != null) {
        if (mStateCallback.hasStates(STATE_GESTURE_COMPLETED)) {
            // If the activity has restarted between setting the page scroll settling callback
            // and actually receiving the callback, just mark the gesture completed
            mGestureState.setState(STATE_RECENTS_SCROLLING_FINISHED);
            return true;
        }
        // The launcher may have been recreated as a result of device rotation.
        int oldState = mStateCallback.getState() & ~LAUNCHER_UI_STATES;
        initStateCallbacks();
        mStateCallback.setState(oldState);
    }
    mWasLauncherAlreadyVisible = alreadyOnHome;
    mActivity = activity;
    // up, or until we transition home and the home animation is composed
    if (alreadyOnHome) {
        mActivity.clearForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
    } else {
        mActivity.addForceInvisibleFlag(STATE_HANDLER_INVISIBILITY_FLAGS);
    }
    mRecentsView = activity.getOverviewPanel();
    mRecentsView.setOnPageTransitionEndCallback(null);
    mStateCallback.setState(STATE_LAUNCHER_PRESENT);
    if (alreadyOnHome) {
        onLauncherStart();
    } else {
        activity.runOnceOnStart(this::onLauncherStart);
    }
    // Set up a entire animation lifecycle callback to notify the current recents view when
    // the animation is canceled
    mGestureState.runOnceAtState(STATE_RECENTS_ANIMATION_CANCELED, () -> {
        ThumbnailData snapshot = mGestureState.consumeRecentsAnimationCanceledSnapshot();
        if (snapshot != null) {
            mRecentsView.switchToScreenshot(snapshot, () -> {
                if (mRecentsAnimationController != null) {
                    mRecentsAnimationController.cleanupScreenshot();
                }
            });
            mRecentsView.onRecentsAnimationComplete();
        }
    });
    setupRecentsViewUi();
    linkRecentsViewScroll();
    return true;
}
Also used : LAUNCHER_QUICKSWITCH_RIGHT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_RIGHT) STATE_END_TARGET_SET(com.android.quickstep.GestureState.STATE_END_TARGET_SET) LAUNCHER_QUICKSWITCH_LEFT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_LEFT) LENGTH_SHORT(android.widget.Toast.LENGTH_SHORT) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData)

Example 2 with ThumbnailData

use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.

the class OverviewCommandHelper method executeCommand.

/**
 * Executes the task and returns true if next task can be executed. If false, then the next
 * task is deferred until {@link #scheduleNextTask} is called
 */
private <T extends StatefulActivity<?>> boolean executeCommand(CommandInfo cmd) {
    BaseActivityInterface<?, T> activityInterface = mOverviewComponentObserver.getActivityInterface();
    RecentsView recents = activityInterface.getVisibleRecentsView();
    if (recents == null) {
        if (cmd.type == TYPE_HIDE) {
            // already hidden
            return true;
        }
    } else {
        switch(cmd.type) {
            case TYPE_SHOW:
                // already visible
                return true;
            case TYPE_HIDE:
                {
                    int currentPage = recents.getNextPage();
                    TaskView tv = (currentPage >= 0 && currentPage < recents.getTaskViewCount()) ? (TaskView) recents.getPageAt(currentPage) : null;
                    return launchTask(recents, tv, cmd);
                }
            case TYPE_TOGGLE:
                return launchTask(recents, getNextTask(recents), cmd);
        }
    }
    if (activityInterface.switchToRecentsIfVisible(() -> scheduleNextTask(cmd))) {
        // If successfully switched, wait until animation finishes
        return false;
    }
    final T activity = activityInterface.getCreatedActivity();
    if (activity != null) {
        InteractionJankMonitorWrapper.begin(activity.getRootView(), InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH);
    }
    GestureState gestureState = mService.createGestureState(GestureState.DEFAULT_STATE);
    gestureState.setHandlingAtomicEvent(true);
    AbsSwipeUpHandler interactionHandler = mService.getSwipeUpHandlerFactory().newHandler(gestureState, cmd.createTime);
    interactionHandler.setGestureEndCallback(() -> onTransitionComplete(cmd, interactionHandler));
    interactionHandler.initWhenReady();
    RecentsAnimationListener recentAnimListener = new RecentsAnimationListener() {

        @Override
        public void onRecentsAnimationStart(RecentsAnimationController controller, RecentsAnimationTargets targets) {
            interactionHandler.onGestureEnded(0, new PointF(), new PointF());
            cmd.removeListener(this);
        }

        @Override
        public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
            interactionHandler.onGestureCancelled();
            cmd.removeListener(this);
            RecentsView createdRecents = activityInterface.getCreatedActivity().getOverviewPanel();
            if (createdRecents != null) {
                createdRecents.onRecentsAnimationComplete();
            }
        }
    };
    if (mTaskAnimationManager.isRecentsAnimationRunning()) {
        cmd.mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(gestureState);
        cmd.mActiveCallbacks.addListener(interactionHandler);
        mTaskAnimationManager.notifyRecentsAnimationState(interactionHandler);
        interactionHandler.onGestureStarted(true);
        cmd.mActiveCallbacks.addListener(recentAnimListener);
        mTaskAnimationManager.notifyRecentsAnimationState(recentAnimListener);
    } else {
        Intent intent = new Intent(interactionHandler.getLaunchIntent());
        intent.putExtra(INTENT_EXTRA_LOG_TRACE_ID, gestureState.getGestureId());
        cmd.mActiveCallbacks = mTaskAnimationManager.startRecentsAnimation(gestureState, intent, interactionHandler);
        interactionHandler.onGestureStarted(false);
        cmd.mActiveCallbacks.addListener(recentAnimListener);
    }
    Trace.beginAsyncSection(TRANSITION_NAME, 0);
    return false;
}
Also used : TaskView(com.android.quickstep.views.TaskView) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData) PointF(android.graphics.PointF) RecentsView(com.android.quickstep.views.RecentsView) Intent(android.content.Intent) RecentsAnimationListener(com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener)

Example 3 with ThumbnailData

use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskThumbnailCache method updateThumbnailInBackground.

private CancellableTask updateThumbnailInBackground(TaskKey key, boolean lowResolution, Consumer<ThumbnailData> callback) {
    Preconditions.assertUIThread();
    ThumbnailData cachedThumbnail = mCache.getAndInvalidateIfModified(key);
    if (cachedThumbnail != null && (!cachedThumbnail.reducedResolution || lowResolution)) {
        // Already cached, lets use that thumbnail
        callback.accept(cachedThumbnail);
        return null;
    }
    CancellableTask<ThumbnailData> request = new CancellableTask<ThumbnailData>() {

        @Override
        public ThumbnailData getResultOnBg() {
            return ActivityManagerWrapper.getInstance().getTaskThumbnail(key.id, lowResolution);
        }

        @Override
        public void handleResult(ThumbnailData result) {
            mCache.put(key, result);
            callback.accept(result);
        }
    };
    mBgExecutor.execute(request);
    return request;
}
Also used : CancellableTask(com.android.quickstep.util.CancellableTask) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData)

Example 4 with ThumbnailData

use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskAnimationManager method startRecentsAnimation.

/**
 * Starts a new recents animation for the activity with the given {@param intent}.
 */
@UiThread
public RecentsAnimationCallbacks startRecentsAnimation(GestureState gestureState, Intent intent, RecentsAnimationCallbacks.RecentsAnimationListener listener) {
    // Notify if recents animation is still running
    if (mController != null) {
        String msg = "New recents animation started before old animation completed";
        if (FeatureFlags.IS_STUDIO_BUILD) {
            throw new IllegalArgumentException(msg);
        } else {
            Log.e("TaskAnimationManager", msg, new Exception());
        }
    }
    // But force-finish it anyways
    finishRunningRecentsAnimation(false);
    final BaseActivityInterface activityInterface = gestureState.getActivityInterface();
    mLastGestureState = gestureState;
    mCallbacks = new RecentsAnimationCallbacks(activityInterface.allowMinimizeSplitScreen());
    mCallbacks.addListener(new RecentsAnimationCallbacks.RecentsAnimationListener() {

        @Override
        public void onRecentsAnimationStart(RecentsAnimationController controller, RecentsAnimationTargets targets) {
            if (mCallbacks == null) {
                // handling this call entirely
                return;
            }
            mController = controller;
            mTargets = targets;
            mLastAppearedTaskTarget = mTargets.findTask(mLastGestureState.getRunningTaskId());
            mLastGestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
        }

        @Override
        public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
            cleanUpRecentsAnimation();
        }

        @Override
        public void onRecentsAnimationFinished(RecentsAnimationController controller) {
            cleanUpRecentsAnimation();
        }

        @Override
        public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
            BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface();
            if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode() && activityInterface.getCreatedActivity() != null) {
                RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel();
                if (recentsView != null) {
                    RemoteAnimationTargetCompat[] apps = new RemoteAnimationTargetCompat[1];
                    apps[0] = appearedTaskTarget;
                    recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId, apps, new RemoteAnimationTargetCompat[0], /* wallpaper */
                    new RemoteAnimationTargetCompat[0]);
                    return;
                }
            }
            if (mController != null) {
                if (mLastAppearedTaskTarget == null || appearedTaskTarget.taskId != mLastAppearedTaskTarget.taskId) {
                    if (mLastAppearedTaskTarget != null) {
                        mController.removeTaskTarget(mLastAppearedTaskTarget);
                    }
                    mLastAppearedTaskTarget = appearedTaskTarget;
                    mLastGestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
                }
            }
        }
    });
    final long eventTime = gestureState.getSwipeUpStartTimeMs();
    mCallbacks.addListener(gestureState);
    mCallbacks.addListener(listener);
    if (ENABLE_SHELL_TRANSITIONS) {
        RemoteTransitionCompat transition = new RemoteTransitionCompat(mCallbacks, mController != null ? mController.getController() : null);
        Bundle options = ActivityOptionsCompat.makeRemoteTransition(transition).setTransientLaunch().toBundle();
        mCtx.startActivity(intent, options);
    } else {
        UI_HELPER_EXECUTOR.execute(() -> ActivityManagerWrapper.getInstance().startRecentsActivity(intent, eventTime, mCallbacks, null, null));
    }
    gestureState.setState(STATE_RECENTS_ANIMATION_INITIALIZED);
    return mCallbacks;
}
Also used : Bundle(android.os.Bundle) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData) RecentsView(com.android.quickstep.views.RecentsView) RemoteTransitionCompat(com.android.systemui.shared.system.RemoteTransitionCompat) UiThread(androidx.annotation.UiThread)

Example 5 with ThumbnailData

use of com.android.systemui.shared.recents.model.ThumbnailData in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsActivityTest method testRecents_showCurrentTask.

@Test
public void testRecents_showCurrentTask() {
    ActivityController<RecentsActivity> controller = Robolectric.buildActivity(RecentsActivity.class);
    RecentsActivity activity = controller.setup().get();
    doLayout(activity);
    FallbackRecentsView frv = activity.getOverviewPanel();
    RunningTaskInfo placeholderTask = new RunningTaskInfo();
    placeholderTask.taskId = 22;
    frv.showCurrentTask(placeholderTask);
    doLayout(activity);
    ThumbnailData thumbnailData = new ThumbnailData();
    ReflectionHelpers.setField(thumbnailData, "thumbnail", Bitmap.createBitmap(300, 500, Config.ARGB_8888));
    frv.switchToScreenshot(thumbnailData, () -> {
    });
    ShadowLooper.idleMainLooper();
}
Also used : FallbackRecentsView(com.android.quickstep.fallback.FallbackRecentsView) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData) RunningTaskInfo(android.app.ActivityManager.RunningTaskInfo) Test(org.junit.Test)

Aggregations

ThumbnailData (com.android.systemui.shared.recents.model.ThumbnailData)7 RecentsView (com.android.quickstep.views.RecentsView)2 RunningTaskInfo (android.app.ActivityManager.RunningTaskInfo)1 Intent (android.content.Intent)1 PointF (android.graphics.PointF)1 Bundle (android.os.Bundle)1 LENGTH_SHORT (android.widget.Toast.LENGTH_SHORT)1 UiThread (androidx.annotation.UiThread)1 LAUNCHER_QUICKSWITCH_LEFT (com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_LEFT)1 LAUNCHER_QUICKSWITCH_RIGHT (com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_RIGHT)1 STATE_END_TARGET_SET (com.android.quickstep.GestureState.STATE_END_TARGET_SET)1 RecentsAnimationListener (com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener)1 FallbackRecentsView (com.android.quickstep.fallback.FallbackRecentsView)1 CancellableTask (com.android.quickstep.util.CancellableTask)1 TaskView (com.android.quickstep.views.TaskView)1 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)1 RemoteTransitionCompat (com.android.systemui.shared.system.RemoteTransitionCompat)1 Test (org.junit.Test)1