Loading services/core/java/com/android/server/wm/Dimmer.java +13 −5 Original line number Original line Diff line number Diff line Loading @@ -40,11 +40,14 @@ class Dimmer { * The {@link WindowContainer} that our Dims are bounded to. We may be dimming on behalf of the * The {@link WindowContainer} that our Dims are bounded to. We may be dimming on behalf of the * host, some controller of it, or one of the hosts children. * host, some controller of it, or one of the hosts children. */ */ @NonNull private final WindowContainer<?> mHost; private final WindowContainer<?> mHost; private static final String TAG = "WindowManagerDimmer"; private static final String TAG = "WindowManagerDimmer"; @Nullable DimState mDimState; DimState mDimState; @NonNull final DimmerAnimationHelper.AnimationAdapterFactory mAnimationAdapterFactory; final DimmerAnimationHelper.AnimationAdapterFactory mAnimationAdapterFactory; /** /** Loading @@ -57,6 +60,7 @@ class Dimmer { // The last container to request to dim // The last container to request to dim private WindowState mLastDimmingWindow; private WindowState mLastDimmingWindow; /** Animation */ /** Animation */ @NonNull private final DimmerAnimationHelper mAnimationHelper; private final DimmerAnimationHelper mAnimationHelper; boolean mSkipAnimation = false; boolean mSkipAnimation = false; // Determines whether the dim layer should animate before destroying. // Determines whether the dim layer should animate before destroying. Loading @@ -64,6 +68,7 @@ class Dimmer { /** Surface visibility and bounds */ /** Surface visibility and bounds */ private boolean mIsVisible = false; private boolean mIsVisible = false; // TODO(b/64816140): Remove after confirming dimmer layer always matches its container. // TODO(b/64816140): Remove after confirming dimmer layer always matches its container. @NonNull final Rect mDimBounds = new Rect(); final Rect mDimBounds = new Rect(); DimState() { DimState() { Loading Loading @@ -165,6 +170,7 @@ class Dimmer { && (mHostContainer.isVisibleRequested() || !Flags.useTasksDimOnly()); && (mHostContainer.isVisibleRequested() || !Flags.useTasksDimOnly()); } } @NonNull private SurfaceControl makeDimLayer() { private SurfaceControl makeDimLayer() { return mHost.makeChildSurface(null) return mHost.makeChildSurface(null) .setParent(mHost.getSurfaceControl()) .setParent(mHost.getSurfaceControl()) Loading @@ -180,7 +186,7 @@ class Dimmer { } } @VisibleForTesting @VisibleForTesting Dimmer(@NonNull WindowContainer host, Dimmer(@NonNull WindowContainer<?> host, @NonNull DimmerAnimationHelper.AnimationAdapterFactory animationFactory) { @NonNull DimmerAnimationHelper.AnimationAdapterFactory animationFactory) { mHost = host; mHost = host; mAnimationAdapterFactory = animationFactory; mAnimationAdapterFactory = animationFactory; Loading Loading @@ -236,7 +242,7 @@ class Dimmer { * If multiple containers call this method, only the changes relative to the topmost will be * If multiple containers call this method, only the changes relative to the topmost will be * applied. * applied. * * * For each call to {@link WindowContainer#prepareSurfaces()} the DimState will be reset, and * <p>For each call to {@link WindowContainer#prepareSurfaces()} the DimState will be reset, and * the child of the host should call adjustRelativeLayer and {@link Dimmer#adjustAppearance} to * the child of the host should call adjustRelativeLayer and {@link Dimmer#adjustAppearance} to * continue dimming. Indeed, this method won't be able to keep dimming or get a new DimState * continue dimming. Indeed, this method won't be able to keep dimming or get a new DimState * without also adjusting the appearance. * without also adjusting the appearance. Loading Loading @@ -301,11 +307,13 @@ class Dimmer { } } /** Returns non-null bounds if the dimmer is showing. */ /** Returns non-null bounds if the dimmer is showing. */ @Nullable @VisibleForTesting @VisibleForTesting SurfaceControl getDimLayer() { SurfaceControl getDimLayer() { return mDimState != null ? mDimState.mDimSurface : null; return mDimState != null ? mDimState.mDimSurface : null; } } @Nullable Rect getDimBounds() { Rect getDimBounds() { return mDimState != null ? mDimState.mDimBounds : null; return mDimState != null ? mDimState.mDimBounds : null; } } Loading services/core/java/com/android/server/wm/DimmerAnimationHelper.java +28 −14 Original line number Original line Diff line number Diff line Loading @@ -51,7 +51,9 @@ public class DimmerAnimationHelper { static class Change { static class Change { private float mAlpha = -1f; private float mAlpha = -1f; private int mBlurRadius = -1; private int mBlurRadius = -1; @Nullable private WindowState mDimmingContainer = null; private WindowState mDimmingContainer = null; @Nullable private WindowContainer<?> mGeometryParent = null; private WindowContainer<?> mGeometryParent = null; private static final float EPSILON = 0.0001f; private static final float EPSILON = 0.0001f; Loading Loading @@ -91,15 +93,22 @@ public class DimmerAnimationHelper { } } } } @NonNull private final Change mCurrentProperties = new Change(); private final Change mCurrentProperties = new Change(); @NonNull private final Change mRequestedProperties = new Change(); private final Change mRequestedProperties = new Change(); @Nullable private AnimationSpec mAlphaAnimationSpec; private AnimationSpec mAlphaAnimationSpec; @NonNull private final SurfaceAnimationRunner mSurfaceAnimationRunner; private final SurfaceAnimationRunner mSurfaceAnimationRunner; @NonNull private final AnimationAdapterFactory mAnimationAdapterFactory; private final AnimationAdapterFactory mAnimationAdapterFactory; @Nullable private AnimationAdapter mLocalAnimationAdapter; private AnimationAdapter mLocalAnimationAdapter; DimmerAnimationHelper(WindowContainer<?> host, AnimationAdapterFactory animationFactory) { DimmerAnimationHelper(@NonNull WindowContainer<?> host, @NonNull AnimationAdapterFactory animationFactory) { mAnimationAdapterFactory = animationFactory; mAnimationAdapterFactory = animationFactory; mSurfaceAnimationRunner = host.mWmService.mSurfaceAnimationRunner; mSurfaceAnimationRunner = host.mWmService.mSurfaceAnimationRunner; } } Loading Loading @@ -130,7 +139,8 @@ public class DimmerAnimationHelper { /** /** * Commit the last changes we received. Called after * Commit the last changes we received. Called after * {@link Change#setExitParameters()}, * {@link Change#setExitParameters()}, * {@link Change#setRequestedRelativeParent(WindowContainer)}, or * {@link Change#setRequestedRelativeParent(WindowState)}, or * {@link Change#setRequestedGeometryParent(WindowContainer)}, or * {@link Change#setRequestedAppearance(float, int)} * {@link Change#setRequestedAppearance(float, int)} */ */ void applyChanges(@NonNull SurfaceControl.Transaction t, @NonNull Dimmer.DimState dim) { void applyChanges(@NonNull SurfaceControl.Transaction t, @NonNull Dimmer.DimState dim) { Loading Loading @@ -227,7 +237,8 @@ public class DimmerAnimationHelper { } } @NonNull @NonNull private static AnimationSpec getRequestedAnimationSpec(Change from, Change to) { private static AnimationSpec getRequestedAnimationSpec(@NonNull Change from, @NonNull Change to) { final float startAlpha = Math.max(from.mAlpha, 0f); final float startAlpha = Math.max(from.mAlpha, 0f); final int startBlur = Math.max(from.mBlurRadius, 0); final int startBlur = Math.max(from.mBlurRadius, 0); long duration = (long) (getDimDuration(to.mDimmingContainer) long duration = (long) (getDimDuration(to.mDimmingContainer) Loading Loading @@ -331,15 +342,17 @@ public class DimmerAnimationHelper { } } private final long mDuration; private final long mDuration; @NonNull private final AnimationSpec.AnimationExtremes<Float> mAlpha; private final AnimationSpec.AnimationExtremes<Float> mAlpha; @NonNull private final AnimationSpec.AnimationExtremes<Integer> mBlur; private final AnimationSpec.AnimationExtremes<Integer> mBlur; float mCurrentAlpha = 0; float mCurrentAlpha = 0; int mCurrentBlur = 0; int mCurrentBlur = 0; boolean mStarted = false; boolean mStarted = false; AnimationSpec(AnimationSpec.AnimationExtremes<Float> alpha, AnimationSpec(@NonNull AnimationSpec.AnimationExtremes<Float> alpha, AnimationSpec.AnimationExtremes<Integer> blur, long duration) { @NonNull AnimationSpec.AnimationExtremes<Integer> blur, long duration) { mAlpha = alpha; mAlpha = alpha; mBlur = blur; mBlur = blur; mDuration = duration; mDuration = duration; Loading Loading @@ -379,7 +392,7 @@ public class DimmerAnimationHelper { } } @Override @Override public void dump(PrintWriter pw, String prefix) { public void dump(@NonNull PrintWriter pw, @NonNull String prefix) { pw.print(prefix); pw.print("from_alpha="); pw.print(mAlpha.mStartValue); pw.print(prefix); pw.print("from_alpha="); pw.print(mAlpha.mStartValue); pw.print(" to_alpha="); pw.print(mAlpha.mFinishValue); pw.print(" to_alpha="); pw.print(mAlpha.mFinishValue); pw.print(prefix); pw.print("from_blur="); pw.print(mBlur.mStartValue); pw.print(prefix); pw.print("from_blur="); pw.print(mBlur.mStartValue); Loading @@ -388,7 +401,7 @@ public class DimmerAnimationHelper { } } @Override @Override public void dumpDebugInner(ProtoOutputStream proto) { public void dumpDebugInner(@NonNull ProtoOutputStream proto) { final long token = proto.start(ALPHA); final long token = proto.start(ALPHA); proto.write(FROM, mAlpha.mStartValue); proto.write(FROM, mAlpha.mStartValue); proto.write(TO, mAlpha.mFinishValue); proto.write(TO, mAlpha.mFinishValue); Loading @@ -398,8 +411,9 @@ public class DimmerAnimationHelper { } } static class AnimationAdapterFactory { static class AnimationAdapterFactory { public AnimationAdapter get(LocalAnimationAdapter.AnimationSpec alphaAnimationSpec, @NonNull SurfaceAnimationRunner runner) { public AnimationAdapter get(@NonNull LocalAnimationAdapter.AnimationSpec alphaAnimationSpec, @NonNull SurfaceAnimationRunner runner) { return new LocalAnimationAdapter(alphaAnimationSpec, runner); return new LocalAnimationAdapter(alphaAnimationSpec, runner); } } } } Loading services/tests/wmtests/src/com/android/server/wm/DimmerTests.java +14 −4 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,9 @@ import android.platform.test.annotations.RequiresFlagsEnabled; import android.view.SurfaceControl; import android.view.SurfaceControl; import android.view.SurfaceSession; import android.view.SurfaceSession; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.server.testutils.StubTransaction; import com.android.server.testutils.StubTransaction; import com.android.server.wm.utils.MockAnimationAdapter; import com.android.server.wm.utils.MockAnimationAdapter; import com.android.window.flags.Flags; import com.android.window.flags.Flags; Loading Loading @@ -66,11 +69,12 @@ public class DimmerTests extends WindowTestsBase { mVisibleRequested = true; mVisibleRequested = true; } } class MockSurfaceBuilder extends SurfaceControl.Builder { static class MockSurfaceBuilder extends SurfaceControl.Builder { MockSurfaceBuilder(SurfaceSession ss) { MockSurfaceBuilder(SurfaceSession ss) { super(ss); super(ss); } } @NonNull @Override @Override public SurfaceControl build() { public SurfaceControl build() { SurfaceControl mSc = mock(SurfaceControl.class); SurfaceControl mSc = mock(SurfaceControl.class); Loading @@ -79,26 +83,31 @@ public class DimmerTests extends WindowTestsBase { } } } } @NonNull @Override @Override SurfaceControl.Builder makeChildSurface(WindowContainer child) { SurfaceControl.Builder makeChildSurface(@Nullable WindowContainer child) { return new MockSurfaceBuilder(mSession); return new MockSurfaceBuilder(mSession); } } @Nullable @Override @Override public SurfaceControl getSurfaceControl() { public SurfaceControl getSurfaceControl() { return mHostControl; return mHostControl; } } @NonNull @Override @Override public SurfaceControl.Transaction getSyncTransaction() { public SurfaceControl.Transaction getSyncTransaction() { return mHostTransaction; return mHostTransaction; } } @NonNull @Override @Override public SurfaceControl.Transaction getPendingTransaction() { public SurfaceControl.Transaction getPendingTransaction() { return mHostTransaction; return mHostTransaction; } } @NonNull @Override @Override public Rect getBounds() { public Rect getBounds() { return mBounds; return mBounds; Loading @@ -106,9 +115,10 @@ public class DimmerTests extends WindowTestsBase { } } static class MockAnimationAdapterFactory extends DimmerAnimationHelper.AnimationAdapterFactory { static class MockAnimationAdapterFactory extends DimmerAnimationHelper.AnimationAdapterFactory { @NonNull @Override @Override public AnimationAdapter get(LocalAnimationAdapter.AnimationSpec alphaAnimationSpec, public AnimationAdapter get(@NonNull LocalAnimationAdapter.AnimationSpec alphaAnimationSpec, SurfaceAnimationRunner runner) { @NonNull SurfaceAnimationRunner runner) { return sTestAnimation; return sTestAnimation; } } } } Loading services/tests/wmtests/src/com/android/server/wm/utils/MockAnimationAdapter.java +5 −4 Original line number Original line Diff line number Diff line Loading @@ -38,8 +38,9 @@ public class MockAnimationAdapter implements AnimationAdapter { } } @Override @Override public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t, public void startAnimation(@NonNull SurfaceControl animationLeash, int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { @NonNull SurfaceControl.Transaction t, int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { // As the animation won't run, finish it immediately // As the animation won't run, finish it immediately finishCallback.onAnimationFinished(0, null); finishCallback.onAnimationFinished(0, null); } } Loading @@ -58,8 +59,8 @@ public class MockAnimationAdapter implements AnimationAdapter { } } @Override @Override public void dump(PrintWriter pw, String prefix) {} public void dump(@NonNull PrintWriter pw, @NonNull String prefix) {} @Override @Override public void dumpDebug(ProtoOutputStream proto) {} public void dumpDebug(@NonNull ProtoOutputStream proto) {} } } Loading
services/core/java/com/android/server/wm/Dimmer.java +13 −5 Original line number Original line Diff line number Diff line Loading @@ -40,11 +40,14 @@ class Dimmer { * The {@link WindowContainer} that our Dims are bounded to. We may be dimming on behalf of the * The {@link WindowContainer} that our Dims are bounded to. We may be dimming on behalf of the * host, some controller of it, or one of the hosts children. * host, some controller of it, or one of the hosts children. */ */ @NonNull private final WindowContainer<?> mHost; private final WindowContainer<?> mHost; private static final String TAG = "WindowManagerDimmer"; private static final String TAG = "WindowManagerDimmer"; @Nullable DimState mDimState; DimState mDimState; @NonNull final DimmerAnimationHelper.AnimationAdapterFactory mAnimationAdapterFactory; final DimmerAnimationHelper.AnimationAdapterFactory mAnimationAdapterFactory; /** /** Loading @@ -57,6 +60,7 @@ class Dimmer { // The last container to request to dim // The last container to request to dim private WindowState mLastDimmingWindow; private WindowState mLastDimmingWindow; /** Animation */ /** Animation */ @NonNull private final DimmerAnimationHelper mAnimationHelper; private final DimmerAnimationHelper mAnimationHelper; boolean mSkipAnimation = false; boolean mSkipAnimation = false; // Determines whether the dim layer should animate before destroying. // Determines whether the dim layer should animate before destroying. Loading @@ -64,6 +68,7 @@ class Dimmer { /** Surface visibility and bounds */ /** Surface visibility and bounds */ private boolean mIsVisible = false; private boolean mIsVisible = false; // TODO(b/64816140): Remove after confirming dimmer layer always matches its container. // TODO(b/64816140): Remove after confirming dimmer layer always matches its container. @NonNull final Rect mDimBounds = new Rect(); final Rect mDimBounds = new Rect(); DimState() { DimState() { Loading Loading @@ -165,6 +170,7 @@ class Dimmer { && (mHostContainer.isVisibleRequested() || !Flags.useTasksDimOnly()); && (mHostContainer.isVisibleRequested() || !Flags.useTasksDimOnly()); } } @NonNull private SurfaceControl makeDimLayer() { private SurfaceControl makeDimLayer() { return mHost.makeChildSurface(null) return mHost.makeChildSurface(null) .setParent(mHost.getSurfaceControl()) .setParent(mHost.getSurfaceControl()) Loading @@ -180,7 +186,7 @@ class Dimmer { } } @VisibleForTesting @VisibleForTesting Dimmer(@NonNull WindowContainer host, Dimmer(@NonNull WindowContainer<?> host, @NonNull DimmerAnimationHelper.AnimationAdapterFactory animationFactory) { @NonNull DimmerAnimationHelper.AnimationAdapterFactory animationFactory) { mHost = host; mHost = host; mAnimationAdapterFactory = animationFactory; mAnimationAdapterFactory = animationFactory; Loading Loading @@ -236,7 +242,7 @@ class Dimmer { * If multiple containers call this method, only the changes relative to the topmost will be * If multiple containers call this method, only the changes relative to the topmost will be * applied. * applied. * * * For each call to {@link WindowContainer#prepareSurfaces()} the DimState will be reset, and * <p>For each call to {@link WindowContainer#prepareSurfaces()} the DimState will be reset, and * the child of the host should call adjustRelativeLayer and {@link Dimmer#adjustAppearance} to * the child of the host should call adjustRelativeLayer and {@link Dimmer#adjustAppearance} to * continue dimming. Indeed, this method won't be able to keep dimming or get a new DimState * continue dimming. Indeed, this method won't be able to keep dimming or get a new DimState * without also adjusting the appearance. * without also adjusting the appearance. Loading Loading @@ -301,11 +307,13 @@ class Dimmer { } } /** Returns non-null bounds if the dimmer is showing. */ /** Returns non-null bounds if the dimmer is showing. */ @Nullable @VisibleForTesting @VisibleForTesting SurfaceControl getDimLayer() { SurfaceControl getDimLayer() { return mDimState != null ? mDimState.mDimSurface : null; return mDimState != null ? mDimState.mDimSurface : null; } } @Nullable Rect getDimBounds() { Rect getDimBounds() { return mDimState != null ? mDimState.mDimBounds : null; return mDimState != null ? mDimState.mDimBounds : null; } } Loading
services/core/java/com/android/server/wm/DimmerAnimationHelper.java +28 −14 Original line number Original line Diff line number Diff line Loading @@ -51,7 +51,9 @@ public class DimmerAnimationHelper { static class Change { static class Change { private float mAlpha = -1f; private float mAlpha = -1f; private int mBlurRadius = -1; private int mBlurRadius = -1; @Nullable private WindowState mDimmingContainer = null; private WindowState mDimmingContainer = null; @Nullable private WindowContainer<?> mGeometryParent = null; private WindowContainer<?> mGeometryParent = null; private static final float EPSILON = 0.0001f; private static final float EPSILON = 0.0001f; Loading Loading @@ -91,15 +93,22 @@ public class DimmerAnimationHelper { } } } } @NonNull private final Change mCurrentProperties = new Change(); private final Change mCurrentProperties = new Change(); @NonNull private final Change mRequestedProperties = new Change(); private final Change mRequestedProperties = new Change(); @Nullable private AnimationSpec mAlphaAnimationSpec; private AnimationSpec mAlphaAnimationSpec; @NonNull private final SurfaceAnimationRunner mSurfaceAnimationRunner; private final SurfaceAnimationRunner mSurfaceAnimationRunner; @NonNull private final AnimationAdapterFactory mAnimationAdapterFactory; private final AnimationAdapterFactory mAnimationAdapterFactory; @Nullable private AnimationAdapter mLocalAnimationAdapter; private AnimationAdapter mLocalAnimationAdapter; DimmerAnimationHelper(WindowContainer<?> host, AnimationAdapterFactory animationFactory) { DimmerAnimationHelper(@NonNull WindowContainer<?> host, @NonNull AnimationAdapterFactory animationFactory) { mAnimationAdapterFactory = animationFactory; mAnimationAdapterFactory = animationFactory; mSurfaceAnimationRunner = host.mWmService.mSurfaceAnimationRunner; mSurfaceAnimationRunner = host.mWmService.mSurfaceAnimationRunner; } } Loading Loading @@ -130,7 +139,8 @@ public class DimmerAnimationHelper { /** /** * Commit the last changes we received. Called after * Commit the last changes we received. Called after * {@link Change#setExitParameters()}, * {@link Change#setExitParameters()}, * {@link Change#setRequestedRelativeParent(WindowContainer)}, or * {@link Change#setRequestedRelativeParent(WindowState)}, or * {@link Change#setRequestedGeometryParent(WindowContainer)}, or * {@link Change#setRequestedAppearance(float, int)} * {@link Change#setRequestedAppearance(float, int)} */ */ void applyChanges(@NonNull SurfaceControl.Transaction t, @NonNull Dimmer.DimState dim) { void applyChanges(@NonNull SurfaceControl.Transaction t, @NonNull Dimmer.DimState dim) { Loading Loading @@ -227,7 +237,8 @@ public class DimmerAnimationHelper { } } @NonNull @NonNull private static AnimationSpec getRequestedAnimationSpec(Change from, Change to) { private static AnimationSpec getRequestedAnimationSpec(@NonNull Change from, @NonNull Change to) { final float startAlpha = Math.max(from.mAlpha, 0f); final float startAlpha = Math.max(from.mAlpha, 0f); final int startBlur = Math.max(from.mBlurRadius, 0); final int startBlur = Math.max(from.mBlurRadius, 0); long duration = (long) (getDimDuration(to.mDimmingContainer) long duration = (long) (getDimDuration(to.mDimmingContainer) Loading Loading @@ -331,15 +342,17 @@ public class DimmerAnimationHelper { } } private final long mDuration; private final long mDuration; @NonNull private final AnimationSpec.AnimationExtremes<Float> mAlpha; private final AnimationSpec.AnimationExtremes<Float> mAlpha; @NonNull private final AnimationSpec.AnimationExtremes<Integer> mBlur; private final AnimationSpec.AnimationExtremes<Integer> mBlur; float mCurrentAlpha = 0; float mCurrentAlpha = 0; int mCurrentBlur = 0; int mCurrentBlur = 0; boolean mStarted = false; boolean mStarted = false; AnimationSpec(AnimationSpec.AnimationExtremes<Float> alpha, AnimationSpec(@NonNull AnimationSpec.AnimationExtremes<Float> alpha, AnimationSpec.AnimationExtremes<Integer> blur, long duration) { @NonNull AnimationSpec.AnimationExtremes<Integer> blur, long duration) { mAlpha = alpha; mAlpha = alpha; mBlur = blur; mBlur = blur; mDuration = duration; mDuration = duration; Loading Loading @@ -379,7 +392,7 @@ public class DimmerAnimationHelper { } } @Override @Override public void dump(PrintWriter pw, String prefix) { public void dump(@NonNull PrintWriter pw, @NonNull String prefix) { pw.print(prefix); pw.print("from_alpha="); pw.print(mAlpha.mStartValue); pw.print(prefix); pw.print("from_alpha="); pw.print(mAlpha.mStartValue); pw.print(" to_alpha="); pw.print(mAlpha.mFinishValue); pw.print(" to_alpha="); pw.print(mAlpha.mFinishValue); pw.print(prefix); pw.print("from_blur="); pw.print(mBlur.mStartValue); pw.print(prefix); pw.print("from_blur="); pw.print(mBlur.mStartValue); Loading @@ -388,7 +401,7 @@ public class DimmerAnimationHelper { } } @Override @Override public void dumpDebugInner(ProtoOutputStream proto) { public void dumpDebugInner(@NonNull ProtoOutputStream proto) { final long token = proto.start(ALPHA); final long token = proto.start(ALPHA); proto.write(FROM, mAlpha.mStartValue); proto.write(FROM, mAlpha.mStartValue); proto.write(TO, mAlpha.mFinishValue); proto.write(TO, mAlpha.mFinishValue); Loading @@ -398,8 +411,9 @@ public class DimmerAnimationHelper { } } static class AnimationAdapterFactory { static class AnimationAdapterFactory { public AnimationAdapter get(LocalAnimationAdapter.AnimationSpec alphaAnimationSpec, @NonNull SurfaceAnimationRunner runner) { public AnimationAdapter get(@NonNull LocalAnimationAdapter.AnimationSpec alphaAnimationSpec, @NonNull SurfaceAnimationRunner runner) { return new LocalAnimationAdapter(alphaAnimationSpec, runner); return new LocalAnimationAdapter(alphaAnimationSpec, runner); } } } } Loading
services/tests/wmtests/src/com/android/server/wm/DimmerTests.java +14 −4 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,9 @@ import android.platform.test.annotations.RequiresFlagsEnabled; import android.view.SurfaceControl; import android.view.SurfaceControl; import android.view.SurfaceSession; import android.view.SurfaceSession; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.server.testutils.StubTransaction; import com.android.server.testutils.StubTransaction; import com.android.server.wm.utils.MockAnimationAdapter; import com.android.server.wm.utils.MockAnimationAdapter; import com.android.window.flags.Flags; import com.android.window.flags.Flags; Loading Loading @@ -66,11 +69,12 @@ public class DimmerTests extends WindowTestsBase { mVisibleRequested = true; mVisibleRequested = true; } } class MockSurfaceBuilder extends SurfaceControl.Builder { static class MockSurfaceBuilder extends SurfaceControl.Builder { MockSurfaceBuilder(SurfaceSession ss) { MockSurfaceBuilder(SurfaceSession ss) { super(ss); super(ss); } } @NonNull @Override @Override public SurfaceControl build() { public SurfaceControl build() { SurfaceControl mSc = mock(SurfaceControl.class); SurfaceControl mSc = mock(SurfaceControl.class); Loading @@ -79,26 +83,31 @@ public class DimmerTests extends WindowTestsBase { } } } } @NonNull @Override @Override SurfaceControl.Builder makeChildSurface(WindowContainer child) { SurfaceControl.Builder makeChildSurface(@Nullable WindowContainer child) { return new MockSurfaceBuilder(mSession); return new MockSurfaceBuilder(mSession); } } @Nullable @Override @Override public SurfaceControl getSurfaceControl() { public SurfaceControl getSurfaceControl() { return mHostControl; return mHostControl; } } @NonNull @Override @Override public SurfaceControl.Transaction getSyncTransaction() { public SurfaceControl.Transaction getSyncTransaction() { return mHostTransaction; return mHostTransaction; } } @NonNull @Override @Override public SurfaceControl.Transaction getPendingTransaction() { public SurfaceControl.Transaction getPendingTransaction() { return mHostTransaction; return mHostTransaction; } } @NonNull @Override @Override public Rect getBounds() { public Rect getBounds() { return mBounds; return mBounds; Loading @@ -106,9 +115,10 @@ public class DimmerTests extends WindowTestsBase { } } static class MockAnimationAdapterFactory extends DimmerAnimationHelper.AnimationAdapterFactory { static class MockAnimationAdapterFactory extends DimmerAnimationHelper.AnimationAdapterFactory { @NonNull @Override @Override public AnimationAdapter get(LocalAnimationAdapter.AnimationSpec alphaAnimationSpec, public AnimationAdapter get(@NonNull LocalAnimationAdapter.AnimationSpec alphaAnimationSpec, SurfaceAnimationRunner runner) { @NonNull SurfaceAnimationRunner runner) { return sTestAnimation; return sTestAnimation; } } } } Loading
services/tests/wmtests/src/com/android/server/wm/utils/MockAnimationAdapter.java +5 −4 Original line number Original line Diff line number Diff line Loading @@ -38,8 +38,9 @@ public class MockAnimationAdapter implements AnimationAdapter { } } @Override @Override public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t, public void startAnimation(@NonNull SurfaceControl animationLeash, int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { @NonNull SurfaceControl.Transaction t, int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) { // As the animation won't run, finish it immediately // As the animation won't run, finish it immediately finishCallback.onAnimationFinished(0, null); finishCallback.onAnimationFinished(0, null); } } Loading @@ -58,8 +59,8 @@ public class MockAnimationAdapter implements AnimationAdapter { } } @Override @Override public void dump(PrintWriter pw, String prefix) {} public void dump(@NonNull PrintWriter pw, @NonNull String prefix) {} @Override @Override public void dumpDebug(ProtoOutputStream proto) {} public void dumpDebug(@NonNull ProtoOutputStream proto) {} } }