From cf51487f83ca4903070a99928a10f3f31c71a591 Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Fri, 15 Nov 2024 17:35:02 +0000 Subject: Remove emptyView from AodBurnInSection When the shade window moves, the emptyView was not removed from the ConstraintLayout, resulting in an exception when addviews was called again (as it was added despite having a parent already) Bug: 362719719 Test: Moved the shade and verified this doesn't crash sysui with the flag turned on. Flag: com.android.systemui.shade_window_goes_around Change-Id: I1b144a359e3a4707788072919646bde2293d92ee --- .../systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt index 8622ffc04601..160380bb09bc 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodBurnInSection.kt @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.view.layout.sections import android.content.Context import android.view.View +import android.view.ViewGroup import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.constraintlayout.widget.ConstraintSet.BOTTOM @@ -47,11 +48,15 @@ constructor( visibility = View.GONE } } + override fun addViews(constraintLayout: ConstraintLayout) { if (!MigrateClocksToBlueprint.isEnabled) { return } - + if (emptyView.parent != null) { + // As emptyView is lazy, it might be already attached. + (emptyView.parent as? ViewGroup)?.removeView(emptyView) + } constraintLayout.addView(emptyView) burnInLayer = AodBurnInLayer(context).apply { -- cgit v1.2.3-59-g8ed1b