From ffe128d46dc45939df08231c8ec382b33306a77f Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 30 Nov 2017 13:54:36 +0100 Subject: Optimize surface hierarchy - Do not reset layer if layer doesn't change. JNI is expensive. - Only assign child layers once if we have to do multiple passes. - Fix issue where layouting the starting window caused the surface to be resized, leading to a blocking SF transaction. Test: go/wm-smoke Test: adb logcat -b events | grep 319, inspect transition times. Fixes: 69632880 Change-Id: I8fffca30591730fae87ed3aeb9df0bdf7d4b55dd --- .../android/server/am/ActivityStackSupervisor.java | 13 +++- .../com/android/server/am/ActivityStarter.java | 1 + .../java/com/android/server/wm/DisplayContent.java | 87 ++++++++++++---------- .../com/android/server/wm/RootWindowContainer.java | 4 +- services/core/java/com/android/server/wm/Task.java | 3 +- .../com/android/server/wm/TaskSnapshotSurface.java | 2 +- .../core/java/com/android/server/wm/TaskStack.java | 5 +- .../com/android/server/wm/TransactionFactory.java | 27 +++++++ .../com/android/server/wm/WindowContainer.java | 49 ++++++++---- .../android/server/wm/WindowManagerService.java | 32 +++----- .../java/com/android/server/wm/WindowState.java | 3 +- .../java/com/android/server/wm/WindowToken.java | 5 +- .../src/com/android/server/wm/DimmerTests.java | 9 +++ .../server/wm/WindowContainerControllerTests.java | 10 +-- .../android/server/wm/WindowContainerTests.java | 5 +- .../src/com/android/server/wm/ZOrderingTests.java | 35 ++++----- 16 files changed, 169 insertions(+), 121 deletions(-) create mode 100644 services/core/java/com/android/server/wm/TransactionFactory.java diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 7561d0f8ad96..723da5023cbf 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -1239,9 +1239,16 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D ResolveInfo resolveIntent(Intent intent, String resolvedType, int userId, int flags) { synchronized (mService) { - return mService.getPackageManagerInternalLocked().resolveIntent(intent, resolvedType, - PackageManager.MATCH_INSTANT | PackageManager.MATCH_DEFAULT_ONLY | flags - | ActivityManagerService.STOCK_PM_FLAGS, userId, true); + try { + Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "resolveIntent"); + return mService.getPackageManagerInternalLocked().resolveIntent( + intent, resolvedType, PackageManager.MATCH_INSTANT + | PackageManager.MATCH_DEFAULT_ONLY | flags + | ActivityManagerService.STOCK_PM_FLAGS, userId, true); + + } finally { + Trace.traceEnd(TRACE_TAG_ACTIVITY_MANAGER); + } } } diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index dda8e9c18229..10fb6e2a0896 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -96,6 +96,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; +import android.os.Trace; import android.os.UserHandle; import android.os.UserManager; import android.service.voice.IVoiceInteractionSession; diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index ca8ffca00ee7..91cad469289a 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -135,6 +135,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; +import android.os.Trace; import android.util.DisplayMetrics; import android.util.MutableBoolean; import android.util.Slog; @@ -178,20 +179,20 @@ class DisplayContent extends WindowContainer extends WindowContainer { + DisplayChildWindowContainer(WindowManagerService service) { + super(service); + } + @Override boolean fillsParent() { return true; @@ -3209,6 +3214,10 @@ class DisplayContent extends WindowContainer= mService.mPolicy.getWindowLayerFromTypeLw( TYPE_INPUT_METHOD_DIALOG, true)) { - t.setRelativeLayer(imeContainer.getSurfaceControl(), - wt.getSurfaceControl(), -1); + imeContainer.assignRelativeLayer(t, wt.getSurfaceControl(), -1); needAssignIme = false; } } if (needAssignIme) { - t.setRelativeLayer(imeContainer.getSurfaceControl(), - getSurfaceControl(), Integer.MAX_VALUE); + imeContainer.assignRelativeLayer(t, getSurfaceControl(), Integer.MAX_VALUE); } } } @@ -3618,7 +3627,8 @@ class DisplayContent extends WindowContainer { private static final int SET_SCREEN_BRIGHTNESS_OVERRIDE = 1; private static final int SET_USER_ACTIVITY_TIMEOUT = 2; - WindowManagerService mService; - private boolean mWallpaperForceHidingChanged = false; private Object mLastWindowFreezeSource = null; private Session mHoldScreen = null; @@ -160,7 +158,7 @@ class RootWindowContainer extends WindowContainer { }; RootWindowContainer(WindowManagerService service) { - mService = service; + super(service); mHandler = new MyHandler(service.mH.getLooper()); mWallpaperController = new WallpaperController(mService); } diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 8aa129a45373..6ea8a4790630 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -59,7 +59,6 @@ class Task extends WindowContainer { final int mTaskId; final int mUserId; private boolean mDeferRemoval = false; - final WindowManagerService mService; final Rect mPreparedFrozenBounds = new Rect(); final Configuration mPreparedFrozenMergedConfig = new Configuration(); @@ -102,10 +101,10 @@ class Task extends WindowContainer { Task(int taskId, TaskStack stack, int userId, WindowManagerService service, int resizeMode, boolean supportsPictureInPicture, TaskDescription taskDescription, TaskWindowContainerController controller) { + super(service); mTaskId = taskId; mStack = stack; mUserId = userId; - mService = service; mResizeMode = resizeMode; mSupportsPictureInPicture = supportsPictureInPicture; setController(controller); diff --git a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java index 94fbd0e1f0d9..259f8df15e31 100644 --- a/services/core/java/com/android/server/wm/TaskSnapshotSurface.java +++ b/services/core/java/com/android/server/wm/TaskSnapshotSurface.java @@ -197,7 +197,7 @@ class TaskSnapshotSurface implements StartingSurface { } try { final int res = session.addToDisplay(window, window.mSeq, layoutParams, - View.VISIBLE, token.getDisplayContent().getDisplayId(), tmpRect, tmpRect, + View.GONE, token.getDisplayContent().getDisplayId(), tmpRect, tmpRect, tmpRect, tmpCutout, null); if (res < 0) { Slog.w(TAG, "Failed to add snapshot starting window res=" + res); diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 4a3a3fc960a5..832d3957ef1b 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -75,9 +75,6 @@ public class TaskStack extends WindowContainer implements /** Unique identifier */ final int mStackId; - /** The service */ - private final WindowManagerService mService; - /** The display this stack sits under. */ // TODO: Track parent marks like this in WindowContainer. private DisplayContent mDisplayContent; @@ -151,7 +148,7 @@ public class TaskStack extends WindowContainer implements final Rect mTmpDimBoundsRect = new Rect(); TaskStack(WindowManagerService service, int stackId, StackWindowController controller) { - mService = service; + super(service); mStackId = stackId; setController(controller); mDockedStackMinimizeThickness = service.mContext.getResources().getDimensionPixelSize( diff --git a/services/core/java/com/android/server/wm/TransactionFactory.java b/services/core/java/com/android/server/wm/TransactionFactory.java new file mode 100644 index 000000000000..067f08369710 --- /dev/null +++ b/services/core/java/com/android/server/wm/TransactionFactory.java @@ -0,0 +1,27 @@ +/* + * 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 android.view.SurfaceControl.Transaction; + +/** + * Helper class to inject custom transaction objects into window manager. + */ +interface TransactionFactory { + Transaction make(); +}; + diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index c371e8832e5a..d6329bfab5a1 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -72,18 +72,25 @@ class WindowContainer extends ConfigurationContainer< WindowContainerController mController; protected SurfaceControl mSurfaceControl; + private int mLastLayer = 0; + private SurfaceControl mLastRelativeToLayer = null; /** * Applied as part of the animation pass in "prepareSurfaces". */ - private Transaction mPendingTransaction = new Transaction(); + private final Transaction mPendingTransaction; + protected final WindowManagerService mService; + + WindowContainer(WindowManagerService service) { + mService = service; + mPendingTransaction = service.mTransactionFactory.make(); + } @Override final protected WindowContainer getParent() { return mParent; } - @Override protected int getChildCount() { return mChildren.size(); @@ -756,34 +763,46 @@ class WindowContainer extends ConfigurationContainer< } void assignLayer(Transaction t, int layer) { - if (mSurfaceControl != null) { + final boolean changed = layer != mLastLayer || mLastRelativeToLayer != null; + if (mSurfaceControl != null && changed) { t.setLayer(mSurfaceControl, layer); + mLastLayer = layer; + mLastRelativeToLayer = null; + } + } + + void assignRelativeLayer(Transaction t, SurfaceControl relativeTo, int layer) { + final boolean changed = layer != mLastLayer || mLastRelativeToLayer != relativeTo; + if (mSurfaceControl != null && changed) { + t.setRelativeLayer(mSurfaceControl, relativeTo, layer); + mLastLayer = layer; + mLastRelativeToLayer = relativeTo; } } void assignChildLayers(Transaction t) { int layer = 0; - boolean boosting = false; // We use two passes as a way to promote children which // need Z-boosting to the end of the list. - for (int i = 0; i < 2; i++ ) { - for (int j = 0; j < mChildren.size(); ++j) { - final WindowContainer wc = mChildren.get(j); - if (wc.needsZBoost() && !boosting) { - continue; - } - wc.assignLayer(t, layer); - wc.assignChildLayers(t); - - layer++; + for (int j = 0; j < mChildren.size(); ++j) { + final WindowContainer wc = mChildren.get(j); + wc.assignChildLayers(t); + if (!wc.needsZBoost()) { + wc.assignLayer(t, layer++); + } + } + for (int j = 0; j < mChildren.size(); ++j) { + final WindowContainer wc = mChildren.get(j); + if (wc.needsZBoost()) { + wc.assignLayer(t, layer++); } - boosting = true; } } void assignChildLayers() { assignChildLayers(getPendingTransaction()); + scheduleAnimation(); } boolean needsZBoost() { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 3ad4df7a7cee..e5982243f94f 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -215,6 +215,7 @@ import android.view.MotionEvent; import android.view.PointerIcon; import android.view.Surface; import android.view.SurfaceControl; +import android.view.SurfaceControl.Builder; import android.view.SurfaceSession; import android.view.View; import android.view.WindowContentFrameStats; @@ -806,12 +807,8 @@ public class WindowManagerService extends IWindowManager.Stub static WindowManagerThreadPriorityBooster sThreadPriorityBooster = new WindowManagerThreadPriorityBooster(); - class DefaultSurfaceBuilderFactory implements SurfaceBuilderFactory { - public SurfaceControl.Builder make(SurfaceSession s) { - return new SurfaceControl.Builder(s); - } - }; - SurfaceBuilderFactory mSurfaceBuilderFactory = new DefaultSurfaceBuilderFactory(); + SurfaceBuilderFactory mSurfaceBuilderFactory = SurfaceControl.Builder::new; + TransactionFactory mTransactionFactory = SurfaceControl.Transaction::new; static void boostPriorityForLockedSection() { sThreadPriorityBooster.boost(); @@ -1502,7 +1499,7 @@ public class WindowManagerService extends IWindowManager.Stub // Don't do layout here, the window must call // relayout to be displayed, so we'll do it there. - displayContent.assignWindowLayers(false /* setLayoutNeeded */); + win.getParent().assignChildLayers(); if (focusChanged) { mInputMonitor.setInputFocusLw(mCurrentFocus, false /*updateInputWindows*/); @@ -1972,6 +1969,13 @@ public class WindowManagerService extends IWindowManager.Stub + " newVis=" + viewVisibility, stack); } + win.setDisplayLayoutNeeded(); + win.mGivenInsetsPending = (flags & WindowManagerGlobal.RELAYOUT_INSETS_PENDING) != 0; + + // We may be deferring layout passes at the moment, but since the client is interested + // in the new out values right now we need to force a layout. + mWindowPlacerLocked.performSurfacePlacement(true /* force */); + // We should only relayout if the view is visible, it is a starting window, or the // associated appToken is not hidden. final boolean shouldRelayout = viewVisibility == View.VISIBLE && @@ -1981,15 +1985,6 @@ public class WindowManagerService extends IWindowManager.Stub if (shouldRelayout) { Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "relayoutWindow: viewVisibility_1"); - // We are about to create a surface, but we didn't run a layout yet. So better run - // a layout now that we already know the right size, as a resize call will make the - // surface transaction blocking until next vsync and slow us down. - // TODO: Ideally we'd create the surface after running layout a bit further down, - // but moving this seems to be too risky at this point in the release. - if (win.mLayoutSeq == -1) { - win.setDisplayLayoutNeeded(); - mWindowPlacerLocked.performSurfacePlacement(true); - } result = win.relayoutVisibleWindow(result, attrChanges, oldVisibility); try { @@ -2091,16 +2086,11 @@ public class WindowManagerService extends IWindowManager.Stub mUnknownAppVisibilityController.notifyRelayouted(win.mAppToken); } - win.setDisplayLayoutNeeded(); - win.mGivenInsetsPending = (flags & WindowManagerGlobal.RELAYOUT_INSETS_PENDING) != 0; Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "relayoutWindow: updateOrientationFromAppTokens"); configChanged = updateOrientationFromAppTokensLocked(false, displayId); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); - // We may be deferring layout passes at the moment, but since the client is interested - // in the new out values right now we need to force a layout. - mWindowPlacerLocked.performSurfacePlacement(true /* force */); if (toBeDisplayed && win.mIsWallpaper) { DisplayInfo displayInfo = win.getDisplayContent().getDisplayInfo(); dc.mWallpaperController.updateWallpaperOffset( diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index d23a6c73d853..e38605d33f26 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -186,7 +186,6 @@ class WindowState extends WindowContainer implements WindowManagerP // to capture touch events in that area. static final int RESIZE_HANDLE_WIDTH_IN_DP = 30; - final WindowManagerService mService; final WindowManagerPolicy mPolicy; final Context mContext; final Session mSession; @@ -627,7 +626,7 @@ class WindowState extends WindowContainer implements WindowManagerP WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token, WindowState parentWindow, int appOp, int seq, WindowManager.LayoutParams a, int viewVisibility, int ownerId, boolean ownerCanAddInternalSystemWindow) { - mService = service; + super(service); mSession = s; mClient = c; mAppOp = appOp; diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java index a3d4b71a68af..5bcf59cf1711 100644 --- a/services/core/java/com/android/server/wm/WindowToken.java +++ b/services/core/java/com/android/server/wm/WindowToken.java @@ -46,9 +46,6 @@ import java.io.PrintWriter; class WindowToken extends WindowContainer { private static final String TAG = TAG_WITH_CLASS_NAME ? "WindowToken" : TAG_WM; - // The window manager! - protected final WindowManagerService mService; - // The actual token. final IBinder token; @@ -107,7 +104,7 @@ class WindowToken extends WindowContainer { WindowToken(WindowManagerService service, IBinder _token, int type, boolean persistOnEmpty, DisplayContent dc, boolean ownerCanManageAppTokens) { - mService = service; + super(service); token = _token; windowType = type; mPersistOnEmpty = persistOnEmpty; diff --git a/services/tests/servicestests/src/com/android/server/wm/DimmerTests.java b/services/tests/servicestests/src/com/android/server/wm/DimmerTests.java index f069d49a244b..4dd51ebd2d06 100644 --- a/services/tests/servicestests/src/com/android/server/wm/DimmerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/DimmerTests.java @@ -48,6 +48,10 @@ public class DimmerTests extends WindowTestsBase { final SurfaceControl mControl = mock(SurfaceControl.class); final SurfaceControl.Transaction mTransaction = mock(SurfaceControl.Transaction.class); + TestWindowContainer() { + super(sWm); + } + @Override SurfaceControl getSurfaceControl() { return mControl; @@ -65,6 +69,10 @@ public class DimmerTests extends WindowTestsBase { final SurfaceControl mHostControl = mock(SurfaceControl.class); final SurfaceControl.Transaction mHostTransaction = mock(SurfaceControl.Transaction.class); + MockSurfaceBuildingContainer() { + super(sWm); + } + class MockSurfaceBuilder extends SurfaceControl.Builder { MockSurfaceBuilder(SurfaceSession ss) { super(ss); @@ -78,6 +86,7 @@ public class DimmerTests extends WindowTestsBase { } } + @Override SurfaceControl.Builder makeChildSurface(WindowContainer child) { return new MockSurfaceBuilder(mSession); diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowContainerControllerTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowContainerControllerTests.java index 8df7568ebcd9..bab2170ad7bb 100644 --- a/services/tests/servicestests/src/com/android/server/wm/WindowContainerControllerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowContainerControllerTests.java @@ -44,7 +44,7 @@ public class WindowContainerControllerTests extends WindowTestsBase { @Test public void testCreation() throws Exception { final WindowContainerController controller = new WindowContainerController(null, sWm); - final WindowContainer container = new WindowContainer(); + final WindowContainer container = new WindowContainer(sWm); container.setController(controller); assertEquals(controller, container.getController()); @@ -54,7 +54,7 @@ public class WindowContainerControllerTests extends WindowTestsBase { @Test public void testSetContainer() throws Exception { final WindowContainerController controller = new WindowContainerController(null, sWm); - final WindowContainer container = new WindowContainer(); + final WindowContainer container = new WindowContainer(sWm); controller.setContainer(container); assertEquals(controller.mContainer, container); @@ -62,7 +62,7 @@ public class WindowContainerControllerTests extends WindowTestsBase { // Assert we can't change the container to another one once set boolean gotException = false; try { - controller.setContainer(new WindowContainer()); + controller.setContainer(new WindowContainer(sWm)); } catch (IllegalArgumentException e) { gotException = true; } @@ -76,7 +76,7 @@ public class WindowContainerControllerTests extends WindowTestsBase { @Test public void testRemoveContainer() throws Exception { final WindowContainerController controller = new WindowContainerController(null, sWm); - final WindowContainer container = new WindowContainer(); + final WindowContainer container = new WindowContainer(sWm); controller.setContainer(container); assertEquals(controller.mContainer, container); @@ -88,7 +88,7 @@ public class WindowContainerControllerTests extends WindowTestsBase { @Test public void testOnOverrideConfigurationChanged() throws Exception { final WindowContainerController controller = new WindowContainerController(null, sWm); - final WindowContainer container = new WindowContainer(); + final WindowContainer container = new WindowContainer(sWm); controller.setContainer(container); assertEquals(controller.mContainer, container); diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowContainerTests.java b/services/tests/servicestests/src/com/android/server/wm/WindowContainerTests.java index 16b6ca684c78..5cb94678a58c 100644 --- a/services/tests/servicestests/src/com/android/server/wm/WindowContainerTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowContainerTests.java @@ -193,7 +193,7 @@ public class WindowContainerTests extends WindowTestsBase { @Test public void testRemoveImmediately_WithController() throws Exception { - final WindowContainer container = new WindowContainer(); + final WindowContainer container = new WindowContainer(sWm); final WindowContainerController controller = new WindowContainerController(null, sWm); container.setController(controller); @@ -208,7 +208,7 @@ public class WindowContainerTests extends WindowTestsBase { @Test public void testSetController() throws Exception { final WindowContainerController controller = new WindowContainerController(null, sWm); - final WindowContainer container = new WindowContainer(); + final WindowContainer container = new WindowContainer(sWm); container.setController(controller); assertEquals(controller, container.getController()); @@ -587,6 +587,7 @@ public class WindowContainerTests extends WindowTestsBase { TestWindowContainer(int layer, boolean isAnimating, boolean isVisible, Integer orientation) { + super(sWm); mLayer = layer; mIsAnimating = isAnimating; mIsVisible = isVisible; diff --git a/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java b/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java index e5cbdba7b507..6468763440a5 100644 --- a/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/ZOrderingTests.java @@ -16,23 +16,6 @@ package com.android.server.wm; -import java.util.HashMap; -import java.util.LinkedList; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import android.view.SurfaceControl; -import android.view.SurfaceSession; -import android.util.Log; - -import android.platform.test.annotations.Presubmit; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; - import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; @@ -42,10 +25,23 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; -import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; +import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; + +import android.platform.test.annotations.Presubmit; +import android.support.test.filters.SmallTest; +import android.support.test.runner.AndroidJUnit4; +import android.view.SurfaceControl; +import android.view.SurfaceSession; + +import org.junit.After; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.HashMap; +import java.util.LinkedList; /** * Tests for the {@link WindowLayersController} class. @@ -79,7 +75,7 @@ public class ZOrderingTests extends WindowTestsBase { } int getLayer(SurfaceControl sc) { - return mLayersForControl.get(sc); + return mLayersForControl.getOrDefault(sc, 0); } SurfaceControl getRelativeLayer(SurfaceControl sc) { @@ -125,6 +121,7 @@ public class ZOrderingTests extends WindowTestsBase { // would miss construction of the top-level layers. mTransaction = new LayerRecordingTransaction(); sWm.mSurfaceBuilderFactory = new HierarchyRecordingBuilderFactory(); + sWm.mTransactionFactory = () -> mTransaction; } @After -- cgit v1.2.3-59-g8ed1b