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

Commit 0edb50c4 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Api review: NotificationManager

Bug: 27365672
Change-Id: Ic0fd82fb9442d10d6b308182a3859497aa882d07
parent 3b848122
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.app;

import android.app.NotificationManager.InterruptionFilter;
import android.content.ComponentName;
import android.net.Uri;
import android.os.Parcel;
@@ -30,7 +31,7 @@ public class AutomaticZenRule implements Parcelable {

    private boolean enabled = false;
    private String name;
    private int interruptionFilter;
    private @InterruptionFilter int interruptionFilter;
    private Uri conditionId;
    private ComponentName owner;
    private String id;
@@ -140,9 +141,9 @@ public class AutomaticZenRule implements Parcelable {

    /**
     * Sets the interruption filter that is applied when this rule is active.
     * @param interruptionFilter One of the INTERRUPTION_FILTER_ constants in NotificationManager.
     * @param interruptionFilter The do not disturb mode to enter when this rule is active.
     */
    public void setInterruptionFilter(int interruptionFilter) {
    public void setInterruptionFilter(@InterruptionFilter int interruptionFilter) {
        this.interruptionFilter = interruptionFilter;
    }

+18 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app;

import com.android.internal.util.Preconditions;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
@@ -45,6 +46,8 @@ import android.service.notification.ZenModeConfig;
import android.util.ArraySet;
import android.util.Log;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
import java.util.List;

@@ -138,6 +141,13 @@ public class NotificationManager
    public static final String ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL
            = "android.app.action.INTERRUPTION_FILTER_CHANGED_INTERNAL";


    /** @hide */
    @IntDef({INTERRUPTION_FILTER_NONE, INTERRUPTION_FILTER_PRIORITY, INTERRUPTION_FILTER_ALARMS,
            INTERRUPTION_FILTER_ALL, INTERRUPTION_FILTER_UNKNOWN})
    @Retention(RetentionPolicy.SOURCE)
    public @interface InterruptionFilter {}

    /**
     * {@link #getCurrentInterruptionFilter() Interruption filter} constant -
     *     Normal interruption filter.
@@ -507,7 +517,10 @@ public class NotificationManager
        return false;
    }

    public int getImportance() {
    /**
     * Returns the user specified importance for notifications from the calling package.
     */
    public @NotificationListenerService.Ranking.Importance int getImportance() {
        INotificationManager service = getService();
        try {
            return service.getPackageImportance(mContext.getPackageName());
@@ -516,6 +529,9 @@ public class NotificationManager
        return NotificationListenerService.Ranking.IMPORTANCE_UNSPECIFIED;
    }

    /**
     * Returns whether notifications from the calling package are blocked.
     */
    public boolean areNotificationsEnabled() {
        INotificationManager service = getService();
        try {
@@ -874,7 +890,7 @@ public class NotificationManager
     * Only available if policy access is granted to this package.
     * See {@link #isNotificationPolicyAccessGranted}.
     */
    public final int getCurrentInterruptionFilter() {
    public final @InterruptionFilter int getCurrentInterruptionFilter() {
        final INotificationManager service = getService();
        try {
            return zenModeToInterruptionFilter(service.getZenMode());
+13 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.service.notification;

import android.annotation.IntDef;
import android.annotation.SystemApi;
import android.annotation.SdkConstant;
import android.app.INotificationManager;
@@ -42,6 +43,8 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -910,6 +913,14 @@ public abstract class NotificationListenerService extends Service {
     * current {@link RankingMap}.
     */
    public static class Ranking {

        /** @hide */
        @IntDef({VISIBILITY_NO_OVERRIDE, IMPORTANCE_UNSPECIFIED, IMPORTANCE_NONE,
                IMPORTANCE_MIN, IMPORTANCE_LOW, IMPORTANCE_DEFAULT, IMPORTANCE_HIGH,
                IMPORTANCE_MAX})
        @Retention(RetentionPolicy.SOURCE)
        public @interface Importance {}

        /** Value signifying that the user has not expressed a per-app visibility override value.
         * @hide */
        public static final int VISIBILITY_NO_OVERRIDE = -1000;
@@ -960,7 +971,7 @@ public abstract class NotificationListenerService extends Service {
        private boolean mMatchesInterruptionFilter;
        private int mVisibilityOverride;
        private int mSuppressedVisualEffects;
        private int mImportance;
        private @Importance int mImportance;
        private CharSequence mImportanceExplanation;

        public Ranking() {}
@@ -1026,7 +1037,7 @@ public abstract class NotificationListenerService extends Service {
         *
         * @return the rank of the notification
         */
        public int getImportance() {
        public @Importance int getImportance() {
            return mImportance;
        }

+1 −1

File changed.

Contains only whitespace changes.