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

Commit 058ab600 authored by Nicolò Mazzucato's avatar Nicolò Mazzucato
Browse files

Add more logging and tracing to Shade

- Log shade display changed success
- Log shade header height on config changes

Bug: 438869931
Test: None, just adding logs
Flag: NONE - adding some logs to debug a race condition
Change-Id: Iba1b49ab972eae0cdc46b41f410450f015363cb3
parent 464c2d69
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.shade

import android.content.Context
import com.android.app.tracing.TraceStateLogger
import com.android.app.tracing.TrackGroupUtils.trackGroup
import com.android.app.tracing.coroutines.TrackTracer.Companion.instantForGroup
@@ -26,6 +27,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.shade.LargeScreenHeaderHelper.Companion.getLargeScreenHeaderHeight
import com.android.systemui.shade.data.repository.ShadeDisplaysRepository
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shade.domain.interactor.ShadeModeInteractor
@@ -33,6 +35,8 @@ import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch

@SysUISingleton
@@ -45,9 +49,10 @@ constructor(
    @ShadeDisplayAware private val configurationRepository: ConfigurationRepository,
    @Application private val scope: CoroutineScope,
    @ShadeDisplayLog private val logBuffer: LogBuffer,
    @ShadeDisplayAware private val context: Context,
) : CoreStartable {
    override fun start() {
        scope.launchTraced("ShadeStateTraceLogger") {
        scope.launchTraced(TAG) {
            launch {
                val stateLogger = createTraceStateLogger("isFullWidthShade")
                shadeModeInteractor.isFullWidthShade.collect { stateLogger.log(it.toString()) }
@@ -76,7 +81,7 @@ constructor(
                        it.smallestScreenWidthDp,
                    )
                    logBuffer.log(
                        "ShadeStateTraceLogger",
                        TAG,
                        LogLevel.DEBUG,
                        {
                            int1 = it.smallestScreenWidthDp
@@ -89,6 +94,28 @@ constructor(
                    )
                }
            }

            launch {
                configurationRepository.onAnyConfigurationChange
                    .map { getLargeScreenHeaderHeight(context) to context.displayId }
                    .distinctUntilChanged()
                    .collect { (largeScreenHeaderHeight, displayId) ->
                        instantForGroup(
                            TRACK_GROUP_NAME,
                            "shadeHeaderHeight",
                            largeScreenHeaderHeight,
                        )
                        logBuffer.log(
                            TAG,
                            LogLevel.DEBUG,
                            {
                                int1 = largeScreenHeaderHeight
                                int1 = displayId
                            },
                            { "New shadeHeaderHeight: $int1, displayId: $int2" },
                        )
                    }
            }
        }
    }

@@ -98,5 +125,6 @@ constructor(

    private companion object {
        const val TRACK_GROUP_NAME = "shade"
        const val TAG = "ShadeStateTraceLogger"
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -147,6 +147,15 @@ constructor(
                    }
                    checkContextDisplayMatchesExpected(destinationId)
                    shadePositionRepository.onDisplayChangedSucceeded(destinationId)
                    logBuffer.log(
                        TAG,
                        LogLevel.DEBUG,
                        {
                            int1 = currentId
                            int2 = destinationId
                        },
                        { "Shade window successfully moved from display $int1 to $int2" },
                    )
                }
            }
        } catch (e: IllegalStateException) {