Merge "Update CPU GPU headroom HAL API" into main
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayIdentification.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayIdentification.aidl
index a0cc9b0..06f2dde 100644
--- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayIdentification.aidl
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/DisplayIdentification.aidl
@@ -36,4 +36,5 @@
 parcelable DisplayIdentification {
   byte port;
   byte[] data;
+  android.hardware.graphics.composer3.ScreenPartStatus screenPartStatus = android.hardware.graphics.composer3.ScreenPartStatus.UNSUPPORTED;
 }
diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ScreenPartStatus.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ScreenPartStatus.aidl
new file mode 100644
index 0000000..ff55370
--- /dev/null
+++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/ScreenPartStatus.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.graphics.composer3;
+@Backing(type="int") @VintfStability
+enum ScreenPartStatus {
+  UNSUPPORTED = 0,
+  ORIGINAL = 1,
+  REPLACED = 2,
+}
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayIdentification.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayIdentification.aidl
index 03ef8e6..a477eb6 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayIdentification.aidl
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/DisplayIdentification.aidl
@@ -16,6 +16,7 @@
 
 package android.hardware.graphics.composer3;
 
+import android.hardware.graphics.composer3.ScreenPartStatus;
 /**
  * Output parameters for IComposerClient.getDisplayIdentificationData
  */
@@ -29,4 +30,8 @@
      * The EDID 1.3 blob identifying the display.
      */
     byte[] data;
+    /**
+     * Indicator for part originality of the screen
+     */
+    ScreenPartStatus screenPartStatus = ScreenPartStatus.UNSUPPORTED;
 }
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/ScreenPartStatus.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/ScreenPartStatus.aidl
new file mode 100644
index 0000000..48c1270
--- /dev/null
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/ScreenPartStatus.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 android.hardware.graphics.composer3;
+
+/**
+ * Information relating to internal screen panel part originality
+ */
+@VintfStability
+@Backing(type="int")
+enum ScreenPartStatus {
+    /**
+     * Device cannot differentiate an original screen from a replaced screen.
+     */
+    UNSUPPORTED = 0,
+    /**
+     * Device has the original screen it was manufactured with.
+     */
+    ORIGINAL = 1,
+    /**
+     * Device has a replaced screen.
+     */
+    REPLACED = 2,
+}
diff --git a/vibrator/aidl/android/hardware/vibrator/CompositePwleV2.aidl b/vibrator/aidl/android/hardware/vibrator/CompositePwleV2.aidl
index 9662ca0..f0d0970 100644
--- a/vibrator/aidl/android/hardware/vibrator/CompositePwleV2.aidl
+++ b/vibrator/aidl/android/hardware/vibrator/CompositePwleV2.aidl
@@ -21,7 +21,11 @@
 @VintfStability
 parcelable CompositePwleV2 {
     /**
-     * An array of primitives that represents the PWLE effect
+     * Represents a PWLE (Piecewise-Linear Envelope) effect as an array of primitives.
+     *
+     * A PWLE effect defines a vibration waveform using amplitude and frequency points.
+     * The envelope linearly interpolates both amplitude and frequency between consecutive points,
+     * creating smooth transitions in the vibration pattern.
      */
     PwleV2Primitive[] pwlePrimitives;
 }
diff --git a/vibrator/aidl/android/hardware/vibrator/FrequencyAccelerationMapEntry.aidl b/vibrator/aidl/android/hardware/vibrator/FrequencyAccelerationMapEntry.aidl
index 470dc80..013ae84 100644
--- a/vibrator/aidl/android/hardware/vibrator/FrequencyAccelerationMapEntry.aidl
+++ b/vibrator/aidl/android/hardware/vibrator/FrequencyAccelerationMapEntry.aidl
@@ -29,7 +29,7 @@
      *
      * This value represents the maximum safe output acceleration (in Gs) achievable at the
      * specified frequency, typically determined during calibration. The actual output acceleration
-     * is assumed to scale linearly with the input amplitude within the range of [0, 1].
+     * should scale linearly based on the 'amplitude' input value.
      */
     float maxOutputAccelerationGs;
 }
diff --git a/vibrator/aidl/android/hardware/vibrator/IVibrator.aidl b/vibrator/aidl/android/hardware/vibrator/IVibrator.aidl
index a2f0017..81d7948 100644
--- a/vibrator/aidl/android/hardware/vibrator/IVibrator.aidl
+++ b/vibrator/aidl/android/hardware/vibrator/IVibrator.aidl
@@ -472,7 +472,11 @@
     int getPwleV2PrimitiveDurationMinMillis();
 
     /**
-     * Play composed sequence of chirps with optional callback upon completion.
+     * Play composed sequence of PWLEs with optional callback upon completion.
+     *
+     * A PWLE (Piecewise-Linear Envelope) effect defines a vibration waveform using amplitude and
+     * frequency points. The envelope linearly interpolates both amplitude and frequency between
+     * consecutive points, creating smooth transitions in the vibration pattern.
      *
      * This may not be supported and this support is reflected in
      * getCapabilities (CAP_COMPOSE_PWLE_EFFECTS_V2).
diff --git a/vibrator/aidl/default/VibrationSession.cpp b/vibrator/aidl/default/VibrationSession.cpp
index cfb6608..4eac831 100644
--- a/vibrator/aidl/default/VibrationSession.cpp
+++ b/vibrator/aidl/default/VibrationSession.cpp
@@ -24,7 +24,7 @@
 namespace hardware {
 namespace vibrator {
 
-static constexpr int32_t SESSION_END_DELAY_MS = 50;
+static constexpr int32_t SESSION_END_DELAY_MS = 20;
 
 ndk::ScopedAStatus VibrationSession::close() {
     LOG(VERBOSE) << "Vibration Session close";
diff --git a/wifi/aidl/default/aidl_callback_util.h b/wifi/aidl/default/aidl_callback_util.h
index 2419db9..d077683 100644
--- a/wifi/aidl/default/aidl_callback_util.h
+++ b/wifi/aidl/default/aidl_callback_util.h
@@ -26,6 +26,7 @@
 namespace {
 std::unordered_map<void* /* callback */, void* /* handler */> callback_handler_map_;
 std::mutex callback_handler_lock_;
+int32_t min_callback_version_ = INT_MAX;
 }
 
 namespace aidl {
@@ -50,6 +51,13 @@
             return false;
         }
 
+        // Callback interface version indicates which methods are available
+        int callbackVersion = getCallbackInterfaceVersion(cb);
+        if (callbackVersion < min_callback_version_) {
+            LOG(INFO) << "Setting min callback version to " << callbackVersion;
+            min_callback_version_ = callbackVersion;
+        }
+
         std::unique_lock<std::mutex> lk(callback_handler_lock_);
         void* cbPtr = reinterpret_cast<void*>(cb->asBinder().get());
         const auto& cbPosition = findCbInSet(cbPtr);
@@ -111,6 +119,8 @@
         // unique_lock unlocked here
     }
 
+    int32_t getMinCallbackVersion() { return min_callback_version_; }
+
   private:
     std::set<std::shared_ptr<CallbackType>> cb_set_;
     AIBinder_DeathRecipient* death_handler_;
@@ -145,6 +155,15 @@
         }
     }
 
+    static int32_t getCallbackInterfaceVersion(std::shared_ptr<CallbackType> callback) {
+        int32_t callbackVersion;
+        if (!callback->getInterfaceVersion(&callbackVersion).isOk()) {
+            LOG(ERROR) << "Unable to check the callback version";
+            return INT_MAX;
+        }
+        return callbackVersion;
+    }
+
     DISALLOW_COPY_AND_ASSIGN(AidlCallbackHandler);
 };
 
diff --git a/wifi/aidl/default/wifi_nan_iface.cpp b/wifi/aidl/default/wifi_nan_iface.cpp
index cefe7f7..9d50798 100644
--- a/wifi/aidl/default/wifi_nan_iface.cpp
+++ b/wifi/aidl/default/wifi_nan_iface.cpp
@@ -672,6 +672,10 @@
     return ifname_;
 }
 
+int32_t WifiNanIface::getMinCallbackVersion() {
+    return event_cb_handler_.getMinCallbackVersion();
+}
+
 std::set<std::shared_ptr<IWifiNanIfaceEventCallback>> WifiNanIface::getEventCallbacks() {
     LOG(ERROR) << "Using original getEventCallbacks";
     return event_cb_handler_.getCallbacks();
diff --git a/wifi/aidl/default/wifi_nan_iface.h b/wifi/aidl/default/wifi_nan_iface.h
index a49ae8c..d2d1d5c 100644
--- a/wifi/aidl/default/wifi_nan_iface.h
+++ b/wifi/aidl/default/wifi_nan_iface.h
@@ -134,6 +134,8 @@
     ndk::ScopedAStatus suspendRequestInternal(char16_t in_cmdId, int8_t sessionId);
     ndk::ScopedAStatus resumeRequestInternal(char16_t in_cmdId, int8_t sessionId);
 
+    int32_t getMinCallbackVersion();
+
     // Overridden in the gTest suite.
     virtual std::set<std::shared_ptr<IWifiNanIfaceEventCallback>> getEventCallbacks();