Loading cmds/am/src/com/android/commands/am/Am.java +58 −28 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ public class Am extends BaseCommand { " am task lock <TASK_ID>\n" + " am task lock stop\n" + " am task resizeable <TASK_ID> [true|false]\n" + " am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am get-config\n" + "\n" + "am start: start an Activity. Options are:\n" + Loading Loading @@ -249,11 +250,11 @@ public class Am extends BaseCommand { "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>" + ".\n" + "\n" + "am stack split: split <STACK_ID> into 2 stacks <v>ertically or <h>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 <STACK_ID> into 2 stacks <v>ertically or <h>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" + Loading @@ -265,6 +266,10 @@ public class Am extends BaseCommand { "\n" + "am task resizeable: change if <TASK_ID> is resizeable (true) or not (false).\n" + "\n" + "am task resize: makes sure <TASK_ID> 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" + Loading Loading @@ -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) { } } Loading Loading @@ -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; Loading Loading @@ -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<Configuration> getRecentConfigurations(int days) { IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService( Context.USAGE_STATS_SERVICE)); Loading Loading @@ -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); } } core/java/android/app/ActivityManagerNative.java +23 −0 Original line number Diff line number Diff line Loading @@ -2313,6 +2313,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } case RESIZE_TASK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int taskId = data.readInt(); Rect r = Rect.CREATOR.createFromParcel(data); resizeTask(taskId, r); reply.writeNoException(); return true; } case GET_TASK_DESCRIPTION_ICON_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); String filename = data.readString(); Loading Loading @@ -5437,6 +5446,20 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override public void resizeTask(int taskId, Rect r) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(taskId); r.writeToParcel(data, 0); mRemote.transact(RESIZE_TASK_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY); reply.readException(); data.recycle(); reply.recycle(); } @Override public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException { Parcel data = Parcel.obtain(); Loading core/java/android/app/IActivityManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -464,6 +464,7 @@ public interface IActivityManager extends IInterface { public void setTaskDescription(IBinder token, ActivityManager.TaskDescription values) throws RemoteException; public void setTaskResizeable(int taskId, boolean resizeable) throws RemoteException; public void resizeTask(int taskId, Rect bounds) throws RemoteException; public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException; public void startInPlaceAnimationOnFrontMostApplication(ActivityOptions opts) Loading Loading @@ -808,4 +809,5 @@ public interface IActivityManager extends IInterface { int GET_FOCUSED_STACK_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+282; int SET_TASK_RESIZEABLE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+283; int REQUEST_ASSIST_CONTEXT_EXTRAS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+284; int RESIZE_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+285; } services/core/java/com/android/server/am/ActivityManagerService.java +19 −0 Original line number Diff line number Diff line Loading @@ -7908,6 +7908,25 @@ public final class ActivityManagerService extends ActivityManagerNative } } @Override public void resizeTask(int taskId, Rect bounds) { enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS, "resizeTask()"); long ident = Binder.clearCallingIdentity(); try { synchronized (this) { TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId, true); if (task == null) { Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found"); return; } mStackSupervisor.resizeTaskLocked(task, bounds); } } finally { Binder.restoreCallingIdentity(ident); } } @Override public Bitmap getTaskDescriptionIcon(String filename) { if (!FileUtils.isValidExtFilename(filename) Loading services/core/java/com/android/server/am/ActivityStack.java +15 −5 Original line number Diff line number Diff line Loading @@ -152,25 +152,25 @@ final class ActivityStack { * The back history of all previous (and possibly still * running) activities. It contains #TaskRecord objects. */ private ArrayList<TaskRecord> mTaskHistory = new ArrayList<TaskRecord>(); private ArrayList<TaskRecord> mTaskHistory = new ArrayList<>(); /** * Used for validating app tokens with window manager. */ final ArrayList<TaskGroup> mValidateAppTokens = new ArrayList<TaskGroup>(); final ArrayList<TaskGroup> mValidateAppTokens = new ArrayList<>(); /** * List of running activities, sorted by recent usage. * The first entry in the list is the least recently used. * It contains HistoryRecord objects. */ final ArrayList<ActivityRecord> mLRUActivities = new ArrayList<ActivityRecord>(); final ArrayList<ActivityRecord> mLRUActivities = new ArrayList<>(); /** * Animations that for the current transition have requested not to * be considered for the transition animation. */ final ArrayList<ActivityRecord> mNoAnimActivities = new ArrayList<ActivityRecord>(); final ArrayList<ActivityRecord> mNoAnimActivities = new ArrayList<>(); /** * When we are in the process of pausing an activity, before starting the Loading Loading @@ -346,6 +346,10 @@ final class ActivityStack { return count; } int numTasks() { return mTaskHistory.size(); } ActivityStack(ActivityStackSupervisor.ActivityContainer activityContainer, RecentTasks recentTasks) { mActivityContainer = activityContainer; Loading Loading @@ -4177,8 +4181,14 @@ final class ActivityStack { } void removeTask(TaskRecord task, String reason) { removeTask(task, reason, true); } void removeTask(TaskRecord task, String reason, boolean removeFromWindowManager) { mStackSupervisor.endLockTaskModeIfTaskEnding(task); if (removeFromWindowManager) { mWindowManager.removeTask(task.taskId); } final ActivityRecord r = mResumedActivity; if (r != null && r.task == task) { mResumedActivity = null; Loading Loading
cmds/am/src/com/android/commands/am/Am.java +58 −28 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ public class Am extends BaseCommand { " am task lock <TASK_ID>\n" + " am task lock stop\n" + " am task resizeable <TASK_ID> [true|false]\n" + " am task resize <TASK_ID> <LEFT,TOP,RIGHT,BOTTOM>\n" + " am get-config\n" + "\n" + "am start: start an Activity. Options are:\n" + Loading Loading @@ -249,11 +250,11 @@ public class Am extends BaseCommand { "am stack resize: change <STACK_ID> size and position to <LEFT,TOP,RIGHT,BOTTOM>" + ".\n" + "\n" + "am stack split: split <STACK_ID> into 2 stacks <v>ertically or <h>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 <STACK_ID> into 2 stacks <v>ertically or <h>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" + Loading @@ -265,6 +266,10 @@ public class Am extends BaseCommand { "\n" + "am task resizeable: change if <TASK_ID> is resizeable (true) or not (false).\n" + "\n" + "am task resize: makes sure <TASK_ID> 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" + Loading Loading @@ -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) { } } Loading Loading @@ -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; Loading Loading @@ -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<Configuration> getRecentConfigurations(int days) { IUsageStatsManager usm = IUsageStatsManager.Stub.asInterface(ServiceManager.getService( Context.USAGE_STATS_SERVICE)); Loading Loading @@ -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); } }
core/java/android/app/ActivityManagerNative.java +23 −0 Original line number Diff line number Diff line Loading @@ -2313,6 +2313,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } case RESIZE_TASK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int taskId = data.readInt(); Rect r = Rect.CREATOR.createFromParcel(data); resizeTask(taskId, r); reply.writeNoException(); return true; } case GET_TASK_DESCRIPTION_ICON_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); String filename = data.readString(); Loading Loading @@ -5437,6 +5446,20 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override public void resizeTask(int taskId, Rect r) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(taskId); r.writeToParcel(data, 0); mRemote.transact(RESIZE_TASK_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY); reply.readException(); data.recycle(); reply.recycle(); } @Override public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException { Parcel data = Parcel.obtain(); Loading
core/java/android/app/IActivityManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -464,6 +464,7 @@ public interface IActivityManager extends IInterface { public void setTaskDescription(IBinder token, ActivityManager.TaskDescription values) throws RemoteException; public void setTaskResizeable(int taskId, boolean resizeable) throws RemoteException; public void resizeTask(int taskId, Rect bounds) throws RemoteException; public Bitmap getTaskDescriptionIcon(String filename) throws RemoteException; public void startInPlaceAnimationOnFrontMostApplication(ActivityOptions opts) Loading Loading @@ -808,4 +809,5 @@ public interface IActivityManager extends IInterface { int GET_FOCUSED_STACK_ID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+282; int SET_TASK_RESIZEABLE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+283; int REQUEST_ASSIST_CONTEXT_EXTRAS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+284; int RESIZE_TASK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+285; }
services/core/java/com/android/server/am/ActivityManagerService.java +19 −0 Original line number Diff line number Diff line Loading @@ -7908,6 +7908,25 @@ public final class ActivityManagerService extends ActivityManagerNative } } @Override public void resizeTask(int taskId, Rect bounds) { enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS, "resizeTask()"); long ident = Binder.clearCallingIdentity(); try { synchronized (this) { TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId, true); if (task == null) { Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found"); return; } mStackSupervisor.resizeTaskLocked(task, bounds); } } finally { Binder.restoreCallingIdentity(ident); } } @Override public Bitmap getTaskDescriptionIcon(String filename) { if (!FileUtils.isValidExtFilename(filename) Loading
services/core/java/com/android/server/am/ActivityStack.java +15 −5 Original line number Diff line number Diff line Loading @@ -152,25 +152,25 @@ final class ActivityStack { * The back history of all previous (and possibly still * running) activities. It contains #TaskRecord objects. */ private ArrayList<TaskRecord> mTaskHistory = new ArrayList<TaskRecord>(); private ArrayList<TaskRecord> mTaskHistory = new ArrayList<>(); /** * Used for validating app tokens with window manager. */ final ArrayList<TaskGroup> mValidateAppTokens = new ArrayList<TaskGroup>(); final ArrayList<TaskGroup> mValidateAppTokens = new ArrayList<>(); /** * List of running activities, sorted by recent usage. * The first entry in the list is the least recently used. * It contains HistoryRecord objects. */ final ArrayList<ActivityRecord> mLRUActivities = new ArrayList<ActivityRecord>(); final ArrayList<ActivityRecord> mLRUActivities = new ArrayList<>(); /** * Animations that for the current transition have requested not to * be considered for the transition animation. */ final ArrayList<ActivityRecord> mNoAnimActivities = new ArrayList<ActivityRecord>(); final ArrayList<ActivityRecord> mNoAnimActivities = new ArrayList<>(); /** * When we are in the process of pausing an activity, before starting the Loading Loading @@ -346,6 +346,10 @@ final class ActivityStack { return count; } int numTasks() { return mTaskHistory.size(); } ActivityStack(ActivityStackSupervisor.ActivityContainer activityContainer, RecentTasks recentTasks) { mActivityContainer = activityContainer; Loading Loading @@ -4177,8 +4181,14 @@ final class ActivityStack { } void removeTask(TaskRecord task, String reason) { removeTask(task, reason, true); } void removeTask(TaskRecord task, String reason, boolean removeFromWindowManager) { mStackSupervisor.endLockTaskModeIfTaskEnding(task); if (removeFromWindowManager) { mWindowManager.removeTask(task.taskId); } final ActivityRecord r = mResumedActivity; if (r != null && r.task == task) { mResumedActivity = null; Loading