Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80a6fd4a authored by Shuzhen Wang's avatar Shuzhen Wang Committed by Android Build Coastguard Worker
Browse files

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
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5df04fca1d97be2e3a8eb665af5ca346c8c552b4)
Merged-In: I9563c39fe6cd59b12f16ad6cb0cafb487c1b0d28
Change-Id: I9563c39fe6cd59b12f16ad6cb0cafb487c1b0d28
parent 7a225582
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -268,6 +268,12 @@ int64_t CameraServiceProxyWrapper::encodeSessionConfiguration(
            const auto& gbps = config.getGraphicBufferProducers();
            const auto& gbps = config.getGraphicBufferProducers();
            int32_t width = 0, height = 0;
            int32_t width = 0, height = 0;
            if (gbps.size() > 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);
                sp<Surface> surface = new Surface(gbps[0], /*useAsync*/false);
                ANativeWindow *anw = surface.get();
                ANativeWindow *anw = surface.get();