Handle multi-user in notif log
Test: manual
Fixes: 141575553
Change-Id: I03ff85358e8ae6ed5e6699358c4f9c785c416ecf
diff --git a/res/layout/notification_log_row.xml b/res/layout/notification_log_row.xml
index 4d44f9f..fea8a29 100644
--- a/res/layout/notification_log_row.xml
+++ b/res/layout/notification_log_row.xml
@@ -71,6 +71,18 @@
android:src="@drawable/ic_notifications_alert"
/>
+ <ImageView
+ android:id="@+id/profile_badge"
+ android:layout_width="@*android:dimen/status_bar_icon_size"
+ android:layout_height="@*android:dimen/status_bar_icon_size"
+ android:layout_centerVertical="true"
+ android:layout_marginEnd="6dp"
+ android:paddingTop="1dp"
+ android:scaleType="fitCenter"
+ android:visibility="gone"
+ android:layout_toStartOf="@id/timestamp"
+ />
+
<DateTimeView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index e5db3ee..c2c8b60 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -83,6 +83,7 @@
public Drawable pkgicon;
public CharSequence pkgname;
public Drawable icon;
+ public boolean badged;
public CharSequence title;
public CharSequence text;
public int priority;
@@ -268,8 +269,8 @@
if (needsAdd) {
mNotificationInfos.addFirst(newInfo);
getPreferenceScreen().addPreference(new HistoricalNotificationPreference(
- getPrefContext(),
- mNotificationInfos.peekFirst(), -1 * mNotificationInfos.size()));
+ getPrefContext(), mNotificationInfos.peekFirst(),
+ -1 * mNotificationInfos.size()));
}
}
@@ -338,9 +339,9 @@
return text == null ? null : String.valueOf(text);
}
- private static Drawable loadIcon(Context context, StatusBarNotification sbn) {
+ private Drawable loadIcon(HistoricalNotificationInfo info, StatusBarNotification sbn) {
Drawable draw = sbn.getNotification().getSmallIcon().loadDrawableAsUser(
- sbn.getPackageContext(context), sbn.getUserId());
+ sbn.getPackageContext(mContext), info.user);
if (draw == null) {
return null;
}
@@ -367,7 +368,6 @@
* booted), stores the data we need to present them, and sorts them chronologically for display.
*/
private void loadNotifications() {
- final int currentUserId = ActivityManager.getCurrentUser();
try {
StatusBarNotification[] active = mNoMan.getActiveNotifications(
mContext.getPackageName());
@@ -380,9 +380,6 @@
for (StatusBarNotification[] resultSet
: new StatusBarNotification[][] { active, dismissed }) {
for (StatusBarNotification sbn : resultSet) {
- if (sbn.getUserId() != UserHandle.USER_ALL & sbn.getUserId() != currentUserId) {
- continue;
- }
if (sbn.getNotification().isGroupSummary()) {
continue;
}
@@ -406,8 +403,10 @@
final Notification n = sbn.getNotification();
final HistoricalNotificationInfo info = new HistoricalNotificationInfo();
info.pkg = sbn.getPackageName();
- info.user = sbn.getUserId();
- info.icon = loadIcon(mContext, sbn);
+ info.user = sbn.getUserId() == UserHandle.USER_ALL
+ ? UserHandle.USER_SYSTEM : sbn.getUserId();
+ info.badged = info.user != ActivityManager.getCurrentUser();
+ info.icon = loadIcon(info, sbn);
if (info.icon == null) {
info.icon = loadPackageIconDrawable(info.pkg, info.user);
}
@@ -645,6 +644,7 @@
private final HistoricalNotificationInfo mInfo;
private static long sLastExpandedTimestamp; // quick hack to keep things from collapsing
public ViewGroup mItemView; // hack to update prefs fast;
+ private Context mContext;
public HistoricalNotificationPreference(Context context, HistoricalNotificationInfo info,
int order) {
@@ -653,6 +653,7 @@
setOrder(order);
setKey(info.key);
mInfo = info;
+ mContext = context;
}
@Override
@@ -697,6 +698,12 @@
((ImageView) mItemView.findViewById(R.id.icon)).setImageDrawable(info.icon);
}
+ ImageView profileBadge = mItemView.findViewById(R.id.profile_badge);
+ Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
+ UserHandle.of(info.user), -1);
+ profileBadge.setImageDrawable(profile);
+ profileBadge.setVisibility(info.badged ? View.VISIBLE : View.GONE);
+
((DateTimeView) mItemView.findViewById(R.id.timestamp)).setTime(mInfo.timestamp);
((TextView) mItemView.findViewById(R.id.notification_extra))