Loading services/core/java/com/android/server/notification/NotificationManagerService.java +24 −18 Original line number Diff line number Diff line Loading @@ -1879,11 +1879,11 @@ public class NotificationManagerService extends SystemService { true, record.getUserId(), REASON_TIMEOUT, null); // If cancellation will be prevented due to lifetime extension, we send an // update to system UI. final int packageImportance = getPackageImportanceWithIdentity( record.getSbn().getPackageName()); synchronized (mNotificationLock) { maybeNotifySystemUiListenerLifetimeExtendedLocked(record, record.getSbn().getPackageName(), mActivityManager.getPackageImportance( record.getSbn().getPackageName())); record.getSbn().getPackageName(), packageImportance); } } else { cancelNotification(record.getSbn().getUid(), Loading Loading @@ -3852,7 +3852,7 @@ public class NotificationManagerService extends SystemService { // If cancellation will be prevented due to lifetime extension, we send an update to // system UI. NotificationRecord record = null; final int packageImportance = mActivityManager.getPackageImportance(pkg); final int packageImportance = getPackageImportanceWithIdentity(pkg); synchronized (mNotificationLock) { record = findNotificationLocked(pkg, tag, id, userId); maybeNotifySystemUiListenerLifetimeExtendedLocked(record, pkg, Loading @@ -3877,10 +3877,9 @@ public class NotificationManagerService extends SystemService { pkg, null, 0, FLAG_FOREGROUND_SERVICE | FLAG_USER_INITIATED_JOB | FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY, userId, REASON_APP_CANCEL_ALL); final int packageImportance = getPackageImportanceWithIdentity(pkg); // If cancellation will be prevented due to lifetime extension, we send updates // to system UI. // In this case, we need to hold the lock to access these lists. final int packageImportance = mActivityManager.getPackageImportance(pkg); synchronized (mNotificationLock) { notifySystemUiListenerLifetimeExtendedListLocked(mNotificationList, packageImportance); Loading Loading @@ -5029,7 +5028,7 @@ public class NotificationManagerService extends SystemService { pkg = info.component.getPackageName(); } if (lifetimeExtensionRefactor()) { packageImportance = mActivityManager.getPackageImportance(pkg); packageImportance = getPackageImportanceWithIdentity(pkg); } else { packageImportance = IMPORTANCE_NONE; } Loading Loading @@ -5348,7 +5347,7 @@ public class NotificationManagerService extends SystemService { final int packageImportance; try { if (lifetimeExtensionRefactor()) { packageImportance = mActivityManager.getPackageImportance(pkg); packageImportance = getPackageImportanceWithIdentity(pkg); } else { packageImportance = IMPORTANCE_NONE; } Loading Loading @@ -7609,14 +7608,9 @@ public class NotificationManagerService extends SystemService { } } // Need escalated privileges to get package importance final long token = Binder.clearCallingIdentity(); boolean isAppForeground; try { isAppForeground = mActivityManager.getPackageImportance(pkg) == IMPORTANCE_FOREGROUND; } finally { Binder.restoreCallingIdentity(token); } // Need escalated privileges to get package importance. final int packageImportance = getPackageImportanceWithIdentity(pkg); boolean isAppForeground = packageImportance == IMPORTANCE_FOREGROUND; mHandler.post(new EnqueueNotificationRunnable(userId, r, isAppForeground, tracker)); return true; } Loading Loading @@ -7944,9 +7938,9 @@ public class NotificationManagerService extends SystemService { NotificationRecord r = mNotificationsByKey.get(key); packageName = r != null ? r.getSbn().getPackageName() : null; } final int packageImportance = getPackageImportanceWithIdentity(packageName); boolean isAppForeground = packageName != null && mActivityManager.getPackageImportance(packageName) == IMPORTANCE_FOREGROUND; && packageImportance == IMPORTANCE_FOREGROUND; synchronized (mNotificationLock) { NotificationRecord r = mNotificationsByKey.get(key); if (r != null) { Loading Loading @@ -11867,6 +11861,18 @@ public class NotificationManagerService extends SystemService { } } @FlaggedApi(FLAG_LIFETIME_EXTENSION_REFACTOR) private int getPackageImportanceWithIdentity(String pkg) { final long token = Binder.clearCallingIdentity(); final int packageImportance; try { packageImportance = mActivityManager.getPackageImportance(pkg); } finally { Binder.restoreCallingIdentity(token); } return packageImportance; } public class NotificationListeners extends ManagedServices { static final String TAG_ENABLED_NOTIFICATION_LISTENERS = "enabled_listeners"; static final String TAG_REQUESTED_LISTENERS = "request_listeners"; Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +24 −18 Original line number Diff line number Diff line Loading @@ -1879,11 +1879,11 @@ public class NotificationManagerService extends SystemService { true, record.getUserId(), REASON_TIMEOUT, null); // If cancellation will be prevented due to lifetime extension, we send an // update to system UI. final int packageImportance = getPackageImportanceWithIdentity( record.getSbn().getPackageName()); synchronized (mNotificationLock) { maybeNotifySystemUiListenerLifetimeExtendedLocked(record, record.getSbn().getPackageName(), mActivityManager.getPackageImportance( record.getSbn().getPackageName())); record.getSbn().getPackageName(), packageImportance); } } else { cancelNotification(record.getSbn().getUid(), Loading Loading @@ -3852,7 +3852,7 @@ public class NotificationManagerService extends SystemService { // If cancellation will be prevented due to lifetime extension, we send an update to // system UI. NotificationRecord record = null; final int packageImportance = mActivityManager.getPackageImportance(pkg); final int packageImportance = getPackageImportanceWithIdentity(pkg); synchronized (mNotificationLock) { record = findNotificationLocked(pkg, tag, id, userId); maybeNotifySystemUiListenerLifetimeExtendedLocked(record, pkg, Loading @@ -3877,10 +3877,9 @@ public class NotificationManagerService extends SystemService { pkg, null, 0, FLAG_FOREGROUND_SERVICE | FLAG_USER_INITIATED_JOB | FLAG_LIFETIME_EXTENDED_BY_DIRECT_REPLY, userId, REASON_APP_CANCEL_ALL); final int packageImportance = getPackageImportanceWithIdentity(pkg); // If cancellation will be prevented due to lifetime extension, we send updates // to system UI. // In this case, we need to hold the lock to access these lists. final int packageImportance = mActivityManager.getPackageImportance(pkg); synchronized (mNotificationLock) { notifySystemUiListenerLifetimeExtendedListLocked(mNotificationList, packageImportance); Loading Loading @@ -5029,7 +5028,7 @@ public class NotificationManagerService extends SystemService { pkg = info.component.getPackageName(); } if (lifetimeExtensionRefactor()) { packageImportance = mActivityManager.getPackageImportance(pkg); packageImportance = getPackageImportanceWithIdentity(pkg); } else { packageImportance = IMPORTANCE_NONE; } Loading Loading @@ -5348,7 +5347,7 @@ public class NotificationManagerService extends SystemService { final int packageImportance; try { if (lifetimeExtensionRefactor()) { packageImportance = mActivityManager.getPackageImportance(pkg); packageImportance = getPackageImportanceWithIdentity(pkg); } else { packageImportance = IMPORTANCE_NONE; } Loading Loading @@ -7609,14 +7608,9 @@ public class NotificationManagerService extends SystemService { } } // Need escalated privileges to get package importance final long token = Binder.clearCallingIdentity(); boolean isAppForeground; try { isAppForeground = mActivityManager.getPackageImportance(pkg) == IMPORTANCE_FOREGROUND; } finally { Binder.restoreCallingIdentity(token); } // Need escalated privileges to get package importance. final int packageImportance = getPackageImportanceWithIdentity(pkg); boolean isAppForeground = packageImportance == IMPORTANCE_FOREGROUND; mHandler.post(new EnqueueNotificationRunnable(userId, r, isAppForeground, tracker)); return true; } Loading Loading @@ -7944,9 +7938,9 @@ public class NotificationManagerService extends SystemService { NotificationRecord r = mNotificationsByKey.get(key); packageName = r != null ? r.getSbn().getPackageName() : null; } final int packageImportance = getPackageImportanceWithIdentity(packageName); boolean isAppForeground = packageName != null && mActivityManager.getPackageImportance(packageName) == IMPORTANCE_FOREGROUND; && packageImportance == IMPORTANCE_FOREGROUND; synchronized (mNotificationLock) { NotificationRecord r = mNotificationsByKey.get(key); if (r != null) { Loading Loading @@ -11867,6 +11861,18 @@ public class NotificationManagerService extends SystemService { } } @FlaggedApi(FLAG_LIFETIME_EXTENSION_REFACTOR) private int getPackageImportanceWithIdentity(String pkg) { final long token = Binder.clearCallingIdentity(); final int packageImportance; try { packageImportance = mActivityManager.getPackageImportance(pkg); } finally { Binder.restoreCallingIdentity(token); } return packageImportance; } public class NotificationListeners extends ManagedServices { static final String TAG_ENABLED_NOTIFICATION_LISTENERS = "enabled_listeners"; static final String TAG_REQUESTED_LISTENERS = "request_listeners";