Add way to check if user has locked the bubble allowed field
Also removes an extra s from a method whoooooops
Bug: 111236845
Test: atest NotificationManagerServiceTest
Change-Id: I1f77afd10b322088aa9cb39b65d70cbd84fb6dc4
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index de3f50a..b629a82 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2339,18 +2339,24 @@
public boolean areBubblesAllowedForPackage(String pkg, int uid) {
enforceSystemOrSystemUIOrSamePackage(pkg,
"Caller not system or systemui or same package");
- return mPreferencesHelper.areBubblessAllowed(pkg, uid);
+ return mPreferencesHelper.areBubblesAllowed(pkg, uid);
}
@Override
public void setBubblesAllowed(String pkg, int uid, boolean allowed) {
- checkCallerIsSystem();
-
+ enforceSystemOrSystemUI("Caller not system or systemui");
mPreferencesHelper.setBubblesAllowed(pkg, uid, allowed);
handleSavePolicyFile();
}
@Override
+ public boolean hasUserApprovedBubblesForPackage(String pkg, int uid) {
+ enforceSystemOrSystemUI("Caller not system or systemui");
+ int lockedFields = mPreferencesHelper.getAppLockedFields(pkg, uid);
+ return (lockedFields & PreferencesHelper.LockableAppFields.USER_LOCKED_BUBBLE) != 0;
+ }
+
+ @Override
public int getPackageImportance(String pkg) {
checkCallerIsSystemOrSameApp(pkg);
return mPreferencesHelper.getImportance(pkg, Binder.getCallingUid());
diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java
index 7a21aa2..3f0043c 100644
--- a/services/core/java/com/android/server/notification/PreferencesHelper.java
+++ b/services/core/java/com/android/server/notification/PreferencesHelper.java
@@ -473,7 +473,7 @@
* @param uid the uid to check if bubbles are allowed for.
* @return whether bubbles are allowed.
*/
- public boolean areBubblessAllowed(String pkg, int uid) {
+ public boolean areBubblesAllowed(String pkg, int uid) {
return getOrCreatePackagePreferences(pkg, uid).allowBubble;
}
@@ -489,7 +489,6 @@
return getOrCreatePackagePreferences(packageName, uid).importance;
}
-
/**
* Returns whether the importance of the corresponding notification is user-locked and shouldn't
* be adjusted by an assistant (via means of a blocking helper, for example). For the channel