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

Commit 1587f28c authored by Nate Myren's avatar Nate Myren
Browse files

Redact BigTextStyle fields in notifications if needed

Fixes: 335488909
Test: atest SensitiveNotificationRedactionTest
Flag: android.service.notification.redact_sensitive_notifications_big_text_style
Change-Id: Ic09f1f66e6b1f0927b0d241b327766f7991ae6db
parent 57ad21ba
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;
@@ -11916,6 +11917,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