Loading services/core/java/com/android/server/notification/NotificationManagerService.java +21 −2 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.app.PendingIntent; import android.app.Person; import android.app.RemoteInput; import android.app.StatusBarManager; import android.app.UriGrantsManager; import android.app.admin.DeviceAdminInfo; Loading Loading @@ -4843,17 +4844,35 @@ public class NotificationManagerService extends SystemService { : null; boolean isForegroundCall = CATEGORY_CALL.equals(notification.category) && (notification.flags & FLAG_FOREGROUND_SERVICE) != 0; // OR message style (which always has a person) // OR message style (which always has a person) with any remote input Class<? extends Notification.Style> style = notification.getNotificationStyle(); boolean isMessageStyle = Notification.MessagingStyle.class.equals(style); boolean notificationAppropriateToBubble = isMessageStyle boolean notificationAppropriateToBubble = (isMessageStyle && hasValidRemoteInput(notification)) || (peopleList != null && !peopleList.isEmpty() && isForegroundCall); // OR something that was previously a bubble & still exists boolean bubbleUpdate = oldRecord != null && (oldRecord.getNotification().flags & FLAG_BUBBLE) != 0; return canBubble && (notificationAppropriateToBubble || appIsForeground || bubbleUpdate); } private boolean hasValidRemoteInput(Notification n) { // Also check for inline reply Notification.Action[] actions = n.actions; if (actions != null) { // Get the remote inputs for (int i = 0; i < actions.length; i++) { Notification.Action action = actions[i]; RemoteInput[] inputs = action.getRemoteInputs(); if (inputs != null && inputs.length > 0) { return true; } } } return false; } private void doChannelWarningToast(CharSequence toastText) { Binder.withCleanCallingIdentity(() -> { final int defaultWarningEnabled = Build.IS_DEBUGGABLE ? 1 : 0; Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Person; import android.app.RemoteInput; import android.app.admin.DevicePolicyManagerInternal; import android.app.usage.UsageStatsManagerInternal; import android.companion.ICompanionDeviceManager; Loading Loading @@ -4523,6 +4524,13 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { Person person = new Person.Builder() .setName("bubblebot") .build(); // It needs remote input to be bubble-able RemoteInput remoteInput = new RemoteInput.Builder("reply_key").setLabel("reply").build(); PendingIntent inputIntent = PendingIntent.getActivity(mContext, 0, new Intent(), 0); Icon icon = Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon); Notification.Action replyAction = new Notification.Action.Builder(icon, "Reply", inputIntent).addRemoteInput(remoteInput) .build(); // Make it messaging style Notification.Builder nb = new Notification.Builder(mContext, mTestNotificationChannel.getId()) Loading @@ -4535,6 +4543,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .addMessage("Is it me you're looking for?", SystemClock.currentThreadTimeMillis(), person) ) .setActions(replyAction) .setSmallIcon(android.R.drawable.sym_def_app_icon); StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 1, null, mUid, 0, Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +21 −2 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ import android.app.NotificationManager; import android.app.NotificationManager.Policy; import android.app.PendingIntent; import android.app.Person; import android.app.RemoteInput; import android.app.StatusBarManager; import android.app.UriGrantsManager; import android.app.admin.DeviceAdminInfo; Loading Loading @@ -4843,17 +4844,35 @@ public class NotificationManagerService extends SystemService { : null; boolean isForegroundCall = CATEGORY_CALL.equals(notification.category) && (notification.flags & FLAG_FOREGROUND_SERVICE) != 0; // OR message style (which always has a person) // OR message style (which always has a person) with any remote input Class<? extends Notification.Style> style = notification.getNotificationStyle(); boolean isMessageStyle = Notification.MessagingStyle.class.equals(style); boolean notificationAppropriateToBubble = isMessageStyle boolean notificationAppropriateToBubble = (isMessageStyle && hasValidRemoteInput(notification)) || (peopleList != null && !peopleList.isEmpty() && isForegroundCall); // OR something that was previously a bubble & still exists boolean bubbleUpdate = oldRecord != null && (oldRecord.getNotification().flags & FLAG_BUBBLE) != 0; return canBubble && (notificationAppropriateToBubble || appIsForeground || bubbleUpdate); } private boolean hasValidRemoteInput(Notification n) { // Also check for inline reply Notification.Action[] actions = n.actions; if (actions != null) { // Get the remote inputs for (int i = 0; i < actions.length; i++) { Notification.Action action = actions[i]; RemoteInput[] inputs = action.getRemoteInputs(); if (inputs != null && inputs.length > 0) { return true; } } } return false; } private void doChannelWarningToast(CharSequence toastText) { Binder.withCleanCallingIdentity(() -> { final int defaultWarningEnabled = Build.IS_DEBUGGABLE ? 1 : 0; Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ import android.app.NotificationChannelGroup; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Person; import android.app.RemoteInput; import android.app.admin.DevicePolicyManagerInternal; import android.app.usage.UsageStatsManagerInternal; import android.companion.ICompanionDeviceManager; Loading Loading @@ -4523,6 +4524,13 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { Person person = new Person.Builder() .setName("bubblebot") .build(); // It needs remote input to be bubble-able RemoteInput remoteInput = new RemoteInput.Builder("reply_key").setLabel("reply").build(); PendingIntent inputIntent = PendingIntent.getActivity(mContext, 0, new Intent(), 0); Icon icon = Icon.createWithResource(mContext, android.R.drawable.sym_def_app_icon); Notification.Action replyAction = new Notification.Action.Builder(icon, "Reply", inputIntent).addRemoteInput(remoteInput) .build(); // Make it messaging style Notification.Builder nb = new Notification.Builder(mContext, mTestNotificationChannel.getId()) Loading @@ -4535,6 +4543,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { .addMessage("Is it me you're looking for?", SystemClock.currentThreadTimeMillis(), person) ) .setActions(replyAction) .setSmallIcon(android.R.drawable.sym_def_app_icon); StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 1, null, mUid, 0, Loading