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

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

Merge "Redact some content of AOD RON notifs in logs" into main

parents 23ed72bd d0e3e96d
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 =