Merge "[DO NOT MERGE] The system can post notifications for any package" into nyc-mr2-dev
am: 1ddddee33f
Change-Id: Iaf9aacd39ea328f3a22f26987eb65df682ddccc5
This commit is contained in:
@@ -2533,7 +2533,6 @@ public class NotificationManagerService extends SystemService {
|
|||||||
final int userId = ActivityManager.handleIncomingUser(callingPid,
|
final int userId = ActivityManager.handleIncomingUser(callingPid,
|
||||||
callingUid, incomingUserId, true, false, "enqueueNotification", pkg);
|
callingUid, incomingUserId, true, false, "enqueueNotification", pkg);
|
||||||
final UserHandle user = new UserHandle(userId);
|
final UserHandle user = new UserHandle(userId);
|
||||||
|
|
||||||
// Fix the notification as best we can.
|
// Fix the notification as best we can.
|
||||||
try {
|
try {
|
||||||
final ApplicationInfo ai = getContext().getPackageManager().getApplicationInfoAsUser(
|
final ApplicationInfo ai = getContext().getPackageManager().getApplicationInfoAsUser(
|
||||||
@@ -2547,13 +2546,16 @@ public class NotificationManagerService extends SystemService {
|
|||||||
|
|
||||||
mUsageStats.registerEnqueuedByApp(pkg);
|
mUsageStats.registerEnqueuedByApp(pkg);
|
||||||
|
|
||||||
|
|
||||||
if (pkg == null || notification == null) {
|
if (pkg == null || notification == null) {
|
||||||
throw new IllegalArgumentException("null not allowed: pkg=" + pkg
|
throw new IllegalArgumentException("null not allowed: pkg=" + pkg
|
||||||
+ " id=" + id + " notification=" + notification);
|
+ " id=" + id + " notification=" + notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The system can post notifications for any package, let us resolve that.
|
||||||
|
final int notificationUid = resolveNotificationUid(opPkg, callingUid, userId);
|
||||||
|
|
||||||
final StatusBarNotification n = new StatusBarNotification(
|
final StatusBarNotification n = new StatusBarNotification(
|
||||||
pkg, opPkg, id, tag, callingUid, callingPid, 0, notification,
|
pkg, opPkg, id, tag, notificationUid, callingPid, 0, notification,
|
||||||
user);
|
user);
|
||||||
|
|
||||||
// Limit the number of notifications that any given package except the android
|
// Limit the number of notifications that any given package except the android
|
||||||
@@ -2623,6 +2625,19 @@ public class NotificationManagerService extends SystemService {
|
|||||||
idOut[0] = id;
|
idOut[0] = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int resolveNotificationUid(String opPackageName, int callingUid, int userId) {
|
||||||
|
// The system can post notifications on behalf of any package it wants
|
||||||
|
if (isCallerSystem() && opPackageName != null && !"android".equals(opPackageName)) {
|
||||||
|
try {
|
||||||
|
return getContext().getPackageManager()
|
||||||
|
.getPackageUidAsUser(opPackageName, userId);
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return callingUid;
|
||||||
|
}
|
||||||
|
|
||||||
private class EnqueueNotificationRunnable implements Runnable {
|
private class EnqueueNotificationRunnable implements Runnable {
|
||||||
private final NotificationRecord r;
|
private final NotificationRecord r;
|
||||||
private final int userId;
|
private final int userId;
|
||||||
|
|||||||
Reference in New Issue
Block a user