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

Commit f1214c52 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[SB Refactor] Add verbose logging about values received by the binder.

More debug logging for b/267236367: Add logs to see if the binder has
received values from the view model (and if yes, which values).

Bug: 267236367
Test: `adb shell dumpsys activity service
com.android.systemui/.SystemUIService VerboseMobileViewLog` -> see
binder logs

Change-Id: I88baa0eb9aa5f302a197a0ee1c2ddfc51648e6e5
parent 3fac1f33
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -155,5 +155,12 @@ abstract class StatusBarPipelineModule {
        fun provideMobileViewLogBuffer(factory: LogBufferFactory): LogBuffer {
            return factory.create("MobileViewLog", 100)
        }

        @Provides
        @SysUISingleton
        @VerboseMobileViewLog
        fun provideVerboseMobileViewLogBuffer(factory: LogBufferFactory): LogBuffer {
            return factory.create("VerboseMobileViewLog", 100)
        }
    }
}
+25 −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 **verbose** changes with the new mobile views. */
@Qualifier
@MustBeDocumented
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
annotation class VerboseMobileViewLog
+1 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.statusbar.pipeline.mobile.ui

import android.view.View
import androidx.annotation.VisibleForTesting
import com.android.systemui.Dumpable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
@@ -109,8 +108,7 @@ constructor(
    }

    companion object {
        @VisibleForTesting
        internal fun Any.getIdForLogging(): String {
        fun Any.getIdForLogging(): String {
            // The identityHashCode is guaranteed to be constant for the lifetime of the object.
            return Integer.toHexString(System.identityHashCode(this))
        }
+76 −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.mobile.ui

import android.view.View
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.plugins.log.LogBuffer
import com.android.systemui.plugins.log.LogLevel
import com.android.systemui.statusbar.pipeline.dagger.VerboseMobileViewLog
import com.android.systemui.statusbar.pipeline.mobile.ui.MobileViewLogger.Companion.getIdForLogging
import com.android.systemui.statusbar.pipeline.mobile.ui.model.SignalIconModel
import javax.inject.Inject

/**
 * Logs for **verbose** changes with the new mobile views.
 *
 * This is a hopefully temporary log until we resolve some open bugs (b/267236367, b/269565345,
 * b/270300839).
 */
@SysUISingleton
class VerboseMobileViewLogger
@Inject
constructor(
    @VerboseMobileViewLog private val buffer: LogBuffer,
) {
    fun logBinderReceivedSignalIcon(parentView: View, subId: Int, icon: SignalIconModel) {
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            {
                str1 = parentView.getIdForLogging()
                int1 = subId
                int2 = icon.level
                bool1 = icon.showExclamationMark
            },
            {
                "Binder[subId=$int1, viewId=$str1] received new signal icon: " +
                    "level=$int2 showExclamation=$bool1"
            },
        )
    }

    fun logBinderReceivedNetworkTypeIcon(parentView: View, subId: Int, icon: Icon.Resource?) {
        buffer.log(
            TAG,
            LogLevel.VERBOSE,
            {
                str1 = parentView.getIdForLogging()
                int1 = subId
                bool1 = icon != null
                int2 = icon?.res ?: -1
            },
            {
                "Binder[subId=$int1, viewId=$str1] received new network type icon: " +
                    if (bool1) "resId=$int2" else "null"
            },
        )
    }
}

private const val TAG = "VerboseMobileViewLogger"
+10 −0
Original line number Diff line number Diff line
@@ -104,6 +104,11 @@ object MobileIconBinder {
                // Set the icon for the triangle
                launch {
                    viewModel.icon.distinctUntilChanged().collect { icon ->
                        viewModel.verboseLogger?.logBinderReceivedSignalIcon(
                            view,
                            viewModel.subscriptionId,
                            icon,
                        )
                        mobileDrawable.level =
                            SignalDrawable.getState(
                                icon.level,
@@ -122,6 +127,11 @@ object MobileIconBinder {
                // Set the network type icon
                launch {
                    viewModel.networkTypeIcon.distinctUntilChanged().collect { dataTypeId ->
                        viewModel.verboseLogger?.logBinderReceivedNetworkTypeIcon(
                            view,
                            viewModel.subscriptionId,
                            dataTypeId,
                        )
                        dataTypeId?.let { IconViewBinder.bind(dataTypeId, networkTypeView) }
                        networkTypeView.visibility = if (dataTypeId != null) VISIBLE else GONE
                    }
Loading