diff --git a/services/core/java/com/android/server/wm/Dimmer.java b/services/core/java/com/android/server/wm/Dimmer.java index e7ab63eab2025..13a1cb6daf385 100644 --- a/services/core/java/com/android/server/wm/Dimmer.java +++ b/services/core/java/com/android/server/wm/Dimmer.java @@ -216,46 +216,16 @@ class Dimmer { return; } - if (container != null) { - // The dim method is called from WindowState.prepareSurfaces(), which is always called - // in the correct Z from lowest Z to highest. This ensures that the dim layer is always - // relative to the highest Z layer with a dim. - t.setRelativeLayer(d.mDimLayer, container.getSurfaceControl(), relativeLayer); - } else { - t.setLayer(d.mDimLayer, Integer.MAX_VALUE); - } + // The dim method is called from WindowState.prepareSurfaces(), which is always called + // in the correct Z from lowest Z to highest. This ensures that the dim layer is always + // relative to the highest Z layer with a dim. + t.setRelativeLayer(d.mDimLayer, container.getSurfaceControl(), relativeLayer); t.setAlpha(d.mDimLayer, alpha); t.setBackgroundBlurRadius(d.mDimLayer, blurRadius); d.mDimming = true; } - /** - * Finish a dim started by dimAbove in the case there was no call to dimAbove. - * - * @param t A Transaction in which to finish the dim. - */ - void stopDim(SurfaceControl.Transaction t) { - if (mDimState != null) { - t.hide(mDimState.mDimLayer); - mDimState.isVisible = false; - mDimState.mDontReset = false; - } - } - - /** - * Place a Dim above the entire host container. The caller is responsible for calling stopDim to - * remove this effect. If the Dim can be assosciated with a particular child of the host - * consider using the other variant of dimAbove which ties the Dim lifetime to the child - * lifetime more explicitly. - * - * @param t A transaction in which to apply the Dim. - * @param alpha The alpha at which to Dim. - */ - void dimAbove(SurfaceControl.Transaction t, float alpha) { - dim(t, null, 1, alpha, 0); - } - /** * Place a dim above the given container, which should be a child of the host container. * for each call to {@link WindowContainer#prepareSurfaces} the Dim state will be reset diff --git a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java b/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java index 55a7c1ba0bcab..befe4e85a7de8 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java @@ -24,7 +24,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_DIMMER; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -138,35 +137,13 @@ public class DimmerTests extends WindowTestsBase { mDimmer = new Dimmer(mHost, mSurfaceAnimatorStarter); } - @Test - public void testDimAboveNoChildCreatesSurface() { - final float alpha = 0.8f; - mDimmer.dimAbove(mTransaction, alpha); - - SurfaceControl dimLayer = getDimLayer(); - - assertNotNull("Dimmer should have created a surface", dimLayer); - - verify(mTransaction).setAlpha(dimLayer, alpha); - verify(mTransaction).setLayer(dimLayer, Integer.MAX_VALUE); - } - - @Test - public void testDimAboveNoChildRedundantlyUpdatesAlphaOnExistingSurface() { - float alpha = 0.8f; - mDimmer.dimAbove(mTransaction, alpha); - final SurfaceControl firstSurface = getDimLayer(); - - alpha = 0.9f; - mDimmer.dimAbove(mTransaction, alpha); - - assertEquals(firstSurface, getDimLayer()); - verify(mTransaction).setAlpha(firstSurface, 0.9f); - } - @Test public void testUpdateDimsAppliesCrop() { - mDimmer.dimAbove(mTransaction, 0.8f); + TestWindowContainer child = new TestWindowContainer(mWm); + mHost.addChild(child, 0); + + final float alpha = 0.8f; + mDimmer.dimAbove(mTransaction, child, alpha); int width = 100; int height = 300; @@ -177,17 +154,6 @@ public class DimmerTests extends WindowTestsBase { verify(mTransaction).show(getDimLayer()); } - @Test - public void testDimAboveNoChildNotReset() { - mDimmer.dimAbove(mTransaction, 0.8f); - SurfaceControl dimLayer = getDimLayer(); - mDimmer.resetDimStates(); - - mDimmer.updateDims(mTransaction, new Rect()); - verify(mTransaction).show(getDimLayer()); - verify(mTransaction, never()).remove(dimLayer); - } - @Test public void testDimAboveWithChildCreatesSurfaceAboveChild() { TestWindowContainer child = new TestWindowContainer(mWm);