Add some logging to help diagnose a crash with duplicate section headers
Test: manual Change-Id: I81ba7561dcb509ca6881cce0b61a5fdd5f5ea661
This commit is contained in:
@@ -172,14 +172,19 @@ class ShadeViewDiffer(
|
||||
private fun treeToMap(tree: NodeSpec): Map<NodeController, NodeSpec> {
|
||||
val map = mutableMapOf<NodeController, NodeSpec>()
|
||||
|
||||
registerNodes(tree, map)
|
||||
try {
|
||||
registerNodes(tree, map)
|
||||
} catch (ex: DuplicateNodeException) {
|
||||
logger.logDuplicateNodeInTree(tree, ex)
|
||||
throw ex
|
||||
}
|
||||
|
||||
return map
|
||||
}
|
||||
|
||||
private fun registerNodes(node: NodeSpec, map: MutableMap<NodeController, NodeSpec>) {
|
||||
if (map.containsKey(node.controller)) {
|
||||
throw RuntimeException("Node ${node.controller.nodeLabel} appears more than once")
|
||||
throw DuplicateNodeException("Node ${node.controller.nodeLabel} appears more than once")
|
||||
}
|
||||
map[node.controller] = node
|
||||
|
||||
@@ -191,6 +196,8 @@ class ShadeViewDiffer(
|
||||
}
|
||||
}
|
||||
|
||||
private class DuplicateNodeException(message: String) : RuntimeException(message)
|
||||
|
||||
private class ShadeNode(
|
||||
val controller: NodeController
|
||||
) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.collection.render
|
||||
import com.android.systemui.log.LogBuffer
|
||||
import com.android.systemui.log.LogLevel
|
||||
import com.android.systemui.log.dagger.NotificationLog
|
||||
import java.lang.RuntimeException
|
||||
import javax.inject.Inject
|
||||
|
||||
class ShadeViewDifferLogger @Inject constructor(
|
||||
@@ -67,6 +68,15 @@ class ShadeViewDifferLogger @Inject constructor(
|
||||
"Moving child view $str1 in $str2 to index $int1"
|
||||
})
|
||||
}
|
||||
|
||||
fun logDuplicateNodeInTree(node: NodeSpec, ex: RuntimeException) {
|
||||
buffer.log(TAG, LogLevel.ERROR, {
|
||||
str1 = ex.toString()
|
||||
str2 = treeSpecToStr(node)
|
||||
}, {
|
||||
"$str1 when mapping tree: $str2"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private const val TAG = "NotifViewManager"
|
||||
Reference in New Issue
Block a user