Loading core/java/android/window/flags/windowing_frontend.aconfig +11 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,17 @@ flag { } } flag { name: "use_tasks_dim_only" namespace: "windowing_frontend" description: "Only use the task's dim and reparent it to the display area when needed instead of coordinating multiple dimmers" bug: "352522056" is_fixed_read_only: true metadata { purpose: PURPOSE_BUGFIX } } flag { name: "release_snapshot_aggressively" namespace: "windowing_frontend" Loading services/core/java/com/android/server/wm/Dimmer.java +19 −5 Original line number Diff line number Diff line Loading @@ -28,7 +28,13 @@ import android.view.SurfaceControl; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.protolog.ProtoLog; import com.android.window.flags.Flags; /** * Utility class for use by a WindowContainer implementation to add "DimLayer" support, that is * black layers of varying opacity at various Z-levels which create the effect of a Dim. */ class Dimmer { /** Loading Loading @@ -122,8 +128,10 @@ class Dimmer { /** * Set the parameters to prepare the dim to be relative parented to the dimming container */ void prepareReparent(@NonNull WindowContainer<?> relativeParent, int relativeLayer) { void prepareReparent(@NonNull WindowContainer<?> geometryParent, @NonNull WindowContainer<?> relativeParent, int relativeLayer) { mAnimationHelper.setRequestedRelativeParent(relativeParent, relativeLayer); mAnimationHelper.setRequestedGeometryParent(geometryParent); } /** Loading @@ -138,7 +146,8 @@ class Dimmer { * Whether anyone is currently requesting the dim */ boolean isDimming() { return mLastRequestedDimContainer != null; return mLastRequestedDimContainer != null && (mHostContainer.isVisibleRequested() || !Flags.useTasksDimOnly()); } private SurfaceControl makeDimLayer() { Loading Loading @@ -208,13 +217,15 @@ class Dimmer { * 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 * without also adjusting the appearance. * @param geometryParent The container that defines the geometry of the dim * @param dimmingContainer The container which to dim above. Should be a child of the host. * @param relativeLayer The position of the dim wrt the container */ public void adjustRelativeLayer(@NonNull WindowContainer<?> dimmingContainer, public void adjustPosition(@NonNull WindowContainer<?> geometryParent, @NonNull WindowContainer<?> dimmingContainer, int relativeLayer) { if (mDimState != null) { mDimState.prepareReparent(dimmingContainer, relativeLayer); mDimState.prepareReparent(geometryParent, dimmingContainer, relativeLayer); } } Loading @@ -236,7 +247,9 @@ class Dimmer { return false; } else { // Someone is dimming, show the requested changes if (!Flags.useTasksDimOnly()) { mDimState.adjustSurfaceLayout(t); } final WindowState ws = mDimState.mLastRequestedDimContainer.asWindowState(); if (!mDimState.mIsVisible && ws != null && ws.mActivityRecord != null && ws.mActivityRecord.mStartingData != null) { Loading @@ -263,6 +276,7 @@ class Dimmer { return mDimState != null ? mDimState.mDimSurface : null; } @Deprecated Rect getDimBounds() { return mDimState != null ? mDimState.mDimBounds : null; } Loading services/core/java/com/android/server/wm/DimmerAnimationHelper.java +19 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.Log; import android.util.proto.ProtoOutputStream; import android.view.SurfaceControl; Loading @@ -48,6 +49,7 @@ public class DimmerAnimationHelper { private float mAlpha = -1f; private int mBlurRadius = -1; private WindowContainer<?> mDimmingContainer = null; private WindowContainer<?> mGeometryParent = null; private int mRelativeLayer = -1; private static final float EPSILON = 0.0001f; Loading Loading @@ -103,6 +105,11 @@ public class DimmerAnimationHelper { mRequestedProperties.mRelativeLayer = relativeLayer; } // Sets the requested layer to reparent the dim to without applying it immediately void setRequestedGeometryParent(WindowContainer<?> geometryParent) { mRequestedProperties.mGeometryParent = geometryParent; } // Sets a requested change without applying it immediately void setRequestedAppearance(float alpha, int blurRadius) { mRequestedProperties.mAlpha = alpha; Loading @@ -129,7 +136,9 @@ public class DimmerAnimationHelper { } dim.ensureVisible(t); relativeReparent(dim.mDimSurface, reparent(dim.mDimSurface, mRequestedProperties.mGeometryParent != mCurrentProperties.mGeometryParent ? mRequestedProperties.mGeometryParent.getSurfaceControl() : null, mRequestedProperties.mDimmingContainer.getSurfaceControl(), mRequestedProperties.mRelativeLayer, t); Loading Loading @@ -214,11 +223,17 @@ public class DimmerAnimationHelper { } /** * Change the relative parent of this dim layer * Change the geometry and relative parent of this dim layer */ void relativeReparent(@NonNull SurfaceControl dimLayer, @NonNull SurfaceControl relativeParent, int relativePosition, @NonNull SurfaceControl.Transaction t) { void reparent(@NonNull SurfaceControl dimLayer, @Nullable SurfaceControl newGeometryParent, @NonNull SurfaceControl relativeParent, int relativePosition, @NonNull SurfaceControl.Transaction t) { try { if (newGeometryParent != null) { t.reparent(dimLayer, newGeometryParent); } t.setRelativeLayer(dimLayer, relativeParent, relativePosition); } catch (NullPointerException e) { Log.w(TAG, "Tried to change parent of dim " + dimLayer + " after remove", e); Loading services/core/java/com/android/server/wm/Task.java +8 −0 Original line number Diff line number Diff line Loading @@ -3201,6 +3201,14 @@ class Task extends TaskFragment { return "Task=" + mTaskId; } WindowContainer<?> getDimmerParent() { if (!inMultiWindowMode() && isTranslucentForTransition()) { return getRootDisplayArea(); } return this; } @Deprecated @Override Dimmer getDimmer() { // If the window is in multi-window mode, we want to dim at the Task level to ensure the dim Loading services/core/java/com/android/server/wm/TaskFragment.java +1 −0 Original line number Diff line number Diff line Loading @@ -3102,6 +3102,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { return forAllWindows(getDimBehindWindow, true); } @Deprecated @Override Dimmer getDimmer() { // If this is in an embedded TaskFragment and we want the dim applies on the TaskFragment. Loading Loading
core/java/android/window/flags/windowing_frontend.aconfig +11 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,17 @@ flag { } } flag { name: "use_tasks_dim_only" namespace: "windowing_frontend" description: "Only use the task's dim and reparent it to the display area when needed instead of coordinating multiple dimmers" bug: "352522056" is_fixed_read_only: true metadata { purpose: PURPOSE_BUGFIX } } flag { name: "release_snapshot_aggressively" namespace: "windowing_frontend" Loading
services/core/java/com/android/server/wm/Dimmer.java +19 −5 Original line number Diff line number Diff line Loading @@ -28,7 +28,13 @@ import android.view.SurfaceControl; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.protolog.ProtoLog; import com.android.window.flags.Flags; /** * Utility class for use by a WindowContainer implementation to add "DimLayer" support, that is * black layers of varying opacity at various Z-levels which create the effect of a Dim. */ class Dimmer { /** Loading Loading @@ -122,8 +128,10 @@ class Dimmer { /** * Set the parameters to prepare the dim to be relative parented to the dimming container */ void prepareReparent(@NonNull WindowContainer<?> relativeParent, int relativeLayer) { void prepareReparent(@NonNull WindowContainer<?> geometryParent, @NonNull WindowContainer<?> relativeParent, int relativeLayer) { mAnimationHelper.setRequestedRelativeParent(relativeParent, relativeLayer); mAnimationHelper.setRequestedGeometryParent(geometryParent); } /** Loading @@ -138,7 +146,8 @@ class Dimmer { * Whether anyone is currently requesting the dim */ boolean isDimming() { return mLastRequestedDimContainer != null; return mLastRequestedDimContainer != null && (mHostContainer.isVisibleRequested() || !Flags.useTasksDimOnly()); } private SurfaceControl makeDimLayer() { Loading Loading @@ -208,13 +217,15 @@ class Dimmer { * 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 * without also adjusting the appearance. * @param geometryParent The container that defines the geometry of the dim * @param dimmingContainer The container which to dim above. Should be a child of the host. * @param relativeLayer The position of the dim wrt the container */ public void adjustRelativeLayer(@NonNull WindowContainer<?> dimmingContainer, public void adjustPosition(@NonNull WindowContainer<?> geometryParent, @NonNull WindowContainer<?> dimmingContainer, int relativeLayer) { if (mDimState != null) { mDimState.prepareReparent(dimmingContainer, relativeLayer); mDimState.prepareReparent(geometryParent, dimmingContainer, relativeLayer); } } Loading @@ -236,7 +247,9 @@ class Dimmer { return false; } else { // Someone is dimming, show the requested changes if (!Flags.useTasksDimOnly()) { mDimState.adjustSurfaceLayout(t); } final WindowState ws = mDimState.mLastRequestedDimContainer.asWindowState(); if (!mDimState.mIsVisible && ws != null && ws.mActivityRecord != null && ws.mActivityRecord.mStartingData != null) { Loading @@ -263,6 +276,7 @@ class Dimmer { return mDimState != null ? mDimState.mDimSurface : null; } @Deprecated Rect getDimBounds() { return mDimState != null ? mDimState.mDimBounds : null; } Loading
services/core/java/com/android/server/wm/DimmerAnimationHelper.java +19 −4 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.Log; import android.util.proto.ProtoOutputStream; import android.view.SurfaceControl; Loading @@ -48,6 +49,7 @@ public class DimmerAnimationHelper { private float mAlpha = -1f; private int mBlurRadius = -1; private WindowContainer<?> mDimmingContainer = null; private WindowContainer<?> mGeometryParent = null; private int mRelativeLayer = -1; private static final float EPSILON = 0.0001f; Loading Loading @@ -103,6 +105,11 @@ public class DimmerAnimationHelper { mRequestedProperties.mRelativeLayer = relativeLayer; } // Sets the requested layer to reparent the dim to without applying it immediately void setRequestedGeometryParent(WindowContainer<?> geometryParent) { mRequestedProperties.mGeometryParent = geometryParent; } // Sets a requested change without applying it immediately void setRequestedAppearance(float alpha, int blurRadius) { mRequestedProperties.mAlpha = alpha; Loading @@ -129,7 +136,9 @@ public class DimmerAnimationHelper { } dim.ensureVisible(t); relativeReparent(dim.mDimSurface, reparent(dim.mDimSurface, mRequestedProperties.mGeometryParent != mCurrentProperties.mGeometryParent ? mRequestedProperties.mGeometryParent.getSurfaceControl() : null, mRequestedProperties.mDimmingContainer.getSurfaceControl(), mRequestedProperties.mRelativeLayer, t); Loading Loading @@ -214,11 +223,17 @@ public class DimmerAnimationHelper { } /** * Change the relative parent of this dim layer * Change the geometry and relative parent of this dim layer */ void relativeReparent(@NonNull SurfaceControl dimLayer, @NonNull SurfaceControl relativeParent, int relativePosition, @NonNull SurfaceControl.Transaction t) { void reparent(@NonNull SurfaceControl dimLayer, @Nullable SurfaceControl newGeometryParent, @NonNull SurfaceControl relativeParent, int relativePosition, @NonNull SurfaceControl.Transaction t) { try { if (newGeometryParent != null) { t.reparent(dimLayer, newGeometryParent); } t.setRelativeLayer(dimLayer, relativeParent, relativePosition); } catch (NullPointerException e) { Log.w(TAG, "Tried to change parent of dim " + dimLayer + " after remove", e); Loading
services/core/java/com/android/server/wm/Task.java +8 −0 Original line number Diff line number Diff line Loading @@ -3201,6 +3201,14 @@ class Task extends TaskFragment { return "Task=" + mTaskId; } WindowContainer<?> getDimmerParent() { if (!inMultiWindowMode() && isTranslucentForTransition()) { return getRootDisplayArea(); } return this; } @Deprecated @Override Dimmer getDimmer() { // If the window is in multi-window mode, we want to dim at the Task level to ensure the dim Loading
services/core/java/com/android/server/wm/TaskFragment.java +1 −0 Original line number Diff line number Diff line Loading @@ -3102,6 +3102,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { return forAllWindows(getDimBehindWindow, true); } @Deprecated @Override Dimmer getDimmer() { // If this is in an embedded TaskFragment and we want the dim applies on the TaskFragment. Loading