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

Commit a8c8667e authored by Jeff Chen's avatar Jeff Chen
Browse files

Fix crash loop when compose_bouncer is on. Flag guard is already performed at...

Fix crash loop when compose_bouncer is on. Flag guard is already performed at BouncerViewBinder#bind.

Bug: 335014117
Test: Flashed to device. Crash loop resolved.
Flag: ACONFIG com.android.systemui.compose_bouncer DEVELOPMENT
Change-Id: Ie164b69f11e3c29308a504ab9c9443ccad70567f
parent b28430af
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
package com.android.systemui.bouncer.ui.binder

import android.view.ViewGroup
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.OnBackPressedDispatcherOwner
import androidx.activity.setViewTreeOnBackPressedDispatcherOwner
import androidx.compose.ui.platform.ComposeView
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
@@ -30,8 +33,25 @@ object ComposeBouncerViewBinder {
    ) {
        view.addView(
            ComposeView(view.context).apply {
                repeatWhenAttached {
                    repeatOnLifecycle(Lifecycle.State.CREATED) {
                        setViewTreeOnBackPressedDispatcherOwner(
                            object : OnBackPressedDispatcherOwner {
                                override val onBackPressedDispatcher =
                                    OnBackPressedDispatcher().apply {
                                        setOnBackInvokedDispatcher(
                                            view.viewRootImpl.onBackInvokedDispatcher
                                        )
                                    }

                                override val lifecycle: Lifecycle =
                                    this@repeatWhenAttached.lifecycle
                            }
                        )
                        setContent { PlatformTheme { BouncerContent(viewModel, dialogFactory) } }
                    }
                }
            }
        )

        view.repeatWhenAttached {