Define launcher_log.proto used for user event logging

b/26494415

Change-Id: I117f290bec3c2b4cbdb43dae03adafbc9cb35a00
diff --git a/protos/launcher_log.proto b/protos/launcher_log.proto
new file mode 100644
index 0000000..a7b6429
--- /dev/null
+++ b/protos/launcher_log.proto
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+syntax = "proto2";
+
+option java_package = "com.android.launcher3.userevent.nano";
+option java_outer_classname = "LauncherLogProto";
+
+package userevent;
+
+message Target {
+  enum Type {
+    NONE = 0;
+    ITEM = 1;
+    CONTROL = 2;
+    CONTAINER = 3;
+  }
+
+  optional Type type = 1;
+
+  // For container type and item type
+  // Used mainly for ContainerType.FOLDER, ItemType.*
+  optional Target parent = 2;
+  optional int32 page_index = 3;
+  optional int32 rank = 4;
+  optional int32 grid_x = 5;
+  optional int32 grid_y = 6;
+
+  // For container types only
+  optional ContainerType container_type = 7;
+  optional int32 cardinality = 8;
+
+  // For control types only
+  optional ControlType control_type = 9;
+
+  // For item types only
+  optional ItemType item_type = 10;
+  optional int32 package_name_hash = 11;
+  optional int32 component_hash = 12;      // Used for ItemType.WIDGET
+  optional int32 intent_hash = 13;         // Used for ItemType.SHORTCUT
+  optional int32 span_x = 14 [default = 1];// Used for ItemType.WIDGET
+  optional int32 span_y = 15 [default = 1];// Used for ItemType.WIDGET
+}
+
+enum ItemType {
+  APP_ICON = 0;
+  SHORTCUT = 1;
+  WIDGET = 2;
+  FOLDER_ICON = 3;
+}
+
+enum ContainerType {
+  WORKSPACE = 0;
+  HOTSEAT = 1;
+  FOLDER = 2;
+  ALLAPPS = 3;
+  WIDGETS = 4;
+  OVERVIEW = 5;
+  PREDICTION = 6;
+  SEARCHRESULT = 7;
+}
+
+enum ControlType {
+  ALL_APPS_BUTTON = 0;
+  WIDGETS_BUTTON = 1;
+  WALLPAPER_BUTTON = 2;
+  SETTINGS_BUTTON = 3;
+  REMOVE_TARGET = 4;
+  UNINSTALL_TARGET = 5;
+  APPINFO_TARGET = 6;
+  RESIZE_HANDLE = 7;
+  FAST_SCROLL_HANDLE = 8;
+  // HOME, BACK, GO_TO_PLAYSTORE
+}
+
+message Action {
+  enum Type {
+    TOUCH = 0;
+    AUTOMATED = 1;
+    // SOFT_KEYBOARD, HARD_KEYBOARD, ASSIST
+  }
+  enum Touch {
+    TAP = 0;
+    LONGPRESS = 1;
+    DRAGDROP = 2;
+    SWIPE = 3;
+    FLING = 4;
+    PINCH = 5;
+  }
+  optional Type type = 1;
+  optional Touch touch = 2;
+}
+
+//
+// Context free grammar of typical user interaction:
+//         Action (Touch) + Target
+//         Action (Touch) + Target + Target
+//
+message LauncherEvent {
+
+  required Action action = 1;
+
+  // List of targets that touch actions can be operated on.
+  optional Target src_target = 2;
+  optional Target dest_target = 3;
+
+  optional int64 action_duration_millis = 4;
+  optional int64 elapsed_container_millis = 5;
+  optional int64 elapsed_session_millis = 6;
+}