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

Commit 8eaf6b90 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Pod] Move Diffable and TableRowLogger to log.table pod.

Pre-requisite for moving TableLogBuffer to a pod.

For now, doesn't move the extension functions because TableLogBuffer
isn't in a pod yet.

Bug: 307607958
Flag: EXEMPT refactor
Test: m SystemUI-core
Change-Id: I09d73ddc23f4f0220d5f9eb5414ab7979c74fc9c
parent efc9b9a1
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ java_library {
    name: "com.android.systemui.pods-aosp-handheld",
    name: "com.android.systemui.pods-aosp-handheld",
    static_libs: [
    static_libs: [
        "com.android.systemui.dagger-api",
        "com.android.systemui.dagger-api",
        "com.android.systemui.log.table-api",
        "com.android.systemui.retail-impl",
        "com.android.systemui.retail-impl",
        "com.android.systemui.util.kotlin",
        "com.android.systemui.util.kotlin",
        "com.android.systemui.util.settings-api",
        "com.android.systemui.util.settings-api",
+29 −0
Original line number Original line Diff line number Diff line
//
// Copyright (C) 2025 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 {
    default_applicable_licenses: ["frameworks_base_packages_SystemUI_license"],
}

java_library {
    name: "com.android.systemui.log.table-api",
    srcs: [
        "*.kt",
    ],
    defaults: [
        "SystemUI_pod_defaults_api",
    ],
}
+53 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 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.log.table

/**
 * An interface that enables logging the difference between values in table format.
 *
 * Many objects that we want to log are data-y objects with a collection of fields. When logging
 * these objects, we want to log each field separately. This allows ABT (Android Bug Tool) to easily
 * highlight changes in individual fields.
 *
 * See [TableLogBuffer].
 */
public interface Diffable<T> {
    /**
     * Finds the differences between [prevVal] and this object and logs those diffs to [row].
     *
     * Each implementer should determine which individual fields have changed between [prevVal] and
     * this object, and only log the fields that have actually changed. This helps save buffer
     * space.
     *
     * For example, if:
     * - prevVal = Object(val1=100, val2=200, val3=300)
     * - this = Object(val1=100, val2=200, val3=333)
     *
     * Then only the val3 change should be logged.
     */
    public fun logDiffs(prevVal: T, row: TableRowLogger)

    /**
     * Logs all the relevant fields of this object to [row].
     *
     * As opposed to [logDiffs], this method should log *all* fields.
     *
     * Implementation is optional. This method will only be used with [logDiffsForTable] in order to
     * fully log the initial value of the flow.
     */
    public fun logFull(row: TableRowLogger) {}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -23,13 +23,13 @@ package com.android.systemui.log.table
 * to individual fields using the [logChange] methods. All logged changes will be associated with
 * to individual fields using the [logChange] methods. All logged changes will be associated with
 * the same timestamp.
 * the same timestamp.
 */
 */
interface TableRowLogger {
public interface TableRowLogger {
    /** Logs a change to a string value. */
    /** Logs a change to a string value. */
    fun logChange(columnName: String, value: String?)
    public fun logChange(columnName: String, value: String?)


    /** Logs a change to a boolean value. */
    /** Logs a change to a boolean value. */
    fun logChange(columnName: String, value: Boolean)
    public fun logChange(columnName: String, value: Boolean)


    /** Logs a change to an int value. */
    /** Logs a change to an int value. */
    fun logChange(columnName: String, value: Int)
    public fun logChange(columnName: String, value: Int)
}
}
+0 −36
Original line number Original line Diff line number Diff line
@@ -25,42 +25,6 @@ import com.android.systemui.kairos.util.NameTag
import com.android.systemui.util.kotlin.pairwiseBy
import com.android.systemui.util.kotlin.pairwiseBy
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.Flow


/**
 * An interface that enables logging the difference between values in table format.
 *
 * Many objects that we want to log are data-y objects with a collection of fields. When logging
 * these objects, we want to log each field separately. This allows ABT (Android Bug Tool) to easily
 * highlight changes in individual fields.
 *
 * See [TableLogBuffer].
 */
interface Diffable<T> {
    /**
     * Finds the differences between [prevVal] and this object and logs those diffs to [row].
     *
     * Each implementer should determine which individual fields have changed between [prevVal] and
     * this object, and only log the fields that have actually changed. This helps save buffer
     * space.
     *
     * For example, if:
     * - prevVal = Object(val1=100, val2=200, val3=300)
     * - this = Object(val1=100, val2=200, val3=333)
     *
     * Then only the val3 change should be logged.
     */
    fun logDiffs(prevVal: T, row: TableRowLogger)

    /**
     * Logs all the relevant fields of this object to [row].
     *
     * As opposed to [logDiffs], this method should log *all* fields.
     *
     * Implementation is optional. This method will only be used with [logDiffsForTable] in order to
     * fully log the initial value of the flow.
     */
    fun logFull(row: TableRowLogger) {}
}

/**
/**
 * Each time the flow is updated with a new value, logs the differences between the previous value
 * Each time the flow is updated with a new value, logs the differences between the previous value
 * and the new value to the given [tableLogBuffer].
 * and the new value to the given [tableLogBuffer].