Search in sources :

Example 31 with RecentsTaskLoader

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

the class Recents method start.

@Override
public void start() {
    sDebugFlags = new RecentsDebugFlags(mContext);
    sSystemServicesProxy = SystemServicesProxy.getInstance(mContext);
    sTaskLoader = new RecentsTaskLoader(mContext);
    sConfiguration = new RecentsConfiguration(mContext);
    mHandler = new Handler();
    UiModeManager uiModeManager = (UiModeManager) mContext.getSystemService(Context.UI_MODE_SERVICE);
    if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
        mImpl = new RecentsTvImpl(mContext);
    } else {
        mImpl = new RecentsImpl(mContext);
    }
    // Check if there is a recents override package
    if ("userdebug".equals(Build.TYPE) || "eng".equals(Build.TYPE)) {
        String cnStr = SystemProperties.get(RECENTS_OVERRIDE_SYSPROP_KEY);
        if (!cnStr.isEmpty()) {
            mOverrideRecentsPackageName = cnStr;
        }
    }
    // Register with the event bus
    EventBus.getDefault().register(this, EVENT_BUS_PRIORITY);
    EventBus.getDefault().register(sSystemServicesProxy, EVENT_BUS_PRIORITY);
    EventBus.getDefault().register(sTaskLoader, EVENT_BUS_PRIORITY);
    // Due to the fact that RecentsActivity is per-user, we need to establish and interface for
    // the system user's Recents component to pass events (like show/hide/toggleRecents) to the
    // secondary user, and vice versa (like visibility change, screen pinning).
    final int processUser = sSystemServicesProxy.getProcessUser();
    if (sSystemServicesProxy.isSystemUser(processUser)) {
        // For the system user, initialize an instance of the interface that we can pass to the
        // secondary user
        mSystemToUserCallbacks = new RecentsSystemUser(mContext, mImpl);
    } else {
        // For the secondary user, bind to the primary user's service to get a persistent
        // interface to register its implementation and to later update its state
        registerWithSystemUser();
    }
    putComponent(Recents.class, this);
}
Also used : RecentsTvImpl(com.android.systemui.recents.tv.RecentsTvImpl) UiModeManager(android.app.UiModeManager) Handler(android.os.Handler) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) Point(android.graphics.Point)

Example 32 with RecentsTaskLoader

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

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 33 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 34 with RecentsTaskLoader

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

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();
    boolean showClearAllRecents = Settings.System.getIntForUser(getContentResolver(), Settings.System.SHOW_CLEAR_ALL_RECENTS, 0, UserHandle.USER_CURRENT) != 0;
    // 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 35 with RecentsTaskLoader

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

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)

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