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

Commit fc762204 authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Revert "[Pod] Add all public methods of TableLogBuffer to interface."" into main

parents 36eb4bac 84503bfe
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ java_library {
    static_libs: [
        "androidx.annotation_annotation",
        "androidx-constraintlayout_constraintlayout",
        "com.android.systemui.log.table-api",
        "PlatformAnimationLib",
        "PluginCoreLib",
        "SystemUICommon",
+3 −48
Original line number Diff line number Diff line
@@ -14,9 +14,6 @@

package com.android.systemui.plugins.log

import com.android.systemui.log.table.Diffable
import com.android.systemui.log.table.TableRowLogger

/**
 * Base interface for a logger that logs changes in table format.
 *
@@ -32,11 +29,7 @@ interface TableLogBufferBase {
        logChange(prefix, columnName, value, isInitial = false)
    }

    /**
     * Logs a String? change.
     *
     * @param isInitial see [TableLogBuffer.logChange(String, Boolean, (TableRowLogger) -> Unit].
     */
    /** Logs a String? change. */
    fun logChange(prefix: String = "", columnName: String, value: String?, isInitial: Boolean)

    /**
@@ -48,11 +41,7 @@ interface TableLogBufferBase {
        logChange(prefix, columnName, value, isInitial = false)
    }

    /**
     * Logs a Boolean change.
     *
     * @param isInitial see [TableLogBuffer.logChange(String, Boolean, (TableRowLogger) -> Unit].
     */
    /** Logs a Boolean change. */
    fun logChange(prefix: String = "", columnName: String, value: Boolean, isInitial: Boolean)

    /**
@@ -64,40 +53,6 @@ interface TableLogBufferBase {
        logChange(prefix, columnName, value, isInitial = false)
    }

    /**
     * Logs an Int? change.
     *
     * @param isInitial see [TableLogBuffer.logChange(String, Boolean, (TableRowLogger) -> Unit].
     */
    /** Logs an Int? change. */
    fun logChange(prefix: String = "", columnName: String, value: Int?, isInitial: Boolean)

    /**
     * Log the differences between [prevVal] and [newVal].
     *
     * The [newVal] object's method [Diffable.logDiffs] will be used to fetch the diffs.
     *
     * @param columnPrefix a prefix that will be applied to every column name that gets logged. This
     *   ensures that all the columns related to the same state object will be grouped together in
     *   the table.
     * @throws IllegalArgumentException if [columnPrefix] or column name contain "|". "|" is used as
     *   the separator token for parsing, so it can't be present in any part of the column name.
     */
    fun <T : Diffable<T>> logDiffs(columnPrefix: String = "", prevVal: T, newVal: T)

    /**
     * Logs change(s) to the buffer using [rowInitializer].
     *
     * @param columnPrefix see [logDiffs].
     * @param rowInitializer a function that will be called immediately to store relevant data on
     *   the row.
     * @param isInitial true if this change represents the starting value for a particular column
     *   (as opposed to a value that was updated after receiving new information). This is used to
     *   help us identify which values were just default starting values, and which values were
     *   derived from updated information. Most callers should use false for this value.
     */
    fun logChange(
        columnPrefix: String = "",
        isInitial: Boolean = false,
        rowInitializer: (TableRowLogger) -> Unit,
    )
}
+41 −4
Original line number Diff line number Diff line
@@ -112,8 +112,19 @@ class TableLogBuffer(
            tableLogBuffer = this,
        )

    /**
     * Log the differences between [prevVal] and [newVal].
     *
     * The [newVal] object's method [Diffable.logDiffs] will be used to fetch the diffs.
     *
     * @param columnPrefix a prefix that will be applied to every column name that gets logged. This
     *   ensures that all the columns related to the same state object will be grouped together in
     *   the table.
     * @throws IllegalArgumentException if [columnPrefix] or column name contain "|". "|" is used as
     *   the separator token for parsing, so it can't be present in any part of the column name.
     */
    @Synchronized
    override fun <T : Diffable<T>> logDiffs(columnPrefix: String, prevVal: T, newVal: T) {
    fun <T : Diffable<T>> logDiffs(columnPrefix: String = "", prevVal: T, newVal: T) {
        val row = tempRow
        row.timestamp = systemClock.currentTimeMillis()
        row.columnPrefix = columnPrefix
@@ -122,10 +133,21 @@ class TableLogBuffer(
        newVal.logDiffs(prevVal, row)
    }

    /**
     * Logs change(s) to the buffer using [rowInitializer].
     *
     * @param columnPrefix see [logDiffs].
     * @param rowInitializer a function that will be called immediately to store relevant data on
     *   the row.
     * @param isInitial true if this change represents the starting value for a particular column
     *   (as opposed to a value that was updated after receiving new information). This is used to
     *   help us identify which values were just default starting values, and which values were
     *   derived from updated information. Most callers should use false for this value.
     */
    @Synchronized
    override fun logChange(
        columnPrefix: String,
        isInitial: Boolean,
    fun logChange(
        columnPrefix: String = "",
        isInitial: Boolean = false,
        rowInitializer: (TableRowLogger) -> Unit,
    ) {
        val row = tempRow
@@ -135,14 +157,29 @@ class TableLogBuffer(
        rowInitializer(row)
    }

    /**
     * Logs a String? change.
     *
     * @param isInitial see [TableLogBuffer.logChange(String, Boolean, (TableRowLogger) -> Unit].
     */
    override fun logChange(prefix: String, columnName: String, value: String?, isInitial: Boolean) {
        logChange(systemClock.currentTimeMillis(), prefix, columnName, value, isInitial)
    }

    /**
     * Logs a boolean change.
     *
     * @param isInitial see [TableLogBuffer.logChange(String, Boolean, (TableRowLogger) -> Unit].
     */
    override fun logChange(prefix: String, columnName: String, value: Boolean, isInitial: Boolean) {
        logChange(systemClock.currentTimeMillis(), prefix, columnName, value, isInitial)
    }

    /**
     * Logs a Int change.
     *
     * @param isInitial see [TableLogBuffer.logChange(String, Boolean, (TableRowLogger) -> Unit].
     */
    override fun logChange(prefix: String, columnName: String, value: Int?, isInitial: Boolean) {
        logChange(systemClock.currentTimeMillis(), prefix, columnName, value, isInitial)
    }