From fd1ce8d5a7aa1ec6c7324b171f7e7a15a95f8759 Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Mon, 17 Jun 2013 16:15:42 -0700 Subject: Add new API getStackBoxInfo Change-Id: Ie2861e5e31bb3876cfe2d5c3d04ff58bb3955634 --- cmds/am/src/com/android/commands/am/Am.java | 25 +++++++++++++++-- core/java/android/app/ActivityManagerNative.java | 32 ++++++++++++++++++++++ core/java/android/app/IActivityManager.java | 2 ++ .../android/server/am/ActivityManagerService.java | 16 +++++++++++ 4 files changed, 72 insertions(+), 3 deletions(-) diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index afedd42..3bbdc48 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -103,10 +103,11 @@ public class Am extends BaseCommand { " am to-intent-uri [INTENT]\n" + " am switch-user \n" + " am stop-user \n" + - " am stack create \n" + + " am stack create \n" + " am stack movetask [true|false]\n" + " am stack resize \n" + " am stack boxes\n" + + " am stack box \n" + "\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + @@ -194,8 +195,12 @@ public class Am extends BaseCommand { "\n" + "am stack create: create a new stack relative to an existing one.\n" + " : the task to populate the new stack with. Must exist.\n" + - " : existing stack's id.\n" + - " : 0: to left of, 1: to right of, 2: above, 3: below\n" + + " : existing stack box's id.\n" + + " : 0: before , per RTL/LTR configuration,\n" + + " 1: after , per RTL/LTR configuration,\n" + + " 2: to left of ,\n" + + " 3: to right of ," + + " 4: above , 5: below \n" + " : float between 0.2 and 0.8 inclusive.\n" + "\n" + "am stack movetask: move from its current stack to the top (true) or" + @@ -205,6 +210,8 @@ public class Am extends BaseCommand { "\n" + "am stack boxes: list the hierarchy of stack boxes and their contents.\n" + "\n" + + "am stack box: list the hierarchy of stack boxes rooted at .\n" + + "\n" + " specifications include these flags and arguments:\n" + " [-a ] [-d ] [-t ]\n" + " [-c [-c ] ...]\n" + @@ -1488,6 +1495,8 @@ public class Am extends BaseCommand { runStackBoxResize(); } else if (op.equals("boxes")) { runStackBoxes(); + } else if (op.equals("box")) { + runStackBoxInfo(); } else { showError("Error: unknown command '" + op + "'"); return; @@ -1554,4 +1563,14 @@ public class Am extends BaseCommand { } catch (RemoteException e) { } } + + private void runStackBoxInfo() throws Exception { + try { + String stackBoxIdStr = nextArgRequired(); + int stackBoxId = Integer.valueOf(stackBoxIdStr); + StackBoxInfo stackBoxInfo = mAm.getStackBoxInfo(stackBoxId); + System.out.println(stackBoxInfo); + } catch (RemoteException e) { + } + } } diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 27e20b9..1573398 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -648,6 +648,20 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } + case GET_STACK_BOX_INFO_TRANSACTION: { + data.enforceInterface(IActivityManager.descriptor); + int stackBoxId = data.readInt(); + StackBoxInfo info = getStackBoxInfo(stackBoxId); + reply.writeNoException(); + if (info != null) { + reply.writeInt(1); + info.writeToParcel(reply, 0); + } else { + reply.writeInt(0); + } + return true; + } + case SET_FOCUSED_STACK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int stackId = data.readInt(); @@ -2672,6 +2686,24 @@ class ActivityManagerProxy implements IActivityManager return list; } @Override + public StackBoxInfo getStackBoxInfo(int stackBoxId) throws RemoteException + { + Parcel data = Parcel.obtain(); + Parcel reply = Parcel.obtain(); + data.writeInterfaceToken(IActivityManager.descriptor); + data.writeInt(stackBoxId); + mRemote.transact(GET_STACK_BOX_INFO_TRANSACTION, data, reply, 0); + reply.readException(); + int res = reply.readInt(); + StackBoxInfo info = null; + if (res != 0) { + info = StackBoxInfo.CREATOR.createFromParcel(reply); + } + data.recycle(); + reply.recycle(); + return info; + } + @Override public void setFocusedStack(int stackId) throws RemoteException { Parcel data = Parcel.obtain(); diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index b48eed2..c8791a4 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -120,6 +120,7 @@ public interface IActivityManager extends IInterface { public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException; public void resizeStackBox(int stackBoxId, float weight) throws RemoteException; public List getStackBoxes() throws RemoteException; + public StackBoxInfo getStackBoxInfo(int stackBoxId) throws RemoteException; public void setFocusedStack(int stackId) throws RemoteException; public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException; /* oneway */ @@ -664,4 +665,5 @@ public interface IActivityManager extends IInterface { int RESIZE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+169; int GET_STACK_BOXES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+170; int SET_FOCUSED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+171; + int GET_STACK_BOX_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+172; } diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 21c752b..62520d5 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -6450,6 +6450,22 @@ public final class ActivityManagerService extends ActivityManagerNative } @Override + public StackBoxInfo getStackBoxInfo(int stackBoxId) { + List stackBoxInfos = mWindowManager.getStackBoxInfos(); + StackBoxInfo info = null; + synchronized (this) { + List stackInfos = getStacks(); + for (StackBoxInfo stackBoxInfo : stackBoxInfos) { + addStackInfoToStackBoxInfo(stackBoxInfo, stackInfos); + if (stackBoxInfo.stackBoxId == stackBoxId) { + info = stackBoxInfo; + } + } + } + return info; + } + + @Override public int getTaskForActivity(IBinder token, boolean onlyRoot) { synchronized(this) { return ActivityRecord.getTaskForActivityLocked(token, onlyRoot); -- cgit v1.1