Merge "DO NOT MERGE Notifs sent from suspended apps should reappear" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0b89c36e8a
@@ -4255,13 +4255,6 @@ public class NotificationManagerService extends SystemService {
|
|||||||
final String pkg = r.sbn.getPackageName();
|
final String pkg = r.sbn.getPackageName();
|
||||||
final int callingUid = r.sbn.getUid();
|
final int callingUid = r.sbn.getUid();
|
||||||
|
|
||||||
final boolean isPackageSuspended = isPackageSuspendedForUser(pkg, callingUid);
|
|
||||||
if (isPackageSuspended) {
|
|
||||||
Slog.e(TAG, "Suppressing notification from package due to package "
|
|
||||||
+ "suspended by administrator.");
|
|
||||||
usageStats.registerSuspendedByAdmin(r);
|
|
||||||
return isPackageSuspended;
|
|
||||||
}
|
|
||||||
final boolean isBlocked =
|
final boolean isBlocked =
|
||||||
mRankingHelper.isGroupBlocked(pkg, callingUid, r.getChannel().getGroup())
|
mRankingHelper.isGroupBlocked(pkg, callingUid, r.getChannel().getGroup())
|
||||||
|| mRankingHelper.getImportance(pkg, callingUid)
|
|| mRankingHelper.getImportance(pkg, callingUid)
|
||||||
@@ -4270,8 +4263,9 @@ public class NotificationManagerService extends SystemService {
|
|||||||
if (isBlocked) {
|
if (isBlocked) {
|
||||||
Slog.e(TAG, "Suppressing notification from package by user request.");
|
Slog.e(TAG, "Suppressing notification from package by user request.");
|
||||||
usageStats.registerBlocked(r);
|
usageStats.registerBlocked(r);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return isBlocked;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class SnoozeNotificationRunnable implements Runnable {
|
protected class SnoozeNotificationRunnable implements Runnable {
|
||||||
@@ -4449,7 +4443,11 @@ public class NotificationManagerService extends SystemService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setHidden(isPackageSuspendedLocked(r));
|
final boolean isPackageSuspended = isPackageSuspendedLocked(r);
|
||||||
|
r.setHidden(isPackageSuspended);
|
||||||
|
if (isPackageSuspended) {
|
||||||
|
mUsageStats.registerSuspendedByAdmin(r);
|
||||||
|
}
|
||||||
NotificationRecord old = mNotificationsByKey.get(key);
|
NotificationRecord old = mNotificationsByKey.get(key);
|
||||||
final StatusBarNotification n = r.sbn;
|
final StatusBarNotification n = r.sbn;
|
||||||
final Notification notification = n.getNotification();
|
final Notification notification = n.getNotification();
|
||||||
@@ -6625,7 +6623,6 @@ public class NotificationManagerService extends SystemService {
|
|||||||
if (!oldSbnVisible && !sbnVisible) {
|
if (!oldSbnVisible && !sbnVisible) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the notification is hidden, don't notifyPosted listeners targeting < P.
|
// If the notification is hidden, don't notifyPosted listeners targeting < P.
|
||||||
// Instead, those listeners will receive notifyPosted when the notification is
|
// Instead, those listeners will receive notifyPosted when the notification is
|
||||||
// unhidden.
|
// unhidden.
|
||||||
|
|||||||
@@ -500,8 +500,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
NotificationChannel channel = new NotificationChannel("id", "name",
|
NotificationChannel channel = new NotificationChannel("id", "name",
|
||||||
IMPORTANCE_HIGH);
|
IMPORTANCE_HIGH);
|
||||||
NotificationRecord r = generateNotificationRecord(channel);
|
NotificationRecord r = generateNotificationRecord(channel);
|
||||||
assertTrue(mService.isBlocked(r, mUsageStats));
|
|
||||||
verify(mUsageStats, times(1)).registerSuspendedByAdmin(eq(r));
|
// isBlocked is only used for user blocking, not app suspension
|
||||||
|
assertFalse(mService.isBlocked(r, mUsageStats));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user