Search in sources :

Example 31 with StackInfo

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

the class ActivityManagerProxy method getStackInfo.

@Override
public StackInfo getStackInfo(int stackId) throws RemoteException {
    Parcel data = Parcel.obtain();
    Parcel reply = Parcel.obtain();
    data.writeInterfaceToken(IActivityManager.descriptor);
    data.writeInt(stackId);
    mRemote.transact(GET_STACK_INFO_TRANSACTION, data, reply, 0);
    reply.readException();
    int res = reply.readInt();
    StackInfo info = null;
    if (res != 0) {
        info = StackInfo.CREATOR.createFromParcel(reply);
    }
    data.recycle();
    reply.recycle();
    return info;
}
Also used : Parcel(android.os.Parcel) StackInfo(android.app.ActivityManager.StackInfo) Point(android.graphics.Point)

Example 32 with StackInfo

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

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 33 with StackInfo

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

the class Am method runTaskDragTaskTest.

private void runTaskDragTaskTest() {
    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;
    Rect taskBounds;
    try {
        stackInfo = mAm.getStackInfo(mAm.getFocusedStackId());
        taskBounds = mAm.getTaskBounds(taskId);
    } catch (RemoteException e) {
        System.err.println("Error getting focus stack info or task bounds: " + e);
        return;
    }
    final Rect stackBounds = stackInfo.bounds;
    int travelRight = stackBounds.width() - taskBounds.width();
    int travelLeft = -travelRight;
    int travelDown = stackBounds.height() - taskBounds.height();
    int travelUp = -travelDown;
    int passes = 0;
    // We do 2 passes to get back to the original location of the task.
    while (passes < 2) {
        // Move right
        System.out.println("Moving right...");
        travelRight = moveTask(taskId, taskBounds, stackBounds, stepSize, travelRight, MOVING_FORWARD, MOVING_HORIZONTALLY, delay_ms);
        System.out.println("Still need to travel right by " + travelRight);
        // Move down
        System.out.println("Moving down...");
        travelDown = moveTask(taskId, taskBounds, stackBounds, stepSize, travelDown, MOVING_FORWARD, !MOVING_HORIZONTALLY, delay_ms);
        System.out.println("Still need to travel down by " + travelDown);
        // Move left
        System.out.println("Moving left...");
        travelLeft = moveTask(taskId, taskBounds, stackBounds, stepSize, travelLeft, !MOVING_FORWARD, MOVING_HORIZONTALLY, delay_ms);
        System.out.println("Still need to travel left by " + travelLeft);
        // Move up
        System.out.println("Moving up...");
        travelUp = moveTask(taskId, taskBounds, stackBounds, stepSize, travelUp, !MOVING_FORWARD, !MOVING_HORIZONTALLY, delay_ms);
        System.out.println("Still need to travel up by " + travelUp);
        try {
            taskBounds = mAm.getTaskBounds(taskId);
        } catch (RemoteException e) {
            System.err.println("Error getting task bounds: " + e);
            return;
        }
        passes++;
    }
}
Also used : Rect(android.graphics.Rect) RemoteException(android.os.RemoteException) StackInfo(android.app.ActivityManager.StackInfo)

Example 34 with StackInfo

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

the class Am method runStackInfo.

private void runStackInfo() throws Exception {
    try {
        String stackIdStr = nextArgRequired();
        int stackId = Integer.parseInt(stackIdStr);
        StackInfo info = mAm.getStackInfo(stackId);
        System.out.println(info);
    } catch (RemoteException e) {
    }
}
Also used : RemoteException(android.os.RemoteException) StackInfo(android.app.ActivityManager.StackInfo)

Example 35 with StackInfo

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

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