diff options
author | Craig Mautner <cmautner@google.com> | 2013-05-24 15:49:29 -0700 |
---|---|---|
committer | Craig Mautner <cmautner@google.com> | 2013-05-24 16:12:57 -0700 |
commit | 5a449154d1795abe8e44b7bfe821d640b145e2c6 (patch) | |
tree | e8a9936e1e39aa01b8d217ff36eab0e9e57715f6 /services/java/com/android/server | |
parent | 5ff12101722874f5e7b0cadf06f4c53f4ec4b917 (diff) | |
download | frameworks_base-5a449154d1795abe8e44b7bfe821d640b145e2c6.zip frameworks_base-5a449154d1795abe8e44b7bfe821d640b145e2c6.tar.gz frameworks_base-5a449154d1795abe8e44b7bfe821d640b145e2c6.tar.bz2 |
Convert API refs to StackBox from ActivityStack.
- Removed IActivityManager.getStacks() since getStackBoxes() is better.
- Made createStacks operate relative to StackBox instead of TaskStack.
- Made resizeStack into resizeStackBox.
Change-Id: I7a0e1f4e34f399b4fd1180c60cc3989f9c2433f3
Diffstat (limited to 'services/java/com/android/server')
4 files changed, 86 insertions, 84 deletions
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() { |