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

Commit d0e3e96d authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Redact some content of AOD RON notifs in logs

This replaces some of the more egregiously revealing pieces of content
(title, text, image URLs as best I could, etc.) in
PromotedNotificationContentModel with redacted versions in the
PromotedNotificationLog, so we aren't literally sticking chat messages
in bugreports.

Bug: 402929218
Flag: com.android.systemui.aod_ui_rich_ongoing
Test: manual
Change-Id: I435f4bc4df668e1e223dd8ee0563160592ed0ef7
parent a0ee889c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ constructor(@PromotedNotificationLog private val buffer: LogBuffer) {
            INFO,
            {
                str1 = entry.logKey
                str2 = content.toString()
                str2 = content.toRedactedString()
            },
            { "extraction succeeded: $str2 for $str1" },
        )
+50 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import androidx.annotation.ColorInt
import com.android.internal.widget.NotificationProgressModel
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
import com.android.systemui.statusbar.notification.row.ImageResult
import com.android.systemui.statusbar.notification.row.LazyImage
import com.android.systemui.statusbar.notification.row.shared.ImageModel

/**
@@ -152,6 +154,54 @@ data class PromotedNotificationContentModel(
        Ineligible,
    }

    fun toRedactedString(): String {
        return ("PromotedNotificationContentModel(" +
            "identity=$identity, " +
            "wasPromotedAutomatically=$wasPromotedAutomatically, " +
            "smallIcon=${smallIcon?.toRedactedString()}, " +
            "appName=$appName, " +
            "subText=${subText?.toRedactedString()}, " +
            "shortCriticalText=$shortCriticalText, " +
            "time=$time, " +
            "lastAudiblyAlertedMs=$lastAudiblyAlertedMs, " +
            "profileBadgeResId=$profileBadgeResId, " +
            "title=${title?.toRedactedString()}, " +
            "text=${text?.toRedactedString()}, " +
            "skeletonLargeIcon=${skeletonLargeIcon?.toRedactedString()}, " +
            "oldProgress=$oldProgress, " +
            "colors=$colors, " +
            "style=$style, " +
            "personIcon=${personIcon?.toRedactedString()}, " +
            "personName=${personName?.toRedactedString()}, " +
            "verificationIcon=$verificationIcon, " +
            "verificationText=$verificationText, " +
            "newProgress=$newProgress)")
    }

    private fun CharSequence.toRedactedString(): String = "[$length]"

    private fun ImageModel.toRedactedString(): String {
        return when (this) {
            is LazyImage -> this.toRedactedString()
            else -> this.toString()
        }
    }

    private fun LazyImage.toRedactedString(): String {
        return ("LazyImage(" +
            "icon=[${icon.javaClass.simpleName}], " +
            "sizeClass=$sizeClass, " +
            "transform=$transform, " +
            "result=${result?.toRedactedString()})")
    }

    private fun ImageResult.toRedactedString(): String {
        return when (this) {
            is ImageResult.Empty -> this.toString()
            is ImageResult.Image -> "Image(drawable=[${drawable.javaClass.simpleName}])"
        }
    }

    companion object {
        @JvmStatic
        fun featureFlagEnabled(): Boolean =