Loading services/core/java/com/android/server/wm/Dimmer.java +4 −34 Original line number Diff line number Diff line Loading @@ -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); } 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 Loading services/tests/wmtests/src/com/android/server/wm/DimmerTests.java +5 −39 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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); Loading Loading
services/core/java/com/android/server/wm/Dimmer.java +4 −34 Original line number Diff line number Diff line Loading @@ -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); } 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 Loading
services/tests/wmtests/src/com/android/server/wm/DimmerTests.java +5 −39 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading @@ -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); Loading