From 410b5a6f987e3dc4acaed0a7a1fa4e081e0c334b Mon Sep 17 00:00:00 2001 From: Bryce Lee Date: Mon, 4 Apr 2022 14:57:13 -0700 Subject: [PATCH] Unbind from overlay before checking attached. Currently, DreamService#finish exits early if the window is not attached. The unbind from the dream overlay service follows this condition. As a result, it is possible that the service is not unbound if the window was never attached. This changelist addresses This potential connection leak by having the unbind precede the check. Fixed: 227498355 Test: manual Change-Id: I7a73258cea5219bea96f4de3b90b4b5a66478fde --- core/java/android/service/dreams/DreamService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java index 001707d228b6b..d4f8a3beb89b7 100644 --- a/core/java/android/service/dreams/DreamService.java +++ b/core/java/android/service/dreams/DreamService.java @@ -1038,14 +1038,14 @@ public class DreamService extends Service implements Window.Callback { } mFinished = true; + mOverlayConnection.unbind(this); + if (mDreamToken == null) { Slog.w(mTag, "Finish was called before the dream was attached."); stopSelf(); return; } - mOverlayConnection.unbind(this); - try { // finishSelf will unbind the dream controller from the dream service. This will // trigger DreamService.this.onDestroy and DreamService.this will die.