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

Commit afebeabb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Camera: Pass physical camera device id during errors"

parents b51fda1b d0e96e3a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17058,6 +17058,7 @@ package android.hardware.camera2 {
  public class CaptureFailure {
    method public long getFrameNumber();
    method @Nullable public String getPhysicalCameraId();
    method public int getReason();
    method @NonNull public android.hardware.camera2.CaptureRequest getRequest();
    method public int getSequenceId();
+17 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package android.hardware.camera2;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -61,17 +62,19 @@ public class CaptureFailure {
    private final boolean mDropped;
    private final int mSequenceId;
    private final long mFrameNumber;
    private final String mErrorPhysicalCameraId;

    /**
     * @hide
     */
    public CaptureFailure(CaptureRequest request, int reason,
            boolean dropped, int sequenceId, long frameNumber) {
            boolean dropped, int sequenceId, long frameNumber, String errorPhysicalCameraId) {
        mRequest = request;
        mReason = reason;
        mDropped = dropped;
        mSequenceId = sequenceId;
        mFrameNumber = frameNumber;
        mErrorPhysicalCameraId = errorPhysicalCameraId;
    }

    /**
@@ -155,4 +158,17 @@ public class CaptureFailure {
    public int getSequenceId() {
        return mSequenceId;
    }

    /**
     * The physical camera device ID in case the capture failure comes from a {@link CaptureRequest}
     * with configured physical camera streams for a logical camera.
     *
     * @return String The physical camera device ID of the respective failing output.
     *         {@code null} in case the capture request has no associated physical camera device.
     * @see CaptureRequest.Builder#setPhysicalCameraKey
     * @see android.hardware.camera2.params.OutputConfiguration#setPhysicalCameraId
     */
    public @Nullable String getPhysicalCameraId() {
        return mErrorPhysicalCameraId;
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -2232,6 +2232,7 @@ public class CameraDeviceImpl extends CameraDevice
            final int requestId = resultExtras.getRequestId();
            final int subsequenceId = resultExtras.getSubsequenceId();
            final long frameNumber = resultExtras.getFrameNumber();
            final String errorPhysicalCameraId = resultExtras.getErrorPhysicalCameraId();
            final CaptureCallbackHolder holder =
                    CameraDeviceImpl.this.mCaptureCallbackMap.get(requestId);

@@ -2287,7 +2288,8 @@ public class CameraDeviceImpl extends CameraDevice
                    reason,
                    /*dropped*/ mayHaveBuffers,
                    requestId,
                    frameNumber);
                    frameNumber,
                    errorPhysicalCameraId);

                failureDispatch = new Runnable() {
                    @Override
+18 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public class CaptureResultExtras implements Parcelable {
    private long frameNumber;
    private int partialResultCount;
    private int errorStreamId;
    private String errorPhysicalCameraId;

    public static final @android.annotation.NonNull Parcelable.Creator<CaptureResultExtras> CREATOR =
            new Parcelable.Creator<CaptureResultExtras>() {
@@ -49,7 +50,8 @@ public class CaptureResultExtras implements Parcelable {

    public CaptureResultExtras(int requestId, int subsequenceId, int afTriggerId,
                               int precaptureTriggerId, long frameNumber,
                               int partialResultCount, int errorStreamId) {
                               int partialResultCount, int errorStreamId,
                               String errorPhysicalCameraId) {
        this.requestId = requestId;
        this.subsequenceId = subsequenceId;
        this.afTriggerId = afTriggerId;
@@ -57,6 +59,7 @@ public class CaptureResultExtras implements Parcelable {
        this.frameNumber = frameNumber;
        this.partialResultCount = partialResultCount;
        this.errorStreamId = errorStreamId;
        this.errorPhysicalCameraId = errorPhysicalCameraId;
    }

    @Override
@@ -73,6 +76,12 @@ public class CaptureResultExtras implements Parcelable {
        dest.writeLong(frameNumber);
        dest.writeInt(partialResultCount);
        dest.writeInt(errorStreamId);
        if ((errorPhysicalCameraId != null) && !errorPhysicalCameraId.isEmpty()) {
            dest.writeBoolean(true);
            dest.writeString(errorPhysicalCameraId);
        } else {
            dest.writeBoolean(false);
        }
    }

    public void readFromParcel(Parcel in) {
@@ -83,6 +92,14 @@ public class CaptureResultExtras implements Parcelable {
        frameNumber = in.readLong();
        partialResultCount = in.readInt();
        errorStreamId = in.readInt();
        boolean errorPhysicalCameraIdPresent = in.readBoolean();
        if (errorPhysicalCameraIdPresent) {
            errorPhysicalCameraId = in.readString();
        }
    }

    public String getErrorPhysicalCameraId() {
        return errorPhysicalCameraId;
    }

    public int getRequestId() {
+2 −2
Original line number Diff line number Diff line
@@ -109,11 +109,11 @@ public class LegacyCameraDevice implements AutoCloseable {
        }
        if (holder == null) {
            return new CaptureResultExtras(ILLEGAL_VALUE, ILLEGAL_VALUE, ILLEGAL_VALUE,
                    ILLEGAL_VALUE, ILLEGAL_VALUE, ILLEGAL_VALUE, ILLEGAL_VALUE);
                    ILLEGAL_VALUE, ILLEGAL_VALUE, ILLEGAL_VALUE, ILLEGAL_VALUE, null);
        }
        return new CaptureResultExtras(holder.getRequestId(), holder.getSubsequeceId(),
                /*afTriggerId*/0, /*precaptureTriggerId*/0, holder.getFrameNumber(),
                /*partialResultCount*/1, errorStreamId);
                /*partialResultCount*/1, errorStreamId, null);
    }

    /**