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

Commit df90c681 authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Add some logging to help diagnose a crash with duplicate section headers

Test: manual
Change-Id: I81ba7561dcb509ca6881cce0b61a5fdd5f5ea661
parent 75d60f7a
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -172,14 +172,19 @@ class ShadeViewDiffer(
    private fun treeToMap(tree: NodeSpec): Map<NodeController, NodeSpec> {
        val map = mutableMapOf<NodeController, NodeSpec>()

        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
) {
+10 −0
Original line number Diff line number Diff line
@@ -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"
 No newline at end of file