Search in sources :

Example 1 with RecentsTaskLoader

use of com.android.systemui.recents.model.RecentsTaskLoader in project platform_frameworks_base by android.

the class RecentsTvImpl method startRecentsActivity.

@Override
protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask, boolean isHomeStackVisible, boolean animate, int growTarget) {
    RecentsTaskLoader loader = Recents.getTaskLoader();
    // the stacks might have changed.
    if (mTriggeredFromAltTab || sInstanceLoadPlan == null) {
        // Create a new load plan if preloadRecents() was never triggered
        sInstanceLoadPlan = loader.createLoadPlan(mContext);
    }
    if (mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
        loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible);
    }
    TaskStack stack = sInstanceLoadPlan.getTaskStack();
    if (!animate) {
        ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, -1, -1);
        startRecentsActivity(runningTask, opts, false, /* fromHome */
        false);
        return;
    }
    boolean hasRecentTasks = stack.getTaskCount() > 0;
    boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks;
    if (useThumbnailTransition) {
        // Try starting with a thumbnail transition
        ActivityOptions opts = getThumbnailTransitionActivityOptionsForTV(runningTask, stack.getTaskCount());
        if (opts != null) {
            startRecentsActivity(runningTask, opts, false, /* fromHome */
            true);
        } else {
            // Fall through below to the non-thumbnail transition
            useThumbnailTransition = false;
        }
    }
    if (!useThumbnailTransition) {
        startRecentsActivity(runningTask, null, true, /* fromHome */
        false);
    }
    mLastToggleTime = SystemClock.elapsedRealtime();
}
Also used : TaskStack(com.android.systemui.recents.model.TaskStack) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) ActivityOptions(android.app.ActivityOptions)

Example 2 with RecentsTaskLoader

use of com.android.systemui.recents.model.RecentsTaskLoader in project platform_frameworks_base by android.

the class RecentsImpl method onBootCompleted.

public void onBootCompleted() {
    // When we start, preload the data associated with the previous recent tasks.
    // We can use a new plan since the caches will be the same.
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
    loader.preloadTasks(plan, -1, false);
    RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
    launchOpts.numVisibleTasks = loader.getIconCacheSize();
    launchOpts.numVisibleTaskThumbnails = loader.getThumbnailCacheSize();
    launchOpts.onlyLoadForCache = true;
    loader.loadTasks(mContext, plan, launchOpts);
}
Also used : ActivityOptions(android.app.ActivityOptions) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader)

Example 3 with RecentsTaskLoader

use of com.android.systemui.recents.model.RecentsTaskLoader in project platform_frameworks_base by android.

the class RecentsImpl method startRecentsActivity.

/**
     * Shows the recents activity
     */
protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask, boolean isHomeStackVisible, boolean animate, int growTarget) {
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
    SystemServicesProxy ssp = Recents.getSystemServices();
    boolean isBlacklisted = (runningTask != null) ? ssp.isBlackListedActivity(runningTask.baseActivity.getClassName()) : false;
    int runningTaskId = !mLaunchedWhileDocking && !isBlacklisted && (runningTask != null) ? runningTask.id : -1;
    // the stacks might have changed.
    if (mLaunchedWhileDocking || mTriggeredFromAltTab || sInstanceLoadPlan == null) {
        // Create a new load plan if preloadRecents() was never triggered
        sInstanceLoadPlan = loader.createLoadPlan(mContext);
    }
    if (mLaunchedWhileDocking || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
        loader.preloadTasks(sInstanceLoadPlan, runningTaskId, !isHomeStackVisible);
    }
    TaskStack stack = sInstanceLoadPlan.getTaskStack();
    boolean hasRecentTasks = stack.getTaskCount() > 0;
    boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks;
    // Update the launch state that we need in updateHeaderBarLayout()
    launchState.launchedFromHome = !useThumbnailTransition && !mLaunchedWhileDocking;
    launchState.launchedFromApp = useThumbnailTransition || mLaunchedWhileDocking;
    launchState.launchedFromBlacklistedApp = launchState.launchedFromApp && isBlacklisted;
    launchState.launchedViaDockGesture = mLaunchedWhileDocking;
    launchState.launchedViaDragGesture = mDraggingInRecents;
    launchState.launchedToTaskId = runningTaskId;
    launchState.launchedWithAltTab = mTriggeredFromAltTab;
    // Preload the icon (this will be a null-op if we have preloaded the icon already in
    // preloadRecents())
    preloadIcon(runningTaskId);
    // Update the header bar if necessary
    Rect windowOverrideRect = getWindowRectOverride(growTarget);
    updateHeaderBarLayout(stack, windowOverrideRect);
    // Prepare the dummy stack for the transition
    TaskStackLayoutAlgorithm.VisibilityReport stackVr = mDummyStackView.computeStackVisibilityReport();
    // Update the remaining launch state
    launchState.launchedNumVisibleTasks = stackVr.numVisibleTasks;
    launchState.launchedNumVisibleThumbnails = stackVr.numVisibleThumbnails;
    if (!animate) {
        startRecentsActivity(ActivityOptions.makeCustomAnimation(mContext, -1, -1));
        return;
    }
    ActivityOptions opts;
    if (isBlacklisted) {
        opts = getUnknownTransitionActivityOptions();
    } else if (useThumbnailTransition) {
        // Try starting with a thumbnail transition
        opts = getThumbnailTransitionActivityOptions(runningTask, mDummyStackView, windowOverrideRect);
    } else {
        // If there is no thumbnail transition, but is launching from home into recents, then
        // use a quick home transition
        opts = hasRecentTasks ? getHomeTransitionActivityOptions() : getUnknownTransitionActivityOptions();
    }
    startRecentsActivity(opts);
    mLastToggleTime = SystemClock.elapsedRealtime();
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) Rect(android.graphics.Rect) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) TaskStackLayoutAlgorithm(com.android.systemui.recents.views.TaskStackLayoutAlgorithm) ActivityOptions(android.app.ActivityOptions)

Example 4 with RecentsTaskLoader

use of com.android.systemui.recents.model.RecentsTaskLoader in project platform_frameworks_base by android.

the class RecentsActivity method onMultiWindowModeChanged.

@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    super.onMultiWindowModeChanged(isInMultiWindowMode);
    // Reload the task stack completely
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this);
    loader.preloadTasks(loadPlan, -1, /* runningTaskId */
    false);
    RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
    loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
    loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails;
    loader.loadTasks(this, loadPlan, loadOpts);
    TaskStack stack = loadPlan.getTaskStack();
    int numStackTasks = stack.getStackTaskCount();
    boolean showDeferredAnimation = numStackTasks > 0;
    EventBus.getDefault().send(new ConfigurationChangedEvent(true, /* fromMultiWindow */
    false, /* fromDeviceOrientationChange */
    false, /* fromDisplayDensityChange */
    numStackTasks > 0));
    EventBus.getDefault().send(new MultiWindowStateChangedEvent(isInMultiWindowMode, showDeferredAnimation, stack));
}
Also used : ActivityOptions(android.app.ActivityOptions) ConfigurationChangedEvent(com.android.systemui.recents.events.activity.ConfigurationChangedEvent) TaskStack(com.android.systemui.recents.model.TaskStack) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) MultiWindowStateChangedEvent(com.android.systemui.recents.events.activity.MultiWindowStateChangedEvent)

Example 5 with RecentsTaskLoader

use of com.android.systemui.recents.model.RecentsTaskLoader in project platform_frameworks_base by android.

the class RecentsImpl method showRelativeAffiliatedTask.

/**
     * Transitions to the next affiliated task.
     */
public void showRelativeAffiliatedTask(boolean showNextTask) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
    loader.preloadTasks(plan, -1, false);
    TaskStack focusedStack = plan.getTaskStack();
    // Return early if there are no tasks in the focused stack
    if (focusedStack == null || focusedStack.getTaskCount() == 0)
        return;
    // Return early if there is no running task (can't determine affiliated tasks in this case)
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    if (runningTask == null)
        return;
    // Return early if the running task is in the home stack (optimization)
    if (SystemServicesProxy.isHomeStack(runningTask.stackId))
        return;
    // Find the task in the recents list
    ArrayList<Task> tasks = focusedStack.getStackTasks();
    Task toTask = null;
    ActivityOptions launchOpts = null;
    int taskCount = tasks.size();
    int numAffiliatedTasks = 0;
    for (int i = 0; i < taskCount; i++) {
        Task task = tasks.get(i);
        if (task.key.id == runningTask.id) {
            TaskGrouping group = task.group;
            Task.TaskKey toTaskKey;
            if (showNextTask) {
                toTaskKey = group.getNextTaskInGroup(task);
                launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_launch_next_affiliated_task_source);
            } else {
                toTaskKey = group.getPrevTaskInGroup(task);
                launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_target, R.anim.recents_launch_prev_affiliated_task_source);
            }
            if (toTaskKey != null) {
                toTask = focusedStack.findTaskWithId(toTaskKey.id);
            }
            numAffiliatedTasks = group.getTaskCount();
            break;
        }
    }
    // Return early if there is no next task
    if (toTask == null) {
        if (numAffiliatedTasks > 1) {
            if (showNextTask) {
                ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_next_affiliated_task_bounce));
            } else {
                ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_bounce));
            }
        }
        return;
    }
    // Keep track of actually launched affiliated tasks
    MetricsLogger.count(mContext, "overview_affiliated_task_launch", 1);
    // Launch the task
    ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) TaskGrouping(com.android.systemui.recents.model.TaskGrouping) ActivityManager(android.app.ActivityManager) ActivityOptions(android.app.ActivityOptions)

Aggregations

RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)60 ActivityOptions (android.app.ActivityOptions)40 TaskStack (com.android.systemui.recents.model.TaskStack)40 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)30 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)30 Task (com.android.systemui.recents.model.Task)20 ActivityManager (android.app.ActivityManager)15 UiModeManager (android.app.UiModeManager)5 Point (android.graphics.Point)5 Rect (android.graphics.Rect)5 Handler (android.os.Handler)5 MutableBoolean (android.util.MutableBoolean)5 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)5 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)5 ConfigurationChangedEvent (com.android.systemui.recents.events.activity.ConfigurationChangedEvent)5 EnterRecentsWindowAnimationCompletedEvent (com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent)5 MultiWindowStateChangedEvent (com.android.systemui.recents.events.activity.MultiWindowStateChangedEvent)5 TaskGrouping (com.android.systemui.recents.model.TaskGrouping)5 RecentsTvImpl (com.android.systemui.recents.tv.RecentsTvImpl)5 HomeRecentsEnterExitAnimationHolder (com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder)5