Loading services/core/java/com/android/server/wm/AlertWindowNotification.java +12 −5 Original line number Original line Diff line number Diff line Loading @@ -72,20 +72,23 @@ class AlertWindowNotification { } } /** Cancels the notification */ /** Cancels the notification */ void cancel() { void cancel(boolean deleteChannel) { // We can't call into NotificationManager with WM lock held since it might call into AM. // We can't call into NotificationManager with WM lock held since it might call into AM. // So, we post a message to do it later. // So, we post a message to do it later. mService.mH.post(this::onCancelNotification); mService.mH.post(() -> onCancelNotification(deleteChannel)); } } /** Don't call with the window manager lock held! */ /** Don't call with the window manager lock held! */ private void onCancelNotification() { private void onCancelNotification(boolean deleteChannel) { if (!mPosted) { if (!mPosted) { // Notification isn't currently posted... // Notification isn't currently posted... return; return; } } mPosted = false; mPosted = false; mNotificationManager.cancel(mNotificationTag, NOTIFICATION_ID); mNotificationManager.cancel(mNotificationTag, NOTIFICATION_ID); if (deleteChannel) { mNotificationManager.deleteNotificationChannel(mNotificationTag); } } } /** Don't call with the window manager lock held! */ /** Don't call with the window manager lock held! */ Loading Loading @@ -146,8 +149,12 @@ class AlertWindowNotification { final String nameChannel = final String nameChannel = context.getString(R.string.alert_windows_notification_channel_name, appName); context.getString(R.string.alert_windows_notification_channel_name, appName); final NotificationChannel channel = new NotificationChannel(mNotificationTag, nameChannel, IMPORTANCE_MIN); NotificationChannel channel = mNotificationManager.getNotificationChannel(mNotificationTag); if (channel != null) { return; } channel = new NotificationChannel(mNotificationTag, nameChannel, IMPORTANCE_MIN); channel.enableLights(false); channel.enableLights(false); channel.enableVibration(false); channel.enableVibration(false); channel.setBlockableSystem(true); channel.setBlockableSystem(true); Loading services/core/java/com/android/server/wm/Session.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -547,7 +547,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { if (allowed) { if (allowed) { mAlertWindowNotification.post(); mAlertWindowNotification.post(); } else { } else { mAlertWindowNotification.cancel(); mAlertWindowNotification.cancel(false /* deleteChannel */); } } } } } } Loading Loading @@ -586,7 +586,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { if (mAlertWindowNotification == null) { if (mAlertWindowNotification == null) { return; return; } } mAlertWindowNotification.cancel(); mAlertWindowNotification.cancel(true /* deleteChannel */); mAlertWindowNotification = null; mAlertWindowNotification = null; } } Loading Loading
services/core/java/com/android/server/wm/AlertWindowNotification.java +12 −5 Original line number Original line Diff line number Diff line Loading @@ -72,20 +72,23 @@ class AlertWindowNotification { } } /** Cancels the notification */ /** Cancels the notification */ void cancel() { void cancel(boolean deleteChannel) { // We can't call into NotificationManager with WM lock held since it might call into AM. // We can't call into NotificationManager with WM lock held since it might call into AM. // So, we post a message to do it later. // So, we post a message to do it later. mService.mH.post(this::onCancelNotification); mService.mH.post(() -> onCancelNotification(deleteChannel)); } } /** Don't call with the window manager lock held! */ /** Don't call with the window manager lock held! */ private void onCancelNotification() { private void onCancelNotification(boolean deleteChannel) { if (!mPosted) { if (!mPosted) { // Notification isn't currently posted... // Notification isn't currently posted... return; return; } } mPosted = false; mPosted = false; mNotificationManager.cancel(mNotificationTag, NOTIFICATION_ID); mNotificationManager.cancel(mNotificationTag, NOTIFICATION_ID); if (deleteChannel) { mNotificationManager.deleteNotificationChannel(mNotificationTag); } } } /** Don't call with the window manager lock held! */ /** Don't call with the window manager lock held! */ Loading Loading @@ -146,8 +149,12 @@ class AlertWindowNotification { final String nameChannel = final String nameChannel = context.getString(R.string.alert_windows_notification_channel_name, appName); context.getString(R.string.alert_windows_notification_channel_name, appName); final NotificationChannel channel = new NotificationChannel(mNotificationTag, nameChannel, IMPORTANCE_MIN); NotificationChannel channel = mNotificationManager.getNotificationChannel(mNotificationTag); if (channel != null) { return; } channel = new NotificationChannel(mNotificationTag, nameChannel, IMPORTANCE_MIN); channel.enableLights(false); channel.enableLights(false); channel.enableVibration(false); channel.enableVibration(false); channel.setBlockableSystem(true); channel.setBlockableSystem(true); Loading
services/core/java/com/android/server/wm/Session.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -547,7 +547,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { if (allowed) { if (allowed) { mAlertWindowNotification.post(); mAlertWindowNotification.post(); } else { } else { mAlertWindowNotification.cancel(); mAlertWindowNotification.cancel(false /* deleteChannel */); } } } } } } Loading Loading @@ -586,7 +586,7 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { if (mAlertWindowNotification == null) { if (mAlertWindowNotification == null) { return; return; } } mAlertWindowNotification.cancel(); mAlertWindowNotification.cancel(true /* deleteChannel */); mAlertWindowNotification = null; mAlertWindowNotification = null; } } Loading