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

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

Merge "Add a setting for hiding silent status icons"

parents ffcf6e54 12ad7ca7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -5811,6 +5811,7 @@ package android.app {
    method public final void setInterruptionFilter(int);
    method public void setNotificationDelegate(@NonNull String);
    method public void setNotificationPolicy(@NonNull android.app.NotificationManager.Policy);
    method public boolean shouldHideSilentStatusBarIcons();
    method public boolean updateAutomaticZenRule(String, android.app.AutomaticZenRule);
    field public static final String ACTION_APP_BLOCK_STATE_CHANGED = "android.app.action.APP_BLOCK_STATE_CHANGED";
    field public static final String ACTION_AUTOMATIC_ZEN_RULE = "android.app.action.AUTOMATIC_ZEN_RULE";
@@ -41555,6 +41556,7 @@ package android.service.notification {
    method public void onNotificationRemoved(android.service.notification.StatusBarNotification);
    method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap);
    method public void onNotificationRemoved(android.service.notification.StatusBarNotification, android.service.notification.NotificationListenerService.RankingMap, int);
    method public void onStatusBarIconsBehaviorChanged(boolean);
    method public final void requestInterruptionFilter(int);
    method public final void requestListenerHints(int);
    method public static void requestRebind(android.content.ComponentName);
+3 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@ interface INotificationManager
    boolean areNotificationsEnabled(String pkg);
    int getPackageImportance(String pkg);

    boolean shouldHideSilentStatusIcons(String callingPkg);
    void setHideSilentStatusIcons(boolean hide);

    void setBubblesAllowed(String pkg, int uid, boolean allowed);
    boolean areBubblesAllowed(String pkg);
    boolean areBubblesAllowedForPackage(String pkg, int uid);
+19 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
@@ -353,7 +354,8 @@ public class NotificationManager {
    public static final int IMPORTANCE_MIN = 1;

    /**
     * Low notification importance: shows everywhere, but is not intrusive.
     * Low notification importance: Shows in the shade, and potentially in the status bar
     * (see {@link #shouldHideSilentStatusBarIcons()}), but is not audibly intrusive.
     */
    public static final int IMPORTANCE_LOW = 2;

@@ -1162,6 +1164,22 @@ public class NotificationManager {
        }
    }

    /**
     * Returns whether the user wants silent notifications (see {@link #IMPORTANCE_LOW} to appear
     * in the status bar.
     *
     * <p>Only available for {@link #isNotificationListenerAccessGranted(ComponentName) notification
     * listeners}.
     */
    public boolean shouldHideSilentStatusBarIcons() {
        INotificationManager service = getService();
        try {
            return service.shouldHideSilentStatusIcons(mContext.getOpPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** @hide */
    public boolean isNotificationPolicyAccessGrantedForPackage(String pkg) {
        INotificationManager service = getService();
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ oneway interface INotificationListener
    void onListenerConnected(in NotificationRankingUpdate update);
    void onNotificationPosted(in IStatusBarNotificationHolder notificationHolder,
            in NotificationRankingUpdate update);
    void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons);
    // stats only for assistant
    void onNotificationRemoved(in IStatusBarNotificationHolder notificationHolder,
            in NotificationRankingUpdate update, in NotificationStats stats, int reason);
+22 −0
Original line number Diff line number Diff line
@@ -468,6 +468,17 @@ public abstract class NotificationListenerService extends Service {
        // optional
    }

    /**
     * Implement this method to be notified when the behavior of silent notifications in the status
     * bar changes. See {@link NotificationManager#shouldHideSilentStatusBarIcons()}.
     *
     * @param hideSilentStatusIcons whether or not status bar icons should be hidden for silent
     *                              notifications
     */
    public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) {
        // optional
    }

    /**
     * Implement this method to learn about notification channel modifications.
     *
@@ -1411,6 +1422,12 @@ public abstract class NotificationListenerService extends Service {
            mHandler.obtainMessage(
                    MyHandler.MSG_ON_NOTIFICATION_CHANNEL_GROUP_MODIFIED, args).sendToTarget();
        }

        @Override
        public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) {
            mHandler.obtainMessage(MyHandler.MSG_ON_STATUS_BAR_ICON_BEHAVIOR_CHANGED,
                    hideSilentStatusIcons).sendToTarget();
        }
    }

    /**
@@ -2142,6 +2159,7 @@ public abstract class NotificationListenerService extends Service {
        public static final int MSG_ON_INTERRUPTION_FILTER_CHANGED = 6;
        public static final int MSG_ON_NOTIFICATION_CHANNEL_MODIFIED = 7;
        public static final int MSG_ON_NOTIFICATION_CHANNEL_GROUP_MODIFIED = 8;
        public static final int MSG_ON_STATUS_BAR_ICON_BEHAVIOR_CHANGED = 9;

        public MyHandler(Looper looper) {
            super(looper, null, false);
@@ -2207,6 +2225,10 @@ public abstract class NotificationListenerService extends Service {
                    int modificationType = (int) args.arg4;
                    onNotificationChannelGroupModified(pkgName, user, group, modificationType);
                } break;

                case MSG_ON_STATUS_BAR_ICON_BEHAVIOR_CHANGED: {
                    onStatusBarIconsBehaviorChanged((Boolean) msg.obj);
                } break;
            }
        }
    }
Loading