diff options
7 files changed, 100 insertions, 123 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index 4055832..afedd42 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -1485,7 +1485,7 @@ public class Am extends BaseCommand { } else if (op.equals("movetask")) { runStackMoveTask(); } else if (op.equals("resize")) { - runStackResize(); + runStackBoxResize(); } else if (op.equals("boxes")) { runStackBoxes(); } else { @@ -1533,14 +1533,14 @@ public class Am extends BaseCommand { } } - private void runStackResize() throws Exception { - String stackIdStr = nextArgRequired(); - int stackId = Integer.valueOf(stackIdStr); + private void runStackBoxResize() throws Exception { + String stackBoxIdStr = nextArgRequired(); + int stackBoxId = Integer.valueOf(stackBoxIdStr); String weightStr = nextArgRequired(); float weight = Float.valueOf(weightStr); try { - mAm.resizeStack(stackId, weight); + mAm.resizeStackBox(stackBoxId, weight); } catch (RemoteException e) { } } diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 84f2c46..aff6244 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -17,7 +17,6 @@ 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; @@ -634,21 +633,13 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM case RESIZE_STACK_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); - int stackId = data.readInt(); + int stackBoxId = data.readInt(); float weight = data.readFloat(); - resizeStack(stackId, weight); + resizeStackBox(stackBoxId, weight); reply.writeNoException(); return true; } - case GET_STACKS_TRANSACTION: { - data.enforceInterface(IActivityManager.descriptor); - List<ActivityManager.StackInfo> list = getStacks(); - reply.writeNoException(); - reply.writeTypedList(list); - return true; - } - case GET_STACK_BOXES_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); List<StackBoxInfo> list = getStackBoxes(); @@ -2622,14 +2613,14 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override - public int createStack(int taskId, int relativeStackId, int position, float weight) + 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(relativeStackId); + data.writeInt(relativeStackBoxId); data.writeInt(position); data.writeFloat(weight); mRemote.transact(CREATE_STACK_TRANSACTION, data, reply, 0); @@ -2654,12 +2645,12 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override - public void resizeStack(int stackId, float weight) throws RemoteException + public void resizeStackBox(int stackBoxId, float weight) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); - data.writeInt(stackId); + data.writeInt(stackBoxId); data.writeFloat(weight); mRemote.transact(RESIZE_STACK_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY); reply.readException(); @@ -2667,19 +2658,6 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } @Override - public List<StackInfo> getStacks() throws RemoteException - { - Parcel data = Parcel.obtain(); - Parcel reply = Parcel.obtain(); - data.writeInterfaceToken(IActivityManager.descriptor); - mRemote.transact(GET_STACKS_TRANSACTION, data, reply, 0); - reply.readException(); - ArrayList<StackInfo> list = reply.createTypedArrayList(StackInfo.CREATOR); - data.recycle(); - reply.recycle(); - return list; - } - @Override public List<StackBoxInfo> getStackBoxes() throws RemoteException { Parcel data = Parcel.obtain(); diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 61b81cf..4baf828 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -19,7 +19,6 @@ package android.app; import android.app.ActivityManager.RunningTaskInfo; import android.app.ActivityManager.RunningServiceInfo; import android.app.ActivityManager.StackBoxInfo; -import android.app.ActivityManager.StackInfo; import android.content.ComponentName; import android.content.ContentProviderNative; import android.content.IContentProvider; @@ -116,12 +115,11 @@ public interface IActivityManager extends IInterface { public void moveTaskToBack(int task) throws RemoteException; public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) throws RemoteException; public void moveTaskBackwards(int task) throws RemoteException; - public int createStack(int taskId, int relativeStackId, int position, float weight) + public int createStack(int taskId, int relativeStackBoxId, int position, float weight) throws RemoteException; public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException; - public void resizeStack(int stackId, float weight) throws RemoteException; + public void resizeStackBox(int stackBoxId, float weight) throws RemoteException; public List<StackBoxInfo> getStackBoxes() throws RemoteException; - public List<StackInfo> getStacks() throws RemoteException; public void setFocusedStack(int stackId) throws RemoteException; public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException; /* oneway */ @@ -663,7 +661,6 @@ public interface IActivityManager extends IInterface { int CREATE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+167; int MOVE_TASK_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+168; int RESIZE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+169; - int GET_STACKS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+170; + int GET_STACK_BOXES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+170; int SET_FOCUSED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+171; - int GET_STACK_BOXES_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 603a6ed..ac723dd 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -4205,7 +4205,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (knownApp != null && knownApp.thread == null) { mPidsSelfLocked.remove(pid); gone = true; - } + } } if (gone) { @@ -4300,7 +4300,7 @@ public final class ActivityManagerService extends ActivityManagerNative } EventLog.writeEvent(EventLogTags.AM_PROC_BOUND, app.userId, app.pid, app.processName); - + app.thread = thread; app.curAdj = app.setAdj = -100; app.curSchedGroup = Process.THREAD_GROUP_DEFAULT; @@ -4318,7 +4318,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (!normalMode) { Slog.i(TAG, "Launching preboot mode app: " + app); } - + if (localLOGV) Slog.v( TAG, "New app record " + app + " thread=" + thread.asBinder() + " pid=" + pid); @@ -4356,7 +4356,7 @@ public final class ActivityManagerService extends ActivityManagerNative || (mBackupTarget.backupMode == BackupRecord.RESTORE_FULL) || (mBackupTarget.backupMode == BackupRecord.BACKUP_FULL); } - + ensurePackageDexOpt(app.instrumentationInfo != null ? app.instrumentationInfo.packageName : app.info.packageName); @@ -5687,6 +5687,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } + @Override public void revokeUriPermission(IApplicationThread caller, Uri uri, int modeFlags) { enforceNotIsolatedCaller("revokeUriPermission"); @@ -5919,6 +5920,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } + @Override public void showWaitingForDebugger(IApplicationThread who, boolean waiting) { synchronized (this) { ProcessRecord app = @@ -5933,6 +5935,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } + @Override public void getMemoryInfo(ActivityManager.MemoryInfo outInfo) { final long homeAppMem = mProcessList.getMemLevel(ProcessList.HOME_APP_ADJ); final long hiddenAppMem = mProcessList.getMemLevel(ProcessList.HIDDEN_APP_MIN_ADJ); @@ -6319,17 +6322,12 @@ public final class ActivityManagerService extends ActivityManagerNative } @Override - public int createStack(int taskId, int relativeStackId, int position, float weight) { - if (DEBUG_STACK) Slog.d(TAG, "createStack: taskId=" + taskId + " relStackId=" + - relativeStackId + " position=" + position + " weight=" + weight); + public int createStack(int taskId, int relativeStackBoxId, int position, float weight) { + if (DEBUG_STACK) Slog.d(TAG, "createStack: taskId=" + taskId + " relStackBoxId=" + + relativeStackBoxId + " position=" + position + " weight=" + weight); synchronized (this) { - if (mStackSupervisor.getStack(relativeStackId) == null) { - if (DEBUG_STACK) Slog.d(TAG, "createStack: invalide relativeStackId=" + - relativeStackId); - return -1; - } int stackId = mStackSupervisor.createStack(); - mWindowManager.createStack(stackId, relativeStackId, position, weight); + mWindowManager.createStack(stackId, relativeStackBoxId, position, weight); if (taskId > 0) { moveTaskToStack(taskId, stackId, true); } @@ -6349,12 +6347,11 @@ public final class ActivityManagerService extends ActivityManagerNative } @Override - public void resizeStack(int stackId, float weight) { - mWindowManager.resizeStack(stackId, weight); + public void resizeStackBox(int stackBoxId, float weight) { + mWindowManager.resizeStackBox(stackBoxId, weight); } - @Override - public List<StackInfo> getStacks() { + private ArrayList<StackInfo> getStacks() { synchronized (this) { ArrayList<ActivityManager.StackInfo> list = new ArrayList<ActivityManager.StackInfo>(); ArrayList<ActivityStack> stacks = mStackSupervisor.getStacks(); diff --git a/services/java/com/android/server/wm/DisplayContent.java b/services/java/com/android/server/wm/DisplayContent.java index 8ad2ef1..0647296 100644 --- a/services/java/com/android/server/wm/DisplayContent.java +++ b/services/java/com/android/server/wm/DisplayContent.java @@ -203,11 +203,11 @@ class DisplayContent { } /** Refer to {@link WindowManagerService#createStack(int, int, int, float)} */ - TaskStack createStack(WindowManagerService service, int stackId, int relativeStackId, + TaskStack createStack(WindowManagerService service, int stackId, int relativeStackBoxId, int position, float weight) { TaskStack newStack = null; - if (DEBUG_STACK) Slog.d(TAG, "createStack: stackId=" + stackId + " relativeStackId=" - + relativeStackId + " position=" + position + " weight=" + weight); + if (DEBUG_STACK) Slog.d(TAG, "createStack: stackId=" + stackId + " relativeStackBoxId=" + + relativeStackBoxId + " position=" + position + " weight=" + weight); if (mStackBoxes.isEmpty()) { if (stackId != HOME_STACK_ID) { throw new IllegalArgumentException("createStack: First stackId not " @@ -226,7 +226,7 @@ class DisplayContent { if (position == StackBox.TASK_STACK_GOES_OVER || position == StackBox.TASK_STACK_GOES_UNDER) { // Position indicates a new box is added at top level only. - if (box.contains(relativeStackId)) { + if (box.contains(relativeStackBoxId)) { StackBox newBox = new StackBox(service, this, null); newStack = new TaskStack(service, stackId, this); newStack.mStackBox = newBox; @@ -239,14 +239,14 @@ class DisplayContent { } } else { // Remaining position values indicate a box must be split. - newStack = box.split(stackId, relativeStackId, position, weight); + newStack = box.split(stackId, relativeStackBoxId, position, weight); if (newStack != null) { break; } } } if (stackBoxNdx < 0) { - throw new IllegalArgumentException("createStack: stackId " + relativeStackId + throw new IllegalArgumentException("createStack: stackBoxId " + relativeStackBoxId + " not found."); } } @@ -256,11 +256,12 @@ class DisplayContent { return newStack; } - /** Refer to {@link WindowManagerService#resizeStack(int, float)} */ - boolean resizeStack(int stackId, float weight) { + /** Refer to {@link WindowManagerService#resizeStackBox(int, float)} */ + boolean resizeStack(int stackBoxId, float weight) { for (int stackBoxNdx = mStackBoxes.size() - 1; stackBoxNdx >= 0; --stackBoxNdx) { final StackBox box = mStackBoxes.get(stackBoxNdx); - if (box.resize(stackId, weight)) { + if (box.resize(stackBoxId, weight)) { + layoutNeeded = true; return true; } } diff --git a/services/java/com/android/server/wm/StackBox.java b/services/java/com/android/server/wm/StackBox.java index e2fd105..15f5dff 100644 --- a/services/java/com/android/server/wm/StackBox.java +++ b/services/java/com/android/server/wm/StackBox.java @@ -26,18 +26,22 @@ import static com.android.server.wm.WindowManagerService.TAG; import java.io.PrintWriter; public class StackBox { - /** Used with {@link WindowManagerService#createStack}. To left of, lower l/r Rect values. */ + /** Used with {@link WindowManagerService#createStack}. Dependent on Configuration LTR/RTL. */ public static final int TASK_STACK_GOES_BEFORE = 0; - /** Used with {@link WindowManagerService#createStack}. To right of, higher l/r Rect values. */ + /** Used with {@link WindowManagerService#createStack}. Dependent on Configuration LTR/RTL. */ public static final int TASK_STACK_GOES_AFTER = 1; + /** Used with {@link WindowManagerService#createStack}. Horizontal to left of. */ + public static final int TASK_STACK_TO_LEFT_OF = 2; + /** Used with {@link WindowManagerService#createStack}. Horizontal to right of. */ + public static final int TASK_STACK_TO_RIGHT_OF = 3; /** Used with {@link WindowManagerService#createStack}. Vertical: lower t/b Rect values. */ - public static final int TASK_STACK_GOES_ABOVE = 2; + public static final int TASK_STACK_GOES_ABOVE = 4; /** Used with {@link WindowManagerService#createStack}. Vertical: higher t/b Rect values. */ - public static final int TASK_STACK_GOES_BELOW = 3; + public static final int TASK_STACK_GOES_BELOW = 5; /** Used with {@link WindowManagerService#createStack}. Put on a higher layer on display. */ - public static final int TASK_STACK_GOES_OVER = 4; + public static final int TASK_STACK_GOES_OVER = 6; /** Used with {@link WindowManagerService#createStack}. Put on a lower layer on display. */ - public static final int TASK_STACK_GOES_UNDER = 5; + public static final int TASK_STACK_GOES_UNDER = 7; static int sCurrentBoxId = 0; @@ -97,15 +101,13 @@ public class StackBox { } /** - * Determine if a particular TaskStack is in this StackBox or any of its descendants. - * @param stackId The TaskStack being considered. - * @return true if the specified TaskStack is in this box or its descendants. False otherwise. + * Determine if a particular StackBox is this one or a descendant of this one. + * @param stackBoxId The StackBox being searched for. + * @return true if the specified StackBox matches this or one of its descendants. */ - boolean contains(int stackId) { - if (mStack != null) { - return mStack.mStackId == stackId; - } - return mFirst.contains(stackId) || mSecond.contains(stackId); + boolean contains(int stackBoxId) { + return mStackBoxId == stackBoxId || mFirst.contains(stackBoxId) + || mSecond.contains(stackBoxId); } /** @@ -155,37 +157,42 @@ public class StackBox { * the specified TaskStack into two children. The size and position each of the new StackBoxes * is determined by the passed parameters. * @param stackId The id of the new TaskStack to create. - * @param relativeStackId The id of the TaskStack to place the new one next to. + * @param relativeStackBoxId The id of the StackBox to place the new TaskStack next to. * @param position One of the static TASK_STACK_GOES_xxx positions defined in this class. * @param weight The percentage size of the parent StackBox to devote to the new TaskStack. * @return The new TaskStack. */ - TaskStack split(int stackId, int relativeStackId, int position, float weight) { - if (mStack == null) { - // Propagate the split to see if the target task stack is in either sub box. - TaskStack stack = mFirst.split(stackId, relativeStackId, position, weight); + TaskStack split(int stackId, int relativeStackBoxId, int position, float weight) { + if (mStackBoxId != relativeStackBoxId) { + // This is not the targeted StackBox. + if (mStack != null) { + return null; + } + // Propagate the split to see if the targeted StackBox is in either sub box. + TaskStack stack = mFirst.split(stackId, relativeStackBoxId, position, weight); if (stack != null) { return stack; } - return mSecond.split(stackId, relativeStackId, position, weight); - } - - // This StackBox contains just a TaskStack. - if (mStack.mStackId != relativeStackId) { - // Barking down the wrong stack. - return null; + return mSecond.split(stackId, relativeStackBoxId, position, weight); } // Found it! TaskStack stack = new TaskStack(mService, stackId, mDisplayContent); TaskStack firstStack; TaskStack secondStack; + if (position == TASK_STACK_GOES_BEFORE) { + // TODO: Test Configuration here for LTR/RTL. + position = TASK_STACK_TO_LEFT_OF; + } else if (position == TASK_STACK_GOES_AFTER) { + // TODO: Test Configuration here for LTR/RTL. + position = TASK_STACK_TO_RIGHT_OF; + } switch (position) { default: - case TASK_STACK_GOES_AFTER: - case TASK_STACK_GOES_BEFORE: + case TASK_STACK_TO_LEFT_OF: + case TASK_STACK_TO_RIGHT_OF: mVertical = false; - if (position == TASK_STACK_GOES_BEFORE) { + if (position == TASK_STACK_TO_LEFT_OF) { mWeight = weight; firstStack = stack; secondStack = mStack; @@ -265,15 +272,16 @@ public class StackBox { return sibling.getStackId(); } - boolean resize(int stackId, float weight) { - if (mStack == null) { - return mFirst.resize(stackId, weight) || mSecond.resize(stackId, weight); + boolean resize(int stackBoxId, float weight) { + if (mStackBoxId != stackBoxId) { + return mStack == null && + (mFirst.resize(stackBoxId, weight) || mSecond.resize(stackBoxId, weight)); } - if (mStack.mStackId == stackId) { + // Don't change weight on topmost stack. + if (mParent != null) { mParent.mWeight = isFirstChild() ? weight : 1.0f - weight; - return true; } - return false; + return true; } /** If this is a terminal StackBox (contains a TaskStack) set the bounds. diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index d19fb2d..7c884c1 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -4782,7 +4782,7 @@ public class WindowManagerService extends IWindowManager.Stub /** * Create a new TaskStack and place it next to an existing stack. * @param stackId The unique identifier of the new stack. - * @param relativeStackId The existing stack that this stack goes before or after. + * @param relativeStackBoxId The existing stack that this stack goes before or after. * @param position One of: * {@link StackBox#TASK_STACK_GOES_BEFORE} * {@link StackBox#TASK_STACK_GOES_AFTER} @@ -4792,7 +4792,7 @@ public class WindowManagerService extends IWindowManager.Stub * {@link StackBox#TASK_STACK_GOES_OVER} * @param weight Relative weight for determining how big to make the new TaskStack. */ - public void createStack(int stackId, int relativeStackId, int position, float weight) { + public void createStack(int stackId, int relativeStackBoxId, int position, float weight) { synchronized (mWindowMap) { if (position <= StackBox.TASK_STACK_GOES_BELOW && (weight < STACK_WEIGHT_MIN || weight > STACK_WEIGHT_MAX)) { @@ -4800,23 +4800,19 @@ public class WindowManagerService extends IWindowManager.Stub "createStack: weight must be between " + STACK_WEIGHT_MIN + " and " + STACK_WEIGHT_MAX + ", weight=" + weight); } - final DisplayContent displayContent; - if (stackId != HOME_STACK_ID) { - // TODO: What to do for the first stack on a non-default display? - final TaskStack relativeStack = mStackIdToStack.get(relativeStackId); - if (relativeStack == null) { - throw new IllegalArgumentException("createStack: Invalid relativeStackId=" + - relativeStackId); + DisplayContentsIterator iterator = new DisplayContentsIterator(); + while (iterator.hasNext()) { + final DisplayContent displayContent = iterator.next(); + TaskStack stack = displayContent.createStack(this, stackId, relativeStackBoxId, + position, weight); + if (stack != null) { + mStackIdToStack.put(stackId, stack); + displayContent.moveStack(stack, true); + performLayoutAndPlaceSurfacesLocked(); + return; } - displayContent = relativeStack.getDisplayContent(); - } else { - displayContent = getDefaultDisplayContentLocked(); } - TaskStack stack = - displayContent.createStack(this, stackId, relativeStackId, position, weight); - mStackIdToStack.put(stackId, stack); - displayContent.moveStack(stack, true); - performLayoutAndPlaceSurfacesLocked(); + Slog.e(TAG, "createStack: Unable to find relativeStackBoxId=" + relativeStackBoxId); } } @@ -4864,7 +4860,7 @@ public class WindowManagerService extends IWindowManager.Stub } } - public void resizeStack(int stackId, float weight) { + public void resizeStackBox(int stackBoxId, float weight) { if (weight < STACK_WEIGHT_MIN || weight > STACK_WEIGHT_MAX) { throw new IllegalArgumentException( "resizeStack: weight must be between " + STACK_WEIGHT_MIN + " and " + @@ -4873,14 +4869,14 @@ public class WindowManagerService extends IWindowManager.Stub synchronized (mWindowMap) { DisplayContentsIterator iterator = new DisplayContentsIterator(); while (iterator.hasNext()) { - if (iterator.next().resizeStack(stackId, weight)) { - break; - } else if (!iterator.hasNext()) { - throw new IllegalArgumentException("resizeStack: stackId " + stackId - + " not found."); + if (iterator.next().resizeStack(stackBoxId, weight)) { + performLayoutAndPlaceSurfacesLocked(); + return; } } } + throw new IllegalArgumentException("resizeStack: stackBoxId " + stackBoxId + + " not found."); } public ArrayList<StackBoxInfo> getStackBoxInfos() { |