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

Commit ff06288d authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Expose NotificationManager#getBubblePreference"

parents 6facc82f e19b76e8
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -6023,7 +6023,7 @@ package android.app {
  public class NotificationManager {
    method public String addAutomaticZenRule(android.app.AutomaticZenRule);
    method public boolean areBubblesAllowed();
    method @Deprecated public boolean areBubblesAllowed();
    method public boolean areNotificationsEnabled();
    method public boolean areNotificationsPaused();
    method public boolean canNotifyAsPackage(@NonNull String);
@@ -6040,6 +6040,7 @@ package android.app {
    method public android.service.notification.StatusBarNotification[] getActiveNotifications();
    method public android.app.AutomaticZenRule getAutomaticZenRule(String);
    method public java.util.Map<java.lang.String,android.app.AutomaticZenRule> getAutomaticZenRules();
    method public int getBubblePreference();
    method @NonNull public android.app.NotificationManager.Policy getConsolidatedNotificationPolicy();
    method public final int getCurrentInterruptionFilter();
    method public int getImportance();
@@ -6074,6 +6075,9 @@ package android.app {
    field public static final int AUTOMATIC_RULE_STATUS_ENABLED = 1; // 0x1
    field public static final int AUTOMATIC_RULE_STATUS_REMOVED = 3; // 0x3
    field public static final int AUTOMATIC_RULE_STATUS_UNKNOWN = -1; // 0xffffffff
    field public static final int BUBBLE_PREFERENCE_ALL = 1; // 0x1
    field public static final int BUBBLE_PREFERENCE_NONE = 0; // 0x0
    field public static final int BUBBLE_PREFERENCE_SELECTED = 2; // 0x2
    field public static final String EXTRA_AUTOMATIC_RULE_ID = "android.app.extra.AUTOMATIC_RULE_ID";
    field public static final String EXTRA_AUTOMATIC_ZEN_RULE_ID = "android.app.extra.AUTOMATIC_ZEN_RULE_ID";
    field public static final String EXTRA_AUTOMATIC_ZEN_RULE_STATUS = "android.app.extra.AUTOMATIC_ZEN_RULE_STATUS";
+43 −4
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.content.pm.ParceledListSlice;
import android.content.pm.ShortcutInfo;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -532,15 +533,23 @@ public class NotificationManager {
    public static final int IMPORTANCE_MAX = 5;

    /**
     * @hide
     * Indicates that the no bubbles are allowed from the app. If the app sends bubbles, only the
     * notification will appear. The notification will have an affordance allowing the user to
     * bubble it. If the user selects this affordance, that notification is approved to bubble
     * and the apps' bubble preference will be upgraded to {@link #BUBBLE_PREFERENCE_SELECTED}.
     */
    public static final int BUBBLE_PREFERENCE_NONE = 0;

    /**
     * @hide
     * Indicates that all bubbles are allowed from the app. If the app sends bubbles, the bubble
     * will appear along with the notification.
     */
    public static final int BUBBLE_PREFERENCE_ALL = 1;

    /**
     * @hide
     * Indicates that only notifications selected by the user will appear as bubbles. If
     * the app sends bubbles that haven't been selected, only the notification appear. If the
     * bubble has been approved by the user, it will appear along with the notification.
     */
    public static final int BUBBLE_PREFERENCE_SELECTED = 2;

@@ -1323,10 +1332,12 @@ public class NotificationManager {
     * notification shade, floating over other apps' content.
     *
     * <p>This value will be ignored for notifications that are posted to channels that do not
     * allow bubbles ({@link NotificationChannel#canBubble()}.
     * allow bubbles ({@link NotificationChannel#canBubble()}).
     *
     * @see Notification#getBubbleMetadata()
     * @deprecated use {@link #getBubblePreference()} instead.
     */
    @Deprecated
    public boolean areBubblesAllowed() {
        INotificationManager service = getService();
        try {
@@ -1336,6 +1347,34 @@ public class NotificationManager {
        }
    }

    /**
     * Gets the bubble preference for the app. This preference only applies to notifications that
     * have been properly configured to bubble.
     *
     * <p>
     * If {@link #BUBBLE_PREFERENCE_ALL}, then any bubble notification will appear as a bubble, as
     * long as the user hasn't excluded it ({@link NotificationChannel#canBubble()}).
     *
     * <p>
     * If {@link #BUBBLE_PREFERENCE_SELECTED}, then any bubble notification will appear as a bubble,
     * as long as the user has selected it.
     *
     * <p>
     * If {@link #BUBBLE_PREFERENCE_NONE}, then no notification may appear as a bubble from the app.
     *
     * @see Notification#getBubbleMetadata()
     * @return the users' bubble preference for the app.
     */
    public int getBubblePreference() {
        INotificationManager service = getService();
        try {
            return service.getBubblePreferenceForPackage(mContext.getPackageName(),
                    Binder.getCallingUid());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Silences the current notification sound, if ones currently playing.
     * <p>
+1 −1
Original line number Diff line number Diff line
@@ -1848,7 +1848,7 @@ public final class Settings {
    /**
     * Activity Action: Show notification bubble settings for a single app.
     * See {@link NotificationManager#areBubblesAllowed()}.
     * See {@link NotificationManager#getBubblePreference()}.
     * <p>
     *     Input: {@link #EXTRA_APP_PACKAGE}, the package to display.
     * <p>