From 53a29a90f35f72462c0d6ad650921d5566c1f8f0 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Mon, 23 Feb 2015 15:42:52 -0800 Subject: Added ActivityManager API and AM command to resize a task. Also fixed issue with ActivityStackSupervisor.moveTaskToStackLocked() functionality not working correctly. Change-Id: Ia13f1e92a7c59ce6543c226533ac8ea623488290 --- cmds/am/src/com/android/commands/am/Am.java | 86 +++++++++++++++++++---------- 1 file changed, 58 insertions(+), 28 deletions(-) (limited to 'cmds') diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 62081ee..a501fa7 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -138,6 +138,7 @@ public class Am extends BaseCommand { " am task lock \n" + " am task lock stop\n" + " am task resizeable [true|false]\n" + + " am task resize \n" + " am get-config\n" + "\n" + "am start: start an Activity. Options are:\n" + @@ -249,11 +250,11 @@ public class Am extends BaseCommand { "am stack resize: change size and position to " + ".\n" + "\n" + - "am stack split: split into 2 stacks ertically or orizontally" + - " starting the new stack with [INTENT] if specified. If [INTENT] isn't" + - " specified and the current stack has more than one task, then the top task" + - " of the current task will be moved to the new stack. Command will also force" + - " all current tasks in both stacks to be resizeable." + + "am stack split: split into 2 stacks ertically or orizontally\n" + + " starting the new stack with [INTENT] if specified. If [INTENT] isn't\n" + + " specified and the current stack has more than one task, then the top task\n" + + " of the current task will be moved to the new stack. Command will also force\n" + + " all current tasks in both stacks to be resizeable.\n" + "\n" + "am stack list: list all of the activity stacks and their sizes.\n" + "\n" + @@ -265,6 +266,10 @@ public class Am extends BaseCommand { "\n" + "am task resizeable: change if is resizeable (true) or not (false).\n" + "\n" + + "am task resize: makes sure is in a stack with the specified bounds.\n" + + " Forces the task to be resizeable and creates a stack if no existing stack\n" + + " has the specified bounds.\n" + + "\n" + "am get-config: retrieve the configuration and any recent configurations\n" + " of the device\n" + "\n" + @@ -1742,33 +1747,14 @@ public class Am extends BaseCommand { private void runStackResize() throws Exception { String stackIdStr = nextArgRequired(); int stackId = Integer.valueOf(stackIdStr); - String leftStr = nextArgRequired(); - int left = Integer.valueOf(leftStr); - String topStr = nextArgRequired(); - int top = Integer.valueOf(topStr); - String rightStr = nextArgRequired(); - int right = Integer.valueOf(rightStr); - String bottomStr = nextArgRequired(); - int bottom = Integer.valueOf(bottomStr); - if (left < 0) { - System.err.println("Error: bad left arg: " + leftStr); - return; - } - if (top < 0) { - System.err.println("Error: bad top arg: " + topStr); - return; - } - if (right <= 0) { - System.err.println("Error: bad right arg: " + rightStr); - return; - } - if (bottom <= 0) { - System.err.println("Error: bad bottom arg: " + bottomStr); + final Rect bounds = getBounds(); + if (bounds == null) { + System.err.println("Error: invalid input bounds"); return; } try { - mAm.resizeStack(stackId, new Rect(left, top, right, bottom)); + mAm.resizeStack(stackId, bounds); } catch (RemoteException e) { } } @@ -1857,6 +1843,8 @@ public class Am extends BaseCommand { runTaskLock(); } else if (op.equals("resizeable")) { runTaskResizeable(); + } else if (op.equals("resize")) { + runTaskResize(); } else { showError("Error: unknown command '" + op + "'"); return; @@ -1890,6 +1878,20 @@ public class Am extends BaseCommand { } } + private void runTaskResize() throws Exception { + final String taskIdStr = nextArgRequired(); + final int taskId = Integer.valueOf(taskIdStr); + final Rect bounds = getBounds(); + if (bounds == null) { + System.err.println("Error: invalid input bounds"); + return; + } + try { + mAm.resizeTask(taskId, bounds); + } catch (RemoteException e) { + } + } + private List getRecentConfigurations(int days) { IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService( Context.USAGE_STATS_SERVICE)); @@ -1986,4 +1988,32 @@ public class Am extends BaseCommand { } return fd; } + + private Rect getBounds() { + String leftStr = nextArgRequired(); + int left = Integer.valueOf(leftStr); + String topStr = nextArgRequired(); + int top = Integer.valueOf(topStr); + String rightStr = nextArgRequired(); + int right = Integer.valueOf(rightStr); + String bottomStr = nextArgRequired(); + int bottom = Integer.valueOf(bottomStr); + if (left < 0) { + System.err.println("Error: bad left arg: " + leftStr); + return null; + } + if (top < 0) { + System.err.println("Error: bad top arg: " + topStr); + return null; + } + if (right <= 0) { + System.err.println("Error: bad right arg: " + rightStr); + return null; + } + if (bottom <= 0) { + System.err.println("Error: bad bottom arg: " + bottomStr); + return null; + } + return new Rect(left, top, right, bottom); + } } -- cgit v1.1