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

Commit c86d8f05 authored by Jeff DeCew's avatar Jeff DeCew Committed by Android (Google) Code Review
Browse files

Merge "[RONs] Do not use cached images when reinflating a notification." into main

parents 08328b6c a0e53b54
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ class PromotedNotificationContentExtractorImplTest : SysuiTestCase() {

    private val underTest = kosmos.promotedNotificationContentExtractor
    private val systemClock = kosmos.fakeSystemClock
    private val rowImageInflater = RowImageInflater.newInstance(previousIndex = null)
    private val rowImageInflater =
        RowImageInflater.newInstance(previousIndex = null, reinflating = false)
    private val imageModelProvider by lazy { rowImageInflater.useForContentModel() }

    @Test
+1 −2
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import com.android.systemui.statusbar.NotificationLockscreenUserManager.REDACTIO
import com.android.systemui.statusbar.NotificationLockscreenUserManager.RedactionType
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.notification.ConversationNotificationProcessor
import com.android.systemui.statusbar.notification.collection.EntryAdapter
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.promoted.FakePromotedNotificationContentExtractor
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
@@ -204,7 +203,7 @@ class NotificationRowContentBinderImplTest : SysuiTestCase() {
        val result =
            NotificationRowContentBinderImpl.InflationProgress(
                packageContext = mContext,
                rowImageInflater = RowImageInflater.newInstance(null),
                rowImageInflater = RowImageInflater.newInstance(null, reinflating = false),
                remoteViews = NewRemoteViews(),
                contentModel = NotificationContentModel(headsUpStatusBarModel),
                promotedContent = null,
+5 −2
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ import com.android.systemui.statusbar.notification.ConversationNotificationProce
import com.android.systemui.statusbar.notification.InflationException;
import com.android.systemui.statusbar.notification.NmSummarizationUiFlag;
import com.android.systemui.statusbar.notification.NotificationUtils;
import com.android.systemui.statusbar.notification.collection.EntryAdapter;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationContentExtractor;
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUiForceExpanded;
@@ -441,8 +440,12 @@ public class NotificationContentInflater implements NotificationRowContentBinder
            NotificationRowContentBinderLogger logger) {
        return TraceUtils.trace("NotificationContentInflater.createRemoteViews", () -> {
            InflationProgress result = new InflationProgress();

            // inflating the contracted view is the legacy invalidation trigger
            boolean reinflating = (reInflateFlags & FLAG_CONTENT_VIEW_CONTRACTED) != 0;
            // create an image inflater
            result.mRowImageInflater = RowImageInflater.newInstance(row.mImageModelIndex);
            result.mRowImageInflater = RowImageInflater.newInstance(row.mImageModelIndex,
                    reinflating);

            if ((reInflateFlags & FLAG_CONTENT_VIEW_CONTRACTED) != 0) {
                logger.logAsyncTaskProgress(row.getLoggingKey(), "creating contracted remote view");
+16 −18
Original line number Diff line number Diff line
@@ -499,7 +499,10 @@ constructor(
            logger.logAsyncTaskProgress(entry.logKey, "loading RON images")
            inflationProgress.rowImageInflater.loadImagesSynchronously(packageContext)

            logger.logAsyncTaskProgress(entry.logKey, "getting row image resolver (on wrong thread!)")
            logger.logAsyncTaskProgress(
                entry.logKey,
                "getting row image resolver (on wrong thread!)",
            )
            val imageResolver = row.imageResolver
            // wait for image resolver to finish preloading
            logger.logAsyncTaskProgress(entry.logKey, "waiting for preloaded images")
@@ -685,13 +688,17 @@ constructor(
            logger: NotificationRowContentBinderLogger,
        ): InflationProgress {
            val rowImageInflater =
                RowImageInflater.newInstance(previousIndex = row.mImageModelIndex)
                RowImageInflater.newInstance(
                    previousIndex = row.mImageModelIndex,
                    // inflating the contracted view is the legacy invalidation trigger
                    reinflating = reInflateFlags and FLAG_CONTENT_VIEW_CONTRACTED != 0,
                )

            val promotedContent =
                if (PromotedNotificationContentModel.featureFlagEnabled()) {
                    logger.logAsyncTaskProgress(
                        entry.logKey,
                        "extracting promoted notification content"
                        "extracting promoted notification content",
                    )
                    val imageModelProvider = rowImageInflater.useForContentModel()
                    promotedNotificationContentExtractor
@@ -750,7 +757,7 @@ constructor(
                ) {
                    logger.logAsyncTaskProgress(
                        entry.logKey,
                        "inflating public single line view model"
                        "inflating public single line view model",
                    )
                    if (bindParams.redactionType == REDACTION_TYPE_SENSITIVE_CONTENT) {
                        SingleLineViewInflater.inflateSingleLineViewModel(
@@ -852,18 +859,12 @@ constructor(
                    } else null
                val expanded =
                    if (reInflateFlags and FLAG_CONTENT_VIEW_EXPANDED != 0) {
                        logger.logAsyncTaskProgress(
                            row.loggingKey,
                            "creating expanded remote view",
                        )
                        logger.logAsyncTaskProgress(row.loggingKey, "creating expanded remote view")
                        createExpandedView(builder, bindParams.isMinimized)
                    } else null
                val headsUp =
                    if (reInflateFlags and FLAG_CONTENT_VIEW_HEADS_UP != 0) {
                        logger.logAsyncTaskProgress(
                            row.loggingKey,
                            "creating heads up remote view",
                        )
                        logger.logAsyncTaskProgress(row.loggingKey, "creating heads up remote view")
                        val isHeadsUpCompact = headsUpStyleProvider.shouldApplyCompactStyle()
                        if (isHeadsUpCompact) {
                            builder.createCompactHeadsUpContentView()
@@ -873,10 +874,7 @@ constructor(
                    } else null
                val public =
                    if (reInflateFlags and FLAG_CONTENT_VIEW_PUBLIC != 0) {
                        logger.logAsyncTaskProgress(
                            row.loggingKey,
                            "creating public remote view"
                        )
                        logger.logAsyncTaskProgress(row.loggingKey, "creating public remote view")
                        if (
                            LockscreenOtpRedaction.isEnabled &&
                                bindParams.redactionType == REDACTION_TYPE_SENSITIVE_CONTENT
@@ -1142,7 +1140,7 @@ constructor(
                            override fun setResultView(v: View) {
                                logger.logAsyncTaskProgress(
                                    entry.logKey,
                                    "group header view applied"
                                    "group header view applied",
                                )
                                result.inflatedGroupHeaderView = v as NotificationHeaderView?
                            }
@@ -1198,7 +1196,7 @@ constructor(
                        }
                    logger.logAsyncTaskProgress(
                        entry.logKey,
                        "applying low priority group header view"
                        "applying low priority group header view",
                    )
                    applyRemoteView(
                        inflationExecutor = inflationExecutor,
+13 −7
Original line number Diff line number Diff line
@@ -83,9 +83,9 @@ interface RowImageInflater {
        inline fun featureFlagEnabled() = PromotedNotificationUiAod.isEnabled

        @JvmStatic
        fun newInstance(previousIndex: ImageModelIndex?): RowImageInflater =
        fun newInstance(previousIndex: ImageModelIndex?, reinflating: Boolean): RowImageInflater =
            if (featureFlagEnabled()) {
                RowImageInflaterImpl(previousIndex)
                RowImageInflaterImpl(previousIndex, reinflating)
            } else {
                RowImageInflaterStub
            }
@@ -110,7 +110,8 @@ private object RowImageInflaterStub : RowImageInflater {
    override fun getNewImageIndex(): ImageModelIndex? = null
}

class RowImageInflaterImpl(private val previousIndex: ImageModelIndex?) : RowImageInflater {
class RowImageInflaterImpl(private val previousIndex: ImageModelIndex?, val reinflating: Boolean) :
    RowImageInflater {
    private val providedImages = mutableListOf<LazyImage>()

    /**
@@ -139,7 +140,12 @@ class RowImageInflaterImpl(private val previousIndex: ImageModelIndex?) : RowIma
                    // ensure all entries are stored
                    providedImages.add(newImage)
                    // load the image result from the index into our new object
                    previousIndex?.findImage(iconData, sizeClass, transform)?.let {
                    previousIndex
                        // skip the cached image when we are "reinflating" to avoid stale content
                        // being displayed from the same URI after the app updated the notif
                        ?.takeUnless { reinflating }
                        ?.findImage(iconData, sizeClass, transform)
                        ?.let {
                            // copy the result into our new object
                            newImage.result = it
                        }
Loading