Loading services/core/java/com/android/server/wm/WindowContainer.java +13 −7 Original line number Diff line number Diff line Loading @@ -179,7 +179,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // List of children for this window container. List is in z-order as the children appear on // screen with the top-most window container at the tail of the list. protected final WindowList<E> mChildren = new WindowList<E>(); protected final ArrayList<E> mChildren = new ArrayList<E>(); // The specified orientation for this window container. // Shouldn't be accessed directly since subclasses can override getOverrideOrientation. Loading Loading @@ -855,7 +855,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< mSurfaceFreezer.unfreeze(getSyncTransaction()); } while (!mChildren.isEmpty()) { final E child = mChildren.peekLast(); final E child = mChildren.getLast(); child.removeImmediately(); // Need to do this after calling remove on the child because the child might try to // remove/detach itself from its parent which will cause an exception if we remove Loading Loading @@ -979,7 +979,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< switch (position) { case POSITION_TOP: if (mChildren.peekLast() != child) { if (getTopChild() != child) { mChildren.remove(child); mChildren.add(child); onChildPositionChanged(child); Loading @@ -990,7 +990,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } break; case POSITION_BOTTOM: if (mChildren.peekFirst() != child) { if (getBottomChild() != child) { mChildren.remove(child); mChildren.addFirst(child); onChildPositionChanged(child); Loading Loading @@ -1445,7 +1445,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< /** Returns the top child container. */ E getTopChild() { return mChildren.peekLast(); final int n = mChildren.size(); return n == 0 ? null : mChildren.get(n - 1); } E getBottomChild() { final int n = mChildren.size(); return n == 0 ? null : mChildren.get(0); } /** Loading Loading @@ -2550,7 +2556,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } if (mParent != null && mParent == other.mParent) { final WindowList<WindowContainer> list = mParent.mChildren; final ArrayList<WindowContainer> list = mParent.mChildren; return list.indexOf(this) > list.indexOf(other) ? 1 : -1; } Loading Loading @@ -2587,7 +2593,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // The position of the first non-common ancestor in the common ancestor list determines // which is greater the which. final WindowList<WindowContainer> list = commonAncestor.mChildren; final ArrayList<WindowContainer> list = commonAncestor.mChildren; return list.indexOf(thisParentChain.peekLast()) > list.indexOf(otherParentChain.peekLast()) ? 1 : -1; } finally { Loading services/core/java/com/android/server/wm/WindowList.javadeleted 100644 → 0 +0 −38 Original line number Diff line number Diff line /* * Copyright (C) 2017 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 com.android.server.wm; import java.util.ArrayList; /** * An {@link ArrayList} with extended functionality to be used as the children data structure in * {@link WindowContainer}. */ class WindowList<E> extends ArrayList<E> { public void addFirst(E e) { add(0, e); } E peekLast() { return size() > 0 ? get(size() - 1) : null; } E peekFirst() { return size() > 0 ? get(0) : null; } } services/core/java/com/android/server/wm/WindowOrganizerController.java +2 −2 Original line number Diff line number Diff line Loading @@ -1596,7 +1596,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub case OP_TYPE_REORDER_TO_BOTTOM_OF_TASK: { final Task task = taskFragment.getTask(); if (task != null) { if (task.mChildren.peekFirst() != taskFragment) { if (task.getBottomChild() != taskFragment) { task.mChildren.remove(taskFragment); task.mChildren.add(0, taskFragment); if (!taskFragment.hasChild()) { Loading @@ -1612,7 +1612,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub case OP_TYPE_REORDER_TO_TOP_OF_TASK: { final Task task = taskFragment.getTask(); if (task != null) { if (task.mChildren.peekLast() != taskFragment) { if (task.getTopChild() != taskFragment) { task.mChildren.remove(taskFragment); task.mChildren.add(taskFragment); if (!taskFragment.hasChild()) { Loading services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +2 −2 Original line number Diff line number Diff line Loading @@ -2482,10 +2482,10 @@ public class ActivityRecordTests extends WindowTestsBase { assertTrue(activity.mChildren.contains(win4)); // The starting window should be on-top of all other windows. assertEquals(startingWin, activity.mChildren.peekLast()); assertEquals(startingWin, activity.getTopChild()); // The base application window should be below all other windows. assertEquals(baseWin, activity.mChildren.peekFirst()); assertEquals(baseWin, activity.getBottomChild()); activity.removeImmediately(); } Loading Loading
services/core/java/com/android/server/wm/WindowContainer.java +13 −7 Original line number Diff line number Diff line Loading @@ -179,7 +179,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // List of children for this window container. List is in z-order as the children appear on // screen with the top-most window container at the tail of the list. protected final WindowList<E> mChildren = new WindowList<E>(); protected final ArrayList<E> mChildren = new ArrayList<E>(); // The specified orientation for this window container. // Shouldn't be accessed directly since subclasses can override getOverrideOrientation. Loading Loading @@ -855,7 +855,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< mSurfaceFreezer.unfreeze(getSyncTransaction()); } while (!mChildren.isEmpty()) { final E child = mChildren.peekLast(); final E child = mChildren.getLast(); child.removeImmediately(); // Need to do this after calling remove on the child because the child might try to // remove/detach itself from its parent which will cause an exception if we remove Loading Loading @@ -979,7 +979,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< switch (position) { case POSITION_TOP: if (mChildren.peekLast() != child) { if (getTopChild() != child) { mChildren.remove(child); mChildren.add(child); onChildPositionChanged(child); Loading @@ -990,7 +990,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } break; case POSITION_BOTTOM: if (mChildren.peekFirst() != child) { if (getBottomChild() != child) { mChildren.remove(child); mChildren.addFirst(child); onChildPositionChanged(child); Loading Loading @@ -1445,7 +1445,13 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< /** Returns the top child container. */ E getTopChild() { return mChildren.peekLast(); final int n = mChildren.size(); return n == 0 ? null : mChildren.get(n - 1); } E getBottomChild() { final int n = mChildren.size(); return n == 0 ? null : mChildren.get(0); } /** Loading Loading @@ -2550,7 +2556,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< } if (mParent != null && mParent == other.mParent) { final WindowList<WindowContainer> list = mParent.mChildren; final ArrayList<WindowContainer> list = mParent.mChildren; return list.indexOf(this) > list.indexOf(other) ? 1 : -1; } Loading Loading @@ -2587,7 +2593,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // The position of the first non-common ancestor in the common ancestor list determines // which is greater the which. final WindowList<WindowContainer> list = commonAncestor.mChildren; final ArrayList<WindowContainer> list = commonAncestor.mChildren; return list.indexOf(thisParentChain.peekLast()) > list.indexOf(otherParentChain.peekLast()) ? 1 : -1; } finally { Loading
services/core/java/com/android/server/wm/WindowList.javadeleted 100644 → 0 +0 −38 Original line number Diff line number Diff line /* * Copyright (C) 2017 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 com.android.server.wm; import java.util.ArrayList; /** * An {@link ArrayList} with extended functionality to be used as the children data structure in * {@link WindowContainer}. */ class WindowList<E> extends ArrayList<E> { public void addFirst(E e) { add(0, e); } E peekLast() { return size() > 0 ? get(size() - 1) : null; } E peekFirst() { return size() > 0 ? get(0) : null; } }
services/core/java/com/android/server/wm/WindowOrganizerController.java +2 −2 Original line number Diff line number Diff line Loading @@ -1596,7 +1596,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub case OP_TYPE_REORDER_TO_BOTTOM_OF_TASK: { final Task task = taskFragment.getTask(); if (task != null) { if (task.mChildren.peekFirst() != taskFragment) { if (task.getBottomChild() != taskFragment) { task.mChildren.remove(taskFragment); task.mChildren.add(0, taskFragment); if (!taskFragment.hasChild()) { Loading @@ -1612,7 +1612,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub case OP_TYPE_REORDER_TO_TOP_OF_TASK: { final Task task = taskFragment.getTask(); if (task != null) { if (task.mChildren.peekLast() != taskFragment) { if (task.getTopChild() != taskFragment) { task.mChildren.remove(taskFragment); task.mChildren.add(taskFragment); if (!taskFragment.hasChild()) { Loading
services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +2 −2 Original line number Diff line number Diff line Loading @@ -2482,10 +2482,10 @@ public class ActivityRecordTests extends WindowTestsBase { assertTrue(activity.mChildren.contains(win4)); // The starting window should be on-top of all other windows. assertEquals(startingWin, activity.mChildren.peekLast()); assertEquals(startingWin, activity.getTopChild()); // The base application window should be below all other windows. assertEquals(baseWin, activity.mChildren.peekFirst()); assertEquals(baseWin, activity.getBottomChild()); activity.removeImmediately(); } Loading