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

Commit 84e1dc18 authored by Avichal Rakesh's avatar Avichal Rakesh
Browse files

Camera2: Add Session Characteristic keys by query version.

The current implementation of
`CameraCharacteristics#getAvailableSessionCharacteristicsKeys` just
hard codes the keys that will be supported in Android V. However, this
meant that there was no way of adding support for more keys in the future.

This CL uses AVAILABLE_SESSION_CHARACTERISTICS_KEYS_MAP which is
generated from metadata_definitions.xml to dynamically calculate the
output of getAvailableSessionCharacteristicsKeys. This allows the output
of the API to change depending on the HAL capability.

Bug: 303645857
Test: atest android.hardware.camera2.cts.CameraDeviceSetupTest passes
Change-Id: I62cdc73b18100ade705d4d91d03669273ad7ed93
parent 3fbb8193
Loading
Loading
Loading
Loading
+33 −12
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>The properties describing a
@@ -569,10 +571,23 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
    @NonNull
    @FlaggedApi(Flags.FLAG_FEATURE_COMBINATION_QUERY)
    public List<CameraCharacteristics.Key<?>> getAvailableSessionCharacteristicsKeys() {
        if (mAvailableSessionCharacteristicsKeys == null) {
            mAvailableSessionCharacteristicsKeys =
                    Arrays.asList(CONTROL_ZOOM_RATIO_RANGE, SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
        if (mAvailableSessionCharacteristicsKeys != null) {
            return mAvailableSessionCharacteristicsKeys;
        }

        Integer queryVersion = get(INFO_SESSION_CONFIGURATION_QUERY_VERSION);
        if (queryVersion == null) {
            mAvailableSessionCharacteristicsKeys = List.of();
            return mAvailableSessionCharacteristicsKeys;
        }

        mAvailableSessionCharacteristicsKeys =
                AVAILABLE_SESSION_CHARACTERISTICS_KEYS_MAP.entrySet().stream()
                        .filter(e -> e.getKey() <= queryVersion)
                        .map(Map.Entry::getValue)
                        .flatMap(Arrays::stream)
                        .collect(Collectors.toUnmodifiableList());

        return mAvailableSessionCharacteristicsKeys;
    }

@@ -6117,16 +6132,22 @@ public final class CameraCharacteristics extends CameraMetadata<CameraCharacteri
    public static final Key<android.util.Range<Float>> EFV_PADDING_ZOOM_FACTOR_RANGE =
            new Key<android.util.Range<Float>>("android.efv.paddingZoomFactorRange", new TypeReference<android.util.Range<Float>>() {{ }});


    /**
     * Mapping from INFO_SESSION_CONFIGURATION_QUERY_VERSION to session characteristics key.
     */
    private static final Map<Integer, Key<?>[]> AVAILABLE_SESSION_CHARACTERISTICS_KEYS_MAP =
            Map.ofEntries(
                Map.entry(
                    35,
                    new Key<?>[] {
                        CONTROL_ZOOM_RATIO_RANGE,
                        SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
                    }
                )
            );

    /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
     * End generated code
     *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/









}
+0 −9
Original line number Diff line number Diff line
@@ -4454,13 +4454,4 @@ public final class CaptureRequest extends CameraMetadata<CaptureRequest.Key<?>>
    /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
     * End generated code
     *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/









}
+0 −10
Original line number Diff line number Diff line
@@ -6133,14 +6133,4 @@ public class CaptureResult extends CameraMetadata<CaptureResult.Key<?>> {
    /*~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~
     * End generated code
     *~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~@~O@*/










}