Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9bfd6c0f authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Add 'ongoing' filter type"

parents 11615dea cd561fc6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package android.service.notification;

import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ALERTING;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_CONVERSATIONS;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ONGOING;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_SILENT;

import android.os.Parcel;
@@ -35,7 +36,8 @@ public class NotificationListenerFilter implements Parcelable {
    public NotificationListenerFilter() {
        mAllowedNotificationTypes = FLAG_FILTER_TYPE_CONVERSATIONS
                | FLAG_FILTER_TYPE_ALERTING
                | FLAG_FILTER_TYPE_SILENT;
                | FLAG_FILTER_TYPE_SILENT
                | FLAG_FILTER_TYPE_ONGOING;
        mDisallowedPackages = new ArraySet<>();
    }

+16 −0
Original line number Diff line number Diff line
@@ -241,6 +241,16 @@ public abstract class NotificationListenerService extends Service {
    })
    public @interface NotificationCancelReason{};

    /**
     * @hide
     */
    @IntDef(flag = true, prefix = { "FLAG_FILTER_TYPE_" }, value = {
            FLAG_FILTER_TYPE_CONVERSATIONS,
            FLAG_FILTER_TYPE_ALERTING,
            FLAG_FILTER_TYPE_SILENT,
            FLAG_FILTER_TYPE_ONGOING
    })
    public @interface NotificationFilterTypes {}
    /**
     * A flag value indicating that this notification listener can see conversation type
     * notifications.
@@ -257,6 +267,12 @@ public abstract class NotificationListenerService extends Service {
     * @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;

    /**
     * The full trim of the StatusBarNotification including all its features.
+3 −2
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_SYSTEM;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ALERTING;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_CONVERSATIONS;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ONGOING;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_SILENT;
import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS;
import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_EFFECTS;
@@ -9497,7 +9498,7 @@ public class NotificationManagerService extends SystemService {

    public class NotificationListeners extends ManagedServices {
        static final String TAG_ENABLED_NOTIFICATION_LISTENERS = "enabled_listeners";
        static final String TAG_REQUESTED_LISTENERS = "requested_listeners";
        static final String TAG_REQUESTED_LISTENERS = "req_listeners";
        static final String TAG_REQUESTED_LISTENER = "listener";
        static final String ATT_COMPONENT = "component";
        static final String ATT_TYPES = "types";
@@ -9686,7 +9687,7 @@ public class NotificationManagerService extends SystemService {
                    final ComponentName cn = ComponentName.unflattenFromString(
                            XmlUtils.readStringAttribute(parser, ATT_COMPONENT));
                    int approved = FLAG_FILTER_TYPE_CONVERSATIONS | FLAG_FILTER_TYPE_ALERTING
                            | FLAG_FILTER_TYPE_SILENT;
                            | FLAG_FILTER_TYPE_SILENT | FLAG_FILTER_TYPE_ONGOING;

                    ArraySet<String> disallowedPkgs = new ArraySet<>();
                    final int listenerOuterDepth = parser.getDepth();
+5 −5
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ public class NotificationListenersTest extends UiServiceTestCase {

    @Test
    public void testReadExtraTag() throws Exception {
        String xml = "<requested_listeners>"
        String xml = "<req_listeners>"
                + "<listener component=\"" + mCn1.flattenToString() + "\" user=\"0\">"
                + "<allowed types=\"7\" />"
                + "<disallowed pkgs=\"\" />"
@@ -89,13 +89,13 @@ public class NotificationListenersTest extends UiServiceTestCase {
                + "<allowed types=\"4\" />"
                + "<disallowed pkgs=\"something\" />"
                + "</listener>"
                + "</requested_listeners>";
                + "</req_listeners>";

        TypedXmlPullParser parser = Xml.newFastPullParser();
        parser.setInput(new BufferedInputStream(
                new ByteArrayInputStream(xml.getBytes())), null);
        parser.nextTag();
        mListeners.readExtraTag("requested_listeners", parser);
        mListeners.readExtraTag("req_listeners", parser);

        validateListenersFromXml();
    }
@@ -120,7 +120,7 @@ public class NotificationListenersTest extends UiServiceTestCase {
        parser.setInput(new BufferedInputStream(
                new ByteArrayInputStream(baos.toByteArray())), null);
        parser.nextTag();
        mListeners.readExtraTag("requested_listeners", parser);
        mListeners.readExtraTag("req_listeners", parser);

        validateListenersFromXml();
    }
@@ -192,7 +192,7 @@ public class NotificationListenersTest extends UiServiceTestCase {

        assertThat(mListeners.getNotificationListenerFilter(
                Pair.create(si.getComponentName(), 0)).getTypes())
                .isEqualTo(7);
                .isEqualTo(15);
        assertThat(mListeners.getNotificationListenerFilter(Pair.create(si.getComponentName(), 0))
                .getDisallowedPackages())
                .isEmpty();