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

Commit 7430d8d8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Notify apps when channels/groups are blocked/unblocked"

parents 83770069 3eb3ffd9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -5617,6 +5617,7 @@ package android.app {
    method public final int getCurrentInterruptionFilter();
    method public int getImportance();
    method public android.app.NotificationChannel getNotificationChannel(java.lang.String);
    method public android.app.NotificationChannelGroup getNotificationChannelGroup(java.lang.String);
    method public java.util.List<android.app.NotificationChannelGroup> getNotificationChannelGroups();
    method public java.util.List<android.app.NotificationChannel> getNotificationChannels();
    method public android.app.NotificationManager.Policy getNotificationPolicy();
@@ -5629,8 +5630,12 @@ package android.app {
    method public void setNotificationPolicy(android.app.NotificationManager.Policy);
    method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
    field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED = "android.app.action.NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED = "android.app.action.NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED";
    field public static final java.lang.String EXTRA_BLOCKED_STATE = "android.app.extra.BLOCKED_STATE";
    field public static final java.lang.String EXTRA_BLOCK_STATE_CHANGED_ID = "android.app.extra.BLOCK_STATE_CHANGED_ID";
    field public static final int IMPORTANCE_DEFAULT = 3; // 0x3
    field public static final int IMPORTANCE_HIGH = 4; // 0x4
    field public static final int IMPORTANCE_LOW = 2; // 0x2
+5 −0
Original line number Diff line number Diff line
@@ -5826,6 +5826,7 @@ package android.app {
    method public final int getCurrentInterruptionFilter();
    method public int getImportance();
    method public android.app.NotificationChannel getNotificationChannel(java.lang.String);
    method public android.app.NotificationChannelGroup getNotificationChannelGroup(java.lang.String);
    method public java.util.List<android.app.NotificationChannelGroup> getNotificationChannelGroups();
    method public java.util.List<android.app.NotificationChannel> getNotificationChannels();
    method public android.app.NotificationManager.Policy getNotificationPolicy();
@@ -5838,8 +5839,12 @@ package android.app {
    method public void setNotificationPolicy(android.app.NotificationManager.Policy);
    method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
    field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED = "android.app.action.NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED = "android.app.action.NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED";
    field public static final java.lang.String EXTRA_BLOCKED_STATE = "android.app.extra.BLOCKED_STATE";
    field public static final java.lang.String EXTRA_BLOCK_STATE_CHANGED_ID = "android.app.extra.BLOCK_STATE_CHANGED_ID";
    field public static final int IMPORTANCE_DEFAULT = 3; // 0x3
    field public static final int IMPORTANCE_HIGH = 4; // 0x4
    field public static final int IMPORTANCE_LOW = 2; // 0x2
+5 −0
Original line number Diff line number Diff line
@@ -5648,6 +5648,7 @@ package android.app {
    method public android.content.ComponentName getEffectsSuppressor();
    method public int getImportance();
    method public android.app.NotificationChannel getNotificationChannel(java.lang.String);
    method public android.app.NotificationChannelGroup getNotificationChannelGroup(java.lang.String);
    method public java.util.List<android.app.NotificationChannelGroup> getNotificationChannelGroups();
    method public java.util.List<android.app.NotificationChannel> getNotificationChannels();
    method public android.app.NotificationManager.Policy getNotificationPolicy();
@@ -5660,8 +5661,12 @@ package android.app {
    method public void setNotificationPolicy(android.app.NotificationManager.Policy);
    method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
    field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED = "android.app.action.NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED = "android.app.action.NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
    field public static final java.lang.String ACTION_NOTIFICATION_POLICY_CHANGED = "android.app.action.NOTIFICATION_POLICY_CHANGED";
    field public static final java.lang.String EXTRA_BLOCKED_STATE = "android.app.extra.BLOCKED_STATE";
    field public static final java.lang.String EXTRA_BLOCK_STATE_CHANGED_ID = "android.app.extra.BLOCK_STATE_CHANGED_ID";
    field public static final int IMPORTANCE_DEFAULT = 3; // 0x3
    field public static final int IMPORTANCE_HIGH = 4; // 0x4
    field public static final int IMPORTANCE_LOW = 2; // 0x2
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ interface INotificationManager
    int getNumNotificationChannelsForPackage(String pkg, int uid, boolean includeDeleted);
    int getDeletedChannelCount(String pkg, int uid);
    void deleteNotificationChannelGroup(String pkg, String channelGroupId);
    NotificationChannelGroup getNotificationChannelGroup(String pkg, String channelGroupId);
    ParceledListSlice getNotificationChannelGroups(String pkg);
    boolean onlyHasDefaultChannel(String pkg, int uid);

+66 −0
Original line number Diff line number Diff line
@@ -92,6 +92,58 @@ public class NotificationManager {
    private static String TAG = "NotificationManager";
    private static boolean localLOGV = false;

    /**
     * Intent that is broadcast when a {@link NotificationChannel} is blocked
     * (when {@link NotificationChannel#getImportance()} is {@link #IMPORTANCE_NONE}) or unblocked
     * (when {@link NotificationChannel#getImportance()} is anything other than
     * {@link #IMPORTANCE_NONE}).
     *
     * This broadcast is only sent to the app that owns the channel that has changed.
     *
     * Input: nothing
     * Output: {@link #EXTRA_BLOCK_STATE_CHANGED_ID}
     */
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED =
            "android.app.action.NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED";

    /**
     * Extra for {@link #ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED} or
     * {@link #ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED} containing the id of the
     * object which has a new blocked state.
     *
     * The value will be the {@link NotificationChannel#getId()} of the channel for
     * {@link #ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED} and
     * the {@link NotificationChannelGroup#getId()} of the group for
     * {@link #ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED}.
     */
    public static final String EXTRA_BLOCK_STATE_CHANGED_ID =
            "android.app.extra.BLOCK_STATE_CHANGED_ID";

    /**
     * Extra for {@link #ACTION_NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED} or
     * {@link #ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED} containing the new blocked
     * state as a boolean.
     *
     * The value will be {@code true} if this channel or group is now blocked and {@code false} if
     * this channel or group is now unblocked.
     */
    public static final String EXTRA_BLOCKED_STATE = "android.app.extra.BLOCKED_STATE";


    /**
     * Intent that is broadcast when a {@link NotificationChannelGroup} is
     * {@link NotificationChannelGroup#isBlocked() blocked} or unblocked.
     *
     * This broadcast is only sent to the app that owns the channel group that has changed.
     *
     * Input: nothing
     * Output: {@link #EXTRA_BLOCK_STATE_CHANGED_ID}
     */
    @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED =
            "android.app.action.NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED";

    /**
     * Intent that is broadcast when the state of {@link #getEffectsSuppressor()} changes.
     * This broadcast is only sent to registered receivers.
@@ -503,6 +555,20 @@ public class NotificationManager {
        }
    }

    /**
     * Returns the notification channel group settings for a given channel group id.
     *
     * The channel group must belong to your package, or null will be returned.
     */
    public NotificationChannelGroup getNotificationChannelGroup(String channelGroupId) {
        INotificationManager service = getService();
        try {
            return service.getNotificationChannelGroup(mContext.getPackageName(), channelGroupId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns all notification channel groups belonging to the calling app.
     */
Loading