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

Commit 0af50eb3 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov Committed by Android (Google) Code Review
Browse files

Merge "TableLogBuffer: Default columnPrefix to ""." into main

parents 6c1a7411 fdb35b5b
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -25,34 +25,34 @@ interface TableLogBufferBase {
     *
     * For Java overloading.
     */
    fun logChange(prefix: String, columnName: String, value: String?) {
    fun logChange(prefix: String = "", columnName: String, value: String?) {
        logChange(prefix, columnName, value, isInitial = false)
    }

    /** Logs a String? change. */
    fun logChange(prefix: String, columnName: String, value: String?, isInitial: Boolean)
    fun logChange(prefix: String = "", columnName: String, value: String?, isInitial: Boolean)

    /**
     * Logs a Boolean change.
     *
     * For Java overloading.
     */
    fun logChange(prefix: String, columnName: String, value: Boolean) {
    fun logChange(prefix: String = "", columnName: String, value: Boolean) {
        logChange(prefix, columnName, value, isInitial = false)
    }

    /** Logs a Boolean change. */
    fun logChange(prefix: String, columnName: String, value: Boolean, isInitial: Boolean)
    fun logChange(prefix: String = "", columnName: String, value: Boolean, isInitial: Boolean)

    /**
     * Logs an Int? change.
     *
     * For Java overloading.
     */
    fun logChange(prefix: String, columnName: String, value: Int?) {
    fun logChange(prefix: String = "", columnName: String, value: Int?) {
        logChange(prefix, columnName, value, isInitial = false)
    }

    /** Logs an Int? change. */
    fun logChange(prefix: String, columnName: String, value: Int?, isInitial: Boolean)
    fun logChange(prefix: String = "", columnName: String, value: Int?, isInitial: Boolean)
}
+6 −6
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ interface Diffable<T> {
 */
fun <T : Diffable<T>> Flow<T>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
    columnPrefix: String = "",
    initialValue: T,
): Flow<T> {
    // Fully log the initial value to the table.
@@ -87,7 +87,7 @@ fun <T : Diffable<T>> Flow<T>.logDiffsForTable(
/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun Flow<Boolean>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
    columnPrefix: String = "",
    columnName: String,
    initialValue: Boolean,
): Flow<Boolean> {
@@ -106,7 +106,7 @@ fun Flow<Boolean>.logDiffsForTable(
/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun Flow<Int>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
    columnPrefix: String = "",
    columnName: String,
    initialValue: Int,
): Flow<Int> {
@@ -125,7 +125,7 @@ fun Flow<Int>.logDiffsForTable(
/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun Flow<Int?>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
    columnPrefix: String = "",
    columnName: String,
    initialValue: Int?,
): Flow<Int?> {
@@ -144,7 +144,7 @@ fun Flow<Int?>.logDiffsForTable(
/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun Flow<String?>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
    columnPrefix: String = "",
    columnName: String,
    initialValue: String?,
): Flow<String?> {
@@ -163,7 +163,7 @@ fun Flow<String?>.logDiffsForTable(
/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun <T> Flow<List<T>>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
    columnPrefix: String = "",
    columnName: String,
    initialValue: List<T>,
): Flow<List<T>> {
+4 −3
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ class TableLogBuffer(
     *   the separator token for parsing, so it can't be present in any part of the column name.
     */
    @Synchronized
    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
@@ -136,6 +136,7 @@ class TableLogBuffer(
    /**
     * 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
@@ -145,9 +146,9 @@ class TableLogBuffer(
     */
    @Synchronized
    fun logChange(
        columnPrefix: String,
        columnPrefix: String = "",
        isInitial: Boolean = false,
        rowInitializer: (TableRowLogger) -> Unit
        rowInitializer: (TableRowLogger) -> Unit,
    ) {
        val row = tempRow
        row.timestamp = systemClock.currentTimeMillis()
+1 −6
Original line number Diff line number Diff line
@@ -81,12 +81,7 @@ constructor(
                awaitClose { observer.isListening = false }
            }
            .distinctUntilChanged()
            .logDiffsForTable(
                logger,
                columnPrefix = "",
                columnName = "isAirplaneMode",
                initialValue = false,
            )
            .logDiffsForTable(logger, columnName = "isAirplaneMode", initialValue = false)
            .stateIn(
                scope,
                started = SharingStarted.WhileSubscribed(),
+0 −1
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ constructor(
            .distinctUntilChanged()
            .logDiffsForTable(
                logger,
                columnPrefix = "",
                columnName = "isAirplaneModeIconVisible",
                initialValue = false,
            )
Loading