From acbd7ef70f7d9f10ae7bc27eac04f3008807dc41 Mon Sep 17 00:00:00 2001 From: thiruram Date: Fri, 17 Apr 2020 19:10:49 -0700 Subject: [PATCH] Updates launcher_atom.proto to support consistent logging for launcher containers. * Updated default of some fields to invalid values. Because when these fields are not actually set on the client, the default values could lead to misinterpretations on the server side. * Refactored container messages into a separate oneof message to use it on the client side as interface. Test: Manual (make NexusLauncherDebug -j100) Bug: 144124838 Change-Id: I2d2ea05e9d7d043682d8ca1a56a238d9d22174bb --- protos/launcher_atom.proto | 46 +++++++++++-------- .../launcher3/model/data/ItemInfo.java | 18 +++++--- 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/protos/launcher_atom.proto b/protos/launcher_atom.proto index a89fe5c594..f0ecba39e8 100644 --- a/protos/launcher_atom.proto +++ b/protos/launcher_atom.proto @@ -23,9 +23,9 @@ option java_outer_classname = "LauncherAtom"; message ItemInfo { oneof Item { Application application = 1; - Task task= 2; + Task task = 2; Shortcut shortcut = 3; - Widget widget = 4; + Widget widget = 4; } // When used for launch event, stores the global predictive rank optional int32 rank = 5; @@ -34,13 +34,23 @@ message ItemInfo { optional bool is_work = 6; // Item can be child node to parent container or parent containers (nested) - oneof Container { - WorkspaceContainer workspace = 7; - HotseatContainer hotseat = 8; - FolderContainer folder = 9; - } + optional ContainerInfo container_info = 7; + // Stores the origin of the Item - optional Origin source = 10; + optional Origin source = 8; +} + +// Represents various launcher surface where items are placed. +message ContainerInfo { + oneof Container { + WorkspaceContainer workspace = 1; + HotseatContainer hotseat = 2; + FolderContainer folder = 3; + AllAppsContainer all_apps_container = 4; + } +} + +message AllAppsContainer { } enum Origin { @@ -68,8 +78,8 @@ message Shortcut { // AppWidgets handled by AppWidgetManager message Widget { - optional int32 span_x = 1; - optional int32 span_y = 2; + optional int32 span_x = 1 [default = 1]; + optional int32 span_y = 2 [default = 1]; optional int32 app_widget_id = 3; optional string package_name = 4; // only populated during snapshot if from workspace optional string component_name = 5; // only populated during snapshot if from workspace @@ -86,9 +96,9 @@ message Task { // Containers message WorkspaceContainer { - optional int32 page_index = 1; // range [-1, l], 0 is the index of the main homescreen - optional int32 grid_x = 2; // [0, m], m varies based on the display density and resolution - optional int32 grid_y = 3; // [0, n], n varies based on the display density and resolution + optional int32 page_index = 1 [default = -2]; // range [-1, l], 0 is the index of the main homescreen + optional int32 grid_x = 2 [default = -1]; // [0, m], m varies based on the display density and resolution + optional int32 grid_y = 3 [default = -1]; // [0, n], n varies based on the display density and resolution } message HotseatContainer { @@ -96,13 +106,11 @@ message HotseatContainer { } message FolderContainer { - optional int32 page_index = 1; - optional int32 grid_x = 2; - optional int32 grid_y = 3; - oneof Container { + optional int32 page_index = 1 [default = -1]; + optional int32 grid_x = 2 [default = -1]; + optional int32 grid_y = 3 [default = -1]; + oneof ParentContainer { WorkspaceContainer workspace = 4; HotseatContainer hotseat = 5; } } - - diff --git a/src/com/android/launcher3/model/data/ItemInfo.java b/src/com/android/launcher3/model/data/ItemInfo.java index 14f9a3e6d1..7ee2090c13 100644 --- a/src/com/android/launcher3/model/data/ItemInfo.java +++ b/src/com/android/launcher3/model/data/ItemInfo.java @@ -35,6 +35,7 @@ import com.android.launcher3.LauncherSettings; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.Workspace; import com.android.launcher3.logger.LauncherAtom; +import com.android.launcher3.logger.LauncherAtom.ContainerInfo; import com.android.launcher3.util.ContentWriter; import java.util.Optional; @@ -290,18 +291,21 @@ public class ItemInfo { .setGridX(fInfo.cellX).setGridY(fInfo.cellY)); break; } - itemBuilder.setFolder(folderBuilder); + itemBuilder.setContainerInfo(ContainerInfo.newBuilder().setFolder(folderBuilder)); } else { switch (container) { case CONTAINER_HOTSEAT: - itemBuilder.setHotseat(LauncherAtom.HotseatContainer.newBuilder() - .setIndex(screenId)); + itemBuilder.setContainerInfo( + ContainerInfo.newBuilder().setHotseat( + LauncherAtom.HotseatContainer.newBuilder().setIndex(screenId))); break; case CONTAINER_DESKTOP: - itemBuilder.setWorkspace(LauncherAtom.WorkspaceContainer.newBuilder() - .setGridX(cellX) - .setGridY(cellY) - .setPageIndex(screenId)); + itemBuilder.setContainerInfo( + ContainerInfo.newBuilder().setWorkspace( + LauncherAtom.WorkspaceContainer.newBuilder() + .setGridX(cellX) + .setGridY(cellY) + .setPageIndex(screenId))); break; } }