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

Commit 823aeb34 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Add Aster UI logging for education tooltips.

Fixes: 341320146
Flag: com.android.window.flags.enable_desktop_windowing_app_handle_education
Test: atest AppHandleEducationControllerTest

Change-Id: I115ded63b1512c83f8d3e8992fe9ba92ad317530
parent 502812e2
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1306,7 +1306,8 @@ public abstract class WMShellModule {
            WindowDecorCaptionHandleRepository windowDecorCaptionHandleRepository,
            DesktopWindowingEducationTooltipController desktopWindowingEducationTooltipController,
            @ShellMainThread CoroutineScope applicationScope,
            @ShellBackgroundThread MainCoroutineDispatcher backgroundDispatcher) {
            @ShellBackgroundThread MainCoroutineDispatcher backgroundDispatcher,
            DesktopModeUiEventLogger desktopModeUiEventLogger) {
        return new AppHandleEducationController(
                context,
                appHandleEducationFilter,
@@ -1314,7 +1315,8 @@ public abstract class WMShellModule {
                windowDecorCaptionHandleRepository,
                desktopWindowingEducationTooltipController,
                applicationScope,
                backgroundDispatcher);
                backgroundDispatcher,
                desktopModeUiEventLogger);
    }

    @WMSingleton
+19 −1
Original line number Diff line number Diff line
@@ -149,7 +149,25 @@ class DesktopModeUiEventLogger(
        @UiEvent(doc = "Enter multi-instance by using the New Window button")
        DESKTOP_WINDOW_MULTI_INSTANCE_NEW_WINDOW_CLICK(2069),
        @UiEvent(doc = "Enter multi-instance by clicking an icon in the Manage Windows menu")
        DESKTOP_WINDOW_MULTI_INSTANCE_MANAGE_WINDOWS_ICON_CLICK(2070);
        DESKTOP_WINDOW_MULTI_INSTANCE_MANAGE_WINDOWS_ICON_CLICK(2070),
        @UiEvent(doc = "Education tooltip on the app handle is shown")
        APP_HANDLE_EDUCATION_TOOLTIP_SHOWN(2097),
        @UiEvent(doc = "Education tooltip on the app handle is clicked")
        APP_HANDLE_EDUCATION_TOOLTIP_CLICKED(2098),
        @UiEvent(doc = "Education tooltip on the app handle is dismissed by the user")
        APP_HANDLE_EDUCATION_TOOLTIP_DISMISSED(2099),
        @UiEvent(doc = "Enter desktop mode education tooltip on the app handle menu is shown")
        ENTER_DESKTOP_MODE_EDUCATION_TOOLTIP_SHOWN(2100),
        @UiEvent(doc = "Enter desktop mode education tooltip on the app handle menu is clicked")
        ENTER_DESKTOP_MODE_EDUCATION_TOOLTIP_CLICKED(2101),
        @UiEvent(doc = "Enter desktop mode education tooltip is dismissed by the user")
        ENTER_DESKTOP_MODE_EDUCATION_TOOLTIP_DISMISSED(2102),
        @UiEvent(doc = "Exit desktop mode education tooltip on the app header menu is shown")
        EXIT_DESKTOP_MODE_EDUCATION_TOOLTIP_SHOWN(2103),
        @UiEvent(doc = "Exit desktop mode education tooltip on the app header menu is clicked")
        EXIT_DESKTOP_MODE_EDUCATION_TOOLTIP_CLICKED(2104),
        @UiEvent(doc = "Exit desktop mode education tooltip is dismissed by the user")
        EXIT_DESKTOP_MODE_EDUCATION_TOOLTIP_DISMISSED(2105);

        override fun getId(): Int = mId
    }
+48 −9
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import android.view.View.LAYOUT_DIRECTION_RTL
import com.android.window.flags.Flags
import com.android.wm.shell.R
import com.android.wm.shell.desktopmode.CaptionState
import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger
import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger.DesktopUiEventEnum
import com.android.wm.shell.desktopmode.WindowDecorCaptionHandleRepository
import com.android.wm.shell.desktopmode.education.data.AppHandleEducationDatastoreRepository
import com.android.wm.shell.shared.annotations.ShellBackgroundThread
@@ -62,6 +64,7 @@ class AppHandleEducationController(
    private val windowingEducationViewController: DesktopWindowingEducationTooltipController,
    @ShellMainThread private val applicationCoroutineScope: CoroutineScope,
    @ShellBackgroundThread private val backgroundDispatcher: MainCoroutineDispatcher,
    private val desktopModeUiEventLogger: DesktopModeUiEventLogger,
) {
    private lateinit var openHandleMenuCallback: (Int) -> Unit
    private lateinit var toDesktopModeCallback: (Int, DesktopModeTransitionSource) -> Unit
@@ -171,6 +174,7 @@ class AppHandleEducationController(

    private fun showEducation(captionState: CaptionState) {
        val appHandleBounds = (captionState as CaptionState.AppHandle).globalAppHandleBounds
        val taskInfo = captionState.runningTaskInfo
        val tooltipGlobalCoordinates =
            Point(appHandleBounds.left + appHandleBounds.width() / 2, appHandleBounds.bottom)
        // Populate information important to inflate app handle education tooltip.
@@ -188,22 +192,34 @@ class AppHandleEducationController(
                arrowDirection =
                    DesktopWindowingEducationTooltipController.TooltipArrowDirection.UP,
                onEducationClickAction = {
                    openHandleMenuCallback(captionState.runningTaskInfo.taskId)
                    openHandleMenuCallback(taskInfo.taskId)
                    desktopModeUiEventLogger.log(
                        taskInfo,
                        DesktopUiEventEnum.APP_HANDLE_EDUCATION_TOOLTIP_CLICKED,
                    )
                },
                onDismissAction = {
                    // TODO: b/341320146 - Log previous tooltip was dismissed
                    desktopModeUiEventLogger.log(
                        taskInfo,
                        DesktopUiEventEnum.APP_HANDLE_EDUCATION_TOOLTIP_DISMISSED,
                    )
                },
            )

        windowingEducationViewController.showEducationTooltip(
            tooltipViewConfig = appHandleTooltipConfig,
            taskId = captionState.runningTaskInfo.taskId,
            taskId = taskInfo.taskId,
        )
        desktopModeUiEventLogger.log(
            taskInfo,
            DesktopUiEventEnum.APP_HANDLE_EDUCATION_TOOLTIP_SHOWN,
        )
    }

    /** Show tooltip that points to windowing image button in app handle menu */
    private suspend fun showWindowingImageButtonTooltip(captionState: CaptionState.AppHandle) {
        val appInfoPillHeight = getSize(R.dimen.desktop_mode_handle_menu_app_info_pill_height)
        val taskInfo = captionState.runningTaskInfo
        val windowingOptionPillHeight =
            getSize(R.dimen.desktop_mode_handle_menu_windowing_pill_height)
        val appHandleMenuWidth =
@@ -245,24 +261,36 @@ class AppHandleEducationController(
                    DesktopWindowingEducationTooltipController.TooltipArrowDirection.HORIZONTAL,
                onEducationClickAction = {
                    toDesktopModeCallback(
                        captionState.runningTaskInfo.taskId,
                        taskInfo.taskId,
                        DesktopModeTransitionSource.APP_HANDLE_MENU_BUTTON,
                    )
                    desktopModeUiEventLogger.log(
                        taskInfo,
                        DesktopUiEventEnum.ENTER_DESKTOP_MODE_EDUCATION_TOOLTIP_CLICKED,
                    )
                },
                onDismissAction = {
                    // TODO: b/341320146 - Log previous tooltip was dismissed
                    desktopModeUiEventLogger.log(
                        taskInfo,
                        DesktopUiEventEnum.ENTER_DESKTOP_MODE_EDUCATION_TOOLTIP_DISMISSED,
                    )
                },
            )

        windowingEducationViewController.showEducationTooltip(
            taskId = captionState.runningTaskInfo.taskId,
            taskId = taskInfo.taskId,
            tooltipViewConfig = windowingImageButtonTooltipConfig,
        )
        desktopModeUiEventLogger.log(
            taskInfo,
            DesktopUiEventEnum.ENTER_DESKTOP_MODE_EDUCATION_TOOLTIP_SHOWN,
        )
    }

    /** Show tooltip that points to app chip button and educates user on how to exit desktop mode */
    private suspend fun showExitWindowingTooltip(captionState: CaptionState.AppHeader) {
        val globalAppChipBounds = captionState.globalAppChipBounds
        val taskInfo = captionState.runningTaskInfo
        val tooltipGlobalCoordinates =
            Point(
                if (isRtl()) {
@@ -287,16 +315,27 @@ class AppHandleEducationController(
                arrowDirection =
                    DesktopWindowingEducationTooltipController.TooltipArrowDirection.HORIZONTAL,
                onDismissAction = {
                    // TODO: b/341320146 - Log previous tooltip was dismissed
                    desktopModeUiEventLogger.log(
                        taskInfo,
                        DesktopUiEventEnum.EXIT_DESKTOP_MODE_EDUCATION_TOOLTIP_DISMISSED,
                    )
                },
                onEducationClickAction = {
                    openHandleMenuCallback(captionState.runningTaskInfo.taskId)
                    openHandleMenuCallback(taskInfo.taskId)
                    desktopModeUiEventLogger.log(
                        taskInfo,
                        DesktopUiEventEnum.EXIT_DESKTOP_MODE_EDUCATION_TOOLTIP_CLICKED,
                    )
                },
            )
        windowingEducationViewController.showEducationTooltip(
            taskId = captionState.runningTaskInfo.taskId,
            taskId = taskInfo.taskId,
            tooltipViewConfig = exitWindowingTooltipConfig,
        )
        desktopModeUiEventLogger.log(
            taskInfo,
            DesktopUiEventEnum.EXIT_DESKTOP_MODE_EDUCATION_TOOLTIP_SHOWN,
        )
    }

    /**
+10 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ import com.android.modules.utils.testing.ExtendedMockitoRule
import com.android.window.flags.Flags
import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.desktopmode.CaptionState
import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger
import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger.DesktopUiEventEnum
import com.android.wm.shell.desktopmode.WindowDecorCaptionHandleRepository
import com.android.wm.shell.desktopmode.education.AppHandleEducationController.Companion.APP_HANDLE_EDUCATION_DELAY_MILLIS
import com.android.wm.shell.desktopmode.education.AppHandleEducationController.Companion.TOOLTIP_VISIBLE_DURATION_MILLIS
@@ -86,6 +88,7 @@ class AppHandleEducationControllerTest : ShellTestCase() {
    @Mock private lateinit var mockDataStoreRepository: AppHandleEducationDatastoreRepository
    @Mock private lateinit var mockCaptionHandleRepository: WindowDecorCaptionHandleRepository
    @Mock private lateinit var mockTooltipController: DesktopWindowingEducationTooltipController
    @Mock private lateinit var mockDesktopModeUiEventLogger: DesktopModeUiEventLogger

    @Before
    fun setUp() {
@@ -105,6 +108,7 @@ class AppHandleEducationControllerTest : ShellTestCase() {
                mockTooltipController,
                testScope.backgroundScope,
                Dispatchers.Main,
                mockDesktopModeUiEventLogger,
            )
    }

@@ -123,6 +127,8 @@ class AppHandleEducationControllerTest : ShellTestCase() {
            verify(mockTooltipController, times(1)).showEducationTooltip(any(), any())
            verify(mockDataStoreRepository, times(1))
                .updateAppHandleHintViewedTimestampMillis(eq(true))
            verify(mockDesktopModeUiEventLogger, times(1))
                .log(any(), eq(DesktopUiEventEnum.APP_HANDLE_EDUCATION_TOOLTIP_SHOWN))
        }

    @Test
@@ -155,6 +161,8 @@ class AppHandleEducationControllerTest : ShellTestCase() {
            verify(mockTooltipController, times(1)).showEducationTooltip(any(), any())
            verify(mockDataStoreRepository, times(1))
                .updateEnterDesktopModeHintViewedTimestampMillis(eq(true))
            verify(mockDesktopModeUiEventLogger, times(1))
                .log(any(), eq(DesktopUiEventEnum.ENTER_DESKTOP_MODE_EDUCATION_TOOLTIP_SHOWN))
        }

    @Test
@@ -170,6 +178,8 @@ class AppHandleEducationControllerTest : ShellTestCase() {
            verify(mockTooltipController, times(1)).showEducationTooltip(any(), any())
            verify(mockDataStoreRepository, times(1))
                .updateExitDesktopModeHintViewedTimestampMillis(eq(true))
            verify(mockDesktopModeUiEventLogger, times(1))
                .log(any(), eq(DesktopUiEventEnum.EXIT_DESKTOP_MODE_EDUCATION_TOOLTIP_SHOWN))
        }

    @Test