Add queryStats to IDisplay interface

Add queryStats for display telemetry usage.

Bug: 303162192
Test: build pass
Change-Id: Ie0fc75c540ac5325984c76084d40e51c2fc9fbfc
diff --git a/display/Android.bp b/display/Android.bp
index 3aa06e3..eb3dd37 100644
--- a/display/Android.bp
+++ b/display/Android.bp
@@ -106,6 +106,6 @@
         },
 
     ],
-    frozen: true,
+    frozen: false,
 
 }
diff --git a/display/aidl_api/com.google.hardware.pixel.display/current/com/google/hardware/pixel/display/DisplayStats.aidl b/display/aidl_api/com.google.hardware.pixel.display/current/com/google/hardware/pixel/display/DisplayStats.aidl
new file mode 100644
index 0000000..1d0f756
--- /dev/null
+++ b/display/aidl_api/com.google.hardware.pixel.display/current/com/google/hardware/pixel/display/DisplayStats.aidl
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+///////////////////////////////////////////////////////////////////////////////
+// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
+///////////////////////////////////////////////////////////////////////////////
+
+// This file is a snapshot of an AIDL file. Do not edit it manually. There are
+// two cases:
+// 1). this is a frozen version file - do not edit this in any case.
+// 2). this is a 'current' file. If you make a backwards compatible change to
+//     the interface (from the latest frozen version), the build system will
+//     prompt you to update this file with `m <name>-update-api`.
+//
+// You must not make a backward incompatible change to any AIDL file built
+// with the aidl_interface module type with versions property set. The module
+// type is used to build AIDL files in a way that they can be used across
+// independently updatable components of the system. If a device is shipped
+// with such a backward incompatible change, it has a high risk of breaking
+// later when a module using the interface is updated, e.g., Mainline modules.
+
+package com.google.hardware.pixel.display;
+@VintfStability
+union DisplayStats {
+  double brightnessNits;
+  int brightnessDbv;
+  int operationRate;
+  double[3] opr;
+}
diff --git a/display/aidl_api/com.google.hardware.pixel.display/current/com/google/hardware/pixel/display/IDisplay.aidl b/display/aidl_api/com.google.hardware.pixel.display/current/com/google/hardware/pixel/display/IDisplay.aidl
index e5de275..20ec725 100644
--- a/display/aidl_api/com.google.hardware.pixel.display/current/com/google/hardware/pixel/display/IDisplay.aidl
+++ b/display/aidl_api/com.google.hardware.pixel.display/current/com/google/hardware/pixel/display/IDisplay.aidl
@@ -60,4 +60,5 @@
   com.google.hardware.pixel.display.HistogramErrorCode reconfigHistogram(in IBinder token, in com.google.hardware.pixel.display.HistogramConfig histogramConfig);
   com.google.hardware.pixel.display.HistogramErrorCode unregisterHistogram(in IBinder token);
   int setFixedTe2Rate(in int rateHz);
+  @nullable com.google.hardware.pixel.display.DisplayStats queryStats(in com.google.hardware.pixel.display.DisplayStats.Tag tag);
 }
diff --git a/display/com/google/hardware/pixel/display/DisplayStats.aidl b/display/com/google/hardware/pixel/display/DisplayStats.aidl
new file mode 100644
index 0000000..2477eb6
--- /dev/null
+++ b/display/com/google/hardware/pixel/display/DisplayStats.aidl
@@ -0,0 +1,37 @@
+/*
+ * 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.google.hardware.pixel.display;
+
+@VintfStability
+union DisplayStats {
+    /**
+     * Get brightness value in nits
+     */
+    double brightnessNits;
+    /**
+     * Get brightness value in dbv
+     */
+    int brightnessDbv;
+    /**
+     * Get operation rate
+     */
+    int operationRate;
+    /**
+     * Get OPR in RGB channels as [OPR_r, OPR_g, OPR_b]
+     */
+    double[3] opr;
+}
diff --git a/display/com/google/hardware/pixel/display/IDisplay.aidl b/display/com/google/hardware/pixel/display/IDisplay.aidl
index ba38c84..709d3c7 100644
--- a/display/com/google/hardware/pixel/display/IDisplay.aidl
+++ b/display/com/google/hardware/pixel/display/IDisplay.aidl
@@ -15,17 +15,18 @@
  */
 
 package com.google.hardware.pixel.display;
+import android.hardware.common.NativeHandle;
+import android.hardware.graphics.common.Rect;
+import com.google.hardware.pixel.display.DisplayStats;
+import com.google.hardware.pixel.display.HbmState;
 import com.google.hardware.pixel.display.HistogramCapability;
 import com.google.hardware.pixel.display.HistogramConfig;
 import com.google.hardware.pixel.display.HistogramErrorCode;
-import com.google.hardware.pixel.display.HbmState;
-import com.google.hardware.pixel.display.LbeState;
-import com.google.hardware.pixel.display.Weight;
 import com.google.hardware.pixel.display.HistogramPos;
+import com.google.hardware.pixel.display.LbeState;
 import com.google.hardware.pixel.display.PanelCalibrationStatus;
 import com.google.hardware.pixel.display.Priority;
-import android.hardware.common.NativeHandle;
-import android.hardware.graphics.common.Rect;
+import com.google.hardware.pixel.display.Weight;
 
 @VintfStability
 interface IDisplay {
@@ -169,7 +170,7 @@
      *                                             queryHistogram)
      */
     HistogramErrorCode histogramSample(in Rect roi, in Weight weight, in HistogramPos pos,
-                                       in Priority pri, out char[] histogrambuffer);
+            in Priority pri, out char[] histogrambuffer);
 
     /**
      * Get the panel calibration status.
@@ -178,8 +179,7 @@
      */
     PanelCalibrationStatus getPanelCalibrationStatus();
 
-
-   /**
+    /**
      * Query Dim Brightness Mode Supported. The dim brightness is a lower minimum brightness,
      * which is not listed in the brightness table. This API is to query whether the dim
      * brightness mode is supported or not.
@@ -310,4 +310,14 @@
      * @return errno if there was a problem with the request, zero if successful
      */
     int setFixedTe2Rate(in int rateHz);
+
+    /**
+     * Query display internal states from HWC.
+     *
+     * @param tag               Identifier to look up for value.
+     * @return                  An union object, data type is based on tag. Please check
+     *                          DisplayStats.aidl for list of supported fields.
+     *                          NULL, upon failure.
+     */
+    @nullable DisplayStats queryStats(in DisplayStats.Tag tag);
 }