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
This commit is contained in:
Bryce Lee
2022-04-04 14:57:13 -07:00
parent b46b98ee48
commit 410b5a6f98

View File

@@ -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.