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

Commit 92d2d983 authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Don't crash when (un)folding with AOD RONs on

Bug: 369151941
Flag: com.android.systemui.aod_ui_rich_ongoing
Test: manual
Change-Id: I2f4651bc4822cad3ca6ee8ac53209e16374bc5f1
parent 92fe4ff2
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -42,6 +42,10 @@ constructor(
) : KeyguardSection() {
    var view: ComposeView? = null

    init {
        logger.logSectionCreated(this)
    }

    override fun addViews(constraintLayout: ConstraintLayout) {
        if (!PromotedNotificationUiAod.isEnabled) {
            return
@@ -56,7 +60,7 @@ constructor(
                constraintLayout.addView(this)
            }

        logger.logSectionAddedViews()
        logger.logSectionAddedViews(this)
    }

    override fun bindData(constraintLayout: ConstraintLayout) {
@@ -68,7 +72,7 @@ constructor(

        // Do nothing; the binding happens in the AODPromotedNotification Composable.

        logger.logSectionBoundData()
        logger.logSectionBoundData(this)
    }

    override fun applyConstraints(constraintSet: ConstraintSet) {
@@ -76,7 +80,8 @@ constructor(
            return
        }

        checkNotNull(view)
        // view may have been created by a different instance of the section (!), and we don't
        // actually *need* it to set constraints, so don't check for it here.

        constraintSet.apply {
            val isShadeLayoutWide = shadeInteractor.isShadeLayoutWide.value
@@ -90,7 +95,7 @@ constructor(
            constrainHeight(viewId, ConstraintSet.WRAP_CONTENT)
        }

        logger.logSectionAppliedConstraints()
        logger.logSectionAppliedConstraints(this)
    }

    override fun removeViews(constraintLayout: ConstraintLayout) {
@@ -102,7 +107,7 @@ constructor(

        view = null

        logger.logSectionRemovedViews()
        logger.logSectionRemovedViews(this)
    }

    companion object {
+34 −8
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.notification.promoted

import androidx.constraintlayout.widget.ConstraintSet
import com.android.systemui.keyguard.ui.view.layout.sections.AodPromotedNotificationSection
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel.ERROR
import com.android.systemui.log.core.LogLevel.INFO
@@ -25,6 +26,7 @@ import com.android.systemui.statusbar.notification.logKey
import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import javax.inject.Inject

@OptIn(ExperimentalStdlibApi::class)
class PromotedNotificationLogger
@Inject
constructor(@PromotedNotificationLog private val buffer: LogBuffer) {
@@ -92,20 +94,44 @@ constructor(@PromotedNotificationLog private val buffer: LogBuffer) {
        buffer.log(AOD_VIEW_BINDER_TAG, INFO, "binder unbound notification")
    }

    fun logSectionAddedViews() {
        buffer.log(AOD_SECTION_TAG, INFO, "section added views")
    fun logSectionCreated(section: AodPromotedNotificationSection) {
        buffer.log(
            AOD_SECTION_TAG,
            INFO,
            "section ${System.identityHashCode(section).toHexString()} created",
        )
    }

    fun logSectionBoundData() {
        buffer.log(AOD_SECTION_TAG, INFO, "section bound data")
    fun logSectionAddedViews(section: AodPromotedNotificationSection) {
        buffer.log(
            AOD_SECTION_TAG,
            INFO,
            "section ${System.identityHashCode(section).toHexString()} added views",
        )
    }

    fun logSectionAppliedConstraints() {
        buffer.log(AOD_SECTION_TAG, INFO, "section applied constraints")
    fun logSectionBoundData(section: AodPromotedNotificationSection) {
        buffer.log(
            AOD_SECTION_TAG,
            INFO,
            "section ${System.identityHashCode(section).toHexString()} bound data",
        )
    }

    fun logSectionRemovedViews() {
        buffer.log(AOD_SECTION_TAG, INFO, "section removed views")
    fun logSectionAppliedConstraints(section: AodPromotedNotificationSection) {
        buffer.log(
            AOD_SECTION_TAG,
            INFO,
            "section ${System.identityHashCode(section).toHexString()} applied constraints",
        )
    }

    fun logSectionRemovedViews(section: AodPromotedNotificationSection) {
        buffer.log(
            AOD_SECTION_TAG,
            INFO,
            "section ${System.identityHashCode(section).toHexString()} removed views",
        )
    }
}