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

Commit 3afb04c5 authored by dshivangi's avatar dshivangi Committed by Shivangi Dubey
Browse files

Add display switch latency tracking

Add display switch latency tracking required for Fold setting.
Fields covered by this CL: Latency in ms, from and to fold state
Bug: 286539409
Test: atest DisplaySwitchLatencyTrackerTest
Flag: ACONFIG fold_lock_setting_enabled TRUNKFOOD

Change-Id: Ia60a139f19c9f3cf607d755feb3a855571b4f267
parent 78478fcb
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.systemui.statusbar.phone.StatusBarHeadsUpChangeListener
import com.android.systemui.stylus.StylusUsiPowerStartable
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
import com.android.systemui.theme.ThemeOverlayController
import com.android.systemui.unfold.DisplaySwitchLatencyTracker
import com.android.systemui.usb.StorageNotification
import com.android.systemui.util.NotificationChannels
import com.android.systemui.util.StartBinderLoggerModule
@@ -141,6 +142,12 @@ abstract class SystemUICoreStartableModule {
    @ClassKey(LatencyTester::class)
    abstract fun bindLatencyTester(sysui: LatencyTester): CoreStartable

    /** Inject into DisplaySwitchLatencyTracker.  */
    @Binds
    @IntoMap
    @ClassKey(DisplaySwitchLatencyTracker::class)
    abstract fun bindDisplaySwitchLatencyTracker(sysui: DisplaySwitchLatencyTracker): CoreStartable

    /** Inject into NotificationChannels.  */
    @Binds
    @IntoMap
+2 −2
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ interface KeyguardRepository {
    val isKeyguardGoingAway: Flow<Boolean>

    /** Is the always-on display available to be used? */
    val isAodAvailable: Flow<Boolean>
    val isAodAvailable: StateFlow<Boolean>

    fun setAodAvailable(value: Boolean)

@@ -338,7 +338,7 @@ constructor(
            .distinctUntilChanged()

    private val _isAodAvailable = MutableStateFlow(false)
    override val isAodAvailable: Flow<Boolean> = _isAodAvailable.asStateFlow()
    override val isAodAvailable: StateFlow<Boolean> = _isAodAvailable.asStateFlow()

    override fun setAodAvailable(value: Boolean) {
        _isAodAvailable.value = value
+1 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ constructor(
    val dozeTimeTick: Flow<Long> = repository.dozeTimeTick

    /** Whether Always-on Display mode is available. */
    val isAodAvailable: Flow<Boolean> = repository.isAodAvailable
    val isAodAvailable: StateFlow<Boolean> = repository.isAodAvailable

    /** Doze transition information. */
    val dozeTransitionModel: Flow<DozeTransitionModel> = repository.dozeTransitionModel
+5 −1
Original line number Diff line number Diff line
@@ -51,7 +51,10 @@ enum class WakeSleepReason(
    BIOMETRIC(isTouch = false, PowerManager.WAKE_REASON_BIOMETRIC),

    /** Something else happened to wake up or sleep the device. */
    OTHER(isTouch = false, PowerManager.WAKE_REASON_UNKNOWN);
    OTHER(isTouch = false, PowerManager.WAKE_REASON_UNKNOWN),

    /** Device goes to sleep due to folding of a foldable device. */
    FOLD(isTouch = false, PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD);

    companion object {
        fun fromPowerManagerWakeReason(reason: Int): WakeSleepReason {
@@ -72,6 +75,7 @@ enum class WakeSleepReason(
        fun fromPowerManagerSleepReason(reason: Int): WakeSleepReason {
            return when (reason) {
                PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON -> POWER_BUTTON
                PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD -> FOLD
                else -> OTHER
            }
        }
+55 −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.unfold

import com.android.systemui.shared.system.SysUiStatsLog

class DisplaySwitchLatencyLogger {

    /**
     * Based on data present in [displaySwitchLatencyEvent], logs metrics for atom
     * [DisplaySwitchLatencyTracked]
     */
    fun log(displaySwitchLatencyEvent: DisplaySwitchLatencyTracker.DisplaySwitchLatencyEvent) {
        with(displaySwitchLatencyEvent) {
            SysUiStatsLog.write(
                SysUiStatsLog.DISPLAY_SWITCH_LATENCY_TRACKED,
                latencyMs,
                fromFoldableDeviceState,
                fromState,
                fromFocusedAppUid,
                fromPipAppUid,
                fromVisibleAppsUid.toIntArray(),
                fromDensityDpi,
                toState,
                toFoldableDeviceState,
                toFocusedAppUid,
                toPipAppUid,
                toVisibleAppsUid.toIntArray(),
                toDensityDpi,
                notificationCount,
                externalDisplayCount,
                throttlingLevel,
                vskinTemperatureC,
                hallSensorToFirstHingeAngleChangeMs,
                hallSensorToDeviceStateChangeMs,
                onScreenTurningOnToOnDrawnMs,
                onDrawnToOnScreenTurnedOnMs,
            )
        }
    }
}
Loading