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

Commit c920be5e authored by Shivangi Dubey's avatar Shivangi Dubey Committed by Android (Google) Code Review
Browse files

Merge "Add display switch latency tracking" into main

parents 2c6d3c9a 3afb04c5
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line 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.stylus.StylusUsiPowerStartable
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
import com.android.systemui.theme.ThemeOverlayController
import com.android.systemui.theme.ThemeOverlayController
import com.android.systemui.unfold.DisplaySwitchLatencyTracker
import com.android.systemui.usb.StorageNotification
import com.android.systemui.usb.StorageNotification
import com.android.systemui.util.NotificationChannels
import com.android.systemui.util.NotificationChannels
import com.android.systemui.util.StartBinderLoggerModule
import com.android.systemui.util.StartBinderLoggerModule
@@ -141,6 +142,12 @@ abstract class SystemUICoreStartableModule {
    @ClassKey(LatencyTester::class)
    @ClassKey(LatencyTester::class)
    abstract fun bindLatencyTester(sysui: LatencyTester): CoreStartable
    abstract fun bindLatencyTester(sysui: LatencyTester): CoreStartable


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

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


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


    fun setAodAvailable(value: Boolean)
    fun setAodAvailable(value: Boolean)


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


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


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


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


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


    /** Something else happened to wake up or sleep the device. */
    /** 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 {
    companion object {
        fun fromPowerManagerWakeReason(reason: Int): WakeSleepReason {
        fun fromPowerManagerWakeReason(reason: Int): WakeSleepReason {
@@ -72,6 +75,7 @@ enum class WakeSleepReason(
        fun fromPowerManagerSleepReason(reason: Int): WakeSleepReason {
        fun fromPowerManagerSleepReason(reason: Int): WakeSleepReason {
            return when (reason) {
            return when (reason) {
                PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON -> POWER_BUTTON
                PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON -> POWER_BUTTON
                PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD -> FOLD
                else -> OTHER
                else -> OTHER
            }
            }
        }
        }
+55 −0
Original line number Original line 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