summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2021-02-10 13:06:43 -0500
committerJulia Reynolds <juliacr@google.com>2021-02-12 12:55:02 -0500
commitb6c718c9b8ebfa19d9ee90973111e21353f94e5c (patch)
treeeddc39fbd0631936e8a7faeb7eb6c91ba8a8673d /core/java
parent98039ded901181b14c3b79edc79d1b9a71bbfbbb (diff)
Allow NLSes to supply a default notif type filter
Test: atest, cts verifier Bug: 173052211 Change-Id: I06a110679c1c9c1de8d0e3f45a2b69c040e538f6
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/service/notification/NotificationListenerFilter.java1
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java23
2 files changed, 20 insertions, 4 deletions
diff --git a/core/java/android/service/notification/NotificationListenerFilter.java b/core/java/android/service/notification/NotificationListenerFilter.java
index 053fb2b1b4eb..9de75cac159a 100644
--- a/core/java/android/service/notification/NotificationListenerFilter.java
+++ b/core/java/android/service/notification/NotificationListenerFilter.java
@@ -32,6 +32,7 @@ import android.util.ArraySet;
*/
public class NotificationListenerFilter implements Parcelable {
private int mAllowedNotificationTypes;
+ // VersionedPackage is holding the pkg name and pkg uid
private ArraySet<VersionedPackage> mDisallowedPackages;
public NotificationListenerFilter() {
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 64cddc35d2bb..f66f85b9e8cc 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -80,6 +80,10 @@ import java.util.Objects;
* &lt;intent-filter>
* &lt;action android:name="android.service.notification.NotificationListenerService" />
* &lt;/intent-filter>
+ * &lt;meta-data
+ * android:name="android.service.notification.default_filter_types"
+ * android:value="1,2">
+ * &lt;/meta-data>
* &lt;/service></pre>
*
* <p>The service should wait for the {@link #onListenerConnected()} event
@@ -103,6 +107,21 @@ public abstract class NotificationListenerService extends Service {
private final String TAG = getClass().getSimpleName();
/**
+ * The name of the {@code meta-data} tag containing a comma separated list of default
+ * integer notification types that should be provided to this listener. See
+ * {@link #FLAG_FILTER_TYPE_ONGOING},
+ * {@link #FLAG_FILTER_TYPE_CONVERSATIONS}, {@link #FLAG_FILTER_TYPE_ALERTING),
+ * and {@link #FLAG_FILTER_TYPE_SILENT}.
+ * <p>This value will only be read if the app has not previously specified a default type list,
+ * and if the user has not overridden the allowed types.</p>
+ * <p>An absent value means 'allow all types'.
+ * A present but empty value means 'allow no types'.</p>
+ *
+ */
+ public static final String META_DATA_DEFAULT_FILTER_TYPES
+ = "android.service.notification.default_filter_types";
+
+ /**
* {@link #getCurrentInterruptionFilter() Interruption filter} constant -
* Normal interruption filter.
*/
@@ -254,23 +273,19 @@ public abstract class NotificationListenerService extends Service {
/**
* A flag value indicating that this notification listener can see conversation type
* notifications.
- * @hide
*/
public static final int FLAG_FILTER_TYPE_CONVERSATIONS = 1;
/**
* A flag value indicating that this notification listener can see altering type notifications.
- * @hide
*/
public static final int FLAG_FILTER_TYPE_ALERTING = 2;
/**
* A flag value indicating that this notification listener can see silent type notifications.
- * @hide
*/
public static final int FLAG_FILTER_TYPE_SILENT = 4;
/**
* A flag value indicating that this notification listener can see important
* ( > {@link NotificationManager#IMPORTANCE_MIN}) ongoing type notifications.
- * @hide
*/
public static final int FLAG_FILTER_TYPE_ONGOING = 8;