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

Commit eb1c80aa authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge "[SB][Notif] For auto-promoted notifs, allow fake shortCriticalText." into main

parents f3623f79 8839de51
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -30,6 +30,14 @@ interface AutomaticPromotionCoordinator : Coordinator {
         * (but not normally promoted notifications).
         */
        const val EXTRA_WAS_AUTOMATICALLY_PROMOTED = "android.wasAutomaticallyPromoted"

        /**
         * An extra set only on automatically promoted notifications that contains text that could
         * reasonably be the short critical text. For now, we're only extracting arrival times. Will
         * be set as a String.
         */
        const val EXTRA_AUTOMATICALLY_EXTRACTED_SHORT_CRITICAL_TEXT =
            "android.automaticallyExtractedShortCriticalText"
    }
}

+9 −1
Original line number Diff line number Diff line
@@ -26,9 +26,11 @@ import android.app.Notification.EXTRA_TEXT
import android.app.Notification.EXTRA_TITLE
import android.app.Notification.ProgressStyle
import android.content.Context
import com.android.systemui.Flags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.promoted.AutomaticPromotionCoordinator.Companion.EXTRA_AUTOMATICALLY_EXTRACTED_SHORT_CRITICAL_TEXT
import com.android.systemui.statusbar.notification.promoted.AutomaticPromotionCoordinator.Companion.EXTRA_WAS_AUTOMATICALLY_PROMOTED
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel.Companion.isPromotedForStatusBarChip
@@ -113,8 +115,14 @@ private fun Notification.shortCriticalText(): String? {
    if (!android.app.Flags.apiRichOngoing()) {
        return null
    }
    if (this.shortCriticalText != null) {
        return this.shortCriticalText
    }
    if (Flags.promoteNotificationsAutomatically()) {
        return this.extras?.getString(EXTRA_AUTOMATICALLY_EXTRACTED_SHORT_CRITICAL_TEXT)
    }
    return null
}

private fun Notification.chronometerCountDown(): Boolean =
    extras?.getBoolean(EXTRA_CHRONOMETER_COUNT_DOWN, /* defaultValue= */ false) ?: false