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

Commit 4b490fbc authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Chipbar] Create a chipbar-specific logger and make some small updates

to logging for both chipbar and temporary display.

Bug: 245610654
Test: dumped ChipbarLog, MediaTttSender, and MediaTttReceiver and verify
they have logs for events
Test: atest TemporaryViewDisplayControllerTest
Test: atest ChipbarCoordinatorTest

Change-Id: I6bb3f8db8810b62a00f9336b6ea7a88d24f35409
parent 13c529d3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ import com.android.systemui.statusbar.policy.dagger.SmartRepliesInflationModule;
import com.android.systemui.statusbar.policy.dagger.StatusBarPolicyModule;
import com.android.systemui.statusbar.window.StatusBarWindowModule;
import com.android.systemui.telephony.data.repository.TelephonyRepositoryModule;
import com.android.systemui.temporarydisplay.dagger.TemporaryDisplayModule;
import com.android.systemui.tuner.dagger.TunerModule;
import com.android.systemui.unfold.SysUIUnfoldModule;
import com.android.systemui.user.UserModule;
@@ -149,6 +150,7 @@ import dagger.Provides;
            SysUIConcurrencyModule.class,
            SysUIUnfoldModule.class,
            TelephonyRepositoryModule.class,
            TemporaryDisplayModule.class,
            TunerModule.class,
            UserModule.class,
            UtilModule.class,
+2 −2
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora
                    "com.android.systemui:${newInfo.wakeReason}",
                )
            }
            logger.logChipAddition()
            logger.logViewAddition(newInfo.windowTitle)
            inflateAndUpdateView(newInfo)
        }

@@ -187,7 +187,7 @@ abstract class TemporaryViewDisplayController<T : TemporaryViewInfo, U : Tempora
        val currentView = currentDisplayInfo.view
        animateViewOut(currentView) { windowManager.removeView(currentView) }

        logger.logChipRemoval(removalReason)
        logger.logViewRemoval(removalReason)
        configurationController.removeCallback(displayScaleListener)
        // Re-set to null immediately (instead as part of the animation end runnable) so
        // that if a new view event comes in while this view is animating out, we still display the
+5 −5
Original line number Diff line number Diff line
@@ -24,13 +24,13 @@ open class TemporaryViewLogger(
    internal val buffer: LogBuffer,
    internal val tag: String,
) {
    /** Logs that we added the chip to a new window. */
    fun logChipAddition() {
        buffer.log(tag, LogLevel.DEBUG, {}, { "Chip added" })
    /** Logs that we added the view in a window titled [windowTitle]. */
    fun logViewAddition(windowTitle: String) {
        buffer.log(tag, LogLevel.DEBUG, { str1 = windowTitle }, { "View added. window=$str1" })
    }

    /** Logs that we removed the chip for the given [reason]. */
    fun logChipRemoval(reason: String) {
        buffer.log(tag, LogLevel.DEBUG, { str1 = reason }, { "Chip removed due to: $str1" })
    fun logViewRemoval(reason: String) {
        buffer.log(tag, LogLevel.DEBUG, { str1 = reason }, { "View removed due to: $str1" })
    }
}
+12 −8
Original line number Diff line number Diff line
@@ -38,8 +38,6 @@ import com.android.systemui.common.ui.binder.IconViewBinder
import com.android.systemui.common.ui.binder.TextViewBinder
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.media.taptotransfer.common.MediaTttLogger
import com.android.systemui.media.taptotransfer.sender.MediaTttSenderLogger
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.statusbar.VibratorHelper
import com.android.systemui.statusbar.policy.ConfigurationController
@@ -63,14 +61,11 @@ import javax.inject.Inject
 * Only one chipbar may be shown at a time.
 * TODO(b/245610654): Should we just display whichever chipbar was most recently requested, or do we
 *   need to maintain a priority ordering?
 *
 * TODO(b/245610654): Remove all media-related items from this class so it's just for generic
 *   chipbars.
 */
@SysUISingleton
open class ChipbarCoordinator @Inject constructor(
        context: Context,
        @MediaTttSenderLogger logger: MediaTttLogger,
        logger: ChipbarLogger,
        windowManager: WindowManager,
        @Main mainExecutor: DelayableExecutor,
        accessibilityManager: AccessibilityManager,
@@ -80,7 +75,7 @@ open class ChipbarCoordinator @Inject constructor(
        private val falsingCollector: FalsingCollector,
        private val viewUtil: ViewUtil,
        private val vibratorHelper: VibratorHelper,
) : TemporaryViewDisplayController<ChipbarInfo, MediaTttLogger>(
) : TemporaryViewDisplayController<ChipbarInfo, ChipbarLogger>(
        context,
        logger,
        windowManager,
@@ -103,7 +98,16 @@ open class ChipbarCoordinator @Inject constructor(
        newInfo: ChipbarInfo,
        currentView: ViewGroup
    ) {
        // TODO(b/245610654): Adding logging here.
        logger.logViewUpdate(
            newInfo.windowTitle,
            newInfo.text.loadText(context),
            when (newInfo.endItem) {
                null -> "null"
                is ChipbarEndItem.Loading -> "loading"
                is ChipbarEndItem.Error -> "error"
                is ChipbarEndItem.Button -> "button(${newInfo.endItem.text.loadText(context)})"
            }
        )

        // Detect falsing touches on the chip.
        parent = currentView.requireViewById(R.id.chipbar_root_view)
+49 −0
Original line number 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.temporarydisplay.chipbar

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
import com.android.systemui.temporarydisplay.TemporaryViewLogger
import com.android.systemui.temporarydisplay.dagger.ChipbarLog
import javax.inject.Inject

/** A logger for the chipbar. */
@SysUISingleton
class ChipbarLogger
@Inject
constructor(
    @ChipbarLog buffer: LogBuffer,
) : TemporaryViewLogger(buffer, "ChipbarLog") {
    /**
     * Logs that the chipbar was updated to display in a window named [windowTitle], with [text] and
     * [endItemDesc].
     */
    fun logViewUpdate(windowTitle: String, text: String?, endItemDesc: String) {
        buffer.log(
            tag,
            LogLevel.DEBUG,
            {
                str1 = windowTitle
                str2 = text
                str3 = endItemDesc
            },
            { "Chipbar updated. window=$str1 text=$str2 endItem=$str3" }
        )
    }
}
Loading