Add DeviceRotatedData pulled atom

Link to approved android metrics design doc:
https://eldar.corp.google.com/assessments/172222121/revisions/1?jsmode=du

Bug: 165063691,175241628
Test: Performed local test as described in westworld guide
Change-Id: I08ee87bcd3adcbd1c685981e78993561b6e8f3b0
diff --git a/stats/atoms.proto b/stats/atoms.proto
index 24b5617..b3f5733 100644
--- a/stats/atoms.proto
+++ b/stats/atoms.proto
@@ -62,6 +62,7 @@
 import "frameworks/proto_logging/stats/enums/stats/sysui/notification_enums.proto";
 import "frameworks/proto_logging/stats/enums/stats/tls/enums.proto";
 import "frameworks/proto_logging/stats/enums/stats/tv/tif_enums.proto";
+import "frameworks/proto_logging/stats/enums/stats/wm/enums.proto";
 import "frameworks/proto_logging/stats/enums/telecomm/enums.proto";
 import "frameworks/proto_logging/stats/enums/telephony/enums.proto";
 import "frameworks/proto_logging/stats/enums/view/enums.proto";
@@ -525,7 +526,7 @@
     }
 
     // Pulled events will start at field 10000.
-    // Next: 10097
+    // Next: 10098
     oneof pulled {
         WifiBytesTransfer wifi_bytes_transfer = 10000 [(module) = "framework"];
         WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001 [(module) = "framework"];
@@ -634,6 +635,7 @@
         ImsRegistrationStats ims_registration_stats = 10094 [(module) = "telephony"];
         CpuTimePerClusterFreq cpu_time_per_cluster_freq = 10095 [(module) = "framework"];
         CpuCyclesPerUidCluster cpu_cycles_per_uid_cluster = 10096 [(module) = "framework"];
+        DeviceRotatedData device_rotated_data = 10097 [(module) = "framework"];
     }
 
     // DO NOT USE field numbers above 100,000 in AOSP.
@@ -12643,16 +12645,44 @@
   // explicitly since data logging will follow the event logging and all these
   // will be joined with other logs such as rotation button clicked.
   optional int64 timestamp_millis = 1;
+  // Device orientation
+  optional android.stats.wm.Orientation proposed_orientation = 2;
+}
 
-  // Detected orientation
-  enum Orientation {
-    UNKNOWN = 0; // undefined during start up
-    ROTATION_0 = 1; // portrait up
-    ROTATION_90 = 2; // landscape on left
-    ROTATION_180 = 3; // portrait down
-    ROTATION_270 = 4; // landscape on right
+/**
+ * Records the raw sensor data published by the device orientation debug sensor. The pull will be
+ * configured to be conditioned on the {@code DeviceRotated} atom.
+ *
+ * Logged from:
+ *   frameworks/base/services/core/java/com/android/server/policy/WindowOrientationListener.java
+ */
+message DeviceRotatedData {
+  // All the sensor data and timestamps used to calculate the orientation
+  optional DeviceRotatedSensorData snapshot = 1 [(log_mode) = MODE_BYTES];
+  // Resulting orientation
+  optional android.stats.wm.Orientation proposed_orientation = 2;
+}
+
+message DeviceRotatedSensorData {
+  optional DeviceRotatedSensorHeader header = 1 [(log_mode) = MODE_BYTES];
+  repeated DeviceRotatedSensorSample sample = 2 [(log_mode) = MODE_BYTES];
+}
+
+message DeviceRotatedSensorHeader {
+  optional int64 timestamp_base_millis = 1;
+}
+
+message DeviceRotatedSensorSample{
+  optional int32 timestamp_offset_millis = 1;
+  enum SensorType {
+    UNKNOWN = 0;
+    ACCEL = 1;
+    GYRO = 2;
   }
-  optional Orientation proposed_orientation = 2;
+  optional SensorType sensor_type = 2;
+  optional float x_value = 3;
+  optional float y_value = 4;
+  optional float z_value = 5;
 }
 
 /**
diff --git a/stats/enums/stats/wm/enums.proto b/stats/enums/stats/wm/enums.proto
new file mode 100644
index 0000000..c6325de
--- /dev/null
+++ b/stats/enums/stats/wm/enums.proto
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2021 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";
+
+package android.stats.wm;
+
+// Orientation of a mobile device
+enum Orientation {
+  UNKNOWN = 0; // undefined during start up
+  ROTATION_0 = 1; // portrait up
+  ROTATION_90 = 2; // landscape on left
+  ROTATION_180 = 3; // portrait down
+  ROTATION_270 = 4; // landscape on right
+}