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

Commit fbd6e788 authored by Subhash Reddy Surkanti (xWF)'s avatar Subhash Reddy Surkanti (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Cache the movable content used for Status icons"

This reverts commit 830dd1ae.

Reason for revert: Likely culprit for b/438849539  - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Bug : 438849539

Change-Id: I9da4dccb6bc7d98517bef55bdac2763db9265b77
parent 830dd1ae
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@ import com.android.systemui.res.R
import com.android.systemui.statusbar.phone.StatusBarLocation
import com.android.systemui.statusbar.phone.StatusIconContainer
import com.android.systemui.statusbar.phone.ui.TintedIconManager
import com.android.systemui.statusbar.systemstatusicons.ui.compose.MovableSystemStatusIconLegacy
import com.android.systemui.statusbar.systemstatusicons.ui.compose.movableSystemStatusIconsLegacyAndroidView

/**
 * Defines interface for classes that can provide a context for UI that renders the status bar
@@ -47,12 +45,6 @@ interface StatusIconContext {
     * cached in the [StatusIconContext].
     */
    fun iconManager(contentKey: ContentKey): TintedIconManager

    /**
     * Returns a [MovableSystemStatusIconLegacy] movable content for the given [TintedIconManager].
     * This movable content will be cached in the [StatusIconContext].
     */
    fun movableContent(tintedIconManager: TintedIconManager): MovableSystemStatusIconLegacy
}

val LocalStatusIconContext =
@@ -71,8 +63,6 @@ fun WithStatusIconContext(
                private val iconContainerByContentKey =
                    mutableMapOf<ContentKey, StatusIconContainer>()
                private val iconManagerByContentKey = mutableMapOf<ContentKey, TintedIconManager>()
                private val movableContentByIconManager =
                    mutableMapOf<TintedIconManager, MovableSystemStatusIconLegacy>()

                override fun iconContainer(contentKey: ContentKey): StatusIconContainer {
                    return iconContainerByContentKey.getOrPut(contentKey) {
@@ -94,14 +84,6 @@ fun WithStatusIconContext(
                        )
                    }
                }

                override fun movableContent(
                    tintedIconManager: TintedIconManager
                ): MovableSystemStatusIconLegacy {
                    return movableContentByIconManager.getOrPut(tintedIconManager) {
                        movableSystemStatusIconsLegacyAndroidView(tintedIconManager)
                    }
                }
            }
        }

+26 −101
Original line number Diff line number Diff line
@@ -17,19 +17,13 @@
package com.android.systemui.statusbar.systemstatusicons.ui.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.movableContentOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.viewinterop.AndroidView
import com.android.systemui.shade.ui.composable.LocalStatusIconContext
import com.android.systemui.statusbar.phone.StatusIconContainer
import com.android.systemui.statusbar.phone.ui.StatusBarIconController
import com.android.systemui.statusbar.phone.ui.TintedIconManager

@Suppress("NAME_SHADOWING")
@Composable
fun SystemStatusIconsLegacy(
    statusBarIconController: StatusBarIconController,
@@ -54,29 +48,13 @@ fun SystemStatusIconsLegacy(
    val micSlot = stringResource(id = com.android.internal.R.string.status_bar_microphone)
    val locationSlot = stringResource(id = com.android.internal.R.string.status_bar_location)

    /*
     * Use `rememberUpdatedState` to guarantee that a state will be exposed (without recomposition)
     * for all these parameters, so the update block will be called when any of them changes.
     */
    val useExpandedFormat by rememberUpdatedState(useExpandedFormat)
    val isTransitioning by rememberUpdatedState(isTransitioning)
    val foregroundColor by rememberUpdatedState(foregroundColor)
    val backgroundColor by rememberUpdatedState(backgroundColor)
    val isSingleCarrier by rememberUpdatedState(isSingleCarrier)
    val isMicCameraIndicationEnabled by rememberUpdatedState(isMicCameraIndicationEnabled)
    val isPrivacyChipEnabled by rememberUpdatedState(isPrivacyChipEnabled)
    val isLocationIndicationEnabled by rememberUpdatedState(isLocationIndicationEnabled)

    val update =
        remember(
            statusBarIconController,
            iconManager,
            carrierIconSlots,
            cameraSlot,
            micSlot,
            locationSlot,
        ) {
            { container: StatusIconContainer ->
    AndroidView(
        factory = {
            statusBarIconController.addIconGroup(iconManager)
            iconContainer
        },
        onRelease = { statusBarIconController.removeIconGroup(iconManager) },
        update = { container ->
            container.setQsExpansionTransitioning(isTransitioning)

            if (isSingleCarrier || !useExpandedFormat) {
@@ -105,60 +83,7 @@ fun SystemStatusIconsLegacy(
            }

            iconManager.setTint(foregroundColor, backgroundColor)
            }
        }

    val statusIconContext = LocalStatusIconContext.current

    val movableContent =
        remember(statusIconContext, iconManager) { statusIconContext.movableContent(iconManager) }

    movableContent(statusBarIconController, iconContainer, update, modifier)
}

/** Alias for [movableSystemStatusIconsLegacyAndroidView] */
typealias MovableSystemStatusIconLegacy =
    @Composable
    (StatusBarIconController, StatusIconContainer, (StatusIconContainer) -> Unit, Modifier) -> Unit

/**
 * Returns a movable content for the given `TintedIconManager`. This can be used to guarantee that
 * the same one is always used (to prevent double registration with [StatusBarIconController]) when
 * used with a cache.
 */
fun movableSystemStatusIconsLegacyAndroidView(
    iconManager: TintedIconManager
): MovableSystemStatusIconLegacy {
    return movableContentOf {
        statusBarIconController: StatusBarIconController,
        iconContainer: StatusIconContainer,
        update: (StatusIconContainer) -> Unit,
        modifier: Modifier ->
        SystemStatusIconsLegacyAndroidView(
            statusBarIconController,
            iconManager,
            iconContainer,
            update,
            modifier,
        )
    }
}

@Composable
private fun SystemStatusIconsLegacyAndroidView(
    statusBarIconController: StatusBarIconController,
    iconManager: TintedIconManager,
    iconContainer: StatusIconContainer,
    update: (StatusIconContainer) -> Unit,
    modifier: Modifier = Modifier,
) {
    AndroidView(
        factory = {
            statusBarIconController.addIconGroup(iconManager)
            iconContainer
        },
        onRelease = { statusBarIconController.removeIconGroup(iconManager) },
        update = update,
        modifier = modifier,
    )
}