diff options
3 files changed, 14 insertions, 20 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/people/ui/compose/PeopleScreen.kt b/packages/SystemUI/compose/features/src/com/android/systemui/people/ui/compose/PeopleScreen.kt index d84e67620177..68f010e1c50d 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/people/ui/compose/PeopleScreen.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/people/ui/compose/PeopleScreen.kt @@ -42,13 +42,10 @@ import androidx.compose.runtime.key import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.repeatOnLifecycle import com.android.compose.theme.LocalAndroidColorScheme import com.android.systemui.R import com.android.systemui.compose.modifiers.sysuiResTag @@ -70,15 +67,6 @@ fun PeopleScreen( val priorityTiles by viewModel.priorityTiles.collectAsState() val recentTiles by viewModel.recentTiles.collectAsState() - // Make sure to refresh the tiles/conversations when the lifecycle is resumed, so that it - // updates them when going back to the Activity after leaving it. - val lifecycleOwner = LocalLifecycleOwner.current - LaunchedEffect(lifecycleOwner, viewModel) { - lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) { - viewModel.onTileRefreshRequested() - } - } - // Call [onResult] this activity when the ViewModel tells us so. LaunchedEffect(viewModel.result) { viewModel.result.collect { result -> diff --git a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.kt b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.kt index 30e84368ac0b..5b7eb454597c 100644 --- a/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/people/PeopleSpaceActivity.kt @@ -20,7 +20,10 @@ import android.appwidget.AppWidgetManager import android.os.Bundle import android.util.Log import androidx.activity.ComponentActivity +import androidx.lifecycle.Lifecycle import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle import com.android.systemui.compose.ComposeFacade.isComposeAvailable import com.android.systemui.compose.ComposeFacade.setPeopleSpaceActivityContent import com.android.systemui.flags.FeatureFlags @@ -29,6 +32,7 @@ import com.android.systemui.people.ui.view.PeopleViewBinder import com.android.systemui.people.ui.view.PeopleViewBinder.bind import com.android.systemui.people.ui.viewmodel.PeopleViewModel import javax.inject.Inject +import kotlinx.coroutines.launch /** People Tile Widget configuration activity that shows the user their conversation tiles. */ class PeopleSpaceActivity @@ -50,6 +54,16 @@ constructor( ) viewModel.onWidgetIdChanged(widgetId) + // Make sure to refresh the tiles/conversations when the lifecycle is resumed, so that it + // updates them when going back to the Activity after leaving it. + // Note that we do this here instead of inside an effect in the PeopleScreen() composable + // because otherwise onTileRefreshRequested() will be called after the first composition, + // which will trigger a new recomposition and redraw, affecting the GPU memory (see + // b/276871425). + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.RESUMED) { viewModel.onTileRefreshRequested() } + } + // Set the content of the activity, using either the View or Compose implementation. if (featureFlags.isEnabled(Flags.COMPOSE_PEOPLE_SPACE) && isComposeAvailable()) { Log.d(TAG, "Using the Compose implementation of the PeopleSpaceActivity") diff --git a/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt b/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt index d8a429e5bb1a..5f338c30c966 100644 --- a/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/people/ui/view/PeopleViewBinder.kt @@ -109,14 +109,6 @@ object PeopleViewBinder { } } } - - // Make sure to refresh the tiles/conversations when the Activity is resumed, so that it - // updates them when going back to the Activity after leaving it. - lifecycleOwner.lifecycleScope.launch { - lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) { - viewModel.onTileRefreshRequested() - } - } } private fun setNoConversationsContent(view: ViewGroup, onGotItClicked: () -> Unit) { |