Loading packages/SystemUI/multivalentTests/src/com/android/systemui/inputdevice/tutorial/domain/interactor/TutorialNotificationCoordinatorTest.kt +12 −6 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.inputdevice.tutorial.data.repository.TutorialSchedulerRepository import com.android.systemui.inputdevice.tutorial.inputDeviceTutorialLogger import com.android.systemui.inputdevice.tutorial.ui.TutorialNotificationCoordinator import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository import com.android.systemui.kosmos.Kosmos Loading Loading @@ -75,16 +76,21 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() { TutorialSchedulerRepository( context, dataStoreScope, dataStoreName = "TutorialNotificationCoordinatorTest" dataStoreName = "TutorialNotificationCoordinatorTest", ) val interactor = TutorialSchedulerInteractor(keyboardRepository, touchpadRepository, repository) TutorialSchedulerInteractor( keyboardRepository, touchpadRepository, repository, kosmos.inputDeviceTutorialLogger, ) underTest = TutorialNotificationCoordinator( testScope.backgroundScope, context, interactor, notificationManager notificationManager, ) notificationCaptor = ArgumentCaptor.forClass(Notification::class.java) underTest.start() Loading @@ -103,7 +109,7 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() { advanceTimeBy(LAUNCH_DELAY) verifyNotification( R.string.launch_keyboard_tutorial_notification_title, R.string.launch_keyboard_tutorial_notification_content R.string.launch_keyboard_tutorial_notification_content, ) } Loading @@ -114,7 +120,7 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() { advanceTimeBy(LAUNCH_DELAY) verifyNotification( R.string.launch_touchpad_tutorial_notification_title, R.string.launch_touchpad_tutorial_notification_content R.string.launch_touchpad_tutorial_notification_content, ) } Loading @@ -126,7 +132,7 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() { advanceTimeBy(LAUNCH_DELAY) verifyNotification( R.string.launch_keyboard_touchpad_tutorial_notification_title, R.string.launch_keyboard_touchpad_tutorial_notification_content R.string.launch_keyboard_touchpad_tutorial_notification_content, ) } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/inputdevice/tutorial/domain/interactor/TutorialSchedulerInteractorTest.kt +8 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType import com.android.systemui.inputdevice.tutorial.data.repository.TutorialSchedulerRepository import com.android.systemui.inputdevice.tutorial.domain.interactor.TutorialSchedulerInteractor.TutorialType import com.android.systemui.inputdevice.tutorial.inputDeviceTutorialLogger import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope Loading Loading @@ -62,10 +63,15 @@ class TutorialSchedulerInteractorTest : SysuiTestCase() { TutorialSchedulerRepository( context, dataStoreScope, dataStoreName = "TutorialSchedulerInteractorTest" dataStoreName = "TutorialSchedulerInteractorTest", ) underTest = TutorialSchedulerInteractor(keyboardRepository, touchpadRepository, schedulerRepository) TutorialSchedulerInteractor( keyboardRepository, touchpadRepository, schedulerRepository, kosmos.inputDeviceTutorialLogger, ) } @After Loading packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/InputDeviceTutorialLogger.kt +16 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.systemui.inputdevice.tutorial import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType import com.android.systemui.inputdevice.tutorial.domain.interactor.ConnectionState import com.android.systemui.inputdevice.tutorial.domain.interactor.TutorialSchedulerInteractor.TutorialType import com.android.systemui.inputdevice.tutorial.ui.viewmodel.Screen as KeyboardTouchpadTutorialScreen import com.android.systemui.log.ConstantStringsLogger import com.android.systemui.log.ConstantStringsLoggerImpl Loading @@ -41,7 +43,7 @@ constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) : str1 = screen.toString() str2 = context.string }, { "Emitting new screen $str1 in $str2" } { "Emitting new screen $str1 in $str2" }, ) } Loading @@ -58,7 +60,7 @@ constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) : TAG, LogLevel.WARNING, { str1 = nextScreen.toString() }, { "next screen should be $str1 but required hardware is missing" } { "next screen should be $str1 but required hardware is missing" }, ) } Loading @@ -72,20 +74,20 @@ constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) : bool1 = connectionState.touchpadConnected bool2 = connectionState.keyboardConnected }, { "Received connection state: touchpad connected: $bool1 keyboard connected: $bool2" } { "Received connection state: touchpad connected: $bool1 keyboard connected: $bool2" }, ) } fun logMovingBetweenScreens( previousScreen: KeyboardTouchpadTutorialScreen?, currentScreen: KeyboardTouchpadTutorialScreen currentScreen: KeyboardTouchpadTutorialScreen, ) { logInfo( { str1 = previousScreen?.toString() ?: "NO_SCREEN" str2 = currentScreen.toString() }, { "Moving from $str1 screen to $str2 screen" } { "Moving from $str1 screen to $str2 screen" }, ) } Loading @@ -93,9 +95,17 @@ constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) : logInfo({ str1 = previousScreen.toString() }, { "Going back to $str1 screen" }) } fun logDeviceFirstConnection(deviceType: DeviceType) { logInfo({ str1 = deviceType.toString() }, { "$str1 has connected for the first time" }) } fun logTutorialLaunched(tutorialType: TutorialType) { logInfo({ str1 = tutorialType.toString() }, { "Launching $str1 tutorial" }) } private inline fun logInfo( messageInitializer: MessageInitializer, noinline messagePrinter: MessagePrinter noinline messagePrinter: MessagePrinter, ) { buffer.log(TAG, LogLevel.INFO, messageInitializer, messagePrinter) } Loading packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/domain/interactor/TutorialSchedulerInteractor.kt +12 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.inputdevice.tutorial.domain.interactor import android.os.SystemProperties import com.android.systemui.dagger.SysUISingleton import com.android.systemui.inputdevice.tutorial.InputDeviceTutorialLogger import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType.KEYBOARD import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType.TOUCHPAD Loading Loading @@ -47,12 +48,13 @@ class TutorialSchedulerInteractor constructor( keyboardRepository: KeyboardRepository, touchpadRepository: TouchpadRepository, private val repo: TutorialSchedulerRepository private val repo: TutorialSchedulerRepository, private val logger: InputDeviceTutorialLogger, ) { private val isAnyDeviceConnected = mapOf( KEYBOARD to keyboardRepository.isAnyKeyboardConnected, TOUCHPAD to touchpadRepository.isAnyTouchpadConnected TOUCHPAD to touchpadRepository.isAnyTouchpadConnected, ) private val touchpadScheduleFlow = flow { Loading @@ -71,10 +73,14 @@ constructor( private suspend fun schedule(deviceType: DeviceType) { if (!repo.wasEverConnected(deviceType)) { logger.d("Waiting for $deviceType to connect") waitForDeviceConnection(deviceType) logger.logDeviceFirstConnection(deviceType) repo.updateFirstConnectionTime(deviceType, Instant.now()) } delay(remainingTime(start = repo.firstConnectionTime(deviceType)!!)) val remainingTime = remainingTime(start = repo.firstConnectionTime(deviceType)!!) logger.d("Tutorial is scheduled in ${remainingTime.inWholeSeconds} seconds") delay(remainingTime) waitForDeviceConnection(deviceType) } Loading @@ -92,6 +98,7 @@ constructor( if (tutorialType == TutorialType.TOUCHPAD || tutorialType == TutorialType.BOTH) repo.updateLaunchTime(TOUCHPAD, Instant.now()) logger.logTutorialLaunched(tutorialType) tutorialType } Loading Loading @@ -119,7 +126,7 @@ constructor( Duration.ofSeconds( SystemProperties.getLong( "persist.peripheral_tutorial_delay_sec", DEFAULT_LAUNCH_DELAY_SEC DEFAULT_LAUNCH_DELAY_SEC, ) ) } Loading @@ -128,6 +135,6 @@ constructor( KEYBOARD, TOUCHPAD, BOTH, NONE NONE, } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/inputdevice/tutorial/domain/interactor/TutorialNotificationCoordinatorTest.kt +12 −6 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.inputdevice.tutorial.data.repository.TutorialSchedulerRepository import com.android.systemui.inputdevice.tutorial.inputDeviceTutorialLogger import com.android.systemui.inputdevice.tutorial.ui.TutorialNotificationCoordinator import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository import com.android.systemui.kosmos.Kosmos Loading Loading @@ -75,16 +76,21 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() { TutorialSchedulerRepository( context, dataStoreScope, dataStoreName = "TutorialNotificationCoordinatorTest" dataStoreName = "TutorialNotificationCoordinatorTest", ) val interactor = TutorialSchedulerInteractor(keyboardRepository, touchpadRepository, repository) TutorialSchedulerInteractor( keyboardRepository, touchpadRepository, repository, kosmos.inputDeviceTutorialLogger, ) underTest = TutorialNotificationCoordinator( testScope.backgroundScope, context, interactor, notificationManager notificationManager, ) notificationCaptor = ArgumentCaptor.forClass(Notification::class.java) underTest.start() Loading @@ -103,7 +109,7 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() { advanceTimeBy(LAUNCH_DELAY) verifyNotification( R.string.launch_keyboard_tutorial_notification_title, R.string.launch_keyboard_tutorial_notification_content R.string.launch_keyboard_tutorial_notification_content, ) } Loading @@ -114,7 +120,7 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() { advanceTimeBy(LAUNCH_DELAY) verifyNotification( R.string.launch_touchpad_tutorial_notification_title, R.string.launch_touchpad_tutorial_notification_content R.string.launch_touchpad_tutorial_notification_content, ) } Loading @@ -126,7 +132,7 @@ class TutorialNotificationCoordinatorTest : SysuiTestCase() { advanceTimeBy(LAUNCH_DELAY) verifyNotification( R.string.launch_keyboard_touchpad_tutorial_notification_title, R.string.launch_keyboard_touchpad_tutorial_notification_content R.string.launch_keyboard_touchpad_tutorial_notification_content, ) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/inputdevice/tutorial/domain/interactor/TutorialSchedulerInteractorTest.kt +8 −2 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType import com.android.systemui.inputdevice.tutorial.data.repository.TutorialSchedulerRepository import com.android.systemui.inputdevice.tutorial.domain.interactor.TutorialSchedulerInteractor.TutorialType import com.android.systemui.inputdevice.tutorial.inputDeviceTutorialLogger import com.android.systemui.keyboard.data.repository.FakeKeyboardRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope Loading Loading @@ -62,10 +63,15 @@ class TutorialSchedulerInteractorTest : SysuiTestCase() { TutorialSchedulerRepository( context, dataStoreScope, dataStoreName = "TutorialSchedulerInteractorTest" dataStoreName = "TutorialSchedulerInteractorTest", ) underTest = TutorialSchedulerInteractor(keyboardRepository, touchpadRepository, schedulerRepository) TutorialSchedulerInteractor( keyboardRepository, touchpadRepository, schedulerRepository, kosmos.inputDeviceTutorialLogger, ) } @After Loading
packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/InputDeviceTutorialLogger.kt +16 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.systemui.inputdevice.tutorial import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType import com.android.systemui.inputdevice.tutorial.domain.interactor.ConnectionState import com.android.systemui.inputdevice.tutorial.domain.interactor.TutorialSchedulerInteractor.TutorialType import com.android.systemui.inputdevice.tutorial.ui.viewmodel.Screen as KeyboardTouchpadTutorialScreen import com.android.systemui.log.ConstantStringsLogger import com.android.systemui.log.ConstantStringsLoggerImpl Loading @@ -41,7 +43,7 @@ constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) : str1 = screen.toString() str2 = context.string }, { "Emitting new screen $str1 in $str2" } { "Emitting new screen $str1 in $str2" }, ) } Loading @@ -58,7 +60,7 @@ constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) : TAG, LogLevel.WARNING, { str1 = nextScreen.toString() }, { "next screen should be $str1 but required hardware is missing" } { "next screen should be $str1 but required hardware is missing" }, ) } Loading @@ -72,20 +74,20 @@ constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) : bool1 = connectionState.touchpadConnected bool2 = connectionState.keyboardConnected }, { "Received connection state: touchpad connected: $bool1 keyboard connected: $bool2" } { "Received connection state: touchpad connected: $bool1 keyboard connected: $bool2" }, ) } fun logMovingBetweenScreens( previousScreen: KeyboardTouchpadTutorialScreen?, currentScreen: KeyboardTouchpadTutorialScreen currentScreen: KeyboardTouchpadTutorialScreen, ) { logInfo( { str1 = previousScreen?.toString() ?: "NO_SCREEN" str2 = currentScreen.toString() }, { "Moving from $str1 screen to $str2 screen" } { "Moving from $str1 screen to $str2 screen" }, ) } Loading @@ -93,9 +95,17 @@ constructor(@InputDeviceTutorialLog private val buffer: LogBuffer) : logInfo({ str1 = previousScreen.toString() }, { "Going back to $str1 screen" }) } fun logDeviceFirstConnection(deviceType: DeviceType) { logInfo({ str1 = deviceType.toString() }, { "$str1 has connected for the first time" }) } fun logTutorialLaunched(tutorialType: TutorialType) { logInfo({ str1 = tutorialType.toString() }, { "Launching $str1 tutorial" }) } private inline fun logInfo( messageInitializer: MessageInitializer, noinline messagePrinter: MessagePrinter noinline messagePrinter: MessagePrinter, ) { buffer.log(TAG, LogLevel.INFO, messageInitializer, messagePrinter) } Loading
packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/domain/interactor/TutorialSchedulerInteractor.kt +12 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.inputdevice.tutorial.domain.interactor import android.os.SystemProperties import com.android.systemui.dagger.SysUISingleton import com.android.systemui.inputdevice.tutorial.InputDeviceTutorialLogger import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType.KEYBOARD import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType.TOUCHPAD Loading Loading @@ -47,12 +48,13 @@ class TutorialSchedulerInteractor constructor( keyboardRepository: KeyboardRepository, touchpadRepository: TouchpadRepository, private val repo: TutorialSchedulerRepository private val repo: TutorialSchedulerRepository, private val logger: InputDeviceTutorialLogger, ) { private val isAnyDeviceConnected = mapOf( KEYBOARD to keyboardRepository.isAnyKeyboardConnected, TOUCHPAD to touchpadRepository.isAnyTouchpadConnected TOUCHPAD to touchpadRepository.isAnyTouchpadConnected, ) private val touchpadScheduleFlow = flow { Loading @@ -71,10 +73,14 @@ constructor( private suspend fun schedule(deviceType: DeviceType) { if (!repo.wasEverConnected(deviceType)) { logger.d("Waiting for $deviceType to connect") waitForDeviceConnection(deviceType) logger.logDeviceFirstConnection(deviceType) repo.updateFirstConnectionTime(deviceType, Instant.now()) } delay(remainingTime(start = repo.firstConnectionTime(deviceType)!!)) val remainingTime = remainingTime(start = repo.firstConnectionTime(deviceType)!!) logger.d("Tutorial is scheduled in ${remainingTime.inWholeSeconds} seconds") delay(remainingTime) waitForDeviceConnection(deviceType) } Loading @@ -92,6 +98,7 @@ constructor( if (tutorialType == TutorialType.TOUCHPAD || tutorialType == TutorialType.BOTH) repo.updateLaunchTime(TOUCHPAD, Instant.now()) logger.logTutorialLaunched(tutorialType) tutorialType } Loading Loading @@ -119,7 +126,7 @@ constructor( Duration.ofSeconds( SystemProperties.getLong( "persist.peripheral_tutorial_delay_sec", DEFAULT_LAUNCH_DELAY_SEC DEFAULT_LAUNCH_DELAY_SEC, ) ) } Loading @@ -128,6 +135,6 @@ constructor( KEYBOARD, TOUCHPAD, BOTH, NONE NONE, } }