public class

AvailableKeysRetriever

extends java.lang.Object

 java.lang.Object

↳androidx.camera.extensions.internal.compat.workaround.AvailableKeysRetriever

Gradle dependencies

compile group: 'androidx.camera', name: 'camera-extensions', version: '1.5.0-alpha01'

  • groupId: androidx.camera
  • artifactId: camera-extensions
  • version: 1.5.0-alpha01

Artifact androidx.camera:camera-extensions:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

A workaround for getting the available CaptureRequest keys safely.

Summary

Constructors
publicAvailableKeysRetriever()

Default constructor.

Methods
public java.util.List<CaptureRequest.Key>getAvailableCaptureRequestKeys(ImageCaptureExtenderImpl imageCaptureExtender, java.lang.String cameraId, CameraCharacteristics cameraCharacteristics, Context context)

Get available CaptureRequest keys from the given .

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public AvailableKeysRetriever()

Default constructor.

Methods

public java.util.List<CaptureRequest.Key> getAvailableCaptureRequestKeys(ImageCaptureExtenderImpl imageCaptureExtender, java.lang.String cameraId, CameraCharacteristics cameraCharacteristics, Context context)

Get available CaptureRequest keys from the given . The cameraId, cameraCharacteristics and the context is needed for invoking onInit whenever necessary.

Source

/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.camera.extensions.internal.compat.workaround;

import android.content.Context;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CaptureRequest;

import androidx.annotation.NonNull;
import androidx.camera.extensions.impl.ImageCaptureExtenderImpl;
import androidx.camera.extensions.internal.compat.quirk.DeviceQuirks;
import androidx.camera.extensions.internal.compat.quirk.GetAvailableKeysNeedsOnInit;

import java.util.List;

/**
 * A workaround for getting the available CaptureRequest keys safely.
 */
public class AvailableKeysRetriever {
    boolean mShouldInvokeOnInit;

    /**
     * Default constructor.
     */
    public AvailableKeysRetriever() {
        mShouldInvokeOnInit = DeviceQuirks.get(GetAvailableKeysNeedsOnInit.class) != null;
    }

    /**
     * Get available CaptureRequest keys from the given {@link ImageCaptureExtenderImpl}. The
     * cameraId, cameraCharacteristics and the context is needed for invoking onInit whenever
     * necessary.
     */
    @NonNull
    public List<CaptureRequest.Key> getAvailableCaptureRequestKeys(
            @NonNull ImageCaptureExtenderImpl imageCaptureExtender,
            @NonNull String cameraId,
            @NonNull CameraCharacteristics cameraCharacteristics,
            @NonNull Context context) {
        if (mShouldInvokeOnInit) {
            imageCaptureExtender.onInit(cameraId, cameraCharacteristics, context);
        }

        try {
            return imageCaptureExtender.getAvailableCaptureRequestKeys();
        } finally {
            if (mShouldInvokeOnInit) {
                imageCaptureExtender.onDeInit();
            }
        }
    }
}