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

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

Merge changes I5986ba47,I8ddeafe4,I385e2050,I1f8b2b4e,Iab75c65a, ... into tm-qpr-dev

* changes:
  [SB Refactor] Migrate mobile's `state.visible` to the new pipeline.
  [SB Refactor] Add better logging for the mobile icon ID.
  [SB Refactor] Add better logging for the network type icon.
  [SB Refactor] Add a table logger for the parent mobile classes.
  [Table logging] Support nullable ints and add more extension functions.
  [SB Refactor] Add logs for the carrier merged connection.
parents 0b5d2db6 2def6f9a
Loading
Loading
Loading
Loading
+46 −12
Original line number Diff line number Diff line
@@ -79,10 +79,10 @@ fun <T : Diffable<T>> Flow<T>.logDiffsForTable(
    }
}

/**
 * Each time the boolean flow is updated with a new value that's different from the previous value,
 * logs the new value to the given [tableLogBuffer].
 */
// Here and below: Various Flow<SomeType> extension functions that are effectively equivalent to the
// above [logDiffsForTable] method.

/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun Flow<Boolean>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
@@ -100,10 +100,8 @@ fun Flow<Boolean>.logDiffsForTable(
        newVal
    }
}
/**
 * Each time the Int flow is updated with a new value that's different from the previous value, logs
 * the new value to the given [tableLogBuffer].
 */

/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun Flow<Int>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
@@ -122,10 +120,26 @@ fun Flow<Int>.logDiffsForTable(
    }
}

/**
 * Each time the String? flow is updated with a new value that's different from the previous value,
 * logs the new value to the given [tableLogBuffer].
 */
/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun Flow<Int?>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
    columnName: String,
    initialValue: Int?,
): Flow<Int?> {
    val initialValueFun = {
        tableLogBuffer.logChange(columnPrefix, columnName, initialValue)
        initialValue
    }
    return this.pairwiseBy(initialValueFun) { prevVal, newVal: Int? ->
        if (prevVal != newVal) {
            tableLogBuffer.logChange(columnPrefix, columnName, newVal)
        }
        newVal
    }
}

/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun Flow<String?>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
@@ -143,3 +157,23 @@ fun Flow<String?>.logDiffsForTable(
        newVal
    }
}

/** See [logDiffsForTable(TableLogBuffer, String, T)]. */
fun <T> Flow<List<T>>.logDiffsForTable(
    tableLogBuffer: TableLogBuffer,
    columnPrefix: String,
    columnName: String,
    initialValue: List<T>,
): Flow<List<T>> {
    val initialValueFun = {
        tableLogBuffer.logChange(columnPrefix, columnName, initialValue.toString())
        initialValue
    }
    return this.pairwiseBy(initialValueFun) { prevVal, newVal: List<T> ->
        if (prevVal != newVal) {
            // TODO(b/267761156): Can we log list changes without using toString?
            tableLogBuffer.logChange(columnPrefix, columnName, newVal.toString())
        }
        newVal
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ data class TableChange(
    var columnName: String = "",
    var type: DataType = DataType.EMPTY,
    var bool: Boolean = false,
    var int: Int = 0,
    var int: Int? = null,
    var str: String? = null,
) {
    /** Resets to default values so that the object can be recycled. */
@@ -54,7 +54,7 @@ data class TableChange(
    }

    /** Sets this to store an int change. */
    fun set(value: Int) {
    fun set(value: Int?) {
        type = DataType.INT
        int = value
    }
+2 −2
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ class TableLogBuffer(
    }

    /** Logs a Int change. */
    fun logChange(prefix: String, columnName: String, value: Int) {
    fun logChange(prefix: String, columnName: String, value: Int?) {
        logChange(systemClock.currentTimeMillis(), prefix, columnName, value)
    }

@@ -155,7 +155,7 @@ class TableLogBuffer(
        change.set(value)
    }

    private fun logChange(timestamp: Long, prefix: String, columnName: String, value: Int) {
    private fun logChange(timestamp: Long, prefix: String, columnName: String, value: Int?) {
        val change = obtain(timestamp, prefix, columnName)
        change.set(value)
    }
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.pipeline.dagger

import javax.inject.Qualifier

/**
 * Logs for mobile data that's **the same across all connections**.
 *
 * This buffer should only be used for the mobile parent classes like [MobileConnectionsRepository]
 * and [MobileIconsInteractor]. It should *not* be used for classes that represent an individual
 * connection, like [MobileConnectionRepository] or [MobileIconInteractor].
 */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class MobileSummaryLog
+7 −0
Original line number Diff line number Diff line
@@ -118,5 +118,12 @@ abstract class StatusBarPipelineModule {
        fun provideAirplaneTableLogBuffer(factory: TableLogBufferFactory): TableLogBuffer {
            return factory.create("AirplaneTableLog", 30)
        }

        @Provides
        @SysUISingleton
        @MobileSummaryLog
        fun provideMobileSummaryLogBuffer(factory: TableLogBufferFactory): TableLogBuffer {
            return factory.create("MobileSummaryLog", 100)
        }
    }
}
Loading