Search in sources :

Example 56 with RecentsTaskLoader

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

the class RecentsActivity method reloadStackView.

/**
     * Reloads the stack views upon launching Recents.
     */
private void reloadStackView() {
    // If the Recents component has preloaded a load plan, then use that to prevent
    // reconstructing the task stack
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan loadPlan = RecentsImpl.consumeInstanceLoadPlan();
    if (loadPlan == null) {
        loadPlan = loader.createLoadPlan(this);
    }
    // Start loading tasks according to the load plan
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    if (!loadPlan.hasTasks()) {
        loader.preloadTasks(loadPlan, launchState.launchedToTaskId, !launchState.launchedFromHome);
    }
    RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
    loadOpts.runningTaskId = launchState.launchedToTaskId;
    loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
    loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails;
    loader.loadTasks(this, loadPlan, loadOpts);
    TaskStack stack = loadPlan.getTaskStack();
    mRecentsView.onReload(mIsVisible, stack.getTaskCount() == 0);
    mRecentsView.updateStack(stack, true);
    // Update the nav bar scrim, but defer the animation until the enter-window event
    boolean animateNavBarScrim = !launchState.launchedViaDockGesture;
    mScrimViews.updateNavBarScrim(animateNavBarScrim, stack.getTaskCount() > 0, null);
    mRecentsView.startFABanimation();
    // If this is a new instance relaunched by AM, without going through the normal mechanisms,
    // then we have to manually trigger the enter animation state
    boolean wasLaunchedByAm = !launchState.launchedFromHome && !launchState.launchedFromApp;
    if (wasLaunchedByAm) {
        EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
    }
    // Keep track of whether we launched from the nav bar button or via alt-tab
    if (launchState.launchedWithAltTab) {
        MetricsLogger.count(this, "overview_trigger_alttab", 1);
    } else {
        MetricsLogger.count(this, "overview_trigger_nav_btn", 1);
    }
    // Keep track of whether we launched from an app or from home
    if (launchState.launchedFromApp) {
        Task launchTarget = stack.getLaunchTarget();
        int launchTaskIndexInStack = launchTarget != null ? stack.indexOfStackTask(launchTarget) : 0;
        MetricsLogger.count(this, "overview_source_app", 1);
        // If from an app, track the stack index of the app in the stack (for affiliated tasks)
        MetricsLogger.histogram(this, "overview_source_app_index", launchTaskIndexInStack);
    } else {
        MetricsLogger.count(this, "overview_source_home", 1);
    }
    // Keep track of the total stack task count
    int taskCount = mRecentsView.getStack().getTaskCount();
    MetricsLogger.histogram(this, "overview_task_count", taskCount);
    setImmersiveRecents();
    // After we have resumed, set the visible state until the next onStop() call
    mIsVisible = true;
}
Also used : EnterRecentsWindowAnimationCompletedEvent(com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent) ActivityOptions(android.app.ActivityOptions) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) AsyncTask(android.os.AsyncTask) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader)

Example 57 with RecentsTaskLoader

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

the class RecentsTvActivity method updateRecentsTasks.

private void updateRecentsTasks() {
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = RecentsImpl.consumeInstanceLoadPlan();
    if (plan == null) {
        plan = loader.createLoadPlan(this);
    }
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    if (!plan.hasTasks()) {
        loader.preloadTasks(plan, -1, !launchState.launchedFromHome);
    }
    int numVisibleTasks = TaskCardView.getNumberOfVisibleTasks(getApplicationContext());
    mLaunchedFromHome = launchState.launchedFromHome;
    TaskStack stack = plan.getTaskStack();
    RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
    loadOpts.runningTaskId = launchState.launchedToTaskId;
    loadOpts.numVisibleTasks = numVisibleTasks;
    loadOpts.numVisibleTaskThumbnails = numVisibleTasks;
    loader.loadTasks(this, plan, loadOpts);
    List stackTasks = stack.getStackTasks();
    Collections.reverse(stackTasks);
    if (mTaskStackViewAdapter == null) {
        mTaskStackViewAdapter = new TaskStackHorizontalViewAdapter(stackTasks);
        mTaskStackHorizontalGridView = mRecentsView.setTaskStackViewAdapter(mTaskStackViewAdapter);
        mHomeRecentsEnterExitAnimationHolder = new HomeRecentsEnterExitAnimationHolder(getApplicationContext(), mTaskStackHorizontalGridView);
    } else {
        mTaskStackViewAdapter.setNewStackTasks(stackTasks);
    }
    mRecentsView.init(stack);
    if (launchState.launchedToTaskId != -1) {
        ArrayList<Task> tasks = stack.getStackTasks();
        int taskCount = tasks.size();
        for (int i = 0; i < taskCount; i++) {
            Task t = tasks.get(i);
            if (t.key.id == launchState.launchedToTaskId) {
                t.isLaunchTarget = true;
                break;
            }
        }
    }
}
Also used : ActivityOptions(android.app.ActivityOptions) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) HomeRecentsEnterExitAnimationHolder(com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder) TaskStack(com.android.systemui.recents.model.TaskStack) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) TaskStackHorizontalViewAdapter(com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter) ArrayList(java.util.ArrayList) List(java.util.List)

Example 58 with RecentsTaskLoader

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

the class RecentsTvActivity method onBusEvent.

public final void onBusEvent(DeleteTaskDataEvent event) {
    // Remove any stored data from the loader
    RecentsTaskLoader loader = Recents.getTaskLoader();
    loader.deleteTaskData(event.task, false);
    // Remove the task from activity manager
    SystemServicesProxy ssp = Recents.getSystemServices();
    ssp.removeTask(event.task.key.id);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader)

Example 59 with RecentsTaskLoader

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

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 60 with RecentsTaskLoader

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

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)

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