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

Commit ebb29524 authored by Jared Duke's avatar Jared Duke Committed by Gerrit Code Review
Browse files

Merge "Use the standard class name for dumpable keys" into main

parents 6050abf7 2902817c
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ open class DumpManager @Inject constructor() {

    /** See [registerCriticalDumpable]. */
    fun registerCriticalDumpable(module: Dumpable) {
        registerCriticalDumpable(module::class.java.canonicalName, module)
        registerCriticalDumpable(module::class.java.name, module)
    }

    /**
@@ -62,7 +62,7 @@ open class DumpManager @Inject constructor() {

    /** See [registerNormalDumpable]. */
    fun registerNormalDumpable(module: Dumpable) {
        registerNormalDumpable(module::class.java.canonicalName, module)
        registerNormalDumpable(module::class.java.name, module)
    }

    /**
@@ -104,13 +104,10 @@ open class DumpManager @Inject constructor() {
        dumpables[name] = DumpableEntry(module, name, priority)
    }

    /**
     * Same as the above override, but automatically uses the canonical class name as the dumpable
     * name.
     */
    /** Same as the above override, but automatically uses the class name as the dumpable name. */
    @Synchronized
    fun registerDumpable(module: Dumpable) {
        registerDumpable(module::class.java.canonicalName, module)
        registerDumpable(module::class.java.name, module)
    }

    /** Unregisters a previously-registered dumpable. */
+16 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.table.TableLogBuffer
import com.google.common.truth.Truth.assertThat
import java.io.PrintWriter
import org.junit.Assert.assertThrows
import org.junit.Before
import org.junit.Test
@@ -130,6 +131,21 @@ class DumpManagerTest : SysuiTestCase() {
        // No exception thrown
    }

    @Test
    fun registerDumpable_supportsAnonymousDumpables() {
        val anonDumpable =
            object : Dumpable {
                override fun dump(pw: PrintWriter, args: Array<out String>) {
                    pw.println("AnonDumpable")
                }
            }

        // THEN registration with implicit names should succeed
        dumpManager.registerCriticalDumpable(anonDumpable)

        // No exception thrown
    }

    @Test
    fun getDumpables_returnsSafeCollection() {
        // GIVEN a variety of registered dumpables