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

Commit ef6d496d authored by Michal Brzezinski's avatar Michal Brzezinski
Browse files

Adding logger for touchpad and keyboard tutorials

Also adding a few basic logs.

Bug: 360873976
Test: just adding logs
Flag: com.android.systemui.shared.new_touchpad_gestures_tutorial
Change-Id: I51bda79dba02ad37c18470fe16a03d923631422e
parent b00b6c65
Loading
Loading
Loading
Loading
+56 −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.inputdevice.tutorial

import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.LogLevel
import com.android.systemui.log.dagger.InputDeviceTutorialLog
import com.android.systemui.touchpad.tutorial.ui.viewmodel.Screen
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject

private const val TAG = "InputDeviceTutorial"

class InputDeviceTutorialLogger
@Inject
constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) {

    fun log(@CompileTimeConstant s: String) {
        buffer.log(TAG, LogLevel.INFO, message = s)
    }

    fun logGoingToScreen(screen: Screen, context: TutorialContext) {
        buffer.log(
            TAG,
            LogLevel.INFO,
            {
                str1 = screen.toString()
                str2 = context.string
            },
            { "Emitting new screen $str1 in $str2" }
        )
    }

    fun logCloseTutorial(context: TutorialContext) {
        buffer.log(TAG, LogLevel.INFO, { str1 = context.string }, { "Closing $str1" })
    }

    enum class TutorialContext(val string: String) {
        KEYBOARD_TOUCHPAD_TUTORIAL("keyboard touchpad tutorial"),
        TOUCHPAD_TUTORIAL("touchpad tutorial"),
    }
}
+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.log.dagger

import javax.inject.Qualifier

/** A [com.android.systemui.log.LogBuffer] for input device tutorial. */
@Qualifier
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
annotation class InputDeviceTutorialLog
+8 −0
Original line number Diff line number Diff line
@@ -660,6 +660,14 @@ public class LogModule {
        return factory.create("KeyboardLog", 50);
    }

    /** Provides a {@link LogBuffer} for the input devices tutorial. */
    @Provides
    @SysUISingleton
    @InputDeviceTutorialLog
    public static LogBuffer provideInputDeviceTutorialLogBuffer(LogBufferFactory factory) {
        return factory.create("InputDeviceTutorialLog", 50);
    }

    /** Provides a {@link LogBuffer} for {@link PackageChangeRepository} */
    @Provides
    @SysUISingleton
+4 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Activity
import androidx.compose.runtime.Composable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.inputdevice.tutorial.InputDeviceTutorialLogger
import com.android.systemui.inputdevice.tutorial.TouchpadTutorialScreensProvider
import com.android.systemui.model.SysUiState
import com.android.systemui.settings.DisplayTracker
@@ -53,9 +54,10 @@ interface TouchpadTutorialModule {
        fun touchpadGesturesInteractor(
            sysUiState: SysUiState,
            displayTracker: DisplayTracker,
            @Background backgroundScope: CoroutineScope
            @Background backgroundScope: CoroutineScope,
            logger: InputDeviceTutorialLogger,
        ): TouchpadGesturesInteractor {
            return TouchpadGesturesInteractor(sysUiState, displayTracker, backgroundScope)
            return TouchpadGesturesInteractor(sysUiState, displayTracker, backgroundScope, logger)
        }
    }
}
+5 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.touchpad.tutorial.domain.interactor

import com.android.systemui.inputdevice.tutorial.InputDeviceTutorialLogger
import com.android.systemui.model.SysUiState
import com.android.systemui.settings.DisplayTracker
import com.android.systemui.shared.system.QuickStepContract
@@ -25,13 +26,16 @@ import kotlinx.coroutines.launch
class TouchpadGesturesInteractor(
    private val sysUiState: SysUiState,
    private val displayTracker: DisplayTracker,
    private val backgroundScope: CoroutineScope
    private val backgroundScope: CoroutineScope,
    private val logger: InputDeviceTutorialLogger,
) {
    fun disableGestures() {
        logger.log("Disabling touchpad gestures across the system")
        setGesturesState(disabled = true)
    }

    fun enableGestures() {
        logger.log("Enabling touchpad gestures across the system")
        setGesturesState(disabled = false)
    }

Loading