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

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

Merge "Cannot have badge only channels"

parents 82e955fc aebfc4e7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -5393,7 +5393,6 @@ package android.app {
    method public android.net.Uri getSound();
    method public long[] getVibrationPattern();
    method public boolean isAllowed();
    method public void setAllowed(boolean);
    method public void setBypassDnd(boolean);
    method public void setImportance(int);
    method public void setLights(boolean);
+0 −1
Original line number Diff line number Diff line
@@ -5555,7 +5555,6 @@ package android.app {
    method public boolean isAllowed();
    method public void lockFields(int);
    method public void populateFromXml(org.xmlpull.v1.XmlPullParser);
    method public void setAllowed(boolean);
    method public void setBypassDnd(boolean);
    method public void setImportance(int);
    method public void setLights(boolean);
+0 −1
Original line number Diff line number Diff line
@@ -5403,7 +5403,6 @@ package android.app {
    method public android.net.Uri getSound();
    method public long[] getVibrationPattern();
    method public boolean isAllowed();
    method public void setAllowed(boolean);
    method public void setBypassDnd(boolean);
    method public void setImportance(int);
    method public void setLights(boolean);
+0 −19
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ public final class NotificationChannel implements Parcelable {
    private static final String ATT_AUDIO_ATTRIBUTES = "audio_attributes";
    private static final String ATT_SHOW_BADGE = "show_badge";
    private static final String ATT_USER_LOCKED = "locked";
    private static final String ATT_ALLOWED = "allowed";
    private static final String DELIMITER = ",";

    /**
@@ -243,18 +242,6 @@ public final class NotificationChannel implements Parcelable {
        this.mImportance = importance;
    }

    /**
     * Sets whether notifications are allowed to be posted to this channel.
     *
     * Only modifiable by the system and notification ranker.
     *
     * @param allowed true if notifications are not allowed from this channel.
     */
    public void setAllowed(boolean allowed) {
        this.mAllowed = allowed;
    }


    // Modifiable by apps on channel creation.

    /**
@@ -406,7 +393,6 @@ public final class NotificationChannel implements Parcelable {
        enableVibration(safeBool(parser, ATT_VIBRATION_ENABLED, false));
        setVibrationPattern(safeLongArray(parser, ATT_VIBRATION, null));
        setShowBadge(safeBool(parser, ATT_SHOW_BADGE, false));
        setAllowed(safeBool(parser, ATT_ALLOWED, true));
        lockFields(safeInt(parser, ATT_USER_LOCKED, 0));
    }

@@ -448,9 +434,6 @@ public final class NotificationChannel implements Parcelable {
        if (canShowBadge()) {
            out.attribute(null, ATT_SHOW_BADGE, Boolean.toString(canShowBadge()));
        }
        if (!isAllowed()) {
            out.attribute(null, ATT_ALLOWED, Boolean.toString(isAllowed()));
        }

        out.endTag(null, TAG_CHANNEL);
    }
@@ -481,8 +464,6 @@ public final class NotificationChannel implements Parcelable {
        record.put(ATT_USER_LOCKED, Integer.toString(getUserLockedFields()));
        record.put(ATT_VIBRATION, longArrayToString(getVibrationPattern()));
        record.put(ATT_SHOW_BADGE, Boolean.toString(canShowBadge()));
        record.put(ATT_ALLOWED, Boolean.toString(isAllowed()));

        return record;
    }

+3 −3
Original line number Diff line number Diff line
@@ -1552,7 +1552,7 @@ public class NotificationManagerService extends SystemService {
        public void updateNotificationChannelForPackage(String pkg, int uid,
                NotificationChannel channel) {
            enforceSystemOrSystemUI("Caller not system or systemui");
            if (!channel.isAllowed()) {
            if (channel.getImportance() == NotificationManager.IMPORTANCE_NONE) {
                // cancel
                cancelAllNotificationsInt(MY_UID, MY_PID, pkg, channel.getId(), 0, 0, true,
                        UserHandle.getUserId(Binder.getCallingUid()), REASON_CHANNEL_BANNED,
@@ -2441,7 +2441,7 @@ public class NotificationManagerService extends SystemService {
        public void updateNotificationChannelFromAssistant(INotificationListener token, String pkg,
                NotificationChannel channel) throws RemoteException {
            ManagedServiceInfo info = mNotificationAssistants.checkServiceTokenLocked(token);
            if (!channel.isAllowed()) {
            if (channel.getImportance() == NotificationManager.IMPORTANCE_NONE) {
                // cancel
                cancelAllNotificationsInt(MY_UID, MY_PID, pkg, channel.getId(), 0, 0, true,
                        info.userid, REASON_CHANNEL_BANNED, null);
@@ -2985,7 +2985,7 @@ public class NotificationManagerService extends SystemService {
            }

            final boolean isBlocked = r.getImportance() == NotificationManager.IMPORTANCE_NONE
                    || !r.getChannel().isAllowed()
                    || r.getChannel().getImportance() == NotificationManager.IMPORTANCE_NONE
                    || !noteNotificationOp(pkg, callingUid);
            if (isBlocked) {
                Slog.e(TAG, "Suppressing notification from package by user request.");
Loading