Fix crash in BrightnessDialog
I couldn't reproduce this brash with the TOT build, but based on the stack trace attached in the bug, I think this cl would fix it. Root cause: The original code added an OnAttachStateChangeListener to the window's DecorView to initialize Compose. This caused an `IllegalStateException` because the DecorView already had a LifecycleOwner from the Activity. And this Activity is the `android.app.Activity`, which is extened by the BrightnessDialog, it did not correctly provide the LifecycleOwner and SavedStateRegistryOwner required by Jetpack Compose. In this change: - The problematic OnAttachStateChangeListener is removed. - Instead of Activity, let BrightnessDialog to extend `androidx.activity.ComponentActivity`, which provides the necessary LifecycleOwner and SavedStateRegistryOwner implementations out of the box. - The corresponding unit test was updated to invoke onResume on the main UI thread via runOnUiThread. This is necessary because lifecycle methods must be called on the main thread, a requirement enforced by ComponentActivity. Bug: 417544544 Flag: com.android.systemui.qs_ui_refactor_compose_fragment Test: Manually. Change-Id: Ia3bf5b0a9b84f46db0665049b852d8d6aeebf39e
Loading
Please register or sign in to comment