From f8c953de9cfd220c781bc947d9d5768e00943c28 Mon Sep 17 00:00:00 2001 From: Valentin Iftime Date: Tue, 13 Jun 2023 17:59:11 +0200 Subject: [PATCH] Do not remove toast window token without removing window This causes the 2nd call to removeWindowToken from finishWindowTokenLocked to fail because the window token has been removed from WMS. This causes window leaks in some edge cases, ie. b/286495456. Test: atest WindowUntrustedTouchTest atest ToastWindowTest atest ToastPresenterTest atest ToastUITest Bug: 204272000 Bug: 286495456 Bug: 282262771 Change-Id: I43e640c230fed0fac85631fe584e77d901af0949 --- .../server/notification/NotificationManagerService.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index d29d9c84501d4..488745c6ea977 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -8718,13 +8718,7 @@ public class NotificationManagerService extends SystemService { ToastRecord lastToast = mToastQueue.remove(index); - mWindowManagerInternal.removeWindowToken(lastToast.windowToken, false /* removeWindows */, - lastToast.displayId); - // We passed 'false' for 'removeWindows' so that the client has time to stop - // rendering (as hide above is a one-way message), otherwise we could crash - // a client which was actively using a surface made from the token. However - // we need to schedule a timeout to make sure the token is eventually killed - // one way or another. + // We need to schedule a timeout to make sure the token is eventually killed scheduleKillTokenTimeout(lastToast); keepProcessAliveForToastIfNeededLocked(record.pid);