summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2014-03-03 18:24:03 +0000
committerKenny Guy <kennyguy@google.com>2014-03-12 19:51:03 +0000
commit3a7c4a5669420ae9b01eda88d1d60114e99d70ff (patch)
tree68043c7d7db82f04eb7a77d1d5ddc54f0a660a4e /packages/SystemUI/src/com
parent0e6ad3b86bcf3d85b7a8b06c9f06344c94fd6222 (diff)
downloadframeworks_base-3a7c4a5669420ae9b01eda88d1d60114e99d70ff.zip
frameworks_base-3a7c4a5669420ae9b01eda88d1d60114e99d70ff.tar.gz
frameworks_base-3a7c4a5669420ae9b01eda88d1d60114e99d70ff.tar.bz2
Show notifications from related users.
When filtering notifications for user include those for users that are related to the current user. Pipe through user id so we know which user the notification is for. Change-Id: I4e2657c23bd7b611d450be5a1f9457824bc062cb
Diffstat (limited to 'packages/SystemUI/src/com')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java60
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java14
2 files changed, 55 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index a89921f..bd36128 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -28,6 +28,7 @@ import android.content.IntentFilter;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.UserInfo;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.database.ContentObserver;
@@ -46,6 +47,7 @@ import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.os.UserManager;
import android.provider.Settings;
import android.service.dreams.DreamService;
import android.service.dreams.IDreamManager;
@@ -55,6 +57,7 @@ import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.TextAppearanceSpan;
import android.util.Log;
+import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.view.ContextThemeWrapper;
import android.view.Display;
@@ -140,6 +143,7 @@ public abstract class BaseStatusBar extends SystemUI implements
protected PopupMenu mNotificationBlamePopup;
protected int mCurrentUserId = 0;
+ final protected SparseArray<UserInfo> mRelatedUsers = new SparseArray<UserInfo>();
protected int mLayoutDirection = -1; // invalid
private Locale mLocale;
@@ -156,6 +160,8 @@ public abstract class BaseStatusBar extends SystemUI implements
private Context mLightThemeContext;
private ImageUtils mImageUtils = new ImageUtils();
+ private UserManager mUserManager;
+
// UI-specific methods
/**
@@ -248,12 +254,26 @@ public abstract class BaseStatusBar extends SystemUI implements
String action = intent.getAction();
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
mCurrentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
+ updateRelatedUserCache();
if (true) Log.v(TAG, "userId " + mCurrentUserId + " is in the house");
userSwitched(mCurrentUserId);
+ } else if (Intent.ACTION_USER_ADDED.equals(action)) {
+ updateRelatedUserCache();
}
}
};
+ private void updateRelatedUserCache() {
+ synchronized (mRelatedUsers) {
+ mRelatedUsers.clear();
+ if (mUserManager != null) {
+ for (UserInfo related : mUserManager.getRelatedUsers(mCurrentUserId)) {
+ mRelatedUsers.put(related.id, related);
+ }
+ }
+ }
+ }
+
public void start() {
mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
@@ -287,6 +307,8 @@ public abstract class BaseStatusBar extends SystemUI implements
mLocale = mContext.getResources().getConfiguration().locale;
mLayoutDirection = TextUtils.getLayoutDirectionFromLocale(mLocale);
+ mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
+
// Connect in to the status bar manager service
StatusBarIconList iconList = new StatusBarIconList();
ArrayList<IBinder> notificationKeys = new ArrayList<IBinder>();
@@ -348,22 +370,28 @@ public abstract class BaseStatusBar extends SystemUI implements
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_USER_SWITCHED);
+ filter.addAction(Intent.ACTION_USER_ADDED);
mContext.registerReceiver(mBroadcastReceiver, filter);
+
+ updateRelatedUserCache();
}
public void userSwitched(int newUserId) {
// should be overridden
}
- public boolean notificationIsForCurrentUser(StatusBarNotification n) {
+ public boolean notificationIsForCurrentOrRelatedUser(StatusBarNotification n) {
final int thisUserId = mCurrentUserId;
final int notificationUserId = n.getUserId();
if (DEBUG && MULTIUSER_DEBUG) {
Log.v(TAG, String.format("%s: current userid: %d, notification userid: %d",
n, thisUserId, notificationUserId));
}
- return notificationUserId == UserHandle.USER_ALL
- || thisUserId == notificationUserId;
+ synchronized (mRelatedUsers) {
+ return notificationUserId == UserHandle.USER_ALL
+ || thisUserId == notificationUserId
+ || mRelatedUsers.get(notificationUserId) != null;
+ }
}
@Override
@@ -389,13 +417,14 @@ public abstract class BaseStatusBar extends SystemUI implements
final String _pkg = n.getPackageName();
final String _tag = n.getTag();
final int _id = n.getId();
+ final int _userId = n.getUserId();
vetoButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Accessibility feedback
v.announceForAccessibility(
mContext.getString(R.string.accessibility_notification_dismissed));
try {
- mBarService.onNotificationClear(_pkg, _tag, _id);
+ mBarService.onNotificationClear(_pkg, _tag, _id, _userId);
} catch (RemoteException ex) {
// system process is dead if we're here.
@@ -907,7 +936,7 @@ public abstract class BaseStatusBar extends SystemUI implements
PendingIntent contentIntent = sbn.getNotification().contentIntent;
if (contentIntent != null) {
final View.OnClickListener listener = makeClicker(contentIntent,
- sbn.getPackageName(), sbn.getTag(), sbn.getId(), isHeadsUp);
+ sbn.getPackageName(), sbn.getTag(), sbn.getId(), isHeadsUp, sbn.getUserId());
content.setOnClickListener(listener);
} else {
content.setOnClickListener(null);
@@ -1017,7 +1046,7 @@ public abstract class BaseStatusBar extends SystemUI implements
TextView debug = (TextView) row.findViewById(R.id.debug_info);
if (debug != null) {
debug.setVisibility(View.VISIBLE);
- debug.setText("U " + entry.notification.getUserId());
+ debug.setText("CU " + mCurrentUserId +" NU " + entry.notification.getUserId());
}
}
entry.row = row;
@@ -1030,9 +1059,9 @@ public abstract class BaseStatusBar extends SystemUI implements
return true;
}
- public NotificationClicker makeClicker(PendingIntent intent, String pkg, String tag, int id,
- boolean forHun) {
- return new NotificationClicker(intent, pkg, tag, id, forHun);
+ public NotificationClicker makeClicker(PendingIntent intent, String pkg, String tag,
+ int id, boolean forHun, int userId) {
+ return new NotificationClicker(intent, pkg, tag, id, forHun, userId);
}
protected class NotificationClicker implements View.OnClickListener {
@@ -1041,14 +1070,16 @@ public abstract class BaseStatusBar extends SystemUI implements
private String mTag;
private int mId;
private boolean mIsHeadsUp;
+ private int mUserId;
public NotificationClicker(PendingIntent intent, String pkg, String tag, int id,
- boolean forHun) {
+ boolean forHun, int userId) {
mIntent = intent;
mPkg = pkg;
mTag = tag;
mId = id;
mIsHeadsUp = forHun;
+ mUserId = userId;
}
public void onClick(View v) {
@@ -1084,7 +1115,7 @@ public abstract class BaseStatusBar extends SystemUI implements
if (mIsHeadsUp) {
mHandler.sendEmptyMessage(MSG_HIDE_HEADS_UP);
}
- mBarService.onNotificationClick(mPkg, mTag, mId);
+ mBarService.onNotificationClick(mPkg, mTag, mId, mUserId);
} catch (RemoteException ex) {
// system process is dead if we're here.
}
@@ -1122,7 +1153,8 @@ public abstract class BaseStatusBar extends SystemUI implements
void handleNotificationError(IBinder key, StatusBarNotification n, String message) {
removeNotification(key);
try {
- mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(), n.getInitialPid(), message);
+ mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(),
+ n.getInitialPid(), message, n.getUserId());
} catch (RemoteException ex) {
// The end is nigh.
}
@@ -1391,7 +1423,7 @@ public abstract class BaseStatusBar extends SystemUI implements
updateNotificationVetoButton(oldEntry.row, notification);
// Is this for you?
- boolean isForCurrentUser = notificationIsForCurrentUser(notification);
+ boolean isForCurrentUser = notificationIsForCurrentOrRelatedUser(notification);
if (DEBUG) Log.d(TAG, "notification is " + (isForCurrentUser ? "" : "not ") + "for you");
// Restart the ticker if it's still running
@@ -1443,7 +1475,7 @@ public abstract class BaseStatusBar extends SystemUI implements
if (contentIntent != null) {
final View.OnClickListener listener = makeClicker(contentIntent,
notification.getPackageName(), notification.getTag(), notification.getId(),
- isHeadsUp);
+ isHeadsUp, notification.getUserId());
entry.content.setOnClickListener(listener);
} else {
entry.content.setOnClickListener(null);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 6718de1..9540bd4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1056,7 +1056,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
for (int i=0; i<N; i++) {
Entry ent = mNotificationData.get(N-i-1);
if (!(provisioned || showNotificationEvenIfUnprovisioned(ent.notification))) continue;
- if (!notificationIsForCurrentUser(ent.notification)) continue;
+
+ // TODO How do we want to badge notifcations from related users.
+ if (!notificationIsForCurrentOrRelatedUser(ent.notification)) continue;
+
final int vis = ent.notification.getNotification().visibility;
if (vis != Notification.VISIBILITY_SECRET) {
// when isLockscreenPublicMode() we show the public form of VISIBILITY_PRIVATE notifications
@@ -1114,7 +1117,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
Entry ent = mNotificationData.get(N-i-1);
if (!((provisioned && ent.notification.getScore() >= HIDE_ICONS_BELOW_SCORE)
|| showNotificationEvenIfUnprovisioned(ent.notification))) continue;
- if (!notificationIsForCurrentUser(ent.notification)) continue;
+ if (!notificationIsForCurrentOrRelatedUser(ent.notification)) continue;
if (isLockscreenPublicMode()
&& ent.notification.getNotification().visibility
== Notification.VISIBILITY_SECRET
@@ -2121,7 +2124,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
if (!isDeviceProvisioned()) return;
// not for you
- if (!notificationIsForCurrentUser(n)) return;
+ if (!notificationIsForCurrentOrRelatedUser(n)) return;
// Show the ticker if one is requested. Also don't do this
// until status bar window is attached to the window manager,
@@ -2429,7 +2432,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
}
try {
mPile.setViewRemoval(true);
- mBarService.onClearAllNotifications();
+ mBarService.onClearAllNotifications(mCurrentUserId);
} catch (Exception ex) { }
}
};
@@ -2607,7 +2610,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode {
mBarService.onNotificationClear(
mInterruptingNotificationEntry.notification.getPackageName(),
mInterruptingNotificationEntry.notification.getTag(),
- mInterruptingNotificationEntry.notification.getId());
+ mInterruptingNotificationEntry.notification.getId(),
+ mInterruptingNotificationEntry.notification.getUserId());
} catch (android.os.RemoteException ex) {
// oh well
}