Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
......@@ -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.
*
......
......@@ -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
......
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment