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

Commit 61c9b1f8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove launched flags for AudioAttributes validation." into main

parents 235f6faf 585ee98e
Loading
Loading
Loading
Loading
+0 −21
Original line number Original line Diff line number Diff line
@@ -192,27 +192,6 @@ flag {
  bug: "330193582"
  bug: "330193582"
}
}


flag {
  name: "restrict_audio_attributes_call"
  namespace: "systemui"
  description: "Only CallStyle notifs can use USAGE_NOTIFICATION_RINGTONE"
  bug: "331793339"
}

flag {
  name: "restrict_audio_attributes_alarm"
  namespace: "systemui"
  description: "Only alarm category notifs can use USAGE_ALARM"
  bug: "331793339"
}

flag {
  name: "restrict_audio_attributes_media"
  namespace: "systemui"
  description: "No notifs can use USAGE_UNKNOWN or USAGE_MEDIA"
  bug: "331793339"
}

flag {
flag {
  name: "clean_up_spans_and_new_lines"
  name: "clean_up_spans_and_new_lines"
  namespace: "systemui"
  namespace: "systemui"
+0 −2
Original line number Original line Diff line number Diff line
@@ -704,8 +704,6 @@ public class NotificationChannelTest {
    }
    }


    @Test
    @Test
    @EnableFlags({Flags.FLAG_RESTRICT_AUDIO_ATTRIBUTES_MEDIA,
            Flags.FLAG_RESTRICT_AUDIO_ATTRIBUTES_CALL, Flags.FLAG_RESTRICT_AUDIO_ATTRIBUTES_ALARM})
    public void testCopy() {
    public void testCopy() {
        NotificationChannel original = new NotificationChannel("id", "name", 2);
        NotificationChannel original = new NotificationChannel("id", "name", 2);
        original.setDescription("desc");
        original.setDescription("desc");
+28 −37
Original line number Original line Diff line number Diff line
@@ -15,9 +15,6 @@
*/
*/
package com.android.server.notification;
package com.android.server.notification;


import static android.app.Flags.restrictAudioAttributesAlarm;
import static android.app.Flags.restrictAudioAttributesCall;
import static android.app.Flags.restrictAudioAttributesMedia;
import static android.app.Notification.CATEGORY_ALARM;
import static android.app.Notification.CATEGORY_ALARM;
import static android.media.AudioAttributes.USAGE_NOTIFICATION;
import static android.media.AudioAttributes.USAGE_NOTIFICATION;


@@ -76,8 +73,6 @@ public class NotificationChannelExtractor implements NotificationSignalExtractor
                record.getSbn().getShortcutId(), true, false);
                record.getSbn().getShortcutId(), true, false);
        record.updateNotificationChannel(updatedChannel);
        record.updateNotificationChannel(updatedChannel);


        if (restrictAudioAttributesCall() || restrictAudioAttributesAlarm()
                || restrictAudioAttributesMedia()) {
        AudioAttributes attributes = record.getChannel().getAudioAttributes();
        AudioAttributes attributes = record.getChannel().getAudioAttributes();
        if (attributes == null) {
        if (attributes == null) {
            if (DBG) Slog.d(TAG, "missing AudioAttributes");
            if (DBG) Slog.d(TAG, "missing AudioAttributes");
@@ -85,20 +80,17 @@ public class NotificationChannelExtractor implements NotificationSignalExtractor
        }
        }


        boolean updateAttributes =  false;
        boolean updateAttributes =  false;
            if (restrictAudioAttributesCall()
        if (!record.getNotification().isStyle(Notification.CallStyle.class)
                    && !record.getNotification().isStyle(Notification.CallStyle.class)
                && attributes.getUsage() == AudioAttributes.USAGE_NOTIFICATION_RINGTONE) {
                && attributes.getUsage() == AudioAttributes.USAGE_NOTIFICATION_RINGTONE) {
            updateAttributes = true;
            updateAttributes = true;
        }
        }
            if (restrictAudioAttributesAlarm()
        if (!CATEGORY_ALARM.equals(record.getNotification().category)
                    && !CATEGORY_ALARM.equals(record.getNotification().category)
               && attributes.getUsage() == AudioAttributes.USAGE_ALARM) {
               && attributes.getUsage() == AudioAttributes.USAGE_ALARM) {
            updateAttributes = true;
            updateAttributes = true;
        }
        }


            if (restrictAudioAttributesMedia()
        if (attributes.getUsage() == AudioAttributes.USAGE_UNKNOWN
                    && (attributes.getUsage() == AudioAttributes.USAGE_UNKNOWN
                || attributes.getUsage() == AudioAttributes.USAGE_MEDIA) {
                    || attributes.getUsage() == AudioAttributes.USAGE_MEDIA)) {
            updateAttributes = true;
            updateAttributes = true;
        }
        }


@@ -110,7 +102,6 @@ public class NotificationChannelExtractor implements NotificationSignalExtractor
                     .build());
                     .build());
            record.updateNotificationChannel(clone);
            record.updateNotificationChannel(clone);
        }
        }
        }


        return null;
        return null;
    }
    }
+4 −10
Original line number Original line Diff line number Diff line
@@ -15,9 +15,6 @@
 */
 */
package com.android.server.notification;
package com.android.server.notification;


import static android.app.Flags.restrictAudioAttributesAlarm;
import static android.app.Flags.restrictAudioAttributesCall;
import static android.app.Flags.restrictAudioAttributesMedia;
import static android.app.Flags.sortSectionByTime;
import static android.app.Flags.sortSectionByTime;
import static android.app.NotificationChannel.USER_LOCKED_IMPORTANCE;
import static android.app.NotificationChannel.USER_LOCKED_IMPORTANCE;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
@@ -1245,8 +1242,6 @@ public final class NotificationRecord {
            calculateImportance();
            calculateImportance();
            calculateUserSentiment();
            calculateUserSentiment();
            mVibration = calculateVibration();
            mVibration = calculateVibration();
            if (restrictAudioAttributesCall() || restrictAudioAttributesAlarm()
                    || restrictAudioAttributesMedia()) {
            if (channel.getAudioAttributes() != null) {
            if (channel.getAudioAttributes() != null) {
                mAttributes = channel.getAudioAttributes();
                mAttributes = channel.getAudioAttributes();
            } else {
            } else {
@@ -1254,7 +1249,6 @@ public final class NotificationRecord {
            }
            }
        }
        }
    }
    }
    }


    public void setShowBadge(boolean showBadge) {
    public void setShowBadge(boolean showBadge) {
        mShowBadge = showBadge;
        mShowBadge = showBadge;
+1 −7
Original line number Original line Diff line number Diff line
@@ -15,9 +15,6 @@
 */
 */
package com.android.server.notification;
package com.android.server.notification;


import static android.app.Flags.restrictAudioAttributesAlarm;
import static android.app.Flags.restrictAudioAttributesCall;
import static android.app.Flags.restrictAudioAttributesMedia;
import static android.app.Flags.sortSectionByTime;
import static android.app.Flags.sortSectionByTime;
import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.app.NotificationManager.IMPORTANCE_MIN;
import static android.text.TextUtils.formatSimple;
import static android.text.TextUtils.formatSimple;
@@ -80,10 +77,7 @@ public class RankingHelper {
                extractor.setConfig(config);
                extractor.setConfig(config);
                extractor.setZenHelper(zenHelper);
                extractor.setZenHelper(zenHelper);
                extractor.setGroupHelper(groupHelper);
                extractor.setGroupHelper(groupHelper);
                if (restrictAudioAttributesAlarm() || restrictAudioAttributesMedia()
                        || restrictAudioAttributesCall()) {
                extractor.setCompatChangeLogger(platformCompat);
                extractor.setCompatChangeLogger(platformCompat);
                }
                mSignalExtractors[i] = extractor;
                mSignalExtractors[i] = extractor;
            } catch (ClassNotFoundException e) {
            } catch (ClassNotFoundException e) {
                Slog.w(TAG, "Couldn't find extractor " + extractorNames[i] + ".", e);
                Slog.w(TAG, "Couldn't find extractor " + extractorNames[i] + ".", e);
Loading