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

Commit e46fbb41 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera: Use map instead of 'CaptureResult' for extension callbacks

Implementations that use the extension service interface
may not be able to access and work with capture results
directly.
Modify the capture result callback so that it can accept
a map of capture result keys and values.

Bug: 325066688
Test: Camera CTS
Change-Id: I835405765cfe78159f1169f801959328a5072659
parent 72134a19
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4827,7 +4827,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 onCaptureCompleted(long, int, @NonNull java.util.Map<android.hardware.camera2.CaptureResult.Key,java.lang.Object>);
    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);
+16 −11
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ 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;
@@ -184,8 +183,8 @@ public abstract class SessionProcessor {
         *                   capture results. This is the return value of
         *                   either {@link #startRepeating} or {@link
         *                   #startMultiFrameCapture}.
         * @param results  The supported capture results. Do note
         *                  that if results 'android.jpeg.quality' and
         * @param results   Key value map of the supported capture results.
         *                  Do note that if results 'android.jpeg.quality' and
         *                  android.jpeg.orientation' are present in the
         *                  process capture input results, then the values
         *                  must also be passed as part of this callback.
@@ -195,7 +194,7 @@ public abstract class SessionProcessor {
         */
        @FlaggedApi(Flags.FLAG_CONCERT_MODE)
        void onCaptureCompleted(long shutterTimestamp, int requestId,
                @NonNull CaptureResult results);
                @NonNull Map<CaptureResult.Key, Object> results);
    }

    /**
@@ -415,7 +414,7 @@ public abstract class SessionProcessor {
        public int startRepeating(ICaptureCallback callback) throws RemoteException {
            return SessionProcessor.this.startRepeating(
                    new HandlerExecutor(new Handler(Looper.getMainLooper())),
                    new CaptureCallbackImpl(callback));
                    new CaptureCallbackImpl(callback, mVendorId));
        }

        @Override
@@ -428,7 +427,7 @@ public abstract class SessionProcessor {
                throws RemoteException {
            return SessionProcessor.this.startMultiFrameCapture(
                    new HandlerExecutor(new Handler(Looper.getMainLooper())),
                    new CaptureCallbackImpl(callback));
                    new CaptureCallbackImpl(callback, mVendorId));
        }

        @Override
@@ -441,7 +440,7 @@ public abstract class SessionProcessor {
                throws RemoteException {
            return SessionProcessor.this.startTrigger(captureRequest,
                    new HandlerExecutor(new Handler(Looper.getMainLooper())),
                    new CaptureCallbackImpl(callback));
                    new CaptureCallbackImpl(callback, mVendorId));
        }

        @Override
@@ -453,9 +452,11 @@ public abstract class SessionProcessor {

    private static final class CaptureCallbackImpl implements CaptureCallback {
        private final ICaptureCallback mCaptureCallback;
        private long mVendorId = -1;

        CaptureCallbackImpl(@NonNull ICaptureCallback cb) {
        CaptureCallbackImpl(@NonNull ICaptureCallback cb, long vendorId) {
            mCaptureCallback = cb;
            mVendorId = vendorId;
        }

        @Override
@@ -505,10 +506,14 @@ public abstract class SessionProcessor {

        @Override
        public void onCaptureCompleted(long shutterTimestamp, int requestId,
                @androidx.annotation.NonNull CaptureResult results) {
                Map<CaptureResult.Key, Object> results) {
            CameraMetadataNative captureResults = new CameraMetadataNative();
            captureResults.setVendorId(mVendorId);
            for (Map.Entry<CaptureResult.Key, Object> entry : results.entrySet()) {
                captureResults.set(entry.getKey(), entry.getValue());
            }
            try {
                mCaptureCallback.onCaptureCompleted(shutterTimestamp, requestId,
                        results.getNativeCopy());
                mCaptureCallback.onCaptureCompleted(shutterTimestamp, requestId, captureResults);
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to notify capture complete due to remote exception!");
            }