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

Commit aab742d7 authored by Kazuki Takise's avatar Kazuki Takise Committed by Android (Google) Code Review
Browse files

Merge "Log restart menu appeared/clicked events" into main

parents e09a0804 771efad7
Loading
Loading
Loading
Loading
+22 −9
Original line number Diff line number Diff line
@@ -984,7 +984,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);
    }

@@ -998,19 +999,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,