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

Commit 26b25da3 authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android (Google) Code Review
Browse files

Merge "Prevent smartspace from disconnecting during rebuilds" into main

parents aa317c37 eb1ccf0d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ interface KeyguardBlueprint {
        rebuildSections: List<KeyguardSection> = listOf(),
        bindData: Boolean = true
    ) {
        rebuildSections.forEach { it.onRebuildBegin() }
        val prevSections = previousBlueprint?.sections ?: listOf()
        val skipSections = sections.intersect(prevSections).subtract(rebuildSections)
        prevSections.subtract(skipSections).forEach { it.removeViews(constraintLayout) }
@@ -49,6 +50,7 @@ interface KeyguardBlueprint {
                it.bindData(constraintLayout)
            }
        }
        rebuildSections.forEach { it.onRebuildEnd() }
    }

    /** Rebuilds views for the target sections, or all of them if unspecified. */
@@ -61,6 +63,7 @@ interface KeyguardBlueprint {
            return
        }

        rebuildSections.forEach { it.onRebuildBegin() }
        rebuildSections.forEach { it.removeViews(constraintLayout) }
        rebuildSections.forEach {
            it.addViews(constraintLayout)
@@ -68,6 +71,7 @@ interface KeyguardBlueprint {
                it.bindData(constraintLayout)
            }
        }
        rebuildSections.forEach { it.onRebuildEnd() }
    }

    fun applyConstraints(constraintSet: ConstraintSet) {
+6 −0
Original line number Diff line number Diff line
@@ -33,6 +33,12 @@ abstract class KeyguardSection {
    /** Removes views and does any data binding destruction. */
    abstract fun removeViews(constraintLayout: ConstraintLayout)

    /* Notifies the section is being rebuilt */
    open fun onRebuildBegin() {}

    /* Notifies the secion that the rebuild is complete */
    open fun onRebuildEnd() {}

    /**
     * Defines equality as same class.
     *
+8 −0
Original line number Diff line number Diff line
@@ -56,6 +56,14 @@ constructor(
    private var smartspaceVisibilityListener: OnGlobalLayoutListener? = null
    private var pastVisibility: Int = -1

    override fun onRebuildBegin() {
        smartspaceController.suppressDisconnects = true
    }

    override fun onRebuildEnd() {
        smartspaceController.suppressDisconnects = false
    }

    override fun addViews(constraintLayout: ConstraintLayout) {
        if (!MigrateClocksToBlueprint.isEnabled) return
        if (!keyguardSmartspaceViewModel.isSmartspaceEnabled) return
+7 −0
Original line number Diff line number Diff line
@@ -143,6 +143,12 @@ constructor(
    private var managedUserHandle: UserHandle? = null
    private var mSplitShadeEnabled = false

    var suppressDisconnects = false
        set(value) {
            field = value
            disconnect()
        }

    // TODO(b/202758428): refactor so that we can test color updates via region samping, similar to
    //  how we test color updates when theme changes (See testThemeChangeUpdatesTextColor).

@@ -522,6 +528,7 @@ constructor(
     */
    fun disconnect() {
        if (!smartspaceViews.isEmpty()) return
        if (suppressDisconnects) return

        execution.assertIsMainThread()