Camera: Handle abandoned output surface in encodeSessionConfiguration

The GraphicBufferProducer contained in the surface in
SessionConfiguration may become null. Check against that
to avoid NPE.

Flag: EXEMPT bugfix
Test: `atest -c -d ZoomCaptureTest --iteration=10` on cuttlefish
Bug: 351035860
Change-Id: I9563c39fe6cd59b12f16ad6cb0cafb487c1b0d28
diff --git a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
index d5e3790..85bca6f 100644
--- a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
+++ b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
@@ -268,6 +268,12 @@
             const auto& gbps = config.getGraphicBufferProducers();
             int32_t width = 0, height = 0;
             if (gbps.size() > 0) {
+                if (gbps[0] == nullptr) {
+                    ALOGE("%s: Failed to query size due to abandoned surface.",
+                            __FUNCTION__);
+                    return CameraFeatureCombinationStats::CAMERA_FEATURE_UNKNOWN;
+                }
+
                 sp<Surface> surface = new Surface(gbps[0], /*useAsync*/false);
                 ANativeWindow *anw = surface.get();