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

Commit 4ee37ff2 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Add support for various extension error types

Extend the required APIs so that extensions are able
to flag various types of capture errors.

Bug: 322520569
Test: Camera CTS
Change-Id: I9061268d4e6b649d8417274e8d5a78a6a75f392d
parent 2fd19818
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19311,6 +19311,7 @@ package android.hardware.camera2 {
  public abstract static class CameraExtensionSession.ExtensionCaptureCallback {
    ctor public CameraExtensionSession.ExtensionCaptureCallback();
    method public void onCaptureFailed(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest);
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") public void onCaptureFailed(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest, int);
    method public void onCaptureProcessProgressed(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest, @IntRange(from=0, to=100) int);
    method public void onCaptureProcessStarted(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest);
    method public void onCaptureResultAvailable(@NonNull android.hardware.camera2.CameraExtensionSession, @NonNull android.hardware.camera2.CaptureRequest, @NonNull android.hardware.camera2.TotalCaptureResult);
+1 −1
Original line number Diff line number Diff line
@@ -4811,7 +4811,7 @@ package android.hardware.camera2.extension {
  @FlaggedApi("com.android.internal.camera.flags.concert_mode") public static interface SessionProcessor.CaptureCallback {
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") public void onCaptureCompleted(long, int, @NonNull android.hardware.camera2.CaptureResult);
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") public void onCaptureFailed(int);
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") public void onCaptureFailed(int, int);
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") public void onCaptureProcessStarted(int);
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") public void onCaptureSequenceAborted(int);
    method @FlaggedApi("com.android.internal.camera.flags.concert_mode") public void onCaptureSequenceCompleted(int);
+31 −0
Original line number Diff line number Diff line
@@ -16,11 +16,14 @@

package android.hardware.camera2;

import android.annotation.FlaggedApi;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.hardware.camera2.utils.HashCodeHelpers;

import com.android.internal.camera.flags.Flags;

import java.util.concurrent.Executor;

/**
@@ -131,6 +134,34 @@ public abstract class CameraExtensionSession implements AutoCloseable {
            // default empty implementation
        }

        /**
         * This method is called instead of
         * {@link #onCaptureProcessStarted} when the camera device failed
         * to produce the required input for the device-specific extension. The
         * cause could be a failed camera capture request, a failed
         * capture result or dropped camera frame. More information about
         * the reason is included in the 'failure' argument.
         *
         * <p>Other requests are unaffected, and some or all image buffers
         * from the capture may have been pushed to their respective output
         * streams.</p>
         *
         * <p>The default implementation of this method does nothing.</p>
         *
         * @param session the session received during
         *                {@link StateCallback#onConfigured(CameraExtensionSession)}
         * @param request The request that was given to the CameraDevice
         * @param failure The capture failure reason
         *
         * @see #capture
         * @see #setRepeatingRequest
         */
        @FlaggedApi(Flags.FLAG_CONCERT_MODE)
        public void onCaptureFailed(@NonNull CameraExtensionSession session,
                @NonNull CaptureRequest request, @CaptureFailure.FailureReason int failure) {
            // default empty implementation
        }

        /**
         * This method is called independently of the others in
         * ExtensionCaptureCallback, when a capture sequence finishes.
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package android.hardware.camera2.extension;

import android.hardware.camera2.extension.CaptureFailure;
import android.hardware.camera2.extension.Request;
import android.hardware.camera2.impl.CameraMetadataNative;

@@ -28,4 +29,5 @@ interface ICaptureCallback
    void onCaptureSequenceAborted(int captureSequenceId);
    void onCaptureCompleted(long shutterTimestamp, int requestId, in CameraMetadataNative results);
    void onCaptureProcessProgressed(int progress);
    void onCaptureProcessFailed(int captureSequenceId, int captureFailureReason);
}
+8 −5
Original line number Diff line number Diff line
@@ -18,8 +18,10 @@ package android.hardware.camera2.extension;

import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CaptureFailure;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.impl.CameraExtensionUtils.HandlerExecutor;
@@ -132,13 +134,14 @@ public abstract class SessionProcessor {
         * This method is called instead of
         * {@link #onCaptureProcessStarted} when the camera device failed
         * to produce the required input for the device-specific
         * extension. The cause could be a failed camera capture request,
         * a failed capture result or dropped camera frame.
         * extension. The callback allows clients to be notified
         * about failure reason.
         *
         * @param captureSequenceId id of the current capture sequence
         * @param failure           The capture failure reason
         */
        @FlaggedApi(Flags.FLAG_CONCERT_MODE)
        void onCaptureFailed(int captureSequenceId);
        void onCaptureFailed(int captureSequenceId, @CaptureFailure.FailureReason int failure);

        /**
         * This method is called independently of the others in the
@@ -474,9 +477,9 @@ public abstract class SessionProcessor {
        }

        @Override
        public void onCaptureFailed(int captureSequenceId) {
        public void onCaptureFailed(int captureSequenceId, int failure) {
            try {
                mCaptureCallback.onCaptureFailed(captureSequenceId);
                mCaptureCallback.onCaptureProcessFailed(captureSequenceId, failure);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to notify capture failure start due to remote exception!");
            }
Loading