Loading services/core/java/com/android/server/wm/DisplayContent.java +20 −20 Original line number Original line Diff line number Diff line Loading @@ -1032,31 +1032,13 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo // Sets the display content for the children. // Sets the display content for the children. onDisplayChanged(this); onDisplayChanged(this); // Add itself as a child to the root container. mInputMonitor = new InputMonitor(mWmService, this); mWmService.mRoot.addChild(this, POSITION_BOTTOM); // TODO(b/62541591): evaluate whether this is the best spot to declare the // {@link DisplayContent} ready for use. mDisplayReady = true; mWmService.mAnimator.addDisplayLocked(mDisplayId); mInputMonitor = new InputMonitor(mWmService, mDisplayId); mInsetsStateController = new InsetsStateController(this); mInsetsStateController = new InsetsStateController(this); mInsetsPolicy = new InsetsPolicy(mInsetsStateController, this); mInsetsPolicy = new InsetsPolicy(mInsetsStateController, this); if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display); if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Creating display=" + display); mWmService.mDisplayWindowSettings.applySettingsToDisplayLocked(this); mWmService.mDisplayWindowSettings.applySettingsToDisplayLocked(this); if (mWmService.mDisplayManagerInternal != null) { mWmService.mDisplayManagerInternal .setDisplayInfoOverrideFromWindowManager(mDisplayId, getDisplayInfo()); configureDisplayPolicy(); } reconfigureDisplayLocked(); onRequestedOverrideConfigurationChanged(getRequestedOverrideConfiguration()); mWmService.mDisplayNotificationController.dispatchDisplayAdded(this); } } boolean isReady() { boolean isReady() { Loading Loading @@ -4992,6 +4974,24 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo // we create the root surfaces explicitly rather than chaining // we create the root surfaces explicitly rather than chaining // up as the default implementation in onParentChanged does. So we // up as the default implementation in onParentChanged does. So we // explicitly do NOT call super here. // explicitly do NOT call super here. if (!isReady()) { // TODO(b/62541591): evaluate whether this is the best spot to declare the // {@link DisplayContent} ready for use. mDisplayReady = true; mWmService.mAnimator.addDisplayLocked(mDisplayId); if (mWmService.mDisplayManagerInternal != null) { mWmService.mDisplayManagerInternal .setDisplayInfoOverrideFromWindowManager(mDisplayId, getDisplayInfo()); configureDisplayPolicy(); } reconfigureDisplayLocked(); onRequestedOverrideConfigurationChanged(getRequestedOverrideConfiguration()); mWmService.mDisplayNotificationController.dispatchDisplayAdded(this); } } } @Override @Override Loading services/core/java/com/android/server/wm/InputMonitor.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -151,10 +151,10 @@ final class InputMonitor { private final UpdateInputWindows mUpdateInputWindows = new UpdateInputWindows(); private final UpdateInputWindows mUpdateInputWindows = new UpdateInputWindows(); public InputMonitor(WindowManagerService service, int displayId) { InputMonitor(WindowManagerService service, DisplayContent displayContent) { mService = service; mService = service; mDisplayContent = mService.mRoot.getDisplayContent(displayId); mDisplayContent = displayContent; mDisplayId = displayId; mDisplayId = displayContent.getDisplayId(); mInputTransaction = mService.mTransactionFactory.get(); mInputTransaction = mService.mTransactionFactory.get(); mHandler = mService.mAnimationHandler; mHandler = mService.mAnimationHandler; mUpdateInputForAllWindowsConsumer = new UpdateInputForAllWindowsConsumer(); mUpdateInputForAllWindowsConsumer = new UpdateInputForAllWindowsConsumer(); Loading services/core/java/com/android/server/wm/RootWindowContainer.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -1377,6 +1377,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> for (int displayNdx = 0; displayNdx < displays.length; ++displayNdx) { for (int displayNdx = 0; displayNdx < displays.length; ++displayNdx) { final Display display = displays[displayNdx]; final Display display = displays[displayNdx]; final DisplayContent displayContent = new DisplayContent(display, this); final DisplayContent displayContent = new DisplayContent(display, this); addChild(displayContent, POSITION_BOTTOM); if (displayContent.mDisplayId == DEFAULT_DISPLAY) { if (displayContent.mDisplayId == DEFAULT_DISPLAY) { mDefaultDisplay = displayContent; mDefaultDisplay = displayContent; } } Loading Loading @@ -1445,6 +1446,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } // The display hasn't been added to ActivityManager yet, create a new record now. // The display hasn't been added to ActivityManager yet, create a new record now. displayContent = new DisplayContent(display, this); displayContent = new DisplayContent(display, this); addChild(displayContent, POSITION_BOTTOM); return displayContent; return displayContent; } } Loading services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -408,6 +408,16 @@ public class SystemServicesTestRule implements TestRule { } } } } /** * Throws if caller doesn't hold the given lock. * @param lock the lock */ static void checkHoldsLock(Object lock) { if (!Thread.holdsLock(lock)) { throw new IllegalStateException("Caller doesn't hold global lock."); } } protected class TestActivityTaskManagerService extends ActivityTaskManagerService { protected class TestActivityTaskManagerService extends ActivityTaskManagerService { // ActivityStackSupervisor may be created more than once while setting up AMS and ATMS. // ActivityStackSupervisor may be created more than once while setting up AMS and ATMS. // We keep the reference in order to prevent creating it twice. // We keep the reference in order to prevent creating it twice. Loading services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java +9 −5 Original line number Original line Diff line number Diff line Loading @@ -72,7 +72,7 @@ class TestDisplayContent extends DisplayContent { private final DisplayInfo mInfo; private final DisplayInfo mInfo; private boolean mCanRotate = true; private boolean mCanRotate = true; private int mWindowingMode = WINDOWING_MODE_FULLSCREEN; private int mWindowingMode = WINDOWING_MODE_FULLSCREEN; private int mPosition = POSITION_TOP; private int mPosition = POSITION_BOTTOM; private final ActivityTaskManagerService mService; private final ActivityTaskManagerService mService; private boolean mSystemDecorations = false; private boolean mSystemDecorations = false; Loading Loading @@ -127,13 +127,13 @@ class TestDisplayContent extends DisplayContent { return this; return this; } } TestDisplayContent build() { TestDisplayContent build() { SystemServicesTestRule.checkHoldsLock(mService.mGlobalLock); final int displayId = SystemServicesTestRule.sNextDisplayId++; final int displayId = SystemServicesTestRule.sNextDisplayId++; final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId, final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId, mInfo, DEFAULT_DISPLAY_ADJUSTMENTS); mInfo, DEFAULT_DISPLAY_ADJUSTMENTS); final TestDisplayContent newDisplay; final TestDisplayContent newDisplay = synchronized (mService.mGlobalLock) { new TestDisplayContent(mService.mStackSupervisor, display); newDisplay = new TestDisplayContent(mService.mStackSupervisor, display); } // disable the normal system decorations // disable the normal system decorations final DisplayPolicy displayPolicy = newDisplay.mDisplayContent.getDisplayPolicy(); final DisplayPolicy displayPolicy = newDisplay.mDisplayContent.getDisplayPolicy(); spyOn(displayPolicy); spyOn(displayPolicy); Loading @@ -153,6 +153,10 @@ class TestDisplayContent extends DisplayContent { doReturn(false).when(newDisplay.mDisplayContent) doReturn(false).when(newDisplay.mDisplayContent) .handlesOrientationChangeFromDescendant(); .handlesOrientationChangeFromDescendant(); } } // Please add stubbing before this line. Services will start using this display in other // threads immediately after adding it to hierarchy. Calling doAnswer() type of stubbing // reduces chance of races, but still doesn't eliminate race conditions. mService.mRootWindowContainer.addChild(newDisplay, mPosition); return newDisplay; return newDisplay; } } } } Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +20 −20 Original line number Original line Diff line number Diff line Loading @@ -1032,31 +1032,13 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo // Sets the display content for the children. // Sets the display content for the children. onDisplayChanged(this); onDisplayChanged(this); // Add itself as a child to the root container. mInputMonitor = new InputMonitor(mWmService, this); mWmService.mRoot.addChild(this, POSITION_BOTTOM); // TODO(b/62541591): evaluate whether this is the best spot to declare the // {@link DisplayContent} ready for use. mDisplayReady = true; mWmService.mAnimator.addDisplayLocked(mDisplayId); mInputMonitor = new InputMonitor(mWmService, mDisplayId); mInsetsStateController = new InsetsStateController(this); mInsetsStateController = new InsetsStateController(this); mInsetsPolicy = new InsetsPolicy(mInsetsStateController, this); mInsetsPolicy = new InsetsPolicy(mInsetsStateController, this); if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display); if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Creating display=" + display); mWmService.mDisplayWindowSettings.applySettingsToDisplayLocked(this); mWmService.mDisplayWindowSettings.applySettingsToDisplayLocked(this); if (mWmService.mDisplayManagerInternal != null) { mWmService.mDisplayManagerInternal .setDisplayInfoOverrideFromWindowManager(mDisplayId, getDisplayInfo()); configureDisplayPolicy(); } reconfigureDisplayLocked(); onRequestedOverrideConfigurationChanged(getRequestedOverrideConfiguration()); mWmService.mDisplayNotificationController.dispatchDisplayAdded(this); } } boolean isReady() { boolean isReady() { Loading Loading @@ -4992,6 +4974,24 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo // we create the root surfaces explicitly rather than chaining // we create the root surfaces explicitly rather than chaining // up as the default implementation in onParentChanged does. So we // up as the default implementation in onParentChanged does. So we // explicitly do NOT call super here. // explicitly do NOT call super here. if (!isReady()) { // TODO(b/62541591): evaluate whether this is the best spot to declare the // {@link DisplayContent} ready for use. mDisplayReady = true; mWmService.mAnimator.addDisplayLocked(mDisplayId); if (mWmService.mDisplayManagerInternal != null) { mWmService.mDisplayManagerInternal .setDisplayInfoOverrideFromWindowManager(mDisplayId, getDisplayInfo()); configureDisplayPolicy(); } reconfigureDisplayLocked(); onRequestedOverrideConfigurationChanged(getRequestedOverrideConfiguration()); mWmService.mDisplayNotificationController.dispatchDisplayAdded(this); } } } @Override @Override Loading
services/core/java/com/android/server/wm/InputMonitor.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -151,10 +151,10 @@ final class InputMonitor { private final UpdateInputWindows mUpdateInputWindows = new UpdateInputWindows(); private final UpdateInputWindows mUpdateInputWindows = new UpdateInputWindows(); public InputMonitor(WindowManagerService service, int displayId) { InputMonitor(WindowManagerService service, DisplayContent displayContent) { mService = service; mService = service; mDisplayContent = mService.mRoot.getDisplayContent(displayId); mDisplayContent = displayContent; mDisplayId = displayId; mDisplayId = displayContent.getDisplayId(); mInputTransaction = mService.mTransactionFactory.get(); mInputTransaction = mService.mTransactionFactory.get(); mHandler = mService.mAnimationHandler; mHandler = mService.mAnimationHandler; mUpdateInputForAllWindowsConsumer = new UpdateInputForAllWindowsConsumer(); mUpdateInputForAllWindowsConsumer = new UpdateInputForAllWindowsConsumer(); Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -1377,6 +1377,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> for (int displayNdx = 0; displayNdx < displays.length; ++displayNdx) { for (int displayNdx = 0; displayNdx < displays.length; ++displayNdx) { final Display display = displays[displayNdx]; final Display display = displays[displayNdx]; final DisplayContent displayContent = new DisplayContent(display, this); final DisplayContent displayContent = new DisplayContent(display, this); addChild(displayContent, POSITION_BOTTOM); if (displayContent.mDisplayId == DEFAULT_DISPLAY) { if (displayContent.mDisplayId == DEFAULT_DISPLAY) { mDefaultDisplay = displayContent; mDefaultDisplay = displayContent; } } Loading Loading @@ -1445,6 +1446,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> } } // The display hasn't been added to ActivityManager yet, create a new record now. // The display hasn't been added to ActivityManager yet, create a new record now. displayContent = new DisplayContent(display, this); displayContent = new DisplayContent(display, this); addChild(displayContent, POSITION_BOTTOM); return displayContent; return displayContent; } } Loading
services/tests/wmtests/src/com/android/server/wm/SystemServicesTestRule.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -408,6 +408,16 @@ public class SystemServicesTestRule implements TestRule { } } } } /** * Throws if caller doesn't hold the given lock. * @param lock the lock */ static void checkHoldsLock(Object lock) { if (!Thread.holdsLock(lock)) { throw new IllegalStateException("Caller doesn't hold global lock."); } } protected class TestActivityTaskManagerService extends ActivityTaskManagerService { protected class TestActivityTaskManagerService extends ActivityTaskManagerService { // ActivityStackSupervisor may be created more than once while setting up AMS and ATMS. // ActivityStackSupervisor may be created more than once while setting up AMS and ATMS. // We keep the reference in order to prevent creating it twice. // We keep the reference in order to prevent creating it twice. Loading
services/tests/wmtests/src/com/android/server/wm/TestDisplayContent.java +9 −5 Original line number Original line Diff line number Diff line Loading @@ -72,7 +72,7 @@ class TestDisplayContent extends DisplayContent { private final DisplayInfo mInfo; private final DisplayInfo mInfo; private boolean mCanRotate = true; private boolean mCanRotate = true; private int mWindowingMode = WINDOWING_MODE_FULLSCREEN; private int mWindowingMode = WINDOWING_MODE_FULLSCREEN; private int mPosition = POSITION_TOP; private int mPosition = POSITION_BOTTOM; private final ActivityTaskManagerService mService; private final ActivityTaskManagerService mService; private boolean mSystemDecorations = false; private boolean mSystemDecorations = false; Loading Loading @@ -127,13 +127,13 @@ class TestDisplayContent extends DisplayContent { return this; return this; } } TestDisplayContent build() { TestDisplayContent build() { SystemServicesTestRule.checkHoldsLock(mService.mGlobalLock); final int displayId = SystemServicesTestRule.sNextDisplayId++; final int displayId = SystemServicesTestRule.sNextDisplayId++; final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId, final Display display = new Display(DisplayManagerGlobal.getInstance(), displayId, mInfo, DEFAULT_DISPLAY_ADJUSTMENTS); mInfo, DEFAULT_DISPLAY_ADJUSTMENTS); final TestDisplayContent newDisplay; final TestDisplayContent newDisplay = synchronized (mService.mGlobalLock) { new TestDisplayContent(mService.mStackSupervisor, display); newDisplay = new TestDisplayContent(mService.mStackSupervisor, display); } // disable the normal system decorations // disable the normal system decorations final DisplayPolicy displayPolicy = newDisplay.mDisplayContent.getDisplayPolicy(); final DisplayPolicy displayPolicy = newDisplay.mDisplayContent.getDisplayPolicy(); spyOn(displayPolicy); spyOn(displayPolicy); Loading @@ -153,6 +153,10 @@ class TestDisplayContent extends DisplayContent { doReturn(false).when(newDisplay.mDisplayContent) doReturn(false).when(newDisplay.mDisplayContent) .handlesOrientationChangeFromDescendant(); .handlesOrientationChangeFromDescendant(); } } // Please add stubbing before this line. Services will start using this display in other // threads immediately after adding it to hierarchy. Calling doAnswer() type of stubbing // reduces chance of races, but still doesn't eliminate race conditions. mService.mRootWindowContainer.addChild(newDisplay, mPosition); return newDisplay; return newDisplay; } } } } Loading