diff options
Diffstat (limited to 'cmds/am/src')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 8187468805c3..acc68cffaa98 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -21,10 +21,12 @@ package com.android.commands.am; import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; import static android.app.ActivityManager.RESIZE_MODE_SYSTEM; import static android.app.ActivityManager.RESIZE_MODE_USER; +import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; import android.app.ActivityManager; import android.app.ActivityManager.StackInfo; import android.app.ActivityManagerNative; +import android.app.ActivityOptions; import android.app.IActivityContainer; import android.app.IActivityController; import android.app.IActivityManager; @@ -106,6 +108,7 @@ public class Am extends BaseCommand { private String mProfileFile; private int mSamplingInterval; private boolean mAutoStop; + private int mStackId; /** * Command-line entry point. @@ -192,6 +195,7 @@ public class Am extends BaseCommand { " --track-allocation: enable tracking of object allocations\n" + " --user <USER_ID> | current: Specify which user to run as; if not\n" + " specified then run as the current user.\n" + + " --stack <STACK_ID>: Specify into which stack should the activity be put." + "\n" + "am startservice: start a Service. Options are:\n" + " --user <USER_ID> | current: Specify which user to run as; if not\n" + @@ -468,6 +472,7 @@ public class Am extends BaseCommand { mSamplingInterval = 0; mAutoStop = false; mUserId = defUser; + mStackId = FULLSCREEN_WORKSPACE_STACK_ID; return Intent.parseCommandArgs(mArgs, new Intent.CommandOptionHandler() { @Override @@ -496,6 +501,8 @@ public class Am extends BaseCommand { mUserId = parseUserArg(nextArgRequired()); } else if (opt.equals("--receiver-permission")) { mReceiverPermission = nextArgRequired(); + } else if (opt.equals("--stack")) { + mStackId = Integer.parseInt(nextArgRequired()); } else { return false; } @@ -553,6 +560,7 @@ public class Am extends BaseCommand { mimeType = mAm.getProviderMimeType(intent.getData(), mUserId); } + do { if (mStopOption) { String packageName; @@ -607,13 +615,20 @@ public class Am extends BaseCommand { IActivityManager.WaitResult result = null; int res; final long startTime = SystemClock.uptimeMillis(); + ActivityOptions options = null; + if (mStackId != FULLSCREEN_WORKSPACE_STACK_ID) { + options = ActivityOptions.makeBasic(); + options.setLaunchStackId(mStackId); + } if (mWaitOption) { result = mAm.startActivityAndWait(null, null, intent, mimeType, - null, null, 0, mStartFlags, profilerInfo, null, mUserId); + null, null, 0, mStartFlags, profilerInfo, + options != null ? options.toBundle() : null, mUserId); res = result.result; } else { res = mAm.startActivityAsUser(null, null, intent, mimeType, - null, null, 0, mStartFlags, profilerInfo, null, mUserId); + null, null, 0, mStartFlags, profilerInfo, + options != null ? options.toBundle() : null, mUserId); } final long endTime = SystemClock.uptimeMillis(); PrintStream out = mWaitOption ? System.out : System.err; @@ -1762,18 +1777,33 @@ public class Am extends BaseCommand { System.err.println("Error: invalid input bounds"); return; } - resizeStack(stackId, bounds, 0, false); + resizeStack(stackId, bounds, 0); } private void runStackResizeAnimated() throws Exception { String stackIdStr = nextArgRequired(); int stackId = Integer.valueOf(stackIdStr); - final Rect bounds = getBounds(); - if (bounds == null) { - System.err.println("Error: invalid input bounds"); - return; + final Rect bounds; + if ("null".equals(mArgs.peekNextArg())) { + bounds = null; + } else { + bounds = getBounds(); + if (bounds == null) { + System.err.println("Error: invalid input bounds"); + return; + } + } + resizeStackUnchecked(stackId, bounds, 0, true); + } + + private void resizeStackUnchecked(int stackId, Rect bounds, int delayMs, boolean animate) { + try { + mAm.resizeStack(stackId, bounds, false, false, animate); + Thread.sleep(delayMs); + } catch (RemoteException e) { + showError("Error: resizing stack " + e); + } catch (InterruptedException e) { } - resizeStack(stackId, bounds, 0, true); } private void runStackResizeDocked() throws Exception { @@ -1790,20 +1820,13 @@ public class Am extends BaseCommand { } } - private void resizeStack(int stackId, Rect bounds, int delayMs, boolean animate) + private void resizeStack(int stackId, Rect bounds, int delayMs) throws Exception { if (bounds == null) { showError("Error: invalid input bounds"); return; } - - try { - mAm.resizeStack(stackId, bounds, false, false, animate); - Thread.sleep(delayMs); - } catch (RemoteException e) { - showError("Error: resizing stack " + e); - } catch (InterruptedException e) { - } + resizeStackUnchecked(stackId, bounds, delayMs, false); } private void runStackPositionTask() throws Exception { @@ -1912,7 +1935,7 @@ public class Am extends BaseCommand { maxChange = Math.min(stepSize, currentPoint - minPoint); currentPoint -= maxChange; setBoundsSide(bounds, side, currentPoint); - resizeStack(DOCKED_STACK_ID, bounds, delayMs, false); + resizeStack(DOCKED_STACK_ID, bounds, delayMs); } System.out.println("Growing docked stack side=" + side); @@ -1920,7 +1943,7 @@ public class Am extends BaseCommand { maxChange = Math.min(stepSize, maxPoint - currentPoint); currentPoint += maxChange; setBoundsSide(bounds, side, currentPoint); - resizeStack(DOCKED_STACK_ID, bounds, delayMs, false); + resizeStack(DOCKED_STACK_ID, bounds, delayMs); } System.out.println("Back to Original size side=" + side); @@ -1928,7 +1951,7 @@ public class Am extends BaseCommand { maxChange = Math.min(stepSize, currentPoint - startPoint); currentPoint -= maxChange; setBoundsSide(bounds, side, currentPoint); - resizeStack(DOCKED_STACK_ID, bounds, delayMs, false); + resizeStack(DOCKED_STACK_ID, bounds, delayMs); } } |