Fix issue #7214090: Need to be able to post notifications to all users
Also fix a bunch of system services that should be doing this. And while doing that, found I needed to fix PendingIntent to evaluate USER_CURRENT at the point of sending, not creation. Note that this may end up with us having some notification shown to non-primary users that lead to settings UI that should only be for the primary user (such as the vpn notification). I'm not sure what to do about this, maybe we need a different UI to come up there or something, but showing the actual notification for those users at least seems less broken than not telling them at all. Change-Id: Iffc51e2d7c847e3d05064d292ab93937646a1ab7
This commit is contained in:
@@ -53,7 +53,6 @@ import android.os.ServiceManager;
|
||||
import android.os.UserHandle;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.Settings;
|
||||
import android.service.dreams.IDreamManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AtomicFile;
|
||||
@@ -890,7 +889,7 @@ public class NotificationManagerService extends INotificationManager.Stub
|
||||
final boolean isSystemNotification = ("android".equals(pkg));
|
||||
|
||||
userId = ActivityManager.handleIncomingUser(callingPid,
|
||||
callingUid, userId, false, true, "enqueueNotification", pkg);
|
||||
callingUid, userId, true, true, "enqueueNotification", pkg);
|
||||
|
||||
// Limit the number of notifications that any given package except the android
|
||||
// package can enqueue. Prevents DOS attacks and deals with leaks.
|
||||
@@ -900,7 +899,7 @@ public class NotificationManagerService extends INotificationManager.Stub
|
||||
final int N = mNotificationList.size();
|
||||
for (int i=0; i<N; i++) {
|
||||
final NotificationRecord r = mNotificationList.get(i);
|
||||
if (r.pkg.equals(pkg)) {
|
||||
if (r.pkg.equals(pkg) && r.userId == userId) {
|
||||
count++;
|
||||
if (count >= MAX_PACKAGE_NOTIFICATIONS) {
|
||||
Slog.e(TAG, "Package has already posted " + count
|
||||
@@ -1261,7 +1260,7 @@ public class NotificationManagerService extends INotificationManager.Stub
|
||||
public void cancelNotificationWithTag(String pkg, String tag, int id, int userId) {
|
||||
checkCallerIsSystemOrSameApp(pkg);
|
||||
userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
|
||||
Binder.getCallingUid(), userId, false, true, "cancelNotificationWithTag", pkg);
|
||||
Binder.getCallingUid(), userId, true, true, "cancelNotificationWithTag", pkg);
|
||||
// Don't allow client applications to cancel foreground service notis.
|
||||
cancelNotification(pkg, tag, id, 0,
|
||||
Binder.getCallingUid() == Process.SYSTEM_UID
|
||||
|
||||
Reference in New Issue
Block a user