Merge "Add overlayfinishing state." into tm-qpr-dev am: 7c24fe78c8 am: b4079321e9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21336521

Change-Id: I964a2662a82145906ddc2f968986d1ac09c40046
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Victor Truong
2023-02-10 17:56:41 +00:00
committed by Automerger Merge Worker

View File

@@ -234,6 +234,7 @@ public class DreamService extends Service implements Window.Callback {
private boolean mCanDoze;
private boolean mDozing;
private boolean mWindowless;
private boolean mOverlayFinishing;
private int mDozeScreenState = Display.STATE_UNKNOWN;
private int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT;
@@ -1051,6 +1052,7 @@ public class DreamService extends Service implements Window.Callback {
// We must unbind from any overlay connection if we are unbound before finishing.
if (mOverlayConnection != null) {
mOverlayConnection.unbind();
mOverlayConnection = null;
}
return super.onUnbind(intent);
@@ -1067,7 +1069,9 @@ public class DreamService extends Service implements Window.Callback {
// If there is an active overlay connection, signal that the dream is ending before
// continuing. Note that the overlay cannot rely on the unbound state, since another dream
// might have bound to it in the meantime.
if (mOverlayConnection != null) {
if (mOverlayConnection != null && !mOverlayFinishing) {
// Set mOverlayFinish to true to only allow this consumer to be added once.
mOverlayFinishing = true;
mOverlayConnection.addConsumer(overlay -> {
try {
overlay.endDream();