Search in sources :

Example 6 with StackInfo

use of android.app.ActivityManager.StackInfo in project android_frameworks_base by ResurrectionRemix.

the class ActivityStackSupervisor method getStackInfoLocked.

private StackInfo getStackInfoLocked(ActivityStack stack) {
    final ActivityDisplay display = mActivityDisplays.get(Display.DEFAULT_DISPLAY);
    StackInfo info = new StackInfo();
    mWindowManager.getStackBounds(stack.mStackId, info.bounds);
    info.displayId = Display.DEFAULT_DISPLAY;
    info.stackId = stack.mStackId;
    info.userId = stack.mCurrentUser;
    info.visible = stack.getStackVisibilityLocked(null) == STACK_VISIBLE;
    info.position = display != null ? display.mStacks.indexOf(stack) : 0;
    ArrayList<TaskRecord> tasks = stack.getAllTasks();
    final int numTasks = tasks.size();
    int[] taskIds = new int[numTasks];
    String[] taskNames = new String[numTasks];
    Rect[] taskBounds = new Rect[numTasks];
    int[] taskUserIds = new int[numTasks];
    for (int i = 0; i < numTasks; ++i) {
        final TaskRecord task = tasks.get(i);
        taskIds[i] = task.taskId;
        taskNames[i] = task.origActivity != null ? task.origActivity.flattenToString() : task.realActivity != null ? task.realActivity.flattenToString() : task.getTopActivity() != null ? task.getTopActivity().packageName : "unknown";
        taskBounds[i] = new Rect();
        mWindowManager.getTaskBounds(task.taskId, taskBounds[i]);
        taskUserIds[i] = task.userId;
    }
    info.taskIds = taskIds;
    info.taskNames = taskNames;
    info.taskBounds = taskBounds;
    info.taskUserIds = taskUserIds;
    final ActivityRecord top = stack.topRunningActivityLocked();
    info.topActivity = top != null ? top.intent.getComponent() : null;
    return info;
}
Also used : Rect(android.graphics.Rect) StackInfo(android.app.ActivityManager.StackInfo)

Example 7 with StackInfo

use of android.app.ActivityManager.StackInfo in project android_frameworks_base by ResurrectionRemix.

the class Am method runTaskSizeTaskTest.

private void runTaskSizeTaskTest() {
    final int taskId = Integer.parseInt(nextArgRequired());
    final int stepSize = Integer.parseInt(nextArgRequired());
    final String delayStr = nextArg();
    final int delay_ms = (delayStr != null) ? Integer.parseInt(delayStr) : 0;
    final StackInfo stackInfo;
    final Rect initialTaskBounds;
    try {
        stackInfo = mAm.getStackInfo(mAm.getFocusedStackId());
        initialTaskBounds = mAm.getTaskBounds(taskId);
    } catch (RemoteException e) {
        System.err.println("Error getting focus stack info or task bounds: " + e);
        return;
    }
    final Rect stackBounds = stackInfo.bounds;
    stackBounds.inset(STACK_BOUNDS_INSET, STACK_BOUNDS_INSET);
    final Rect currentTaskBounds = new Rect(initialTaskBounds);
    // Size by top-left
    System.out.println("Growing top-left");
    do {
        currentTaskBounds.top -= getStepSize(currentTaskBounds.top, stackBounds.top, stepSize, GREATER_THAN_TARGET);
        currentTaskBounds.left -= getStepSize(currentTaskBounds.left, stackBounds.left, stepSize, GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (stackBounds.top < currentTaskBounds.top || stackBounds.left < currentTaskBounds.left);
    // Back to original size
    System.out.println("Shrinking top-left");
    do {
        currentTaskBounds.top += getStepSize(currentTaskBounds.top, initialTaskBounds.top, stepSize, !GREATER_THAN_TARGET);
        currentTaskBounds.left += getStepSize(currentTaskBounds.left, initialTaskBounds.left, stepSize, !GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (initialTaskBounds.top > currentTaskBounds.top || initialTaskBounds.left > currentTaskBounds.left);
    // Size by top-right
    System.out.println("Growing top-right");
    do {
        currentTaskBounds.top -= getStepSize(currentTaskBounds.top, stackBounds.top, stepSize, GREATER_THAN_TARGET);
        currentTaskBounds.right += getStepSize(currentTaskBounds.right, stackBounds.right, stepSize, !GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (stackBounds.top < currentTaskBounds.top || stackBounds.right > currentTaskBounds.right);
    // Back to original size
    System.out.println("Shrinking top-right");
    do {
        currentTaskBounds.top += getStepSize(currentTaskBounds.top, initialTaskBounds.top, stepSize, !GREATER_THAN_TARGET);
        currentTaskBounds.right -= getStepSize(currentTaskBounds.right, initialTaskBounds.right, stepSize, GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (initialTaskBounds.top > currentTaskBounds.top || initialTaskBounds.right < currentTaskBounds.right);
    // Size by bottom-left
    System.out.println("Growing bottom-left");
    do {
        currentTaskBounds.bottom += getStepSize(currentTaskBounds.bottom, stackBounds.bottom, stepSize, !GREATER_THAN_TARGET);
        currentTaskBounds.left -= getStepSize(currentTaskBounds.left, stackBounds.left, stepSize, GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (stackBounds.bottom > currentTaskBounds.bottom || stackBounds.left < currentTaskBounds.left);
    // Back to original size
    System.out.println("Shrinking bottom-left");
    do {
        currentTaskBounds.bottom -= getStepSize(currentTaskBounds.bottom, initialTaskBounds.bottom, stepSize, GREATER_THAN_TARGET);
        currentTaskBounds.left += getStepSize(currentTaskBounds.left, initialTaskBounds.left, stepSize, !GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (initialTaskBounds.bottom < currentTaskBounds.bottom || initialTaskBounds.left > currentTaskBounds.left);
    // Size by bottom-right
    System.out.println("Growing bottom-right");
    do {
        currentTaskBounds.bottom += getStepSize(currentTaskBounds.bottom, stackBounds.bottom, stepSize, !GREATER_THAN_TARGET);
        currentTaskBounds.right += getStepSize(currentTaskBounds.right, stackBounds.right, stepSize, !GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (stackBounds.bottom > currentTaskBounds.bottom || stackBounds.right > currentTaskBounds.right);
    // Back to original size
    System.out.println("Shrinking bottom-right");
    do {
        currentTaskBounds.bottom -= getStepSize(currentTaskBounds.bottom, initialTaskBounds.bottom, stepSize, GREATER_THAN_TARGET);
        currentTaskBounds.right -= getStepSize(currentTaskBounds.right, initialTaskBounds.right, stepSize, GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (initialTaskBounds.bottom < currentTaskBounds.bottom || initialTaskBounds.right < currentTaskBounds.right);
}
Also used : Rect(android.graphics.Rect) RemoteException(android.os.RemoteException) StackInfo(android.app.ActivityManager.StackInfo)

Example 8 with StackInfo

use of android.app.ActivityManager.StackInfo in project android_frameworks_base by ResurrectionRemix.

the class Am method runStackSizeDockedStackTest.

private void runStackSizeDockedStackTest() throws Exception {
    final int stepSize = Integer.parseInt(nextArgRequired());
    final String side = nextArgRequired();
    final String delayStr = nextArg();
    final int delayMs = (delayStr != null) ? Integer.parseInt(delayStr) : 0;
    Rect bounds;
    try {
        StackInfo info = mAm.getStackInfo(DOCKED_STACK_ID);
        if (info == null) {
            showError("Docked stack doesn't exist");
            return;
        }
        if (info.bounds == null) {
            showError("Docked stack doesn't have a bounds");
            return;
        }
        bounds = info.bounds;
    } catch (RemoteException e) {
        showError("Unable to get docked stack info:" + e);
        return;
    }
    final boolean horizontalGrowth = "l".equals(side) || "r".equals(side);
    final int changeSize = (horizontalGrowth ? bounds.width() : bounds.height()) / 2;
    int currentPoint;
    switch(side) {
        case "l":
            currentPoint = bounds.left;
            break;
        case "r":
            currentPoint = bounds.right;
            break;
        case "t":
            currentPoint = bounds.top;
            break;
        case "b":
            currentPoint = bounds.bottom;
            break;
        default:
            showError("Unknown growth side: " + side);
            return;
    }
    final int startPoint = currentPoint;
    final int minPoint = currentPoint - changeSize;
    final int maxPoint = currentPoint + changeSize;
    int maxChange;
    System.out.println("Shrinking docked stack side=" + side);
    while (currentPoint > minPoint) {
        maxChange = Math.min(stepSize, currentPoint - minPoint);
        currentPoint -= maxChange;
        setBoundsSide(bounds, side, currentPoint);
        resizeStack(DOCKED_STACK_ID, bounds, delayMs);
    }
    System.out.println("Growing docked stack side=" + side);
    while (currentPoint < maxPoint) {
        maxChange = Math.min(stepSize, maxPoint - currentPoint);
        currentPoint += maxChange;
        setBoundsSide(bounds, side, currentPoint);
        resizeStack(DOCKED_STACK_ID, bounds, delayMs);
    }
    System.out.println("Back to Original size side=" + side);
    while (currentPoint > startPoint) {
        maxChange = Math.min(stepSize, currentPoint - startPoint);
        currentPoint -= maxChange;
        setBoundsSide(bounds, side, currentPoint);
        resizeStack(DOCKED_STACK_ID, bounds, delayMs);
    }
}
Also used : Rect(android.graphics.Rect) RemoteException(android.os.RemoteException) StackInfo(android.app.ActivityManager.StackInfo)

Example 9 with StackInfo

use of android.app.ActivityManager.StackInfo in project android_frameworks_base by DirtyUnicorns.

the class Am method runTaskSizeTaskTest.

private void runTaskSizeTaskTest() {
    final int taskId = Integer.parseInt(nextArgRequired());
    final int stepSize = Integer.parseInt(nextArgRequired());
    final String delayStr = nextArg();
    final int delay_ms = (delayStr != null) ? Integer.parseInt(delayStr) : 0;
    final StackInfo stackInfo;
    final Rect initialTaskBounds;
    try {
        stackInfo = mAm.getStackInfo(mAm.getFocusedStackId());
        initialTaskBounds = mAm.getTaskBounds(taskId);
    } catch (RemoteException e) {
        System.err.println("Error getting focus stack info or task bounds: " + e);
        return;
    }
    final Rect stackBounds = stackInfo.bounds;
    stackBounds.inset(STACK_BOUNDS_INSET, STACK_BOUNDS_INSET);
    final Rect currentTaskBounds = new Rect(initialTaskBounds);
    // Size by top-left
    System.out.println("Growing top-left");
    do {
        currentTaskBounds.top -= getStepSize(currentTaskBounds.top, stackBounds.top, stepSize, GREATER_THAN_TARGET);
        currentTaskBounds.left -= getStepSize(currentTaskBounds.left, stackBounds.left, stepSize, GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (stackBounds.top < currentTaskBounds.top || stackBounds.left < currentTaskBounds.left);
    // Back to original size
    System.out.println("Shrinking top-left");
    do {
        currentTaskBounds.top += getStepSize(currentTaskBounds.top, initialTaskBounds.top, stepSize, !GREATER_THAN_TARGET);
        currentTaskBounds.left += getStepSize(currentTaskBounds.left, initialTaskBounds.left, stepSize, !GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (initialTaskBounds.top > currentTaskBounds.top || initialTaskBounds.left > currentTaskBounds.left);
    // Size by top-right
    System.out.println("Growing top-right");
    do {
        currentTaskBounds.top -= getStepSize(currentTaskBounds.top, stackBounds.top, stepSize, GREATER_THAN_TARGET);
        currentTaskBounds.right += getStepSize(currentTaskBounds.right, stackBounds.right, stepSize, !GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (stackBounds.top < currentTaskBounds.top || stackBounds.right > currentTaskBounds.right);
    // Back to original size
    System.out.println("Shrinking top-right");
    do {
        currentTaskBounds.top += getStepSize(currentTaskBounds.top, initialTaskBounds.top, stepSize, !GREATER_THAN_TARGET);
        currentTaskBounds.right -= getStepSize(currentTaskBounds.right, initialTaskBounds.right, stepSize, GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (initialTaskBounds.top > currentTaskBounds.top || initialTaskBounds.right < currentTaskBounds.right);
    // Size by bottom-left
    System.out.println("Growing bottom-left");
    do {
        currentTaskBounds.bottom += getStepSize(currentTaskBounds.bottom, stackBounds.bottom, stepSize, !GREATER_THAN_TARGET);
        currentTaskBounds.left -= getStepSize(currentTaskBounds.left, stackBounds.left, stepSize, GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (stackBounds.bottom > currentTaskBounds.bottom || stackBounds.left < currentTaskBounds.left);
    // Back to original size
    System.out.println("Shrinking bottom-left");
    do {
        currentTaskBounds.bottom -= getStepSize(currentTaskBounds.bottom, initialTaskBounds.bottom, stepSize, GREATER_THAN_TARGET);
        currentTaskBounds.left += getStepSize(currentTaskBounds.left, initialTaskBounds.left, stepSize, !GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (initialTaskBounds.bottom < currentTaskBounds.bottom || initialTaskBounds.left > currentTaskBounds.left);
    // Size by bottom-right
    System.out.println("Growing bottom-right");
    do {
        currentTaskBounds.bottom += getStepSize(currentTaskBounds.bottom, stackBounds.bottom, stepSize, !GREATER_THAN_TARGET);
        currentTaskBounds.right += getStepSize(currentTaskBounds.right, stackBounds.right, stepSize, !GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (stackBounds.bottom > currentTaskBounds.bottom || stackBounds.right > currentTaskBounds.right);
    // Back to original size
    System.out.println("Shrinking bottom-right");
    do {
        currentTaskBounds.bottom -= getStepSize(currentTaskBounds.bottom, initialTaskBounds.bottom, stepSize, GREATER_THAN_TARGET);
        currentTaskBounds.right -= getStepSize(currentTaskBounds.right, initialTaskBounds.right, stepSize, GREATER_THAN_TARGET);
        taskResize(taskId, currentTaskBounds, delay_ms, true);
    } while (initialTaskBounds.bottom < currentTaskBounds.bottom || initialTaskBounds.right < currentTaskBounds.right);
}
Also used : Rect(android.graphics.Rect) RemoteException(android.os.RemoteException) StackInfo(android.app.ActivityManager.StackInfo)

Example 10 with StackInfo

use of android.app.ActivityManager.StackInfo in project android_frameworks_base by DirtyUnicorns.

the class Am method runStackSizeDockedStackTest.

private void runStackSizeDockedStackTest() throws Exception {
    final int stepSize = Integer.parseInt(nextArgRequired());
    final String side = nextArgRequired();
    final String delayStr = nextArg();
    final int delayMs = (delayStr != null) ? Integer.parseInt(delayStr) : 0;
    Rect bounds;
    try {
        StackInfo info = mAm.getStackInfo(DOCKED_STACK_ID);
        if (info == null) {
            showError("Docked stack doesn't exist");
            return;
        }
        if (info.bounds == null) {
            showError("Docked stack doesn't have a bounds");
            return;
        }
        bounds = info.bounds;
    } catch (RemoteException e) {
        showError("Unable to get docked stack info:" + e);
        return;
    }
    final boolean horizontalGrowth = "l".equals(side) || "r".equals(side);
    final int changeSize = (horizontalGrowth ? bounds.width() : bounds.height()) / 2;
    int currentPoint;
    switch(side) {
        case "l":
            currentPoint = bounds.left;
            break;
        case "r":
            currentPoint = bounds.right;
            break;
        case "t":
            currentPoint = bounds.top;
            break;
        case "b":
            currentPoint = bounds.bottom;
            break;
        default:
            showError("Unknown growth side: " + side);
            return;
    }
    final int startPoint = currentPoint;
    final int minPoint = currentPoint - changeSize;
    final int maxPoint = currentPoint + changeSize;
    int maxChange;
    System.out.println("Shrinking docked stack side=" + side);
    while (currentPoint > minPoint) {
        maxChange = Math.min(stepSize, currentPoint - minPoint);
        currentPoint -= maxChange;
        setBoundsSide(bounds, side, currentPoint);
        resizeStack(DOCKED_STACK_ID, bounds, delayMs);
    }
    System.out.println("Growing docked stack side=" + side);
    while (currentPoint < maxPoint) {
        maxChange = Math.min(stepSize, maxPoint - currentPoint);
        currentPoint += maxChange;
        setBoundsSide(bounds, side, currentPoint);
        resizeStack(DOCKED_STACK_ID, bounds, delayMs);
    }
    System.out.println("Back to Original size side=" + side);
    while (currentPoint > startPoint) {
        maxChange = Math.min(stepSize, currentPoint - startPoint);
        currentPoint -= maxChange;
        setBoundsSide(bounds, side, currentPoint);
        resizeStack(DOCKED_STACK_ID, bounds, delayMs);
    }
}
Also used : Rect(android.graphics.Rect) RemoteException(android.os.RemoteException) StackInfo(android.app.ActivityManager.StackInfo)

Aggregations

StackInfo (android.app.ActivityManager.StackInfo)35 Rect (android.graphics.Rect)20 RemoteException (android.os.RemoteException)20 Parcel (android.os.Parcel)10 Point (android.graphics.Point)5