diff --git a/src/com/android/settings/notification/history/NotificationHistoryActivity.java b/src/com/android/settings/notification/history/NotificationHistoryActivity.java index 9b78ae987b6..9f8a07fd414 100644 --- a/src/com/android/settings/notification/history/NotificationHistoryActivity.java +++ b/src/com/android/settings/notification/history/NotificationHistoryActivity.java @@ -51,6 +51,7 @@ import com.android.settings.R; import com.android.settings.notification.NotificationBackend; import com.android.settings.widget.SwitchBar; +import java.util.ArrayList; import java.util.Arrays; public class NotificationHistoryActivity extends Activity { @@ -252,7 +253,7 @@ public class NotificationHistoryActivity extends Activity { rv.setNestedScrollingEnabled(false); ((NotificationSbnAdapter) rv.getAdapter()).onRebuildComplete( - Arrays.asList(snoozed)); + new ArrayList<>(Arrays.asList(snoozed))); } try { @@ -268,7 +269,7 @@ public class NotificationHistoryActivity extends Activity { rv.setNestedScrollingEnabled(false); ((NotificationSbnAdapter) rv.getAdapter()).onRebuildComplete( - Arrays.asList(dismissed)); + new ArrayList<>(Arrays.asList(dismissed))); mDismissView.setVisibility(View.VISIBLE); } catch (Exception e) { Slog.e(TAG, "Cannot load recently dismissed", e); diff --git a/src/com/android/settings/notification/history/NotificationSbnAdapter.java b/src/com/android/settings/notification/history/NotificationSbnAdapter.java index a35b5d4cf22..f1dcf47f27f 100644 --- a/src/com/android/settings/notification/history/NotificationSbnAdapter.java +++ b/src/com/android/settings/notification/history/NotificationSbnAdapter.java @@ -17,6 +17,8 @@ package com.android.settings.notification.history; import static android.content.pm.PackageManager.*; +import static android.os.UserHandle.USER_ALL; +import static android.os.UserHandle.USER_CURRENT; import android.app.Notification; import android.content.Context; @@ -77,12 +79,13 @@ public class NotificationSbnAdapter extends holder.setTitle(getTitleString(sbn.getNotification())); holder.setSummary(getTextString(mContext, sbn.getNotification())); holder.setPostedTime(sbn.getPostTime()); - if (!mUserBadgeCache.containsKey(sbn.getUserId())) { + int userId = normalizeUserId(sbn); + if (!mUserBadgeCache.containsKey(userId)) { Drawable profile = mContext.getPackageManager().getUserBadgeForDensity( - UserHandle.of(sbn.getUserId()), -1); - mUserBadgeCache.put(sbn.getUserId(), profile); + UserHandle.of(userId), -1); + mUserBadgeCache.put(userId, profile); } - holder.setProfileBadge(mUserBadgeCache.get(sbn.getUserId())); + holder.setProfileBadge(mUserBadgeCache.get(userId)); } else { Slog.w(TAG, "null entry in list at position " + position); } @@ -153,7 +156,7 @@ public class NotificationSbnAdapter extends private Drawable loadIcon(StatusBarNotification sbn) { Drawable draw = sbn.getNotification().getSmallIcon().loadDrawableAsUser( - sbn.getPackageContext(mContext), sbn.getUserId()); + sbn.getPackageContext(mContext), normalizeUserId(sbn)); if (draw == null) { return null; } @@ -161,4 +164,12 @@ public class NotificationSbnAdapter extends draw.setColorFilter(sbn.getNotification().color, PorterDuff.Mode.SRC_ATOP); return draw; } + + private int normalizeUserId(StatusBarNotification sbn) { + int userId = sbn.getUserId(); + if (userId == USER_ALL) { + userId = USER_CURRENT; + } + return userId; + } }