Search in sources :

Example 41 with SystemServicesProxy

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

the class RecentsTaskLoadPlan method preloadRawTasks.

/**
     * An optimization to preload the raw list of tasks. The raw tasks are saved in least-recent
     * to most-recent order.
     */
public synchronized void preloadRawTasks(boolean includeFrontMostExcludedTask) {
    int currentUserId = UserHandle.USER_CURRENT;
    updateCurrentQuietProfilesCache(currentUserId);
    SystemServicesProxy ssp = Recents.getSystemServices();
    mRawTasks = ssp.getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), currentUserId, includeFrontMostExcludedTask, mCurrentQuietProfiles);
    // Since the raw tasks are given in most-recent to least-recent order, we need to reverse it
    Collections.reverse(mRawTasks);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy)

Example 42 with SystemServicesProxy

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

the class RecentsTaskLoader method getAndUpdateContentDescription.

/**
     * Returns the cached task content description if the task key is not expired, updating the
     * cache if it is.
     */
String getAndUpdateContentDescription(Task.TaskKey taskKey, Resources res) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    // Return the cached content description if it exists
    String label = mContentDescriptionCache.getAndInvalidateIfModified(taskKey);
    if (label != null) {
        return label;
    }
    // All short paths failed, load the label from the activity info and cache it
    ActivityInfo activityInfo = getAndUpdateActivityInfo(taskKey);
    if (activityInfo != null) {
        label = ssp.getBadgedContentDescription(activityInfo, taskKey.userId, res);
        mContentDescriptionCache.put(taskKey, label);
        return label;
    }
    // cache it
    return "";
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ActivityInfo(android.content.pm.ActivityInfo)

Example 43 with SystemServicesProxy

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

the class TaskStackLayoutAlgorithm method update.

/**
     * Computes the minimum and maximum scroll progress values and the progress values for each task
     * in the stack.
     */
void update(TaskStack stack, ArraySet<Task.TaskKey> ignoreTasksSet) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
    // Clear the progress map
    mTaskIndexMap.clear();
    // Return early if we have no tasks
    ArrayList<Task> tasks = stack.getStackTasks();
    if (tasks.isEmpty()) {
        mFrontMostTaskP = 0;
        mMinScrollP = mMaxScrollP = mInitialScrollP = 0;
        mNumStackTasks = mNumFreeformTasks = 0;
        return;
    }
    // Filter the set of freeform and stack tasks
    ArrayList<Task> freeformTasks = new ArrayList<>();
    ArrayList<Task> stackTasks = new ArrayList<>();
    for (int i = 0; i < tasks.size(); i++) {
        Task task = tasks.get(i);
        if (ignoreTasksSet.contains(task.key)) {
            continue;
        }
        if (task.isFreeformTask()) {
            freeformTasks.add(task);
        } else {
            stackTasks.add(task);
        }
    }
    mNumStackTasks = stackTasks.size();
    mNumFreeformTasks = freeformTasks.size();
    // Put each of the tasks in the progress map at a fixed index (does not need to actually
    // map to a scroll position, just by index)
    int taskCount = stackTasks.size();
    for (int i = 0; i < taskCount; i++) {
        Task task = stackTasks.get(i);
        mTaskIndexMap.put(task.key.id, i);
    }
    // Update the freeform tasks
    if (!freeformTasks.isEmpty()) {
        mFreeformLayoutAlgorithm.update(freeformTasks, this);
    }
    // Calculate the min/max/initial scroll
    Task launchTask = stack.getLaunchTarget();
    int launchTaskIndex = launchTask != null ? stack.indexOfStackTask(launchTask) : mNumStackTasks - 1;
    if (getInitialFocusState() == STATE_FOCUSED) {
        int maxBottomOffset = mStackBottomOffset + mTaskRect.height();
        float maxBottomNormX = getNormalizedXFromFocusedY(maxBottomOffset, FROM_BOTTOM);
        mFocusedRange.offset(0f);
        mMinScrollP = 0;
        mMaxScrollP = Math.max(mMinScrollP, (mNumStackTasks - 1) - Math.max(0, mFocusedRange.getAbsoluteX(maxBottomNormX)));
        if (launchState.launchedFromHome) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else {
            mInitialScrollP = Utilities.clamp(launchTaskIndex - 1, mMinScrollP, mMaxScrollP);
        }
    } else if (!ssp.hasFreeformWorkspaceSupport() && mNumStackTasks == 1) {
        // If there is one stack task, ignore the min/max/initial scroll positions
        mMinScrollP = 0;
        mMaxScrollP = 0;
        mInitialScrollP = 0;
    } else {
        // Set the max scroll to be the point where the front most task is visible with the
        // stack bottom offset
        int maxBottomOffset = mStackBottomOffset + mTaskRect.height();
        float maxBottomNormX = getNormalizedXFromUnfocusedY(maxBottomOffset, FROM_BOTTOM);
        mUnfocusedRange.offset(0f);
        mMinScrollP = 0;
        mMaxScrollP = Math.max(mMinScrollP, (mNumStackTasks - 1) - Math.max(0, mUnfocusedRange.getAbsoluteX(maxBottomNormX)));
        boolean scrollToFront = launchState.launchedFromHome || launchState.launchedViaDockGesture;
        if (launchState.launchedFromBlacklistedApp) {
            mInitialScrollP = mMaxScrollP;
        } else if (launchState.launchedWithAltTab) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else if (scrollToFront) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else {
            // We are overriding the initial two task positions, so set the initial scroll
            // position to match the second task (aka focused task) position
            float initialTopNormX = getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP);
            mInitialScrollP = Math.max(mMinScrollP, Math.min(mMaxScrollP, (mNumStackTasks - 2)) - Math.max(0, mUnfocusedRange.getAbsoluteX(initialTopNormX)));
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) ArrayList(java.util.ArrayList)

Example 44 with SystemServicesProxy

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

the class TaskStackLayoutAlgorithm method getStackTransform.

/**
     * Update/get the transform.
     *
     * @param ignoreSingleTaskCase When set, will ensure that the transform computed does not take
     *                             into account the special single-task case.  This is only used
     *                             internally to ensure that we can calculate the transform for any
     *                             position in the stack.
     */
public void getStackTransform(float taskProgress, float nonOverrideTaskProgress, float stackScroll, int focusState, TaskViewTransform transformOut, TaskViewTransform frontTransform, boolean ignoreSingleTaskCase, boolean forceUpdate) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    // Ensure that the task is in range
    mUnfocusedRange.offset(stackScroll);
    mFocusedRange.offset(stackScroll);
    boolean unfocusedVisible = mUnfocusedRange.isInRange(taskProgress);
    boolean focusedVisible = mFocusedRange.isInRange(taskProgress);
    // Skip if the task is not visible
    if (!forceUpdate && !unfocusedVisible && !focusedVisible) {
        transformOut.reset();
        return;
    }
    // Map the absolute task progress to the normalized x at the stack scroll.  We use this to
    // calculate positions along the curve.
    mUnfocusedRange.offset(stackScroll);
    mFocusedRange.offset(stackScroll);
    float unfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
    float focusedRangeX = mFocusedRange.getNormalizedX(taskProgress);
    // Map the absolute task progress to the normalized x at the bounded stack scroll.  We use
    // this to calculate bounded properties, like translationZ and outline alpha.
    float boundedStackScroll = Utilities.clamp(stackScroll, mMinScrollP, mMaxScrollP);
    mUnfocusedRange.offset(boundedStackScroll);
    mFocusedRange.offset(boundedStackScroll);
    float boundedScrollUnfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
    float boundedScrollUnfocusedNonOverrideRangeX = mUnfocusedRange.getNormalizedX(nonOverrideTaskProgress);
    // Map the absolute task progress to the normalized x at the upper bounded stack scroll.
    // We use this to calculate the dim, which is bounded only on one end.
    float lowerBoundedStackScroll = Utilities.clamp(stackScroll, -Float.MAX_VALUE, mMaxScrollP);
    mUnfocusedRange.offset(lowerBoundedStackScroll);
    mFocusedRange.offset(lowerBoundedStackScroll);
    float lowerBoundedUnfocusedRangeX = mUnfocusedRange.getNormalizedX(taskProgress);
    float lowerBoundedFocusedRangeX = mFocusedRange.getNormalizedX(taskProgress);
    int x = (mStackRect.width() - mTaskRect.width()) / 2;
    int y;
    float z;
    float dimAlpha;
    float viewOutlineAlpha;
    if (!ssp.hasFreeformWorkspaceSupport() && mNumStackTasks == 1 && !ignoreSingleTaskCase) {
        // When there is exactly one task, then decouple the task from the stack and just move
        // in screen space
        float tmpP = (mMinScrollP - stackScroll) / mNumStackTasks;
        int centerYOffset = (mStackRect.top - mTaskRect.top) + (mStackRect.height() - mSystemInsets.bottom - mTaskRect.height()) / 2;
        y = centerYOffset + getYForDeltaP(tmpP, 0);
        z = mMaxTranslationZ;
        dimAlpha = 0f;
        viewOutlineAlpha = OUTLINE_ALPHA_MIN_VALUE + (OUTLINE_ALPHA_MAX_VALUE - OUTLINE_ALPHA_MIN_VALUE) / 2f;
    } else {
        // Otherwise, update the task to the stack layout
        int unfocusedY = (int) ((1f - mUnfocusedCurveInterpolator.getInterpolation(unfocusedRangeX)) * mStackRect.height());
        int focusedY = (int) ((1f - mFocusedCurveInterpolator.getInterpolation(focusedRangeX)) * mStackRect.height());
        float unfocusedDim = mUnfocusedDimCurveInterpolator.getInterpolation(lowerBoundedUnfocusedRangeX);
        float focusedDim = mFocusedDimCurveInterpolator.getInterpolation(lowerBoundedFocusedRangeX);
        // dim when the task is scrolled back towards the top of the screen
        if (mNumStackTasks <= 2 && nonOverrideTaskProgress == 0f) {
            if (boundedScrollUnfocusedRangeX >= 0.5f) {
                unfocusedDim = 0f;
            } else {
                float offset = mUnfocusedDimCurveInterpolator.getInterpolation(0.5f);
                unfocusedDim -= offset;
                unfocusedDim *= MAX_DIM / (MAX_DIM - offset);
            }
        }
        y = (mStackRect.top - mTaskRect.top) + (int) Utilities.mapRange(focusState, unfocusedY, focusedY);
        z = Utilities.mapRange(Utilities.clamp01(boundedScrollUnfocusedNonOverrideRangeX), mMinTranslationZ, mMaxTranslationZ);
        dimAlpha = Utilities.mapRange(focusState, unfocusedDim, focusedDim);
        viewOutlineAlpha = Utilities.mapRange(Utilities.clamp01(boundedScrollUnfocusedRangeX), OUTLINE_ALPHA_MIN_VALUE, OUTLINE_ALPHA_MAX_VALUE);
    }
    // Fill out the transform
    transformOut.scale = 1f;
    transformOut.alpha = 1f;
    transformOut.translationZ = z;
    transformOut.dimAlpha = dimAlpha;
    transformOut.viewOutlineAlpha = viewOutlineAlpha;
    transformOut.rect.set(mTaskRect);
    transformOut.rect.offset(x, y);
    Utilities.scaleRectAboutCenter(transformOut.rect, transformOut.scale);
    transformOut.visible = (transformOut.rect.top < mStackRect.bottom) && (frontTransform == null || transformOut.rect.top != frontTransform.rect.top);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy)

Example 45 with SystemServicesProxy

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

the class RecentsViewTouchHandler method onBusEvent.

/**** Events ****/
public final void onBusEvent(DragStartEvent event) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    mRv.getParent().requestDisallowInterceptTouchEvent(true);
    mDragRequested = true;
    // We defer starting the actual drag handling until the user moves past the drag slop
    mIsDragging = false;
    mDragTask = event.task;
    mTaskView = event.taskView;
    mDropTargets.clear();
    int[] recentsViewLocation = new int[2];
    mRv.getLocationInWindow(recentsViewLocation);
    mTaskViewOffset.set(mTaskView.getLeft() - recentsViewLocation[0] + event.tlOffset.x, mTaskView.getTop() - recentsViewLocation[1] + event.tlOffset.y);
    float x = mDownPos.x - mTaskViewOffset.x;
    float y = mDownPos.y - mTaskViewOffset.y;
    mTaskView.setTranslationX(x);
    mTaskView.setTranslationY(y);
    mVisibleDockStates.clear();
    if (ActivityManager.supportsMultiWindow() && !ssp.hasDockedTask() && mDividerSnapAlgorithm.isSplitScreenFeasible()) {
        Recents.logDockAttempt(mRv.getContext(), event.task.getTopComponent(), event.task.resizeMode);
        if (!event.task.isDockable) {
            EventBus.getDefault().send(new ShowIncompatibleAppOverlayEvent());
        } else {
            // Add the dock state drop targets (these take priority)
            TaskStack.DockState[] dockStates = getDockStatesForCurrentOrientation();
            for (TaskStack.DockState dockState : dockStates) {
                registerDropTargetForCurrentDrag(dockState);
                dockState.update(mRv.getContext());
                mVisibleDockStates.add(dockState);
            }
        }
    }
    // Request other drop targets to register themselves
    EventBus.getDefault().send(new DragStartInitializeDropTargetsEvent(event.task, event.taskView, this));
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) DragStartInitializeDropTargetsEvent(com.android.systemui.recents.events.ui.dragndrop.DragStartInitializeDropTargetsEvent) ShowIncompatibleAppOverlayEvent(com.android.systemui.recents.events.ui.ShowIncompatibleAppOverlayEvent)

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