Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar; |
| 18 | |
Julia Reynolds | 0abae11 | 2018-06-08 10:36:57 -0400 | [diff] [blame] | 19 | import static android.app.NotificationManager.IMPORTANCE_DEFAULT; |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 20 | import static android.app.NotificationManager.IMPORTANCE_HIGH; |
Julia Reynolds | 0abae11 | 2018-06-08 10:36:57 -0400 | [diff] [blame] | 21 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 22 | import android.annotation.Nullable; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 23 | import android.app.ActivityManager; |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 24 | import android.app.Instrumentation; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 25 | import android.app.Notification; |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 26 | import android.app.Notification.BubbleMetadata; |
Julia Reynolds | 0abae11 | 2018-06-08 10:36:57 -0400 | [diff] [blame] | 27 | import android.app.NotificationChannel; |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 28 | import android.app.PendingIntent; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 29 | import android.content.Context; |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 30 | import android.content.Intent; |
Mady Mellor | c39b4ae | 2019-01-09 17:11:37 -0800 | [diff] [blame] | 31 | import android.graphics.drawable.Icon; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 32 | import android.os.UserHandle; |
| 33 | import android.service.notification.StatusBarNotification; |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 34 | import android.text.TextUtils; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 35 | import android.view.LayoutInflater; |
| 36 | import android.widget.RemoteViews; |
| 37 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 38 | import androidx.test.InstrumentationRegistry; |
| 39 | |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 40 | import com.android.systemui.R; |
Mark Renouf | a9fbb6e | 2019-02-11 12:48:22 -0500 | [diff] [blame] | 41 | import com.android.systemui.bubbles.BubblesTestActivity; |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 42 | import com.android.systemui.statusbar.notification.collection.NotificationEntry; |
Mady Mellor | ebdbbb9 | 2018-11-15 14:36:48 -0800 | [diff] [blame] | 43 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
Ned Burns | 1a5e22f | 2019-02-14 15:11:52 -0500 | [diff] [blame] | 44 | import com.android.systemui.statusbar.notification.row.NotificationContentInflater.InflationFlag; |
| 45 | import com.android.systemui.statusbar.notification.row.NotificationContentInflaterTest; |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 46 | import com.android.systemui.statusbar.phone.HeadsUpManagerPhone; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 47 | import com.android.systemui.statusbar.phone.NotificationGroupManager; |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 48 | import com.android.systemui.statusbar.policy.HeadsUpManager; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 49 | |
| 50 | /** |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 51 | * A helper class to create {@link ExpandableNotificationRow} (for both individual and group |
| 52 | * notifications). |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 53 | */ |
| 54 | public class NotificationTestHelper { |
| 55 | |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 56 | /** Package name for testing purposes. */ |
| 57 | public static final String PKG = "com.android.systemui"; |
| 58 | /** System UI id for testing purposes. */ |
| 59 | public static final int UID = 1000; |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 60 | /** Current {@link UserHandle} of the system. */ |
| 61 | public static final UserHandle USER_HANDLE = UserHandle.of(ActivityManager.getCurrentUser()); |
Rohan Shah | 20790b8 | 2018-07-02 17:21:04 -0700 | [diff] [blame] | 62 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 63 | private static final String GROUP_KEY = "gruKey"; |
| 64 | |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 65 | private final Context mContext; |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 66 | private final Instrumentation mInstrumentation; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 67 | private int mId; |
| 68 | private final NotificationGroupManager mGroupManager = new NotificationGroupManager(); |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 69 | private ExpandableNotificationRow mRow; |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 70 | private HeadsUpManager mHeadsUpManager; |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 71 | |
| 72 | public NotificationTestHelper(Context context) { |
| 73 | mContext = context; |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 74 | mInstrumentation = InstrumentationRegistry.getInstrumentation(); |
yoshiki iguchi | 4e30e76 | 2018-02-06 12:09:23 +0900 | [diff] [blame] | 75 | mHeadsUpManager = new HeadsUpManagerPhone(mContext, null, mGroupManager, null, null); |
Kevin | a97ea05 | 2018-09-11 13:53:18 -0700 | [diff] [blame] | 76 | mGroupManager.setHeadsUpManager(mHeadsUpManager); |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 77 | } |
| 78 | |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 79 | /** |
| 80 | * Creates a generic row. |
| 81 | * |
| 82 | * @return a generic row with no special properties. |
| 83 | * @throws Exception |
| 84 | */ |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 85 | public ExpandableNotificationRow createRow() throws Exception { |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 86 | return createRow(PKG, UID, USER_HANDLE); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 89 | /** |
| 90 | * Create a row with the package and user id specified. |
| 91 | * |
| 92 | * @param pkg package |
| 93 | * @param uid user id |
| 94 | * @return a row with a notification using the package and user id |
| 95 | * @throws Exception |
| 96 | */ |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 97 | public ExpandableNotificationRow createRow(String pkg, int uid, UserHandle userHandle) |
| 98 | throws Exception { |
| 99 | return createRow(pkg, uid, userHandle, false /* isGroupSummary */, null /* groupKey */); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 102 | /** |
| 103 | * Creates a row based off the notification given. |
| 104 | * |
| 105 | * @param notification the notification |
| 106 | * @return a row built off the notification |
| 107 | * @throws Exception |
| 108 | */ |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 109 | public ExpandableNotificationRow createRow(Notification notification) throws Exception { |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 110 | return generateRow(notification, PKG, UID, USER_HANDLE, 0 /* extraInflationFlags */); |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Create a row with the specified content views inflated in addition to the default. |
| 115 | * |
| 116 | * @param extraInflationFlags the flags corresponding to the additional content views that |
| 117 | * should be inflated |
| 118 | * @return a row with the specified content views inflated in addition to the default |
| 119 | * @throws Exception |
| 120 | */ |
| 121 | public ExpandableNotificationRow createRow(@InflationFlag int extraInflationFlags) |
| 122 | throws Exception { |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 123 | return generateRow(createNotification(), PKG, UID, USER_HANDLE, extraInflationFlags); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Returns an {@link ExpandableNotificationRow} group with the given number of child |
| 128 | * notifications. |
| 129 | */ |
| 130 | public ExpandableNotificationRow createGroup(int numChildren) throws Exception { |
| 131 | ExpandableNotificationRow row = createGroupSummary(GROUP_KEY); |
| 132 | for (int i = 0; i < numChildren; i++) { |
| 133 | ExpandableNotificationRow childRow = createGroupChild(GROUP_KEY); |
| 134 | row.addChildNotification(childRow); |
| 135 | } |
| 136 | return row; |
| 137 | } |
| 138 | |
| 139 | /** Returns a group notification with 2 child notifications. */ |
| 140 | public ExpandableNotificationRow createGroup() throws Exception { |
| 141 | return createGroup(2); |
| 142 | } |
| 143 | |
| 144 | private ExpandableNotificationRow createGroupSummary(String groupkey) throws Exception { |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 145 | return createRow(PKG, UID, USER_HANDLE, true /* isGroupSummary */, groupkey); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | private ExpandableNotificationRow createGroupChild(String groupkey) throws Exception { |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 149 | return createRow(PKG, UID, USER_HANDLE, false /* isGroupSummary */, groupkey); |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble. |
| 154 | */ |
| 155 | public ExpandableNotificationRow createBubble() throws Exception { |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 156 | return createBubble(null); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Returns an {@link ExpandableNotificationRow} that should be shown as a bubble. |
| 161 | * |
| 162 | * @param deleteIntent the intent to assign to {@link BubbleMetadata#deleteIntent} |
| 163 | */ |
| 164 | public ExpandableNotificationRow createBubble(@Nullable PendingIntent deleteIntent) |
| 165 | throws Exception { |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 166 | Notification n = createNotification(false /* isGroupSummary */, |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 167 | null /* groupKey */, true /* isBubble */, deleteIntent); |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 168 | return generateRow(n, PKG, UID, USER_HANDLE, 0 /* extraInflationFlags */, IMPORTANCE_HIGH); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Creates a notification row with the given details. |
| 173 | * |
| 174 | * @param pkg package used for creating a {@link StatusBarNotification} |
| 175 | * @param uid uid used for creating a {@link StatusBarNotification} |
| 176 | * @param isGroupSummary whether the notification row is a group summary |
| 177 | * @param groupKey the group key for the notification group used across notifications |
| 178 | * @return a row with that's either a standalone notification or a group notification if the |
| 179 | * groupKey is non-null |
| 180 | * @throws Exception |
| 181 | */ |
| 182 | private ExpandableNotificationRow createRow( |
| 183 | String pkg, |
| 184 | int uid, |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 185 | UserHandle userHandle, |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 186 | boolean isGroupSummary, |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 187 | @Nullable String groupKey) |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 188 | throws Exception { |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 189 | Notification notif = createNotification(isGroupSummary, groupKey); |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 190 | return generateRow(notif, pkg, uid, userHandle, 0 /* inflationFlags */); |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Creates a generic notification. |
| 195 | * |
| 196 | * @return a notification with no special properties |
| 197 | */ |
| 198 | private Notification createNotification() { |
| 199 | return createNotification(false /* isGroupSummary */, null /* groupKey */); |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Creates a notification with the given parameters. |
| 204 | * |
| 205 | * @param isGroupSummary whether the notification is a group summary |
| 206 | * @param groupKey the group key for the notification group used across notifications |
| 207 | * @return a notification that is in the group specified or standalone if unspecified |
| 208 | */ |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 209 | private Notification createNotification(boolean isGroupSummary, @Nullable String groupKey) { |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 210 | return createNotification(isGroupSummary, groupKey, false /* isBubble */, |
| 211 | null /* bubbleDeleteIntent */); |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Creates a notification with the given parameters. |
| 216 | * |
| 217 | * @param isGroupSummary whether the notification is a group summary |
| 218 | * @param groupKey the group key for the notification group used across notifications |
| 219 | * @param isBubble whether this notification should bubble |
| 220 | * @return a notification that is in the group specified or standalone if unspecified |
| 221 | */ |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 222 | private Notification createNotification(boolean isGroupSummary, |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 223 | @Nullable String groupKey, boolean isBubble, |
| 224 | @Nullable PendingIntent bubbleDeleteIntent) { |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 225 | Notification publicVersion = new Notification.Builder(mContext).setSmallIcon( |
| 226 | R.drawable.ic_person) |
| 227 | .setCustomContentView(new RemoteViews(mContext.getPackageName(), |
| 228 | R.layout.custom_view_dark)) |
| 229 | .build(); |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 230 | Notification.Builder notificationBuilder = new Notification.Builder(mContext, "channelId") |
| 231 | .setSmallIcon(R.drawable.ic_person) |
| 232 | .setContentTitle("Title") |
| 233 | .setContentText("Text") |
Kevin | d5022f9 | 2018-10-08 18:30:26 -0700 | [diff] [blame] | 234 | .setPublicVersion(publicVersion) |
| 235 | .setStyle(new Notification.BigTextStyle().bigText("Big Text")); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 236 | if (isGroupSummary) { |
| 237 | notificationBuilder.setGroupSummary(true); |
| 238 | } |
| 239 | if (!TextUtils.isEmpty(groupKey)) { |
| 240 | notificationBuilder.setGroup(groupKey); |
| 241 | } |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 242 | if (isBubble) { |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 243 | BubbleMetadata metadata = makeBubbleMetadata(bubbleDeleteIntent); |
| 244 | notificationBuilder.setBubbleMetadata(metadata); |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 245 | } |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 246 | return notificationBuilder.build(); |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 247 | } |
| 248 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 249 | private ExpandableNotificationRow generateRow( |
| 250 | Notification notification, |
| 251 | String pkg, |
| 252 | int uid, |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 253 | UserHandle userHandle, |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 254 | @InflationFlag int extraInflationFlags) |
| 255 | throws Exception { |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 256 | return generateRow(notification, pkg, uid, userHandle, extraInflationFlags, |
| 257 | IMPORTANCE_DEFAULT); |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | private ExpandableNotificationRow generateRow( |
| 261 | Notification notification, |
| 262 | String pkg, |
| 263 | int uid, |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 264 | UserHandle userHandle, |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 265 | @InflationFlag int extraInflationFlags, |
| 266 | int importance) |
Julia Reynolds | fc64001 | 2018-02-21 12:25:27 -0500 | [diff] [blame] | 267 | throws Exception { |
Selim Cinek | 1079067 | 2017-03-08 16:33:05 -0800 | [diff] [blame] | 268 | LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( |
| 269 | mContext.LAYOUT_INFLATER_SERVICE); |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 270 | mRow = (ExpandableNotificationRow) inflater.inflate( |
| 271 | R.layout.status_bar_notification_row, |
| 272 | null /* root */, |
| 273 | false /* attachToRoot */); |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 274 | ExpandableNotificationRow row = mRow; |
Selim Cinek | 1079067 | 2017-03-08 16:33:05 -0800 | [diff] [blame] | 275 | row.setGroupManager(mGroupManager); |
Selim Cinek | 5cf1d05 | 2017-06-01 17:36:46 -0700 | [diff] [blame] | 276 | row.setHeadsUpManager(mHeadsUpManager); |
| 277 | row.setAboveShelfChangedListener(aboveShelf -> {}); |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 278 | StatusBarNotification sbn = new StatusBarNotification( |
| 279 | pkg, |
| 280 | pkg, |
| 281 | mId++, |
| 282 | null /* tag */, |
| 283 | uid, |
| 284 | 2000 /* initialPid */, |
| 285 | notification, |
Yohei Yukawa | 7276946 | 2019-01-20 09:28:08 -0800 | [diff] [blame] | 286 | userHandle, |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 287 | null /* overrideGroupKey */, |
| 288 | System.currentTimeMillis()); |
Ned Burns | f81c4c4 | 2019-01-07 14:10:43 -0500 | [diff] [blame] | 289 | NotificationEntry entry = new NotificationEntry(sbn); |
Evan Laird | 9449285 | 2018-10-25 13:43:01 -0400 | [diff] [blame] | 290 | entry.setRow(row); |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 291 | entry.createIcons(mContext, sbn); |
Julia Reynolds | 0abae11 | 2018-06-08 10:36:57 -0400 | [diff] [blame] | 292 | entry.channel = new NotificationChannel( |
Mady Mellor | b4991e6 | 2019-01-10 15:14:51 -0800 | [diff] [blame] | 293 | notification.getChannelId(), notification.getChannelId(), importance); |
Julia Reynolds | 0abae11 | 2018-06-08 10:36:57 -0400 | [diff] [blame] | 294 | entry.channel.setBlockableSystem(true); |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 295 | row.setEntry(entry); |
| 296 | row.getNotificationInflater().addInflationFlags(extraInflationFlags); |
Ned Burns | 1a5e22f | 2019-02-14 15:11:52 -0500 | [diff] [blame] | 297 | NotificationContentInflaterTest.runThenWaitForInflation( |
Kevin | d4660b2 | 2018-09-27 10:57:35 -0700 | [diff] [blame] | 298 | () -> row.inflateViews(), |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 299 | row.getNotificationInflater()); |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 300 | |
Rohan Shah | 524cf7b | 2018-03-15 14:40:02 -0700 | [diff] [blame] | 301 | // This would be done as part of onAsyncInflationFinished, but we skip large amounts of |
| 302 | // the callback chain, so we need to make up for not adding it to the group manager |
| 303 | // here. |
| 304 | mGroupManager.onEntryAdded(entry); |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 305 | return row; |
| 306 | } |
Mady Mellor | c39b4ae | 2019-01-09 17:11:37 -0800 | [diff] [blame] | 307 | |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 308 | private BubbleMetadata makeBubbleMetadata(PendingIntent deleteIntent) { |
Mark Renouf | a9fbb6e | 2019-02-11 12:48:22 -0500 | [diff] [blame] | 309 | Intent target = new Intent(mContext, BubblesTestActivity.class); |
| 310 | PendingIntent bubbleIntent = PendingIntent.getActivity(mContext, 0, target, 0); |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 311 | |
| 312 | return new BubbleMetadata.Builder() |
Mady Mellor | c39b4ae | 2019-01-09 17:11:37 -0800 | [diff] [blame] | 313 | .setIntent(bubbleIntent) |
Mark Renouf | 08bc42a | 2019-03-07 13:01:59 -0500 | [diff] [blame] | 314 | .setDeleteIntent(deleteIntent) |
Mady Mellor | c39b4ae | 2019-01-09 17:11:37 -0800 | [diff] [blame] | 315 | .setTitle("bubble title") |
| 316 | .setIcon(Icon.createWithResource(mContext, 1)) |
| 317 | .setDesiredHeight(314) |
| 318 | .build(); |
| 319 | } |
Selim Cinek | 6fd06b5 | 2017-03-07 15:54:10 -0800 | [diff] [blame] | 320 | } |