Merge "Add Power HAL changes for ADPF Timeline API" into main
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/CompositionData.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/CompositionData.aidl
new file mode 100644
index 0000000..9ab4818
--- /dev/null
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/CompositionData.aidl
@@ -0,0 +1,43 @@
+/*
+ * 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 android.hardware.power;
+@VintfStability
+parcelable CompositionData {
+  long timestampNanos;
+  long[] scheduledPresentTimestampsNanos;
+  long latchTimestampNanos;
+  android.hardware.power.FrameProducer[] producers;
+  @nullable android.hardware.power.CompositionUpdate updateData;
+  long[] outputIds;
+}
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/CompositionUpdate.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/CompositionUpdate.aidl
new file mode 100644
index 0000000..a0c4b21
--- /dev/null
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/CompositionUpdate.aidl
@@ -0,0 +1,40 @@
+/*
+ * 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 android.hardware.power;
+@VintfStability
+parcelable CompositionUpdate {
+  long timestampNanos;
+  android.hardware.power.FrameProducerUpdate[] producerUpdates;
+  long[] deadOutputIds;
+}
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/FrameProducer.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/FrameProducer.aidl
new file mode 100644
index 0000000..0d9084b
--- /dev/null
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/FrameProducer.aidl
@@ -0,0 +1,43 @@
+/*
+ * 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 android.hardware.power;
+@VintfStability
+parcelable FrameProducer {
+  long producerId;
+  int uid;
+  double fps;
+  @nullable android.hardware.power.LatchedFrameData currentlyLatchedFrame;
+  boolean cpuDeadlineMissed;
+  boolean gpuDeadlineMissed;
+}
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/FrameProducerUpdate.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/FrameProducerUpdate.aidl
new file mode 100644
index 0000000..08ea3dc
--- /dev/null
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/FrameProducerUpdate.aidl
@@ -0,0 +1,40 @@
+/*
+ * 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 android.hardware.power;
+@VintfStability
+parcelable FrameProducerUpdate {
+  long producerId;
+  boolean isDead;
+  int[] sessions;
+}
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/IPower.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/IPower.aidl
index 10456cb..a855ddd 100644
--- a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/IPower.aidl
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/IPower.aidl
@@ -48,4 +48,6 @@
   float getGpuHeadroom(in android.hardware.power.GpuHeadroomParams params);
   long getCpuHeadroomMinIntervalMillis();
   long getGpuHeadroomMinIntervalMillis();
+  oneway void sendCompositionData(in android.hardware.power.CompositionData[] data);
+  oneway void sendCompositionUpdate(in android.hardware.power.CompositionUpdate update);
 }
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/LatchedFrameData.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/LatchedFrameData.aidl
new file mode 100644
index 0000000..01ce157
--- /dev/null
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/LatchedFrameData.aidl
@@ -0,0 +1,43 @@
+/*
+ * 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 android.hardware.power;
+@VintfStability
+parcelable LatchedFrameData {
+  long frameStartTimestampNanos;
+  long intendedPresentTimestampNanos;
+  long bufferSubmissionTimestampNanos;
+  long gpuSignalTimestampNanos;
+  boolean usedGpu;
+  @nullable ParcelFileDescriptor gpuAcquireFence;
+}
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/SessionMode.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/SessionMode.aidl
index ffa790d..448dbb3 100644
--- a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/SessionMode.aidl
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/SessionMode.aidl
@@ -36,4 +36,6 @@
 enum SessionMode {
   POWER_EFFICIENCY,
   GRAPHICS_PIPELINE,
+  AUTO_CPU,
+  AUTO_GPU,
 }
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/SupportInfo.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/SupportInfo.aidl
index 85da2fc..9609169 100644
--- a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/SupportInfo.aidl
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/SupportInfo.aidl
@@ -40,4 +40,12 @@
   long sessionHints;
   long sessionModes;
   long sessionTags;
+  android.hardware.power.SupportInfo.CompositionDataSupportInfo compositionData;
+  @VintfStability
+  parcelable CompositionDataSupportInfo {
+    boolean isSupported;
+    boolean disableGpuFences;
+    int maxBatchSize;
+    boolean alwaysBatch;
+  }
 }
diff --git a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/WorkDuration.aidl b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/WorkDuration.aidl
index 45013dd..25a5350 100644
--- a/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/WorkDuration.aidl
+++ b/power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/WorkDuration.aidl
@@ -39,4 +39,5 @@
   long workPeriodStartTimestampNanos;
   long cpuDurationNanos;
   long gpuDurationNanos;
+  long intendedPresentTimestampNanos;
 }
diff --git a/power/aidl/android/hardware/power/CompositionData.aidl b/power/aidl/android/hardware/power/CompositionData.aidl
new file mode 100644
index 0000000..43c636f
--- /dev/null
+++ b/power/aidl/android/hardware/power/CompositionData.aidl
@@ -0,0 +1,75 @@
+/*
+ * 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 android.hardware.power;
+
+import android.hardware.power.CompositionUpdate;
+import android.hardware.power.FrameProducer;
+
+/**
+ * Object sent to PowerHAL once per frame during commit that contains relevant
+ * timing data for a given set of frame producers, drawing to a given set of outputs.
+ *
+ * This will generally be layer objects drawing to displays, but could also represent
+ * things like arbitrary graphics buffers drawing into network sockets. All frame
+ * producers that participated in this composition and have associated
+ * sessions will be listed under "producers".
+ *
+ * All timestamps use SYSTEM_TIME_MONOTONIC clock, at nanosecond resolution.
+ */
+@VintfStability
+parcelable CompositionData {
+    /**
+     * Timestamp for when the message was sent, useful to combine and correlate
+     * composition data with any reported info from sessions.
+     *
+     * The latchTime can be used alongside this for chronologically
+     * ordering events that happened during latching, such as frame drop.
+     */
+    long timestampNanos;
+
+    /**
+     * Scheduled presentation times for each outputId, corresponding to the outputId
+     * with the same index.
+     */
+    long[] scheduledPresentTimestampsNanos;
+
+    /**
+     * The current frame's latch time for buffers targeting its vsync, this serves
+     * as the effective frame deadline unless the frame latches with GPU unsignaled.
+     */
+    long latchTimestampNanos;
+
+    /**
+     * The set of frame producers that tried to present this vsync on these outputs,
+     * ignoring the ones without associated sessions.
+     */
+    FrameProducer[] producers;
+
+    /**
+     * Optional parcel containing information not bound to a specific frame,
+     * such as lifecycle updates. These updates can be sent along with CompositionData
+     * to minimize additional calls, when appropriate.
+     */
+    @nullable CompositionUpdate updateData;
+
+    /**
+     * A list of IDs corresponding to one or more outputs, such as displays,
+     * that are the intended recipients of this frame composition. Each output
+     * ID is guaranteed to be unique for its lifetime.
+     */
+    long[] outputIds;
+}
diff --git a/power/aidl/android/hardware/power/CompositionUpdate.aidl b/power/aidl/android/hardware/power/CompositionUpdate.aidl
new file mode 100644
index 0000000..7cd451c
--- /dev/null
+++ b/power/aidl/android/hardware/power/CompositionUpdate.aidl
@@ -0,0 +1,43 @@
+/*
+ * 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 android.hardware.power;
+
+import android.hardware.power.FrameProducerUpdate;
+
+/**
+ * An update regarding composition objects that might be sent outside of a normal
+ * sendCompositionData call, such as for lifecycle updates. This object is either
+ * attached to CompositionData or sent separately, depending on current activity
+ * and urgency.
+ */
+@VintfStability
+parcelable CompositionUpdate {
+    /**
+     * Timestamp for when the message was sent.
+     */
+    long timestampNanos;
+
+    /**
+     * Update objects for all frame producers that have changed.
+     */
+    FrameProducerUpdate[] producerUpdates;
+
+    /**
+     * The IDs of any outputs that have disconnected in the framework.
+     */
+    long[] deadOutputIds;
+}
diff --git a/power/aidl/android/hardware/power/FrameProducer.aidl b/power/aidl/android/hardware/power/FrameProducer.aidl
new file mode 100644
index 0000000..9ff77d3
--- /dev/null
+++ b/power/aidl/android/hardware/power/FrameProducer.aidl
@@ -0,0 +1,63 @@
+/*
+ * 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 android.hardware.power;
+
+import android.hardware.power.LatchedFrameData;
+
+/**
+ * Abstract unit of frame production. Frame production could be for outputs
+ * such as layers, sets of layers, serial devices, or a network connection.
+ * Frame producers are associated with one or more sessions that provide timing context
+ * and thread associations for the producer.
+ */
+@VintfStability
+parcelable FrameProducer {
+    /**
+     * ID of the producer, unique per-producer at a given time.
+     */
+    long producerId;
+
+    /**
+     * UID of the process that owns the producer.
+     */
+    int uid;
+
+    /**
+     * The framerate of the producer. This parameter will be set when SF is reasonably
+     * confident it knows what framerate of the frame producer is, and will
+     * be set to -1 in cases where SF is not sure, or it's rapidly changing.
+     */
+    double fps;
+
+    /**
+     * Info for the currently latching frame on this producer,
+     * this value will be null if the producer tried but failed to latch.
+     */
+    @nullable LatchedFrameData currentlyLatchedFrame;
+
+    /**
+     * True if SF thinks a frame tried to latch for this producer but failed because the
+     * CPU did not submit a buffer on time; currentlyLatchedFrame is null if this is true.
+     */
+    boolean cpuDeadlineMissed;
+
+    /**
+     * True if SF thinks a frame tried to latch for this producer, but failed because the
+     * GPU did not finish on time; currentlyLatchedFrame is null if this is true.
+     */
+    boolean gpuDeadlineMissed;
+}
diff --git a/power/aidl/android/hardware/power/FrameProducerUpdate.aidl b/power/aidl/android/hardware/power/FrameProducerUpdate.aidl
new file mode 100644
index 0000000..3075a8e
--- /dev/null
+++ b/power/aidl/android/hardware/power/FrameProducerUpdate.aidl
@@ -0,0 +1,45 @@
+
+/*
+ * 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 android.hardware.power;
+
+/**
+ * A single update for an individual producer object.
+ */
+@VintfStability
+parcelable FrameProducerUpdate {
+    /**
+     * The ID of the producer, guaranteed to be unique at a given time.
+     */
+    long producerId;
+
+    /**
+     * If true, this producer is no longer active and its data can be released.
+     * "sessions" will be blank in this case, as there are no more associations
+     * with this producer.
+     */
+    boolean isDead;
+
+    /**
+     * The IDs of all sessions associated with the producer, corresponding to the
+     * ID in SessionConfig returned to the framework during session creation.
+     *
+     * If an object was created without a Session ID by using an older creation
+     * method, it is not eligible to be associated to a FrameProducer.
+     */
+    int[] sessions;
+}
diff --git a/power/aidl/android/hardware/power/IPower.aidl b/power/aidl/android/hardware/power/IPower.aidl
index e2f121c..db1d93f 100644
--- a/power/aidl/android/hardware/power/IPower.aidl
+++ b/power/aidl/android/hardware/power/IPower.aidl
@@ -18,6 +18,8 @@
 
 import android.hardware.power.Boost;
 import android.hardware.power.ChannelConfig;
+import android.hardware.power.CompositionData;
+import android.hardware.power.CompositionUpdate;
 import android.hardware.power.CpuHeadroomParams;
 import android.hardware.power.GpuHeadroomParams;
 import android.hardware.power.IPowerHintSession;
@@ -152,9 +154,7 @@
      * Called to get detailed information on the support status of various PowerHAL
      * features, such as hint sessions and specific boosts.
      *
-     * @return  a SupportInfo giving detailed support information, or
-     *          EX_UNSUPPORTED_OPERATION if detailed support checking is itself
-     *          not supported.
+     * @return  a SupportInfo giving detailed support information.
      */
     SupportInfo getSupportInfo();
 
@@ -200,4 +200,22 @@
      * @throws EX_UNSUPPORTED_OPERATION if the API is unsupported.
      */
     long getGpuHeadroomMinIntervalMillis();
+
+    /**
+     * Sent to PowerHAL when there are surface-attached sessions being composed,
+     * providing FPS and frame timing data that can be used to supplement
+     * and validate timing sent via reportActual. This call can be batched,
+     * especially in the case of a steady state or low-intensity workload.
+     *
+     * @param   data The aggregated composition data object.
+     */
+    oneway void sendCompositionData(in CompositionData[] data);
+
+    /**
+     * Sent to inform the HAL about important updates outside of the normal
+     * reporting cycle, such as lifecycle updates for displays or FrameProducers.
+     *
+     * @param   update The aggregated composition update object.
+     */
+    oneway void sendCompositionUpdate(in CompositionUpdate update);
 }
diff --git a/power/aidl/android/hardware/power/LatchedFrameData.aidl b/power/aidl/android/hardware/power/LatchedFrameData.aidl
new file mode 100644
index 0000000..0642669
--- /dev/null
+++ b/power/aidl/android/hardware/power/LatchedFrameData.aidl
@@ -0,0 +1,70 @@
+/*
+ * 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 android.hardware.power;
+
+/**
+ * Frame information for a specific frame producer on a specific composition, used to
+ * provide timing information and adjust boosting or scheduling strategies for sessions
+ * associated with that producer to compensate for observed behavior.
+ *
+ * All timestamps use SYSTEM_TIME_MONOTONIC clock, at nanosecond resolution.
+ */
+@VintfStability
+parcelable LatchedFrameData {
+    /**
+     * Timestamp for the start of this frame, will be set to -1 if unknown.
+     */
+    long frameStartTimestampNanos;
+
+    /**
+     * Original, intended presentation time of the frame.
+     *
+     * This can be used along with the buffer submission timestamp to infer
+     * if the frame was supposed to present during a previous composition and got delayed.
+     *
+     * It can be compared with the "intendedPresentTimestampNanos" on WorkDurations to
+     * determine which reported duration sessions correspond with which LatchedFrameData,
+     * for sessions that use both manual reporting and have associated FrameProducers
+     */
+    long intendedPresentTimestampNanos;
+
+    /**
+     * Timestamp of buffer submission to SF from the CPU.
+     */
+    long bufferSubmissionTimestampNanos;
+
+    /**
+     * Timestamp where the GPU fence signaled, will be set to -1 if the buffer
+     * latched unsignaled or if the GPU was not used.
+     */
+    long gpuSignalTimestampNanos;
+
+    /**
+     * True if this frame used the GPU for rendering.
+     */
+    boolean usedGpu;
+
+    /**
+     * Optional GPU fence, sent only when the buffer latches unsignaled, and if
+     * sending fences is configured on the device in SupportInfo. If the updates
+     * are batched, a fence will only be sent for the most recent update.
+     *
+     * Can be used to get accurate gpu completion timestamps, and to boost if it
+     * looks like a frame might not signal before the deadline.
+     */
+    @nullable ParcelFileDescriptor gpuAcquireFence;
+}
diff --git a/power/aidl/android/hardware/power/SessionMode.aidl b/power/aidl/android/hardware/power/SessionMode.aidl
index 3d5a76f..5bd0e15 100644
--- a/power/aidl/android/hardware/power/SessionMode.aidl
+++ b/power/aidl/android/hardware/power/SessionMode.aidl
@@ -32,4 +32,20 @@
      * which will be called of higher priority in terms of CPU resources and scheduling.
      */
     GRAPHICS_PIPELINE,
+
+    /**
+     * This mode indicates that the session does not intend to report CPU timing
+     * information, and that it instead will rely entirely on information from
+     * SurfaceFlinger. This mode is only supported for sessions that have
+     * GRAPHICS_PIPELINE enabled.
+     */
+    AUTO_CPU,
+
+    /**
+     * This mode indicates that the session does not intend to report GPU timing
+     * information, and that it instead will rely entirely on information from
+     * SurfaceFlinger. This mode is only supported for sessions that have
+     * GRAPHICS_PIPELINE enabled.
+     */
+    AUTO_GPU,
 }
diff --git a/power/aidl/android/hardware/power/SupportInfo.aidl b/power/aidl/android/hardware/power/SupportInfo.aidl
index 46bcdd3..4178b3a 100644
--- a/power/aidl/android/hardware/power/SupportInfo.aidl
+++ b/power/aidl/android/hardware/power/SupportInfo.aidl
@@ -37,37 +37,73 @@
 @VintfStability
 parcelable SupportInfo {
     /**
-     * Boolean representing whether hint sessions are supported on this device
+     * Boolean representing whether hint sessions are supported on this device.
      */
     boolean usesSessions;
 
     /**
-     * The set of "Boost" enum values that are supported by this device
-     * Each bit should correspond to a value of the "Boost.aidl" enum
+     * The set of "Boost" enum values that are supported by this device,
+     * each bit should correspond to a value of the "Boost.aidl" enum.
      */
     long boosts;
 
     /**
-     * The set of "Mode" enum values that are supported by this device
-     * Each bit should correspond to a value of the "Mode.aidl" enum
+     * The set of "Mode" enum values that are supported by this device,
+     * each bit should correspond to a value of the "Mode.aidl" enum.
      */
     long modes;
 
     /**
-     * The set of "SessionHint" enum values that are supported by this device
-     * Each bit should correspond to a value of the "SessionHint.aidl" enum
+     * The set of "SessionHint" enum values that are supported by this device,
+     * each bit should correspond to a value of the "SessionHint.aidl" enum.
      */
     long sessionHints;
 
     /**
-     * The set of "SessionMode" enum values that are supported by this device
-     * Each bit should correspond to a value of the "SessionMode.aidl" enum
+     * The set of "SessionMode" enum values that are supported by this device,
+     * each bit should correspond to a value of the "SessionMode.aidl" enum.
      */
     long sessionModes;
 
     /**
-     * The set of "SessionTag" enum values that are supported by this device
-     * Each bit should correspond to a value of the "SessionTag.aidl" enum
+     * The set of "SessionTag" enum values that are supported by this device,
+     * each bit should correspond to a value of the "SessionTag.aidl" enum.
      */
     long sessionTags;
+
+    /**
+     * Parcel detailing support info for receiving additional frame composition
+     * data when sessions are associated with frame producers.
+     */
+    CompositionDataSupportInfo compositionData;
+
+    @VintfStability
+    parcelable CompositionDataSupportInfo {
+        /**
+         * Whether the sendCompositionData and sendCompositionUpdate APIs are
+         * supported on this device. The rest of the fields on this parcelable
+         * are ignored if this is false.
+         */
+        boolean isSupported;
+
+        /**
+         * Whether to disable sending relevant GPU fence file descriptors along with
+         * timing information when the frame callback happens.
+         */
+        boolean disableGpuFences;
+
+        /**
+         * The maximum number of updates to batch before sending. This can be ignored
+         * if "overrideIfUrgent" is set. Setting to a value less than or equal to 1
+         * disables batching entirely.
+         */
+        int maxBatchSize;
+
+        /**
+         * Whether to ignore important notifications such as FPS changes and frame
+         * deadline misses, and always send maximum size batches. By default, the
+         * framework will send batches early if these important events happen.
+         */
+        boolean alwaysBatch;
+    }
 }
diff --git a/power/aidl/android/hardware/power/WorkDuration.aidl b/power/aidl/android/hardware/power/WorkDuration.aidl
index fcd638b..bcf279a 100644
--- a/power/aidl/android/hardware/power/WorkDuration.aidl
+++ b/power/aidl/android/hardware/power/WorkDuration.aidl
@@ -19,7 +19,7 @@
 @VintfStability
 parcelable WorkDuration {
     /**
-     * Time stamp in nanoseconds based on CLOCK_MONOTONIC when the duration
+     * Timestamp in nanoseconds based on CLOCK_MONOTONIC when the duration
      * sample was measured.
      */
     long timeStampNanos;
@@ -49,4 +49,21 @@
      * SDK/NDK reportActualWorkDuration API.
      */
     long gpuDurationNanos;
+
+    /**
+     * Timestamp indicating the approximate time when this frame is intended to
+     * present by the app, and will be required for all sessions associated with
+     * frame producers. This should always be provided if the session is associated
+     * with a pipeline, even if it is not using the GRAPHICS_PIPELINE mode.
+     *
+     * This timestamp is intended to be used for correlating CompositionData timing
+     * information with reported WorkDurations from apps. WorkDurations for
+     * sessions associated with a frame producers, without a reasonable value set
+     * for this field should be discarded.
+     *
+     * Intended vsync times can be inferred or retrieved from Choreographer callbacks.
+     * While this timestamp is not required to be perfectly accurate, it should
+     * roughly correspond with an expected vsync time, and should be discarded otherwise.
+     */
+    long intendedPresentTimestampNanos;
 }
diff --git a/power/aidl/default/Power.cpp b/power/aidl/default/Power.cpp
index 1fc0a0a..d9353fe 100644
--- a/power/aidl/default/Power.cpp
+++ b/power/aidl/default/Power.cpp
@@ -33,6 +33,8 @@
 using ::aidl::android::hardware::common::fmq::MQDescriptor;
 using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
 using ::aidl::android::hardware::power::ChannelMessage;
+using ::aidl::android::hardware::power::CompositionData;
+using ::aidl::android::hardware::power::CompositionUpdate;
 using ::android::AidlMessageQueue;
 
 using ndk::ScopedAStatus;
@@ -142,19 +144,33 @@
 }
 
 ndk::ScopedAStatus Power::getSupportInfo(SupportInfo* _aidl_return) {
-    static SupportInfo supportInfo = {
-            .usesSessions = false,
-            .modes = bitsForEnum<Mode>(),
-            .boosts = bitsForEnum<Boost>(),
-            .sessionHints = 0,
-            .sessionModes = 0,
-            .sessionTags = 0,
-    };
+    static SupportInfo supportInfo = {.usesSessions = false,
+                                      .modes = bitsForEnum<Mode>(),
+                                      .boosts = bitsForEnum<Boost>(),
+                                      .sessionHints = 0,
+                                      .sessionModes = 0,
+                                      .sessionTags = 0,
+                                      .compositionData = {
+                                              .isSupported = false,
+                                              .disableGpuFences = false,
+                                              .maxBatchSize = 1,
+                                              .alwaysBatch = false,
+                                      }};
     // Copy the support object into the binder
     *_aidl_return = supportInfo;
     return ndk::ScopedAStatus::ok();
 }
 
+ndk::ScopedAStatus Power::sendCompositionData(const std::vector<CompositionData>&) {
+    LOG(INFO) << "Composition data received!";
+    return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus Power::sendCompositionUpdate(const CompositionUpdate&) {
+    LOG(INFO) << "Composition update received!";
+    return ndk::ScopedAStatus::ok();
+}
+
 }  // namespace example
 }  // namespace impl
 }  // namespace power
diff --git a/power/aidl/default/Power.h b/power/aidl/default/Power.h
index a77a514..51528c6 100644
--- a/power/aidl/default/Power.h
+++ b/power/aidl/default/Power.h
@@ -51,6 +51,8 @@
                                       float* _aidl_return) override;
     ndk::ScopedAStatus getCpuHeadroomMinIntervalMillis(int64_t* _aidl_return) override;
     ndk::ScopedAStatus getGpuHeadroomMinIntervalMillis(int64_t* _aidl_return) override;
+    ndk::ScopedAStatus sendCompositionData(const std::vector<CompositionData>& in_data) override;
+    ndk::ScopedAStatus sendCompositionUpdate(const CompositionUpdate& in_update) override;
 
   private:
     std::vector<std::shared_ptr<IPowerHintSession>> mPowerHintSessions;
diff --git a/power/aidl/vts/VtsHalPowerTargetTest.cpp b/power/aidl/vts/VtsHalPowerTargetTest.cpp
index 5e3ddd5..0df360a 100644
--- a/power/aidl/vts/VtsHalPowerTargetTest.cpp
+++ b/power/aidl/vts/VtsHalPowerTargetTest.cpp
@@ -36,6 +36,8 @@
 namespace aidl::android::hardware::power {
 namespace {
 
+using namespace std::chrono_literals;
+
 using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
 using ::android::AidlMessageQueue;
 using ::android::hardware::EventFlag;
@@ -137,7 +139,11 @@
         power = IPower::fromBinder(ndk::SpAIBinder(binder));
         auto status = power->getInterfaceVersion(&mServiceVersion);
         ASSERT_TRUE(status.isOk());
-        if (mServiceVersion >= 2) {
+        if (mServiceVersion >= 6) {
+            mSupportInfo = std::make_optional<SupportInfo>();
+            ASSERT_TRUE(power->getSupportInfo(&(*mSupportInfo)).isOk());
+            mSessionSupport = mSupportInfo->usesSessions;
+        } else if (mServiceVersion >= 2) {
             status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &mSession);
             mSessionSupport = status.isOk();
         }
@@ -147,6 +153,7 @@
     int32_t mServiceVersion;
     std::shared_ptr<IPowerHintSession> mSession;
     bool mSessionSupport = false;
+    std::optional<SupportInfo> mSupportInfo = std::nullopt;
 };
 
 class HintSessionAidl : public PowerAidl {
@@ -341,20 +348,49 @@
 }
 
 TEST_P(PowerAidl, hasSupportInfo) {
-    SupportInfo config;
-    ASSERT_TRUE(power->getSupportInfo(&config).isOk());
+    if (mServiceVersion < 6) {
+        GTEST_SKIP() << "DEVICE not launching with Power V6 and beyond.";
+    }
+    ASSERT_TRUE(mSupportInfo.has_value());
     for (Mode mode : kModes) {
         bool supported;
         power->isModeSupported(mode, &supported);
-        ASSERT_EQ(supported, supportFromBitset(config.modes, mode));
+        ASSERT_EQ(supported, supportFromBitset(mSupportInfo->modes, mode));
     }
     for (Boost boost : kBoosts) {
         bool supported;
         power->isBoostSupported(boost, &supported);
-        ASSERT_EQ(supported, supportFromBitset(config.boosts, boost));
+        ASSERT_EQ(supported, supportFromBitset(mSupportInfo->boosts, boost));
     }
 }
 
+TEST_P(PowerAidl, receivesCompositionData) {
+    if (mServiceVersion < 6) {
+        GTEST_SKIP() << "DEVICE not launching with Power V6 and beyond.";
+    }
+    if (mSupportInfo->compositionData.isSupported) {
+        GTEST_SKIP() << "Composition data marked as unsupported.";
+    }
+    // Sending an empty object is fine, we just want to confirm it accepts the tx
+    std::vector<CompositionData> out{};
+    out.emplace_back();
+    auto status = power->sendCompositionData(out);
+    ASSERT_TRUE(status.isOk());
+}
+
+TEST_P(PowerAidl, receivesCompositionUpdate) {
+    if (mServiceVersion < 6) {
+        GTEST_SKIP() << "DEVICE not launching with Power V6 and beyond.";
+    }
+    if (mSupportInfo->compositionData.isSupported) {
+        GTEST_SKIP() << "Composition data marked as unsupported.";
+    }
+
+    CompositionUpdate out{};
+    auto status = power->sendCompositionUpdate(out);
+    ASSERT_TRUE(status.isOk());
+}
+
 TEST_P(HintSessionAidl, createAndCloseHintSession) {
     if (!mSessionSupport) {
         GTEST_SKIP() << "DEVICE not support Hint Session.";