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

Commit 771efad7 authored by Kazuki Takise's avatar Kazuki Takise
Browse files

Log restart menu appeared/clicked events

APPEARED needs to be done in AppHeaderViewHolder instead of
HandleMenu because this is where the error icon gets shown and
the user is nudged to restart the app.

For CLICKED, it should be just okay to check
isRestartMenuEnabledForDisplayMove in
ShellTaskOrganizer#onSizeCompatRestartButtonClicked() as this
corresponds to whether the app restarts from handle menu
(assuming the restart menu and button are not shown at the same
time).

Flag: com.android.window.flags.enable_restart_menu_for_connected_displays
Bug: 425818504
Test: Manually tested on Atom Tester.
Change-Id: I73b650b3b287733dc1b0ed2e46a310cd08a9f797
parent 9d463e70
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -983,7 +983,8 @@ public class ShellTaskOrganizer extends TaskOrganizer {
        if (info == null) {
            return;
        }
        logSizeCompatRestartButtonEventReported(info,
        logCompatRestartButtonEventReported(info.getTaskInfo(),
                FrameworkStatsLog.SIZE_COMPAT_RESTART_BUTTON_EVENT_REPORTED,
                FrameworkStatsLog.SIZE_COMPAT_RESTART_BUTTON_EVENT_REPORTED__EVENT__APPEARED);
    }

@@ -997,19 +998,31 @@ public class ShellTaskOrganizer extends TaskOrganizer {
        if (info == null) {
            return;
        }
        logSizeCompatRestartButtonEventReported(info,
        final RunningTaskInfo taskInfo = info.getTaskInfo();
        logCompatRestartButtonClicked(taskInfo);
        restartTaskTopActivityProcessIfVisible(taskInfo.token);
    }

    private void logCompatRestartButtonClicked(@NonNull RunningTaskInfo taskInfo) {
        if (taskInfo.appCompatTaskInfo.isRestartMenuEnabledForDisplayMove()) {
            final int type = FrameworkStatsLog
                    .DISPLAY_COMPAT_RESTART_MENU_EVENT_REPORTED__EVENT__RESTART_MENU_EVENT_CLICKED;
            logCompatRestartButtonEventReported(taskInfo,
                    FrameworkStatsLog.DISPLAY_COMPAT_RESTART_MENU_EVENT_REPORTED, type);
        } else {
            logCompatRestartButtonEventReported(taskInfo,
                    FrameworkStatsLog.SIZE_COMPAT_RESTART_BUTTON_EVENT_REPORTED,
                    FrameworkStatsLog.SIZE_COMPAT_RESTART_BUTTON_EVENT_REPORTED__EVENT__CLICKED);
        restartTaskTopActivityProcessIfVisible(info.getTaskInfo().token);
        }
    }

    private void logSizeCompatRestartButtonEventReported(@NonNull TaskAppearedInfo info,
            int event) {
        ActivityInfo topActivityInfo = info.getTaskInfo().topActivityInfo;
    private void logCompatRestartButtonEventReported(@NonNull RunningTaskInfo taskInfo, int event,
            int type) {
        ActivityInfo topActivityInfo = taskInfo.topActivityInfo;
        if (topActivityInfo == null) {
            return;
        }
        FrameworkStatsLog.write(FrameworkStatsLog.SIZE_COMPAT_RESTART_BUTTON_EVENT_REPORTED,
                topActivityInfo.applicationInfo.uid, event);
        FrameworkStatsLog.write(event, topActivityInfo.applicationInfo.uid, type);
    }

    /**
+21 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.internal.R.color.materialColorSecondaryContainer
import com.android.internal.R.color.materialColorSurfaceContainerHigh
import com.android.internal.R.color.materialColorSurfaceContainerLow
import com.android.internal.R.color.materialColorSurfaceDim
import com.android.internal.util.FrameworkStatsLog
import com.android.wm.shell.R
import com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.InputMethod
import com.android.wm.shell.desktopmode.DesktopModeUiEventLogger
@@ -456,6 +457,7 @@ class AppHeaderViewHolder(
        enableMaximizeLongClick: Boolean,
        isCaptionVisible: Boolean,
    ) {
        logDisplayCompatRestartButtonEventReported(taskInfo)
        currentTaskInfo = taskInfo
        if (DesktopModeFlags.ENABLE_THEMED_APP_HEADERS.isTrue) {
            bindDataWithThemedHeaders(
@@ -471,6 +473,25 @@ class AppHeaderViewHolder(
        }
    }

    fun logDisplayCompatRestartButtonEventReported(newTaskInfo: RunningTaskInfo) {
        val type = FrameworkStatsLog
            .DISPLAY_COMPAT_RESTART_MENU_EVENT_REPORTED__EVENT__RESTART_MENU_EVENT_APPEARED
        val prevIsRestartMenuEnabledForDisplayMove =
            if (::currentTaskInfo.isInitialized) {
                currentTaskInfo.appCompatTaskInfo.isRestartMenuEnabledForDisplayMove
            } else {
                false
            }
        if (!prevIsRestartMenuEnabledForDisplayMove
                && newTaskInfo.appCompatTaskInfo.isRestartMenuEnabledForDisplayMove
                && newTaskInfo.isFreeform) {
            FrameworkStatsLog.write(
                FrameworkStatsLog.DISPLAY_COMPAT_RESTART_MENU_EVENT_REPORTED,
                newTaskInfo.effectiveUid, type
            )
        }
    }

    private fun bindDataLegacy(
        taskInfo: RunningTaskInfo,
        hasGlobalFocus: Boolean,