Remove WindowContainerController

It is no longer used. Reference removal:
root 31acb3f, stack 279f558, task 0e7aff9, activity 1ee84ea.

Bug: 80414790
Bug: 141248611
Test: go/wm-smoke
Change-Id: I23515d7ad5f218a70dfa05e5818a6ec2c2f857e8
This commit is contained in:
Riddle Hsu
2019-09-23 18:52:36 +08:00
parent cb17c92130
commit 5947c364df
8 changed files with 6 additions and 298 deletions

View File

@@ -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<ActivityStack>
implements WindowContainerListener {
class ActivityDisplay extends ConfigurationContainer<ActivityStack> {
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<ActivityStack>
}
}
@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<ActivityStack>
}
// 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<ActivityStack>
// 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 {

View File

@@ -1145,7 +1145,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
*/
void initializeDisplayOverrideConfiguration() {
if (mAcitvityDisplay != null) {
mAcitvityDisplay.onInitializeOverrideConfiguration(getRequestedOverrideConfiguration());
mAcitvityDisplay.getRequestedOverrideConfiguration()
.updateFrom(getRequestedOverrideConfiguration());
}
}

View File

@@ -106,9 +106,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
private final Pools.SynchronizedPool<ForAllWindowsConsumerWrapper> 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<E extends WindowContainer> extends ConfigurationContainer<
if (mParent != null) {
mParent.removeChild(this);
}
if (mController != null) {
setController(null);
}
}
/**
@@ -1005,23 +997,6 @@ class WindowContainer<E extends 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);

View File

@@ -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<E extends WindowContainer, I extends WindowContainerListener>
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);
}
}
}

View File

@@ -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) {}
}

View File

@@ -149,7 +149,6 @@ public class TaskStackTests extends WindowTestsBase {
// After removing, the task will be isolated.
assertNull(task.getParent());
assertEquals(0, task.getChildCount());
assertNull(task.getController());
}
@Test

View File

@@ -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());
}
}

View File

@@ -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);