Merge "Check distraction flags in addition to suspension state" into qt-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ad7f37d4fd
@@ -2266,7 +2266,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
final int callingUid = Binder.getCallingUid();
|
final int callingUid = Binder.getCallingUid();
|
||||||
final boolean isSystemToast = isCallerSystemOrPhone()
|
final boolean isSystemToast = isCallerSystemOrPhone()
|
||||||
|| PackageManagerService.PLATFORM_PACKAGE_NAME.equals(pkg);
|
|| PackageManagerService.PLATFORM_PACKAGE_NAME.equals(pkg);
|
||||||
final boolean isPackageSuspended = isPackageSuspendedForUser(pkg, callingUid);
|
final boolean isPackageSuspended = isPackagePaused(pkg);
|
||||||
final boolean notificationsDisabledForPackage = !areNotificationsEnabledForPackage(pkg,
|
final boolean notificationsDisabledForPackage = !areNotificationsEnabledForPackage(pkg,
|
||||||
callingUid);
|
callingUid);
|
||||||
|
|
||||||
@@ -4120,17 +4120,7 @@ public class NotificationManagerService extends SystemService {
|
|||||||
Preconditions.checkNotNull(pkg);
|
Preconditions.checkNotNull(pkg);
|
||||||
checkCallerIsSameApp(pkg);
|
checkCallerIsSameApp(pkg);
|
||||||
|
|
||||||
boolean isPaused;
|
return isPackagePausedOrSuspended(pkg, Binder.getCallingUid());
|
||||||
|
|
||||||
final PackageManagerInternal pmi = LocalServices.getService(
|
|
||||||
PackageManagerInternal.class);
|
|
||||||
int flags = pmi.getDistractingPackageRestrictions(
|
|
||||||
pkg, Binder.getCallingUserHandle().getIdentifier());
|
|
||||||
isPaused = ((flags & PackageManager.RESTRICTION_HIDE_NOTIFICATIONS) != 0);
|
|
||||||
|
|
||||||
isPaused |= isPackageSuspendedForUser(pkg, Binder.getCallingUid());
|
|
||||||
|
|
||||||
return isPaused;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyPrivilegedListener(INotificationListener token, UserHandle user,
|
private void verifyPrivilegedListener(INotificationListener token, UserHandle user,
|
||||||
@@ -5352,11 +5342,18 @@ public class NotificationManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy("mNotificationLock")
|
@GuardedBy("mNotificationLock")
|
||||||
private boolean isPackageSuspendedLocked(NotificationRecord r) {
|
boolean isPackagePausedOrSuspended(String pkg, int uid) {
|
||||||
final String pkg = r.sbn.getPackageName();
|
boolean isPaused;
|
||||||
final int callingUid = r.sbn.getUid();
|
|
||||||
|
|
||||||
return isPackageSuspendedForUser(pkg, callingUid);
|
final PackageManagerInternal pmi = LocalServices.getService(
|
||||||
|
PackageManagerInternal.class);
|
||||||
|
int flags = pmi.getDistractingPackageRestrictions(
|
||||||
|
pkg, Binder.getCallingUserHandle().getIdentifier());
|
||||||
|
isPaused = ((flags & PackageManager.RESTRICTION_HIDE_NOTIFICATIONS) != 0);
|
||||||
|
|
||||||
|
isPaused |= isPackageSuspendedForUser(pkg, uid);
|
||||||
|
|
||||||
|
return isPaused;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class PostNotificationRunnable implements Runnable {
|
protected class PostNotificationRunnable implements Runnable {
|
||||||
@@ -5389,7 +5386,8 @@ public class NotificationManagerService extends SystemService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isPackageSuspended = isPackageSuspendedLocked(r);
|
final boolean isPackageSuspended =
|
||||||
|
isPackagePausedOrSuspended(r.sbn.getPackageName(), r.getUid());
|
||||||
r.setHidden(isPackageSuspended);
|
r.setHidden(isPackageSuspended);
|
||||||
if (isPackageSuspended) {
|
if (isPackageSuspended) {
|
||||||
mUsageStats.registerSuspendedByAdmin(r);
|
mUsageStats.registerSuspendedByAdmin(r);
|
||||||
|
|||||||
Reference in New Issue
Block a user