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

Commit 2d5bbe4b authored by Shuzhen Wang's avatar Shuzhen Wang
Browse files

Camera2: Add API to expose all physical camera metadata

Give the app ability to query all the physical camera's physical
metadata within TotalCaptureResult.

With this new API, getPhysicalCameraKey becomes redundant.

Test: Camera ITS for logical multi-camera
Bug: 66697407
Change-Id: I4a0cbc81bef705e870f7e4ec79dc3481f9e87ae6
parent 1124724c
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -11616,15 +11616,15 @@ package android.content.res {
  public final class AssetManager implements java.lang.AutoCloseable {
    method public void close();
    method public final java.lang.String[] getLocales();
    method public final java.lang.String[] list(java.lang.String) throws java.io.IOException;
    method public final java.io.InputStream open(java.lang.String) throws java.io.IOException;
    method public final java.io.InputStream open(java.lang.String, int) throws java.io.IOException;
    method public final android.content.res.AssetFileDescriptor openFd(java.lang.String) throws java.io.IOException;
    method public final android.content.res.AssetFileDescriptor openNonAssetFd(java.lang.String) throws java.io.IOException;
    method public final android.content.res.AssetFileDescriptor openNonAssetFd(int, java.lang.String) throws java.io.IOException;
    method public final android.content.res.XmlResourceParser openXmlResourceParser(java.lang.String) throws java.io.IOException;
    method public final android.content.res.XmlResourceParser openXmlResourceParser(int, java.lang.String) throws java.io.IOException;
    method public java.lang.String[] getLocales();
    method public java.lang.String[] list(java.lang.String) throws java.io.IOException;
    method public java.io.InputStream open(java.lang.String) throws java.io.IOException;
    method public java.io.InputStream open(java.lang.String, int) throws java.io.IOException;
    method public android.content.res.AssetFileDescriptor openFd(java.lang.String) throws java.io.IOException;
    method public android.content.res.AssetFileDescriptor openNonAssetFd(java.lang.String) throws java.io.IOException;
    method public android.content.res.AssetFileDescriptor openNonAssetFd(int, java.lang.String) throws java.io.IOException;
    method public android.content.res.XmlResourceParser openXmlResourceParser(java.lang.String) throws java.io.IOException;
    method public android.content.res.XmlResourceParser openXmlResourceParser(int, java.lang.String) throws java.io.IOException;
    field public static final int ACCESS_BUFFER = 3; // 0x3
    field public static final int ACCESS_RANDOM = 1; // 0x1
    field public static final int ACCESS_STREAMING = 2; // 0x2
@@ -16294,7 +16294,7 @@ package android.hardware.camera2 {
  public final class TotalCaptureResult extends android.hardware.camera2.CaptureResult {
    method public java.util.List<android.hardware.camera2.CaptureResult> getPartialResults();
    method public <T> T getPhysicalCameraKey(android.hardware.camera2.CaptureResult.Key<T>, java.lang.String);
    method public java.util.Map<java.lang.String, android.hardware.camera2.CaptureResult> getPhysicalCameraResults();
  }
}
+20 −34
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.hardware.camera2;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.hardware.camera2.impl.CameraMetadataNative;
import android.hardware.camera2.impl.CaptureResultExtras;
import android.hardware.camera2.impl.PhysicalCaptureResultInfo;
@@ -26,6 +25,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>The total assembled results of a single image capture from the image sensor.</p>
@@ -49,9 +49,9 @@ import java.util.List;
 *
 * <p>For a logical multi-camera device, if the CaptureRequest contains a surface for an underlying
 * physical camera, the corresponding {@link TotalCaptureResult} object will include the metadata
 * for that physical camera. And its keys and values can be accessed by
 * {@link #getPhysicalCameraKey}. If all requested surfaces are for the logical camera, no
 * metadata for physical camera will be included.</p>
 * for that physical camera. And the mapping between the physical camera id and result metadata
 * can be accessed via {@link #getPhysicalCameraResults}. If all requested surfaces are for the
 * logical camera, no metadata for physical camera will be included.</p>
 *
 * <p>{@link TotalCaptureResult} objects are immutable.</p>
 *
@@ -62,7 +62,7 @@ public final class TotalCaptureResult extends CaptureResult {
    private final List<CaptureResult> mPartialResults;
    private final int mSessionId;
    // The map between physical camera id and capture result
    private final HashMap<String, CameraMetadataNative> mPhysicalCaptureResults;
    private final HashMap<String, CaptureResult> mPhysicalCaptureResults;

    /**
     * Takes ownership of the passed-in camera metadata and the partial results
@@ -83,10 +83,12 @@ public final class TotalCaptureResult extends CaptureResult {

        mSessionId = sessionId;

        mPhysicalCaptureResults = new HashMap<String, CameraMetadataNative>();
        mPhysicalCaptureResults = new HashMap<String, CaptureResult>();
        for (PhysicalCaptureResultInfo onePhysicalResult : physicalResults) {
            CaptureResult physicalResult = new CaptureResult(
                    onePhysicalResult.getCameraMetadata(), parent, extras);
            mPhysicalCaptureResults.put(onePhysicalResult.getCameraId(),
                    onePhysicalResult.getCameraMetadata());
                    physicalResult);
        }
    }

@@ -101,7 +103,7 @@ public final class TotalCaptureResult extends CaptureResult {

        mPartialResults = new ArrayList<>();
        mSessionId = CameraCaptureSession.SESSION_ID_NONE;
        mPhysicalCaptureResults = new HashMap<String, CameraMetadataNative>();
        mPhysicalCaptureResults = new HashMap<String, CaptureResult>();
    }

    /**
@@ -132,36 +134,20 @@ public final class TotalCaptureResult extends CaptureResult {
    }

    /**
     * Get a capture result field value for a particular physical camera id.
     * Get the map between physical camera ids and their capture result metadata
     *
     * <p>The field definitions can be found in {@link CaptureResult}.</p>
     *
     * <p>This function can be called for logical camera devices, which are devices that have
     * <p>This function can be called for logical multi-camera devices, which are devices that have
     * REQUEST_AVAILABLE_CAPABILITIES_LOGICAL_MULTI_CAMERA capability and calls to {@link
     * CameraCharacteristics#getPhysicalCameraIds} return a non-empty list of physical devices that
     * are backing the logical camera. The camera id included in physicalCameraId argument
     * selects an individual physical device, and returns its specific capture result field.</p>
     *
     * <p>This function should only be called if one or more streams from the underlying
     * 'physicalCameraId' was requested by the corresponding capture request.</p>
     *
     * @throws IllegalArgumentException if the key was not valid, or the physicalCameraId is not
     * applicable to the current camera, or a stream from 'physicalCameraId' is not requested by the
     * corresponding capture request.
     *
     * @param key The result field to read.
     * @param physicalCameraId The physical camera the result originates from.
     * are backing the logical camera.</p>
     *
     * @return The value of that key, or {@code null} if the field is not set.
     */
    @Nullable
    public <T> T getPhysicalCameraKey(Key<T> key, @NonNull String physicalCameraId) {
        if (!mPhysicalCaptureResults.containsKey(physicalCameraId)) {
            throw new IllegalArgumentException(
                    "No TotalCaptureResult exists for physical camera " + physicalCameraId);
        }
     * <p>If one or more streams from the underlying physical cameras were requested by the
     * corresponding capture request, this function returns the result metadata for those physical
     * cameras. Otherwise, an empty map is returned.</p>

        CameraMetadataNative physicalMetadata = mPhysicalCaptureResults.get(physicalCameraId);
        return physicalMetadata.get(key);
     * @return unmodifiable map between physical camera ids and their capture result metadata
     */
    public Map<String, CaptureResult> getPhysicalCameraResults() {
        return Collections.unmodifiableMap(mPhysicalCaptureResults);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -368,7 +368,7 @@ public final class OutputConfiguration implements Parcelable {
     * desirable for the camera application to request streams from individual physical cameras.
     * This call achieves it by mapping the OutputConfiguration to the physical camera id.</p>
     *
     * <p>The valid physical camera id can be queried by {@link
     * <p>The valid physical camera ids can be queried by {@link
     * android.hardware.camera2.CameraCharacteristics#getPhysicalCameraIds}.
     * </p>
     *