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

Commit ecb323e3 authored by Zhijun He's avatar Zhijun He
Browse files

Camera2 API: Fix missing callback issue

Callback/Listener classes must extend the AIDL Stub class and implement the
methods. Also rename the frameId to requestId to avoid confusion.

Change-Id: I1b2f0e2f99230917f9e0e1875ba3ba1c7859c805
parent 5d6e487e
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.hardware.ICameraServiceListener;
import android.hardware.IProCameraUser;
import android.hardware.camera2.utils.CameraBinderDecorator;
import android.hardware.camera2.utils.CameraRuntimeException;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -279,7 +278,7 @@ public final class CameraManager {

    // TODO: this class needs unit tests
    // TODO: extract class into top level
    private class CameraServiceListener extends Binder implements ICameraServiceListener  {
    private class CameraServiceListener extends ICameraServiceListener.Stub {

        // Keep up-to-date with ICameraServiceListener.h

+2 −2
Original line number Diff line number Diff line
@@ -25,6 +25,6 @@ interface ICameraDeviceCallbacks
     * Keep up-to-date with frameworks/av/include/camera/camera2/ICameraDeviceCallbacks.h
     */

    void notifyCallback(int msgType, int ext1, int ext2);
    void onResultReceived(int frameId, in CameraMetadata result);
    oneway void notifyCallback(int msgType, int ext1, int ext2);
    oneway void onResultReceived(int frameId, in CameraMetadata result);
}
+12 −8
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraProperties;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.utils.CameraRuntimeException;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
@@ -40,6 +39,7 @@ import java.util.Stack;
public class CameraDevice implements android.hardware.camera2.CameraDevice {

    private final String TAG;
    private final boolean DEBUG;

    // TODO: guard every function with if (!mRemoteDevice) check (if it was closed)
    private ICameraDeviceUser mRemoteDevice;
@@ -59,6 +59,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
    public CameraDevice(String cameraId) {
        mCameraId = cameraId;
        TAG = String.format("CameraDevice-%s-JV", mCameraId);
        DEBUG = Log.isLoggable(TAG, Log.DEBUG);
    }

    public CameraDeviceCallbacks getCallbacks() {
@@ -288,7 +289,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
    }

    // TODO: unit tests
    public class CameraDeviceCallbacks extends Binder implements ICameraDeviceCallbacks {
    public class CameraDeviceCallbacks extends ICameraDeviceCallbacks.Stub {

        @Override
        public IBinder asBinder() {
@@ -298,14 +299,17 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
        // TODO: consider rename to onMessageReceived
        @Override
        public void notifyCallback(int msgType, int ext1, int ext2) throws RemoteException {
            if (DEBUG) {
                Log.d(TAG, "Got message " + msgType + " ext1: " + ext1 + " , ext2: " + ext2);
            }
            // TODO implement rest
        }

        @Override
        public void onResultReceived(int frameId, CameraMetadata result) throws RemoteException {
            Log.d(TAG, "Received result for frameId " + frameId);

        public void onResultReceived(int requestId, CameraMetadata result) throws RemoteException {
            if (DEBUG) {
                Log.d(TAG, "Received result for id " + requestId);
            }
            CaptureListenerHolder holder;

            synchronized (mLock) {
@@ -313,7 +317,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
                //        exposing the methods necessary like subscribeToRequest, unsubscribe..
                // TODO: make class static class

                holder = CameraDevice.this.mCaptureListenerMap.get(frameId);
                holder = CameraDevice.this.mCaptureListenerMap.get(requestId);

                // Clean up listener once we no longer expect to see it.

@@ -321,7 +325,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
                // we probably want cancelRequest to return # of times it already enqueued and
                // keep a counter.
                if (holder != null && !holder.isRepeating()) {
                    CameraDevice.this.mCaptureListenerMap.remove(frameId);
                    CameraDevice.this.mCaptureListenerMap.remove(requestId);
                }
            }