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

Commit 1c3e90e2 authored by Nate Myren's avatar Nate Myren Committed by Android (Google) Code Review
Browse files

Merge "Redact BigTextStyle fields in notifications if needed" into main

parents 0fa3534c 1587f28c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -14,7 +14,17 @@ flag {
  namespace: "systemui"
  description: "This flag controls the redacting of sensitive notifications from untrusted NotificationListenerServices"
  bug: "306271190"
}

flag {
  name: "redact_sensitive_notifications_big_text_style"
  is_exported: true
  namespace: "systemui"
  description: "This flag controls the redacting of BigTextStyle fields in sensitive notifications"
  bug: "335488909"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
+2 −4
Original line number Diff line number Diff line
@@ -6436,10 +6436,8 @@ ul.</string>
    <!-- Communal profile label on a screen. This can be used as a tab label for this profile in tabbed views and can be used to represent the profile in sharing surfaces, etc. [CHAR LIMIT=20] -->
    <string name="profile_label_communal">Communal</string>

    <!-- Notification message used when a notification's normal message contains sensitive information. -->
    <!-- TODO b/301960090: replace with redacted message string and action title, when/if UX provides one -->
    <!-- DO NOT TRANSLATE -->
    <string name="redacted_notification_message"></string>
    <!-- Notification message used when a notification's normal message contains sensitive information [CHAR_LIMIT=NOTIF_BODY] -->
    <string name="redacted_notification_message">Sensitive notification content hidden</string>
    <!-- Notification action title used instead of a notification's normal title sensitive [CHAR_LIMIT=NOTIF_BODY] -->
    <string name="redacted_notification_action_title"></string>

+9 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_SYSTEM;
import static android.service.notification.Flags.callstyleCallbackApi;
import static android.service.notification.Flags.redactSensitiveNotificationsFromUntrustedListeners;
import static android.service.notification.Flags.redactSensitiveNotificationsBigTextStyle;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ALERTING;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_CONVERSATIONS;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ONGOING;
@@ -11917,6 +11918,14 @@ public class NotificationManagerService extends SystemService {
                        redactedText, System.currentTimeMillis(), empty));
                redactedNotifBuilder.setStyle(messageStyle);
            }
            if (redactSensitiveNotificationsBigTextStyle()
                    && oldNotif.isStyle(Notification.BigTextStyle.class)) {
                Notification.BigTextStyle bigTextStyle = new Notification.BigTextStyle();
                bigTextStyle.bigText(mContext.getString(R.string.redacted_notification_message));
                bigTextStyle.setBigContentTitle("");
                bigTextStyle.setSummaryText("");
                redactedNotifBuilder.setStyle(bigTextStyle);
            }
            Notification redacted = redactedNotifBuilder.build();
            // Notification extras can't always be overridden by a builder (configured by a system