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

Commit 02038f4d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Log various TaskView properties in TaksContainer.itemInfo" into main

parents 22f15212 09f24332
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ message ItemInfo {
    FolderIcon folder_icon = 9;
    Slice slice = 10;
    SearchActionItem search_action_item = 11;
    TaskView task_view = 15;
  }
  // When used for launch event, stores the global predictive rank
  optional int32 rank = 5;
@@ -262,6 +263,21 @@ message Task {
  optional int32 index = 3;
}

// TaskView in RecentsView.
message TaskView {
  // TaskViewType.
  optional int32 type = 1;

  // Index of TaskView in RecentsView.
  optional int32 index = 2;

  // ComponentName of the Task.
  optional string component_name = 3;

  // Number of tasks in the TaskView.
  optional int32 cardinality = 4;
}

// Represents folder in a closed state.
message FolderIcon {
  // Number of items inside folder.
+80 −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.launcher3.model.data

import android.content.Context
import android.content.Intent
import androidx.annotation.VisibleForTesting
import androidx.annotation.VisibleForTesting.Companion.PRIVATE
import com.android.launcher3.Flags.privateSpaceRestrictAccessibilityDrag
import com.android.launcher3.LauncherSettings
import com.android.launcher3.logger.LauncherAtom
import com.android.launcher3.pm.UserCache
import com.android.quickstep.TaskUtils
import com.android.quickstep.views.TaskContainer

class TaskViewItemInfo(taskContainer: TaskContainer) : WorkspaceItemInfo() {
    @VisibleForTesting(otherwise = PRIVATE) val taskViewAtom: LauncherAtom.TaskView

    init {
        itemType = LauncherSettings.Favorites.ITEM_TYPE_TASK
        container = LauncherSettings.Favorites.CONTAINER_TASKSWITCHER
        val componentKey = TaskUtils.getLaunchComponentKeyForTask(taskContainer.task.key)
        user = componentKey.user
        intent = Intent().setComponent(componentKey.componentName)
        title = taskContainer.task.title
        if (privateSpaceRestrictAccessibilityDrag()) {
            if (
                UserCache.getInstance(taskContainer.taskView.context)
                    .getUserInfo(componentKey.user)
                    .isPrivate
            ) {
                runtimeStatusFlags = runtimeStatusFlags or ItemInfoWithIcon.FLAG_NOT_PINNABLE
            }
        }

        taskViewAtom =
            createTaskViewAtom(
                type = taskContainer.taskView.type.ordinal,
                index =
                    taskContainer.taskView.recentsView?.indexOfChild(taskContainer.taskView) ?: -1,
                componentName = componentKey.componentName.flattenToShortString(),
                cardinality = taskContainer.taskView.taskContainers.size,
            )
    }

    override fun buildProto(cInfo: CollectionInfo?, context: Context): LauncherAtom.ItemInfo =
        super.buildProto(cInfo, context).toBuilder().setTaskView(taskViewAtom).build()

    companion object {
        @VisibleForTesting(otherwise = PRIVATE)
        fun createTaskViewAtom(
            type: Int,
            index: Int,
            componentName: String,
            cardinality: Int,
        ): LauncherAtom.TaskView =
            LauncherAtom.TaskView.newBuilder()
                .apply {
                    this.type = type
                    this.index = index
                    this.componentName = componentName
                    this.cardinality = cardinality
                }
                .build()
    }
}
+62 −73
Original line number Diff line number Diff line
@@ -733,48 +733,40 @@ public class StatsLogCompatManager extends StatsLogManager {
                            .getQueryLength() : -1;
                }
            default:
                return info.getFolderIcon().getCardinality();
                return switch (info.getItemCase()) {
                    case FOLDER_ICON -> info.getFolderIcon().getCardinality();
                    case TASK_VIEW -> info.getTaskView().getCardinality();
                    default -> 0;
                };
        }
    }

    private static String getPackageName(LauncherAtom.ItemInfo info) {
        switch (info.getItemCase()) {
            case APPLICATION:
                return info.getApplication().getPackageName();
            case SHORTCUT:
                return info.getShortcut().getShortcutName();
            case WIDGET:
                return info.getWidget().getPackageName();
            case TASK:
                return info.getTask().getPackageName();
            case SEARCH_ACTION_ITEM:
                return info.getSearchActionItem().getPackageName();
            default:
                return null;
        }
        return switch (info.getItemCase()) {
            case APPLICATION -> info.getApplication().getPackageName();
            case SHORTCUT -> info.getShortcut().getShortcutName();
            case WIDGET -> info.getWidget().getPackageName();
            case TASK -> info.getTask().getPackageName();
            case SEARCH_ACTION_ITEM -> info.getSearchActionItem().getPackageName();
            default -> null;
        };
    }

    private static String getComponentName(LauncherAtom.ItemInfo info) {
        switch (info.getItemCase()) {
            case APPLICATION:
                return info.getApplication().getComponentName();
            case SHORTCUT:
                return info.getShortcut().getShortcutName();
            case WIDGET:
                return info.getWidget().getComponentName();
            case TASK:
                return info.getTask().getComponentName();
            case SEARCH_ACTION_ITEM:
                return info.getSearchActionItem().getTitle();
            case SLICE:
                return info.getSlice().getUri();
            default:
                return null;
        }
        return switch (info.getItemCase()) {
            case APPLICATION -> info.getApplication().getComponentName();
            case SHORTCUT -> info.getShortcut().getShortcutName();
            case WIDGET -> info.getWidget().getComponentName();
            case TASK -> info.getTask().getComponentName();
            case TASK_VIEW -> info.getTaskView().getComponentName();
            case SEARCH_ACTION_ITEM -> info.getSearchActionItem().getTitle();
            case SLICE -> info.getSlice().getUri();
            default -> null;
        };
    }

    private static int getGridX(LauncherAtom.ItemInfo info, boolean parent) {
        LauncherAtom.ContainerInfo containerInfo = info.getContainerInfo();
        ContainerInfo containerInfo = info.getContainerInfo();
        if (containerInfo.getContainerCase() == FOLDER) {
            if (parent) {
                return containerInfo.getFolder().getWorkspace().getGridX();
@@ -802,37 +794,38 @@ public class StatsLogCompatManager extends StatsLogManager {
    }

    private static int getPageId(LauncherAtom.ItemInfo info) {
        if (info.hasTask()) {
            return info.getTask().getIndex();
        }
        switch (info.getContainerInfo().getContainerCase()) {
            case FOLDER:
                return info.getContainerInfo().getFolder().getPageIndex();
            case HOTSEAT:
                return info.getContainerInfo().getHotseat().getIndex();
            case PREDICTED_HOTSEAT_CONTAINER:
                return info.getContainerInfo().getPredictedHotseatContainer().getIndex();
            case TASK_BAR_CONTAINER:
                return info.getContainerInfo().getTaskBarContainer().getIndex();
            default:
                return info.getContainerInfo().getWorkspace().getPageIndex();
        return switch (info.getItemCase()) {
            case TASK -> info.getTask().getIndex();
            case TASK_VIEW -> info.getTaskView().getIndex();
            default -> getPageIdFromContainerInfo(info.getContainerInfo());
        };
    }

    private static int getPageIdFromContainerInfo(LauncherAtom.ContainerInfo containerInfo) {
        return switch (containerInfo.getContainerCase()) {
            case FOLDER -> containerInfo.getFolder().getPageIndex();
            case HOTSEAT -> containerInfo.getHotseat().getIndex();
            case PREDICTED_HOTSEAT_CONTAINER ->
                    containerInfo.getPredictedHotseatContainer().getIndex();
            case TASK_BAR_CONTAINER -> containerInfo.getTaskBarContainer().getIndex();
            default -> containerInfo.getWorkspace().getPageIndex();
        };
    }

    private static int getParentPageId(LauncherAtom.ItemInfo info) {
        switch (info.getContainerInfo().getContainerCase()) {
            case FOLDER:
        return switch (info.getContainerInfo().getContainerCase()) {
            case FOLDER -> {
                if (info.getContainerInfo().getFolder().getParentContainerCase()
                        == ParentContainerCase.HOTSEAT) {
                    return info.getContainerInfo().getFolder().getHotseat().getIndex();
                    yield info.getContainerInfo().getFolder().getHotseat().getIndex();
                }
                return info.getContainerInfo().getFolder().getWorkspace().getPageIndex();
            case SEARCH_RESULT_CONTAINER:
                return info.getContainerInfo().getSearchResultContainer().getWorkspace()
                        .getPageIndex();
            default:
                return info.getContainerInfo().getWorkspace().getPageIndex();
                yield info.getContainerInfo().getFolder().getWorkspace().getPageIndex();
            }
            case SEARCH_RESULT_CONTAINER ->
                    info.getContainerInfo().getSearchResultContainer().getWorkspace()
                            .getPageIndex();
            default -> info.getContainerInfo().getWorkspace().getPageIndex();
        };
    }

    private static int getHierarchy(LauncherAtom.ItemInfo info) {
@@ -857,25 +850,21 @@ public class StatsLogCompatManager extends StatsLogManager {
    }

    private static String getStateString(int state) {
        switch (state) {
            case LAUNCHER_UICHANGED__DST_STATE__BACKGROUND:
                return "BACKGROUND";
            case LAUNCHER_UICHANGED__DST_STATE__HOME:
                return "HOME";
            case LAUNCHER_UICHANGED__DST_STATE__OVERVIEW:
                return "OVERVIEW";
            case LAUNCHER_UICHANGED__DST_STATE__ALLAPPS:
                return "ALLAPPS";
            default:
                return "INVALID";
        }
        return switch (state) {
            case LAUNCHER_UICHANGED__DST_STATE__BACKGROUND -> "BACKGROUND";
            case LAUNCHER_UICHANGED__DST_STATE__HOME -> "HOME";
            case LAUNCHER_UICHANGED__DST_STATE__OVERVIEW -> "OVERVIEW";
            case LAUNCHER_UICHANGED__DST_STATE__ALLAPPS -> "ALLAPPS";
            default -> "INVALID";
        };
    }

    private static int getFeatures(LauncherAtom.ItemInfo info) {
        if (info.getItemCase().equals(LauncherAtom.ItemInfo.ItemCase.WIDGET)) {
            return info.getWidget().getWidgetFeatures();
        }
        return 0;
        return switch (info.getItemCase()) {
            case WIDGET -> info.getWidget().getWidgetFeatures();
            case TASK_VIEW -> info.getTaskView().getType();
            default -> 0;
        };
    }

    private static int getSearchAttributes(LauncherAtom.ItemInfo info) {
+3 −28
Original line number Diff line number Diff line
@@ -16,19 +16,13 @@

package com.android.quickstep.views

import android.content.Intent
import android.graphics.Bitmap
import android.view.View
import com.android.launcher3.Flags.enableRefactorTaskThumbnail
import com.android.launcher3.Flags.privateSpaceRestrictAccessibilityDrag
import com.android.launcher3.LauncherSettings
import com.android.launcher3.model.data.ItemInfoWithIcon
import com.android.launcher3.model.data.WorkspaceItemInfo
import com.android.launcher3.pm.UserCache
import com.android.launcher3.model.data.TaskViewItemInfo
import com.android.launcher3.util.SplitConfigurationOptions
import com.android.launcher3.util.TransformingTouchDelegate
import com.android.quickstep.TaskOverlayFactory
import com.android.quickstep.TaskUtils
import com.android.quickstep.ViewUtils.addAccessibleChildToList
import com.android.quickstep.recents.di.RecentsDependencies
import com.android.quickstep.recents.di.get
@@ -123,27 +117,8 @@ class TaskContainer(
            else thumbnailViewDeprecated.sysUiStatusNavFlags

    /** Builds proto for logging */
    val itemInfo: WorkspaceItemInfo
        get() =
            WorkspaceItemInfo().apply {
                itemType = LauncherSettings.Favorites.ITEM_TYPE_TASK
                container = LauncherSettings.Favorites.CONTAINER_TASKSWITCHER
                val componentKey = TaskUtils.getLaunchComponentKeyForTask(task.key)
                user = componentKey.user
                intent = Intent().setComponent(componentKey.componentName)
                title = task.title
                taskView.recentsView?.let { screenId = it.indexOfChild(taskView) }
                if (privateSpaceRestrictAccessibilityDrag()) {
                    if (
                        UserCache.getInstance(taskView.context)
                            .getUserInfo(componentKey.user)
                            .isPrivate
                    ) {
                        runtimeStatusFlags =
                            runtimeStatusFlags or ItemInfoWithIcon.FLAG_NOT_PINNABLE
                    }
                }
            }
    val itemInfo: TaskViewItemInfo
        get() = TaskViewItemInfo(this)

    fun bind() {
        digitalWellBeingToast?.bind(task, taskView, snapshotView, stagePosition)
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ constructor(
    defStyleRes: Int = 0,
    focusBorderAnimator: BorderAnimator? = null,
    hoverBorderAnimator: BorderAnimator? = null,
    private val type: TaskViewType = TaskViewType.SINGLE,
    val type: TaskViewType = TaskViewType.SINGLE,
    protected val thumbnailFullscreenParams: FullscreenDrawParams = FullscreenDrawParams(context),
) : FrameLayout(context, attrs), ViewPool.Reusable {
    /**
Loading