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

Commit d3c86632 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

camera2: Fix backward compatibility breakage for setting metering regions.



With the new entries in sSetCommandMap, the private functions for
setting metering regions cast the input value to MeteringRegion[], which
can break some existing clients which pass in Object[] to
CameraMetadata.set(). We revert to the old behavior of letting Marshaler
handle conversion from Object[] -> MeteringRectangle[] internally.

Bug: 195095702

Test: GCA with different zoom (basic validity)
Test: ITS scene1_1
Test: Camera CTS

Change-Id: Iea372adf76d1c6f81f1c63ff2bd3553ab39f30e4
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent a0178237
Loading
Loading
Loading
Loading
+12 −9
Original line number Original line Diff line number Diff line
@@ -1720,21 +1720,21 @@ public class CameraMetadataNative implements Parcelable {
                new SetCommand() {
                new SetCommand() {
            @Override
            @Override
            public <T> void setValue(CameraMetadataNative metadata, T value) {
            public <T> void setValue(CameraMetadataNative metadata, T value) {
                metadata.setAWBRegions((MeteringRectangle[]) value);
                metadata.setAWBRegions(value);
            }
            }
        });
        });
        sSetCommandMap.put(CaptureRequest.CONTROL_AF_REGIONS.getNativeKey(),
        sSetCommandMap.put(CaptureRequest.CONTROL_AF_REGIONS.getNativeKey(),
                new SetCommand() {
                new SetCommand() {
            @Override
            @Override
            public <T> void setValue(CameraMetadataNative metadata, T value) {
            public <T> void setValue(CameraMetadataNative metadata, T value) {
                metadata.setAFRegions((MeteringRectangle[]) value);
                metadata.setAFRegions(value);
            }
            }
        });
        });
        sSetCommandMap.put(CaptureRequest.CONTROL_AE_REGIONS.getNativeKey(),
        sSetCommandMap.put(CaptureRequest.CONTROL_AE_REGIONS.getNativeKey(),
                new SetCommand() {
                new SetCommand() {
            @Override
            @Override
            public <T> void setValue(CameraMetadataNative metadata, T value) {
            public <T> void setValue(CameraMetadataNative metadata, T value) {
                metadata.setAERegions((MeteringRectangle[]) value);
                metadata.setAERegions(value);
            }
            }
        });
        });
    }
    }
@@ -1815,30 +1815,33 @@ public class CameraMetadataNative implements Parcelable {
        return true;
        return true;
    }
    }


    private <T> boolean setAFRegions(MeteringRectangle[] afRegions) {
    private <T> boolean setAFRegions(T afRegions) {
        if (afRegions == null) {
        if (afRegions == null) {
            return false;
            return false;
        }
        }
        setBase(CaptureRequest.CONTROL_AF_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AF_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AF_REGIONS, afRegions);
        // The cast to CaptureRequest.Key is needed since java does not support template
        // specialization and we need to route this method to
        // setBase(CaptureRequest.Key<T> key, T value)
        setBase((CaptureRequest.Key)CaptureRequest.CONTROL_AF_REGIONS, afRegions);
        return true;
        return true;
    }
    }


    private <T> boolean setAERegions(MeteringRectangle[] aeRegions) {
    private <T> boolean setAERegions(T aeRegions) {
        if (aeRegions == null) {
        if (aeRegions == null) {
            return false;
            return false;
        }
        }
        setBase(CaptureRequest.CONTROL_AE_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AE_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AE_REGIONS, aeRegions);
        setBase((CaptureRequest.Key)CaptureRequest.CONTROL_AE_REGIONS, aeRegions);
        return true;
        return true;
    }
    }


    private <T> boolean setAWBRegions(MeteringRectangle[] awbRegions) {
    private <T> boolean setAWBRegions(T awbRegions) {
        if (awbRegions == null) {
        if (awbRegions == null) {
            return false;
            return false;
        }
        }
        setBase(CaptureRequest.CONTROL_AWB_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AWB_REGIONS_SET, true);
        setBase(CaptureRequest.CONTROL_AWB_REGIONS, awbRegions);
        setBase((CaptureRequest.Key)CaptureRequest.CONTROL_AWB_REGIONS, awbRegions);
        return true;
        return true;
    }
    }