Search in sources :

Example 21 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

the class RecentController method startMultiWindow.

public void startMultiWindow() {
    SystemServicesProxy ssp = SystemServicesProxy.getInstance(mContext);
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    int createMode = ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
    if (ssp.startTaskInDockedMode(runningTask.id, createMode)) {
        openLastApptoBottom();
        if (!isShowing()) {
            showRecents();
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ActivityManager(android.app.ActivityManager) Point(android.graphics.Point)

Example 22 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

the class RecentsImpl method showNextTask.

/**
     * Transitions to the next recent task in the stack.
     */
public void 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
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    if (runningTask == null)
        return;
    // Find the task in the recents list
    boolean isRunningTaskInHomeStack = SystemServicesProxy.isHomeStack(runningTask.stackId);
    ArrayList<Task> tasks = focusedStack.getStackTasks();
    Task toTask = null;
    ActivityOptions launchOpts = null;
    int taskCount = tasks.size();
    for (int i = taskCount - 1; i >= 1; i--) {
        Task task = tasks.get(i);
        if (isRunningTaskInHomeStack) {
            toTask = tasks.get(i - 1);
            launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_fast_toggle_app_home_exit);
            break;
        } else if (task.key.id == runningTask.id) {
            toTask = tasks.get(i - 1);
            launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_target, R.anim.recents_launch_prev_affiliated_task_source);
            break;
        }
    }
    // Return early if there is no next task
    if (toTask == null) {
        ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_bounce));
        return;
    }
    // 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) ActivityManager(android.app.ActivityManager) ActivityOptions(android.app.ActivityOptions)

Example 23 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

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 24 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

the class RecentsImpl method updateHeaderBarLayout.

/**
     * Prepares the header bar layout for the next transition, if the task view bounds has changed
     * since the last call, it will attempt to re-measure and layout the header bar to the new size.
     *
     * @param stack the stack to initialize the stack layout with
     * @param windowRectOverride the rectangle to use when calculating the stack state which can
     *                           be different from the current window rect if recents is resizing
     *                           while being launched
     */
private void updateHeaderBarLayout(TaskStack stack, Rect windowRectOverride) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    Rect displayRect = ssp.getDisplayRect();
    Rect systemInsets = new Rect();
    ssp.getStableInsets(systemInsets);
    Rect windowRect = windowRectOverride != null ? new Rect(windowRectOverride) : ssp.getWindowRect();
    // them identical.
    if (ssp.hasDockedTask()) {
        windowRect.bottom -= systemInsets.bottom;
        systemInsets.bottom = 0;
    }
    calculateWindowStableInsets(systemInsets, windowRect);
    windowRect.offsetTo(0, 0);
    TaskStackLayoutAlgorithm stackLayout = mDummyStackView.getStackAlgorithm();
    // Rebind the header bar and draw it for the transition
    stackLayout.setSystemInsets(systemInsets);
    if (stack != null) {
        stackLayout.getTaskStackBounds(displayRect, windowRect, systemInsets.top, systemInsets.left, systemInsets.right, mTaskStackBounds);
        stackLayout.reset();
        stackLayout.initialize(displayRect, windowRect, mTaskStackBounds, TaskStackLayoutAlgorithm.StackState.getStackStateForStack(stack));
        mDummyStackView.setTasks(stack, false);
        // Get the width of a task view so that we know how wide to draw the header bar.
        int taskViewWidth = 0;
        if (mDummyStackView.useGridLayout()) {
            TaskGridLayoutAlgorithm gridLayout = mDummyStackView.getGridAlgorithm();
            gridLayout.initialize(windowRect);
            taskViewWidth = (int) gridLayout.getTransform(0, /* taskIndex */
            stack.getTaskCount(), new TaskViewTransform(), stackLayout).rect.width();
        } else {
            Rect taskViewBounds = stackLayout.getUntransformedTaskViewBounds();
            if (!taskViewBounds.isEmpty()) {
                taskViewWidth = taskViewBounds.width();
            }
        }
        if (taskViewWidth > 0) {
            synchronized (mHeaderBarLock) {
                if (mHeaderBar.getMeasuredWidth() != taskViewWidth || mHeaderBar.getMeasuredHeight() != mTaskBarHeight) {
                    if (mDummyStackView.useGridLayout()) {
                        mHeaderBar.setShouldDarkenBackgroundColor(true);
                        mHeaderBar.setNoUserInteractionState();
                    }
                    mHeaderBar.forceLayout();
                    mHeaderBar.measure(MeasureSpec.makeMeasureSpec(taskViewWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(mTaskBarHeight, MeasureSpec.EXACTLY));
                }
                mHeaderBar.layout(0, 0, taskViewWidth, mTaskBarHeight);
            }
            // Update the transition bitmap to match the new header bar height
            if (mThumbTransitionBitmapCache == null || (mThumbTransitionBitmapCache.getWidth() != taskViewWidth) || (mThumbTransitionBitmapCache.getHeight() != mTaskBarHeight)) {
                mThumbTransitionBitmapCache = Bitmap.createBitmap(taskViewWidth, mTaskBarHeight, Bitmap.Config.ARGB_8888);
            }
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) TaskGridLayoutAlgorithm(com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm) TaskViewTransform(com.android.systemui.recents.views.TaskViewTransform) TaskStackLayoutAlgorithm(com.android.systemui.recents.views.TaskStackLayoutAlgorithm)

Example 25 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

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

SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)243 Rect (android.graphics.Rect)45 ActivityManager (android.app.ActivityManager)35 ActivityInfo (android.content.pm.ActivityInfo)34 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)30 TaskStack (com.android.systemui.recents.model.TaskStack)30 Task (com.android.systemui.recents.model.Task)25 Drawable (android.graphics.drawable.Drawable)19 Point (android.graphics.Point)16 ActivityOptions (android.app.ActivityOptions)15 ComponentName (android.content.ComponentName)15 RemoteException (android.os.RemoteException)15 MutableBoolean (android.util.MutableBoolean)15 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)15 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)15 Bitmap (android.graphics.Bitmap)14 ArrayList (java.util.ArrayList)14 BitmapDrawable (android.graphics.drawable.BitmapDrawable)12 ActivityNotFoundException (android.content.ActivityNotFoundException)10 Intent (android.content.Intent)10