diff --git a/services/core/java/com/android/server/wm/ActivityDisplay.java b/services/core/java/com/android/server/wm/ActivityDisplay.java index e488cc91f9bac..2bdcea5ba94e7 100644 --- a/services/core/java/com/android/server/wm/ActivityDisplay.java +++ b/services/core/java/com/android/server/wm/ActivityDisplay.java @@ -84,8 +84,7 @@ import java.util.ArrayList; * Exactly one of these classes per Display in the system. Capable of holding zero or more * attached {@link ActivityStack}s. */ -class ActivityDisplay extends ConfigurationContainer - implements WindowContainerListener { +class ActivityDisplay extends ConfigurationContainer { private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityDisplay" : TAG_ATM; private static final String TAG_STACK = TAG + POSTFIX_STACK; @@ -201,11 +200,6 @@ class ActivityDisplay extends ConfigurationContainer } } - @Override - public void onInitializeOverrideConfiguration(Configuration config) { - getRequestedOverrideConfiguration().updateFrom(config); - } - void addChild(ActivityStack stack, int position) { if (position == POSITION_BOTTOM) { position = 0; @@ -291,9 +285,7 @@ class ActivityDisplay extends ConfigurationContainer } // Since positionChildAt() is called during the creation process of pinned stacks, - // ActivityStack#getStack() can be null. In this special case, - // since DisplayContest#positionStackAt() is called in TaskStack#onConfigurationChanged(), - // we don't have to call WindowContainerController#positionChildAt() here. + // ActivityStack#getStack() can be null. if (stack.getTaskStack() != null && mDisplayContent != null) { mDisplayContent.positionStackAt(insertPosition, stack.getTaskStack(), includingParents); @@ -1202,8 +1194,8 @@ class ActivityDisplay extends ConfigurationContainer // Stacks could be reparented from the removed display to other display. While // reparenting the last stack of the removed display, the remove display is ready to be // released (no more ActivityStack). But, we cannot release it at that moment or the - // related WindowContainer and WindowContainerController will also be removed. So, we - // set display as removed after reparenting stack finished. + // related WindowContainer will also be removed. So, we set display as removed after + // reparenting stack finished. final ActivityDisplay toDisplay = mRootActivityContainer.getDefaultDisplay(); mRootActivityContainer.mStackSupervisor.beginDeferResume(); try { diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 755180eb8d37c..348c8b47c4144 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1145,7 +1145,8 @@ class DisplayContent extends WindowContainer extends ConfigurationContainer< private final Pools.SynchronizedPool mConsumerWrapperPool = new Pools.SynchronizedPool<>(3); - // The owner/creator for this container. No controller if null. - WindowContainerController mController; - // The display this window container is on. protected DisplayContent mDisplayContent; @@ -356,11 +353,6 @@ class WindowContainer extends ConfigurationContainer< if (mParent != null) { mParent.removeChild(this); } - - if (mController != null) { - setController(null); - } - } /** @@ -1005,23 +997,6 @@ class WindowContainer extends ConfigurationContainer< } while (current != null); } - WindowContainerController getController() { - return mController; - } - - void setController(WindowContainerController controller) { - if (mController != null && controller != null) { - throw new IllegalArgumentException("Can't set controller=" + mController - + " for container=" + this + " Already set to=" + mController); - } - if (controller != null) { - controller.setContainer(this); - } else if (mController != null) { - mController.setContainer(null); - } - mController = controller; - } - SurfaceControl.Builder makeSurface() { final WindowContainer p = getParent(); return p.makeChildSurface(this); diff --git a/services/core/java/com/android/server/wm/WindowContainerController.java b/services/core/java/com/android/server/wm/WindowContainerController.java deleted file mode 100644 index 17bc0e2de1f80..0000000000000 --- a/services/core/java/com/android/server/wm/WindowContainerController.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2016 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 android.content.res.Configuration; - -/** - * Class that allows the owner/creator of a {@link WindowContainer} to communicate directly with the - * container and make changes. - * Note that public calls (mostly in sub-classes) into this class are assumed to be originating from - * outside the window manager so the window manager lock is held and appropriate permissions are - * checked before calls are allowed to proceed. - * - * Test class: {@link WindowContainerControllerTests} - */ -class WindowContainerController - implements ConfigurationContainerListener { - - final WindowManagerService mService; - final RootWindowContainer mRoot; - final WindowManagerGlobalLock mGlobalLock; - - // The window container this controller owns. - E mContainer; - // Interface for communicating changes back to the owner. - final I mListener; - - WindowContainerController(I listener, WindowManagerService service) { - mListener = listener; - mService = service; - mRoot = mService != null ? mService.mRoot : null; - mGlobalLock = mService != null ? mService.mGlobalLock : null; - } - - void setContainer(E container) { - if (mContainer != null && container != null) { - throw new IllegalArgumentException("Can't set container=" + container - + " for controller=" + this + " Already set to=" + mContainer); - } - mContainer = container; - if (mContainer != null && mListener != null) { - mListener.registerConfigurationChangeListener(this); - } - } - - void removeContainer() { - // TODO: See if most uses cases should support removeIfPossible here. - //mContainer.removeIfPossible(); - if (mContainer == null) { - return; - } - - mContainer.setController(null); - mContainer = null; - if (mListener != null) { - mListener.unregisterConfigurationChangeListener(this); - } - } - - @Override - public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) { - synchronized (mGlobalLock) { - if (mContainer == null) { - return; - } - mContainer.onRequestedOverrideConfigurationChanged(overrideConfiguration); - } - } -} diff --git a/services/core/java/com/android/server/wm/WindowContainerListener.java b/services/core/java/com/android/server/wm/WindowContainerListener.java deleted file mode 100644 index 3d3d2e02693c6..0000000000000 --- a/services/core/java/com/android/server/wm/WindowContainerListener.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2016 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 android.content.res.Configuration; - -/** - * Interface used by the owner/creator of the container to listen to changes with the container. - * @see WindowContainerController - */ -public interface WindowContainerListener { - void registerConfigurationChangeListener(ConfigurationContainerListener listener); - void unregisterConfigurationChangeListener(ConfigurationContainerListener listener); - default void onInitializeOverrideConfiguration(Configuration config) {} -} diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java index a2c76bed78409..87713cb0181c8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java @@ -151,7 +151,6 @@ public class TaskStackTests extends WindowTestsBase { // After removing, the task will be isolated. assertNull(task.getParent()); assertEquals(0, task.getChildCount()); - assertNull(task.getController()); } @Test diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerControllerTests.java deleted file mode 100644 index fc78635242403..0000000000000 --- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerControllerTests.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2016 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 static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; -import static android.content.res.Configuration.EMPTY; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import android.content.res.Configuration; -import android.platform.test.annotations.Presubmit; - -import androidx.test.filters.SmallTest; - -import org.junit.Test; - -/** - * Test class for {@link WindowContainerController}. - * - * Build/Install/Run: - * atest WmTests:WindowContainerControllerTests - */ -@SmallTest -@Presubmit -public class WindowContainerControllerTests extends WindowTestsBase { - - @Test - public void testCreation() { - final WindowContainerController controller = new WindowContainerController<>(null, mWm); - final WindowContainer container = new WindowContainer(mWm); - - container.setController(controller); - assertEquals(controller, container.getController()); - assertEquals(controller.mContainer, container); - } - - @Test - public void testSetContainer() { - final WindowContainerController controller = new WindowContainerController<>(null, mWm); - final WindowContainer container = new WindowContainer(mWm); - - controller.setContainer(container); - assertEquals(controller.mContainer, container); - - // Assert we can't change the container to another one once set - boolean gotException = false; - try { - controller.setContainer(new WindowContainer(mWm)); - } catch (IllegalArgumentException e) { - gotException = true; - } - assertTrue(gotException); - - // Assert that we can set the container to null. - controller.setContainer(null); - assertNull(controller.mContainer); - } - - @Test - public void testRemoveContainer() { - final WindowContainerController controller = new WindowContainerController<>(null, mWm); - final WindowContainer container = new WindowContainer(mWm); - - controller.setContainer(container); - assertEquals(controller.mContainer, container); - - controller.removeContainer(); - assertNull(controller.mContainer); - } - - @Test - public void testOnOverrideConfigurationChanged() { - final WindowContainerController controller = new WindowContainerController<>(null, mWm); - final WindowContainer container = new WindowContainer(mWm); - - controller.setContainer(container); - assertEquals(controller.mContainer, container); - assertEquals(EMPTY, container.getRequestedOverrideConfiguration()); - - final Configuration config = new Configuration(); - config.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM); - config.windowConfiguration.setAppBounds(10, 10, 10, 10); - - // Assert that the config change through the controller is propagated to the container. - controller.onRequestedOverrideConfigurationChanged(config); - assertEquals(config, container.getRequestedOverrideConfiguration()); - - // Assert the container configuration isn't changed after removal from the controller. - controller.removeContainer(); - controller.onRequestedOverrideConfigurationChanged(EMPTY); - assertEquals(config, container.getRequestedOverrideConfiguration()); - } -} diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java index 921f105d1d25b..8117ff601a8fa 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java @@ -215,44 +215,6 @@ public class WindowContainerTests extends WindowTestsBase { assertEquals(0, root.getChildrenCount()); } - @Test - public void testRemoveImmediately_WithController() { - final WindowContainer container = new WindowContainer(mWm); - final WindowContainerController controller = new WindowContainerController<>(null, mWm); - - container.setController(controller); - assertEquals(controller, container.getController()); - assertEquals(container, controller.mContainer); - - container.removeImmediately(); - assertNull(container.getController()); - assertNull(controller.mContainer); - } - - @Test - public void testSetController() { - final WindowContainerController controller = new WindowContainerController<>(null, mWm); - final WindowContainer container = new WindowContainer(mWm); - - container.setController(controller); - assertEquals(controller, container.getController()); - assertEquals(container, controller.mContainer); - - // Assert we can't change the controller to another one once set - boolean gotException = false; - try { - container.setController(new WindowContainerController<>(null, mWm)); - } catch (IllegalArgumentException e) { - gotException = true; - } - assertTrue(gotException); - - // Assert that we can set the controller to null. - container.setController(null); - assertNull(container.getController()); - assertNull(controller.mContainer); - } - @Test public void testAddChildByIndex() { final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(mWm);