Merge "Camera: Disable surface usage caching for external surfaces" into 24D1-dev
diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
index 8c6fa8f..3cd4543 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
@@ -1030,7 +1030,8 @@
 
 status_t Camera3OutputStream::getEndpointUsageForSurface(uint64_t *usage,
         const sp<Surface>& surface) {
-    if (mConsumerUsageCachedValue.has_value() && flags::surface_ipc()) {
+    bool internalConsumer = (mConsumer.get() != nullptr) && (mConsumer == surface);
+    if (mConsumerUsageCachedValue.has_value() && flags::surface_ipc() && internalConsumer) {
         *usage = mConsumerUsageCachedValue.value();
         return OK;
     }
@@ -1039,7 +1040,9 @@
 
     res = native_window_get_consumer_usage(static_cast<ANativeWindow*>(surface.get()), usage);
     applyZSLUsageQuirk(camera_stream::format, usage);
-    mConsumerUsageCachedValue = *usage;
+    if (internalConsumer) {
+        mConsumerUsageCachedValue = *usage;
+    }
     return res;
 }