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

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

[SB][Screen Chips] Add logs for the chip state.

This CL:
1) Adds logs in each of the interactors that affects the chips
2) Adds a log in the main view model stating which chips want to be
   shown.

In order to achieve #2, I added a fourth string to LogMessage.

Bug: 332662551
Flag: com.android.systemui.status_bar_screen_sharing_chips

Test: Start and stop each type of chip, then dump the StatusBarChips log
-> see all the right logs (see sample logs in b/332662551#comment35)

Change-Id: I21daaee19f8fc383c940925e77bb4df00f180389
parent 72cd9a53
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ import com.android.systemui.startable.Dependencies;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.chips.StatusBarChipsModule;
import com.android.systemui.statusbar.connectivity.ConnectivityModule;
import com.android.systemui.statusbar.dagger.StatusBarModule;
import com.android.systemui.statusbar.disableflags.dagger.DisableFlagsModule;
@@ -242,6 +243,7 @@ import javax.inject.Named;
        SmartspaceModule.class,
        StatusBarEventsModule.class,
        StatusBarModule.class,
        StatusBarChipsModule.class,
        StatusBarPipelineModule.class,
        StatusBarPolicyModule.class,
        StatusBarViewBinderModule.class,
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.chips

import javax.inject.Qualifier

/** Logs for events related to the status bar chips. */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class StatusBarChipsLog
+35 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.chips

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogBufferFactory
import dagger.Module
import dagger.Provides

@Module
abstract class StatusBarChipsModule {
    companion object {
        @Provides
        @SysUISingleton
        @StatusBarChipsLog
        fun provideChipsLogBuffer(factory: LogBufferFactory): LogBuffer {
            return factory.create("StatusBarChips", 200)
        }
    }
}
+22 −1
Original line number Diff line number Diff line
@@ -17,15 +17,36 @@
package com.android.systemui.statusbar.chips.call.domain.interactor

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.statusbar.chips.StatusBarChipsLog
import com.android.systemui.statusbar.phone.ongoingcall.data.repository.OngoingCallRepository
import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn

/** Interactor for the ongoing phone call chip shown in the status bar. */
@SysUISingleton
class CallChipInteractor
@Inject
constructor(
    @Application private val scope: CoroutineScope,
    repository: OngoingCallRepository,
    @StatusBarChipsLog private val logger: LogBuffer,
) {
    val ongoingCallState = repository.ongoingCallState
    val ongoingCallState: StateFlow<OngoingCallModel> =
        repository.ongoingCallState
            .onEach {
                logger.log(TAG, LogLevel.INFO, { str1 = it::class.simpleName }, { "State: $str1" })
            }
            .stateIn(scope, SharingStarted.Lazily, OngoingCallModel.NoCall)

    companion object {
        private const val TAG = "OngoingCall"
    }
}
+21 −1
Original line number Diff line number Diff line
@@ -19,8 +19,11 @@ package com.android.systemui.statusbar.chips.mediaprojection.domain.interactor
import android.content.pm.PackageManager
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.mediaprojection.data.model.MediaProjectionState
import com.android.systemui.mediaprojection.data.repository.MediaProjectionRepository
import com.android.systemui.statusbar.chips.StatusBarChipsLog
import com.android.systemui.statusbar.chips.mediaprojection.domain.model.ProjectionChipModel
import com.android.systemui.util.Utils
import javax.inject.Inject
@@ -45,12 +48,16 @@ constructor(
    @Application private val scope: CoroutineScope,
    private val mediaProjectionRepository: MediaProjectionRepository,
    private val packageManager: PackageManager,
    @StatusBarChipsLog private val logger: LogBuffer,
) {
    val projection: StateFlow<ProjectionChipModel> =
        mediaProjectionRepository.mediaProjectionState
            .map { state ->
                when (state) {
                    is MediaProjectionState.NotProjecting -> ProjectionChipModel.NotProjecting
                    is MediaProjectionState.NotProjecting -> {
                        logger.log(TAG, LogLevel.INFO, {}, { "State: NotProjecting" })
                        ProjectionChipModel.NotProjecting
                    }
                    is MediaProjectionState.Projecting -> {
                        val type =
                            if (isProjectionToOtherDevice(state.hostPackage)) {
@@ -58,6 +65,15 @@ constructor(
                            } else {
                                ProjectionChipModel.Type.SHARE_TO_APP
                            }
                        logger.log(
                            TAG,
                            LogLevel.INFO,
                            {
                                str1 = type.name
                                str2 = state.hostPackage
                            },
                            { "State: Projecting(type=$str1 hostPackage=$str2)" }
                        )
                        ProjectionChipModel.Projecting(type, state)
                    }
                }
@@ -81,4 +97,8 @@ constructor(
        // marked as going to a different device, even if that isn't always true. See b/321078669.
        return Utils.isHeadlessRemoteDisplayProvider(packageManager, packageName)
    }

    companion object {
        private const val TAG = "MediaProjection"
    }
}
Loading