Loading Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ LOCAL_SRC_FILES += \ core/java/android/accounts/IAccountManagerResponse.aidl \ core/java/android/accounts/IAccountAuthenticator.aidl \ core/java/android/accounts/IAccountAuthenticatorResponse.aidl \ core/java/android/app/IActivityContainer.aidl \ core/java/android/app/IActivityContainerCallback.aidl \ core/java/android/app/IActivityController.aidl \ core/java/android/app/IActivityPendingResult.aidl \ core/java/android/app/IAlarmManager.aidl \ Loading cmds/am/src/com/android/commands/am/Am.java +45 −44 Original line number Diff line number Diff line Loading @@ -19,8 +19,9 @@ package com.android.commands.am; import android.app.ActivityManager; import android.app.ActivityManager.StackBoxInfo; import android.app.ActivityManager.StackInfo; import android.app.ActivityManagerNative; import android.app.IActivityContainer; import android.app.IActivityController; import android.app.IActivityManager; import android.app.IInstrumentationWatcher; Loading @@ -31,9 +32,11 @@ import android.content.IIntentReceiver; import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.ResolveInfo; import android.graphics.Rect; import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; Loading Loading @@ -106,11 +109,11 @@ public class Am extends BaseCommand { " am to-intent-uri [INTENT]\n" + " am switch-user <USER_ID>\n" + " am stop-user <USER_ID>\n" + " am stack create <TASK_ID> <RELATIVE_STACK_BOX_ID> <POSITION> <WEIGHT>\n" + " am stack create <TASK_ID> <DISPLAY_ID>\n" + " am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" + " am stack resize <STACK_ID> <WEIGHT>\n" + " am stack boxes\n" + " am stack box <STACK_BOX_ID>\n" + " am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am stack list\n" + " am stack info <STACK_ID>\n" + "\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + Loading Loading @@ -204,24 +207,16 @@ public class Am extends BaseCommand { "am stop-user: stop execution of USER_ID, not allowing it to run any\n" + " code until a later explicit switch to it.\n" + "\n" + "am stack create: create a new stack relative to an existing one.\n" + " <TASK_ID>: the task to populate the new stack with. Must exist.\n" + " <RELATIVE_STACK_BOX_ID>: existing stack box's id.\n" + " <POSITION>: 0: before <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,\n" + " 1: after <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,\n" + " 2: to left of <RELATIVE_STACK_BOX_ID>,\n" + " 3: to right of <RELATIVE_STACK_BOX_ID>," + " 4: above <RELATIVE_STACK_BOX_ID>, 5: below <RELATIVE_STACK_BOX_ID>\n" + " <WEIGHT>: float between 0.2 and 0.8 inclusive.\n" + "am stack create: create a new stack containing <TASK_ID> which must exist\n" + "\n" + "am stack movetask: move <TASK_ID> from its current stack to the top (true) or" + " bottom (false) of <STACK_ID>.\n" + "\n" + "am stack resize: change <STACK_ID> relative size to new <WEIGHT>.\n" + "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>.\n" + "\n" + "am stack boxes: list the hierarchy of stack boxes and their contents.\n" + "am stack list: list all of the activity stacks and their sizes.\n" + "\n" + "am stack box: list the hierarchy of stack boxes rooted at <STACK_BOX_ID>.\n" + "am stack info: display the information about activity stack <STACK_ID>.\n" + "\n" + "<INTENT> specifications include these flags and arguments:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + Loading Loading @@ -1551,11 +1546,11 @@ public class Am extends BaseCommand { } else if (op.equals("movetask")) { runStackMoveTask(); } else if (op.equals("resize")) { runStackBoxResize(); } else if (op.equals("boxes")) { runStackBoxes(); } else if (op.equals("box")) { runStackBoxInfo(); runStackResize(); } else if (op.equals("list")) { runStackList(); } else if (op.equals("info")) { runStackInfo(); } else { showError("Error: unknown command '" + op + "'"); return; Loading @@ -1565,16 +1560,16 @@ public class Am extends BaseCommand { private void runStackCreate() throws Exception { String taskIdStr = nextArgRequired(); int taskId = Integer.valueOf(taskIdStr); String relativeToStr = nextArgRequired(); int relativeTo = Integer.valueOf(relativeToStr); String positionStr = nextArgRequired(); int position = Integer.valueOf(positionStr); String weightStr = nextArgRequired(); float weight = Float.valueOf(weightStr); String displayIdStr = nextArgRequired(); int displayId = Integer.valueOf(displayIdStr); try { int stackId = mAm.createStack(taskId, relativeTo, position, weight); System.out.println("createStack returned new stackId=" + stackId + "\n\n"); IBinder homeActivityToken = mAm.getHomeActivityToken(); IActivityContainer container = mAm.createActivityContainer(homeActivityToken, null); final int stackId = container.getStackId(); System.out.println("createStack returned new stackId=" + stackId + "\n"); container.attachToDisplay(displayId); mAm.moveTaskToStack(taskId, stackId, true); } catch (RemoteException e) { } } Loading @@ -1601,34 +1596,40 @@ public class Am extends BaseCommand { } } private void runStackBoxResize() throws Exception { String stackBoxIdStr = nextArgRequired(); int stackBoxId = Integer.valueOf(stackBoxIdStr); String weightStr = nextArgRequired(); float weight = Float.valueOf(weightStr); 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); try { mAm.resizeStackBox(stackBoxId, weight); mAm.resizeStack(stackId, new Rect(left, top, right, bottom)); } catch (RemoteException e) { } } private void runStackBoxes() throws Exception { private void runStackList() throws Exception { try { List<StackBoxInfo> stackBoxes = mAm.getStackBoxes(); for (StackBoxInfo info : stackBoxes) { List<StackInfo> stacks = mAm.getAllStackInfos(); for (StackInfo info : stacks) { System.out.println(info); } } catch (RemoteException e) { } } private void runStackBoxInfo() throws Exception { private void runStackInfo() throws Exception { try { String stackBoxIdStr = nextArgRequired(); int stackBoxId = Integer.valueOf(stackBoxIdStr); StackBoxInfo stackBoxInfo = mAm.getStackBoxInfo(stackBoxId); System.out.println(stackBoxInfo); String stackIdStr = nextArgRequired(); int stackId = Integer.valueOf(stackIdStr); StackInfo info = mAm.getStackInfo(stackId); System.out.println(info); } catch (RemoteException e) { } } Loading core/java/android/app/ActivityManager.java +7 −94 Original line number Diff line number Diff line Loading @@ -1288,107 +1288,16 @@ public class ActivityManager { } } /** * Information you can retrieve about the WindowManager StackBox hierarchy. * @hide */ public static class StackBoxInfo implements Parcelable { public int stackBoxId; public float weight; public boolean vertical; public Rect bounds; public StackBoxInfo[] children; public int stackId; public StackInfo stack; @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(stackBoxId); dest.writeFloat(weight); dest.writeInt(vertical ? 1 : 0); bounds.writeToParcel(dest, flags); dest.writeInt(stackId); if (children != null) { children[0].writeToParcel(dest, flags); children[1].writeToParcel(dest, flags); } else { stack.writeToParcel(dest, flags); } } public void readFromParcel(Parcel source) { stackBoxId = source.readInt(); weight = source.readFloat(); vertical = source.readInt() == 1; bounds = Rect.CREATOR.createFromParcel(source); stackId = source.readInt(); if (stackId == -1) { children = new StackBoxInfo[2]; children[0] = StackBoxInfo.CREATOR.createFromParcel(source); children[1] = StackBoxInfo.CREATOR.createFromParcel(source); } else { stack = StackInfo.CREATOR.createFromParcel(source); } } public static final Creator<StackBoxInfo> CREATOR = new Creator<ActivityManager.StackBoxInfo>() { @Override public StackBoxInfo createFromParcel(Parcel source) { return new StackBoxInfo(source); } @Override public StackBoxInfo[] newArray(int size) { return new StackBoxInfo[size]; } }; public StackBoxInfo() { } public StackBoxInfo(Parcel source) { readFromParcel(source); } public String toString(String prefix) { StringBuilder sb = new StringBuilder(256); sb.append(prefix); sb.append("Box id=" + stackBoxId); sb.append(" weight=" + weight); sb.append(" vertical=" + vertical); sb.append(" bounds=" + bounds.toShortString()); sb.append("\n"); if (children != null) { sb.append(prefix); sb.append("First child=\n"); sb.append(children[0].toString(prefix + " ")); sb.append(prefix); sb.append("Second child=\n"); sb.append(children[1].toString(prefix + " ")); } else { sb.append(prefix); sb.append("Stack=\n"); sb.append(stack.toString(prefix + " ")); } return sb.toString(); } @Override public String toString() { return toString(""); } } /** * Information you can retrieve about an ActivityStack in the system. * @hide */ public static class StackInfo implements Parcelable { public int stackId; public Rect bounds; public Rect bounds = new Rect(); public int[] taskIds; public String[] taskNames; public int displayId; @Override public int describeContents() { Loading @@ -1404,6 +1313,7 @@ public class ActivityManager { dest.writeInt(bounds.bottom); dest.writeIntArray(taskIds); dest.writeStringArray(taskNames); dest.writeInt(displayId); } public void readFromParcel(Parcel source) { Loading @@ -1412,6 +1322,7 @@ public class ActivityManager { source.readInt(), source.readInt(), source.readInt(), source.readInt()); taskIds = source.createIntArray(); taskNames = source.createStringArray(); displayId = source.readInt(); } public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() { Loading @@ -1435,7 +1346,9 @@ public class ActivityManager { public String toString(String prefix) { StringBuilder sb = new StringBuilder(256); sb.append(prefix); sb.append("Stack id="); sb.append(stackId); sb.append(" bounds="); sb.append(bounds.toShortString()); sb.append("\n"); sb.append(" bounds="); sb.append(bounds.toShortString()); sb.append(" displayId="); sb.append(displayId); sb.append("\n"); prefix = prefix + " "; for (int i = 0; i < taskIds.length; ++i) { sb.append(prefix); sb.append("taskId="); sb.append(taskIds[i]); Loading core/java/android/app/ActivityManagerNative.java +68 −48 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package android.app; import android.app.ActivityManager.StackBoxInfo; import android.app.ActivityManager.StackInfo; import android.content.ComponentName; import android.content.IIntentReceiver; import android.content.IIntentSender; Loading @@ -31,6 +31,7 @@ import android.content.pm.ParceledListSlice; import android.content.pm.UserInfo; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Rect; import android.net.Uri; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -611,18 +612,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } case CREATE_STACK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int taskId = data.readInt(); int relativeStackId = data.readInt(); int position = data.readInt(); float weight = data.readFloat(); int res = createStack(taskId, relativeStackId, position, weight); reply.writeNoException(); reply.writeInt(res); return true; } case MOVE_TASK_TO_STACK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int taskId = data.readInt(); Loading @@ -635,25 +624,26 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM case RESIZE_STACK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int stackBoxId = data.readInt(); int stackId = data.readInt(); float weight = data.readFloat(); resizeStackBox(stackBoxId, weight); Rect r = Rect.CREATOR.createFromParcel(data); resizeStack(stackId, r); reply.writeNoException(); return true; } case GET_STACK_BOXES_TRANSACTION: { case GET_ALL_STACK_INFOS_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); List<StackBoxInfo> list = getStackBoxes(); List<StackInfo> list = getAllStackInfos(); reply.writeNoException(); reply.writeTypedList(list); return true; } case GET_STACK_BOX_INFO_TRANSACTION: { case GET_STACK_INFO_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int stackBoxId = data.readInt(); StackBoxInfo info = getStackBoxInfo(stackBoxId); int stackId = data.readInt(); StackInfo info = getStackInfo(stackId); reply.writeNoException(); if (info != null) { reply.writeInt(1); Loading Loading @@ -2028,6 +2018,26 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM reply.writeNoException(); return true; } case CREATE_ACTIVITY_CONTAINER_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder parentActivityToken = data.readStrongBinder(); IActivityContainerCallback callback = (IActivityContainerCallback) data.readStrongBinder(); IActivityContainer activityContainer = createActivityContainer(parentActivityToken, callback); reply.writeNoException(); reply.writeStrongBinder(activityContainer.asBinder()); return true; } case GET_HOME_ACTIVITY_TOKEN_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder homeActivityToken = getHomeActivityToken(); reply.writeNoException(); reply.writeStrongBinder(homeActivityToken); return true; } } return super.onTransact(code, data, reply, flags); Loading Loading @@ -2715,24 +2725,6 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override public int createStack(int taskId, int relativeStackBoxId, int position, float weight) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(taskId); data.writeInt(relativeStackBoxId); data.writeInt(position); data.writeFloat(weight); mRemote.transact(CREATE_STACK_TRANSACTION, data, reply, 0); reply.readException(); int res = reply.readInt(); data.recycle(); reply.recycle(); return res; } @Override public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException { Parcel data = Parcel.obtain(); Loading @@ -2747,44 +2739,44 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override public void resizeStackBox(int stackBoxId, float weight) throws RemoteException public void resizeStack(int stackBoxId, Rect r) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(stackBoxId); data.writeFloat(weight); r.writeToParcel(data, 0); mRemote.transact(RESIZE_STACK_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY); reply.readException(); data.recycle(); reply.recycle(); } @Override public List<StackBoxInfo> getStackBoxes() throws RemoteException public List<StackInfo> getAllStackInfos() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); mRemote.transact(GET_STACK_BOXES_TRANSACTION, data, reply, 0); mRemote.transact(GET_ALL_STACK_INFOS_TRANSACTION, data, reply, 0); reply.readException(); ArrayList<StackBoxInfo> list = reply.createTypedArrayList(StackBoxInfo.CREATOR); ArrayList<StackInfo> list = reply.createTypedArrayList(StackInfo.CREATOR); data.recycle(); reply.recycle(); return list; } @Override public StackBoxInfo getStackBoxInfo(int stackBoxId) throws RemoteException public StackInfo getStackInfo(int stackId) 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); data.writeInt(stackId); mRemote.transact(GET_STACK_INFO_TRANSACTION, data, reply, 0); reply.readException(); int res = reply.readInt(); StackBoxInfo info = null; StackInfo info = null; if (res != 0) { info = StackBoxInfo.CREATOR.createFromParcel(reply); info = StackInfo.CREATOR.createFromParcel(reply); } data.recycle(); reply.recycle(); Loading Loading @@ -4660,5 +4652,33 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } public IActivityContainer createActivityContainer(IBinder parentActivityToken, IActivityContainerCallback callback) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(parentActivityToken); data.writeStrongBinder((IBinder)callback); mRemote.transact(CREATE_ACTIVITY_CONTAINER_TRANSACTION, data, reply, 0); reply.readException(); IActivityContainer res = IActivityContainer.Stub.asInterface(reply.readStrongBinder()); data.recycle(); reply.recycle(); return res; } public IBinder getHomeActivityToken() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); mRemote.transact(GET_HOME_ACTIVITY_TOKEN_TRANSACTION, data, reply, 0); reply.readException(); IBinder res = reply.readStrongBinder(); data.recycle(); reply.recycle(); return res; } private IBinder mRemote; } core/java/android/app/IActivityContainer.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /** * Copyright (c) 2013, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app; import android.app.IActivityContainerCallback; import android.content.Intent; import android.os.IBinder; /** @hide */ interface IActivityContainer { void attachToDisplay(int displayId); int getStackId(); void detachFromDisplay(); void startActivity(in Intent intent); } Loading
Android.mk +2 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,8 @@ LOCAL_SRC_FILES += \ core/java/android/accounts/IAccountManagerResponse.aidl \ core/java/android/accounts/IAccountAuthenticator.aidl \ core/java/android/accounts/IAccountAuthenticatorResponse.aidl \ core/java/android/app/IActivityContainer.aidl \ core/java/android/app/IActivityContainerCallback.aidl \ core/java/android/app/IActivityController.aidl \ core/java/android/app/IActivityPendingResult.aidl \ core/java/android/app/IAlarmManager.aidl \ Loading
cmds/am/src/com/android/commands/am/Am.java +45 −44 Original line number Diff line number Diff line Loading @@ -19,8 +19,9 @@ package com.android.commands.am; import android.app.ActivityManager; import android.app.ActivityManager.StackBoxInfo; import android.app.ActivityManager.StackInfo; import android.app.ActivityManagerNative; import android.app.IActivityContainer; import android.app.IActivityController; import android.app.IActivityManager; import android.app.IInstrumentationWatcher; Loading @@ -31,9 +32,11 @@ import android.content.IIntentReceiver; import android.content.Intent; import android.content.pm.IPackageManager; import android.content.pm.ResolveInfo; import android.graphics.Rect; import android.net.Uri; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.ServiceManager; Loading Loading @@ -106,11 +109,11 @@ public class Am extends BaseCommand { " am to-intent-uri [INTENT]\n" + " am switch-user <USER_ID>\n" + " am stop-user <USER_ID>\n" + " am stack create <TASK_ID> <RELATIVE_STACK_BOX_ID> <POSITION> <WEIGHT>\n" + " am stack create <TASK_ID> <DISPLAY_ID>\n" + " am stack movetask <TASK_ID> <STACK_ID> [true|false]\n" + " am stack resize <STACK_ID> <WEIGHT>\n" + " am stack boxes\n" + " am stack box <STACK_BOX_ID>\n" + " am stack resize <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am stack list\n" + " am stack info <STACK_ID>\n" + "\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + Loading Loading @@ -204,24 +207,16 @@ public class Am extends BaseCommand { "am stop-user: stop execution of USER_ID, not allowing it to run any\n" + " code until a later explicit switch to it.\n" + "\n" + "am stack create: create a new stack relative to an existing one.\n" + " <TASK_ID>: the task to populate the new stack with. Must exist.\n" + " <RELATIVE_STACK_BOX_ID>: existing stack box's id.\n" + " <POSITION>: 0: before <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,\n" + " 1: after <RELATIVE_STACK_BOX_ID>, per RTL/LTR configuration,\n" + " 2: to left of <RELATIVE_STACK_BOX_ID>,\n" + " 3: to right of <RELATIVE_STACK_BOX_ID>," + " 4: above <RELATIVE_STACK_BOX_ID>, 5: below <RELATIVE_STACK_BOX_ID>\n" + " <WEIGHT>: float between 0.2 and 0.8 inclusive.\n" + "am stack create: create a new stack containing <TASK_ID> which must exist\n" + "\n" + "am stack movetask: move <TASK_ID> from its current stack to the top (true) or" + " bottom (false) of <STACK_ID>.\n" + "\n" + "am stack resize: change <STACK_ID> relative size to new <WEIGHT>.\n" + "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>.\n" + "\n" + "am stack boxes: list the hierarchy of stack boxes and their contents.\n" + "am stack list: list all of the activity stacks and their sizes.\n" + "\n" + "am stack box: list the hierarchy of stack boxes rooted at <STACK_BOX_ID>.\n" + "am stack info: display the information about activity stack <STACK_ID>.\n" + "\n" + "<INTENT> specifications include these flags and arguments:\n" + " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" + Loading Loading @@ -1551,11 +1546,11 @@ public class Am extends BaseCommand { } else if (op.equals("movetask")) { runStackMoveTask(); } else if (op.equals("resize")) { runStackBoxResize(); } else if (op.equals("boxes")) { runStackBoxes(); } else if (op.equals("box")) { runStackBoxInfo(); runStackResize(); } else if (op.equals("list")) { runStackList(); } else if (op.equals("info")) { runStackInfo(); } else { showError("Error: unknown command '" + op + "'"); return; Loading @@ -1565,16 +1560,16 @@ public class Am extends BaseCommand { private void runStackCreate() throws Exception { String taskIdStr = nextArgRequired(); int taskId = Integer.valueOf(taskIdStr); String relativeToStr = nextArgRequired(); int relativeTo = Integer.valueOf(relativeToStr); String positionStr = nextArgRequired(); int position = Integer.valueOf(positionStr); String weightStr = nextArgRequired(); float weight = Float.valueOf(weightStr); String displayIdStr = nextArgRequired(); int displayId = Integer.valueOf(displayIdStr); try { int stackId = mAm.createStack(taskId, relativeTo, position, weight); System.out.println("createStack returned new stackId=" + stackId + "\n\n"); IBinder homeActivityToken = mAm.getHomeActivityToken(); IActivityContainer container = mAm.createActivityContainer(homeActivityToken, null); final int stackId = container.getStackId(); System.out.println("createStack returned new stackId=" + stackId + "\n"); container.attachToDisplay(displayId); mAm.moveTaskToStack(taskId, stackId, true); } catch (RemoteException e) { } } Loading @@ -1601,34 +1596,40 @@ public class Am extends BaseCommand { } } private void runStackBoxResize() throws Exception { String stackBoxIdStr = nextArgRequired(); int stackBoxId = Integer.valueOf(stackBoxIdStr); String weightStr = nextArgRequired(); float weight = Float.valueOf(weightStr); 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); try { mAm.resizeStackBox(stackBoxId, weight); mAm.resizeStack(stackId, new Rect(left, top, right, bottom)); } catch (RemoteException e) { } } private void runStackBoxes() throws Exception { private void runStackList() throws Exception { try { List<StackBoxInfo> stackBoxes = mAm.getStackBoxes(); for (StackBoxInfo info : stackBoxes) { List<StackInfo> stacks = mAm.getAllStackInfos(); for (StackInfo info : stacks) { System.out.println(info); } } catch (RemoteException e) { } } private void runStackBoxInfo() throws Exception { private void runStackInfo() throws Exception { try { String stackBoxIdStr = nextArgRequired(); int stackBoxId = Integer.valueOf(stackBoxIdStr); StackBoxInfo stackBoxInfo = mAm.getStackBoxInfo(stackBoxId); System.out.println(stackBoxInfo); String stackIdStr = nextArgRequired(); int stackId = Integer.valueOf(stackIdStr); StackInfo info = mAm.getStackInfo(stackId); System.out.println(info); } catch (RemoteException e) { } } Loading
core/java/android/app/ActivityManager.java +7 −94 Original line number Diff line number Diff line Loading @@ -1288,107 +1288,16 @@ public class ActivityManager { } } /** * Information you can retrieve about the WindowManager StackBox hierarchy. * @hide */ public static class StackBoxInfo implements Parcelable { public int stackBoxId; public float weight; public boolean vertical; public Rect bounds; public StackBoxInfo[] children; public int stackId; public StackInfo stack; @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(stackBoxId); dest.writeFloat(weight); dest.writeInt(vertical ? 1 : 0); bounds.writeToParcel(dest, flags); dest.writeInt(stackId); if (children != null) { children[0].writeToParcel(dest, flags); children[1].writeToParcel(dest, flags); } else { stack.writeToParcel(dest, flags); } } public void readFromParcel(Parcel source) { stackBoxId = source.readInt(); weight = source.readFloat(); vertical = source.readInt() == 1; bounds = Rect.CREATOR.createFromParcel(source); stackId = source.readInt(); if (stackId == -1) { children = new StackBoxInfo[2]; children[0] = StackBoxInfo.CREATOR.createFromParcel(source); children[1] = StackBoxInfo.CREATOR.createFromParcel(source); } else { stack = StackInfo.CREATOR.createFromParcel(source); } } public static final Creator<StackBoxInfo> CREATOR = new Creator<ActivityManager.StackBoxInfo>() { @Override public StackBoxInfo createFromParcel(Parcel source) { return new StackBoxInfo(source); } @Override public StackBoxInfo[] newArray(int size) { return new StackBoxInfo[size]; } }; public StackBoxInfo() { } public StackBoxInfo(Parcel source) { readFromParcel(source); } public String toString(String prefix) { StringBuilder sb = new StringBuilder(256); sb.append(prefix); sb.append("Box id=" + stackBoxId); sb.append(" weight=" + weight); sb.append(" vertical=" + vertical); sb.append(" bounds=" + bounds.toShortString()); sb.append("\n"); if (children != null) { sb.append(prefix); sb.append("First child=\n"); sb.append(children[0].toString(prefix + " ")); sb.append(prefix); sb.append("Second child=\n"); sb.append(children[1].toString(prefix + " ")); } else { sb.append(prefix); sb.append("Stack=\n"); sb.append(stack.toString(prefix + " ")); } return sb.toString(); } @Override public String toString() { return toString(""); } } /** * Information you can retrieve about an ActivityStack in the system. * @hide */ public static class StackInfo implements Parcelable { public int stackId; public Rect bounds; public Rect bounds = new Rect(); public int[] taskIds; public String[] taskNames; public int displayId; @Override public int describeContents() { Loading @@ -1404,6 +1313,7 @@ public class ActivityManager { dest.writeInt(bounds.bottom); dest.writeIntArray(taskIds); dest.writeStringArray(taskNames); dest.writeInt(displayId); } public void readFromParcel(Parcel source) { Loading @@ -1412,6 +1322,7 @@ public class ActivityManager { source.readInt(), source.readInt(), source.readInt(), source.readInt()); taskIds = source.createIntArray(); taskNames = source.createStringArray(); displayId = source.readInt(); } public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() { Loading @@ -1435,7 +1346,9 @@ public class ActivityManager { public String toString(String prefix) { StringBuilder sb = new StringBuilder(256); sb.append(prefix); sb.append("Stack id="); sb.append(stackId); sb.append(" bounds="); sb.append(bounds.toShortString()); sb.append("\n"); sb.append(" bounds="); sb.append(bounds.toShortString()); sb.append(" displayId="); sb.append(displayId); sb.append("\n"); prefix = prefix + " "; for (int i = 0; i < taskIds.length; ++i) { sb.append(prefix); sb.append("taskId="); sb.append(taskIds[i]); Loading
core/java/android/app/ActivityManagerNative.java +68 −48 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package android.app; import android.app.ActivityManager.StackBoxInfo; import android.app.ActivityManager.StackInfo; import android.content.ComponentName; import android.content.IIntentReceiver; import android.content.IIntentSender; Loading @@ -31,6 +31,7 @@ import android.content.pm.ParceledListSlice; import android.content.pm.UserInfo; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Rect; import android.net.Uri; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -611,18 +612,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } case CREATE_STACK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int taskId = data.readInt(); int relativeStackId = data.readInt(); int position = data.readInt(); float weight = data.readFloat(); int res = createStack(taskId, relativeStackId, position, weight); reply.writeNoException(); reply.writeInt(res); return true; } case MOVE_TASK_TO_STACK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int taskId = data.readInt(); Loading @@ -635,25 +624,26 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM case RESIZE_STACK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int stackBoxId = data.readInt(); int stackId = data.readInt(); float weight = data.readFloat(); resizeStackBox(stackBoxId, weight); Rect r = Rect.CREATOR.createFromParcel(data); resizeStack(stackId, r); reply.writeNoException(); return true; } case GET_STACK_BOXES_TRANSACTION: { case GET_ALL_STACK_INFOS_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); List<StackBoxInfo> list = getStackBoxes(); List<StackInfo> list = getAllStackInfos(); reply.writeNoException(); reply.writeTypedList(list); return true; } case GET_STACK_BOX_INFO_TRANSACTION: { case GET_STACK_INFO_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int stackBoxId = data.readInt(); StackBoxInfo info = getStackBoxInfo(stackBoxId); int stackId = data.readInt(); StackInfo info = getStackInfo(stackId); reply.writeNoException(); if (info != null) { reply.writeInt(1); Loading Loading @@ -2028,6 +2018,26 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM reply.writeNoException(); return true; } case CREATE_ACTIVITY_CONTAINER_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder parentActivityToken = data.readStrongBinder(); IActivityContainerCallback callback = (IActivityContainerCallback) data.readStrongBinder(); IActivityContainer activityContainer = createActivityContainer(parentActivityToken, callback); reply.writeNoException(); reply.writeStrongBinder(activityContainer.asBinder()); return true; } case GET_HOME_ACTIVITY_TOKEN_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IBinder homeActivityToken = getHomeActivityToken(); reply.writeNoException(); reply.writeStrongBinder(homeActivityToken); return true; } } return super.onTransact(code, data, reply, flags); Loading Loading @@ -2715,24 +2725,6 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override public int createStack(int taskId, int relativeStackBoxId, int position, float weight) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(taskId); data.writeInt(relativeStackBoxId); data.writeInt(position); data.writeFloat(weight); mRemote.transact(CREATE_STACK_TRANSACTION, data, reply, 0); reply.readException(); int res = reply.readInt(); data.recycle(); reply.recycle(); return res; } @Override public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException { Parcel data = Parcel.obtain(); Loading @@ -2747,44 +2739,44 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override public void resizeStackBox(int stackBoxId, float weight) throws RemoteException public void resizeStack(int stackBoxId, Rect r) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(stackBoxId); data.writeFloat(weight); r.writeToParcel(data, 0); mRemote.transact(RESIZE_STACK_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY); reply.readException(); data.recycle(); reply.recycle(); } @Override public List<StackBoxInfo> getStackBoxes() throws RemoteException public List<StackInfo> getAllStackInfos() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); mRemote.transact(GET_STACK_BOXES_TRANSACTION, data, reply, 0); mRemote.transact(GET_ALL_STACK_INFOS_TRANSACTION, data, reply, 0); reply.readException(); ArrayList<StackBoxInfo> list = reply.createTypedArrayList(StackBoxInfo.CREATOR); ArrayList<StackInfo> list = reply.createTypedArrayList(StackInfo.CREATOR); data.recycle(); reply.recycle(); return list; } @Override public StackBoxInfo getStackBoxInfo(int stackBoxId) throws RemoteException public StackInfo getStackInfo(int stackId) 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); data.writeInt(stackId); mRemote.transact(GET_STACK_INFO_TRANSACTION, data, reply, 0); reply.readException(); int res = reply.readInt(); StackBoxInfo info = null; StackInfo info = null; if (res != 0) { info = StackBoxInfo.CREATOR.createFromParcel(reply); info = StackInfo.CREATOR.createFromParcel(reply); } data.recycle(); reply.recycle(); Loading Loading @@ -4660,5 +4652,33 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } public IActivityContainer createActivityContainer(IBinder parentActivityToken, IActivityContainerCallback callback) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(parentActivityToken); data.writeStrongBinder((IBinder)callback); mRemote.transact(CREATE_ACTIVITY_CONTAINER_TRANSACTION, data, reply, 0); reply.readException(); IActivityContainer res = IActivityContainer.Stub.asInterface(reply.readStrongBinder()); data.recycle(); reply.recycle(); return res; } public IBinder getHomeActivityToken() throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); mRemote.transact(GET_HOME_ACTIVITY_TOKEN_TRANSACTION, data, reply, 0); reply.readException(); IBinder res = reply.readStrongBinder(); data.recycle(); reply.recycle(); return res; } private IBinder mRemote; }
core/java/android/app/IActivityContainer.aidl 0 → 100644 +29 −0 Original line number Diff line number Diff line /** * Copyright (c) 2013, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.app; import android.app.IActivityContainerCallback; import android.content.Intent; import android.os.IBinder; /** @hide */ interface IActivityContainer { void attachToDisplay(int displayId); int getStackId(); void detachFromDisplay(); void startActivity(in Intent intent); }