(Camera)ProCamera: Remove unused functions from binder interface

Change-Id: I0582268cef6e84b630bc87c8a03dcd69d54c440d
diff --git a/camera/Camera.cpp b/camera/Camera.cpp
index f417c90..e8908d2 100644
--- a/camera/Camera.cpp
+++ b/camera/Camera.cpp
@@ -283,7 +283,14 @@
 void Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,
                           camera_frame_metadata_t *metadata)
 {
-    return CameraBaseT::dataCallback(msgType, dataPtr, metadata);
+    sp<CameraListener> listener;
+    {
+        Mutex::Autolock _l(mLock);
+        listener = mListener;
+    }
+    if (listener != NULL) {
+        listener->postData(msgType, dataPtr, metadata);
+    }
 }
 
 // callback from camera service when timestamped frame is ready
@@ -302,7 +309,15 @@
         return;
     }
 
-    if (!CameraBaseT::dataCallbackTimestamp(timestamp, msgType, dataPtr)) {
+    sp<CameraListener> listener;
+    {
+        Mutex::Autolock _l(mLock);
+        listener = mListener;
+    }
+
+    if (listener != NULL) {
+        listener->postDataTimestamp(timestamp, msgType, dataPtr);
+    } else {
         ALOGW("No listener was set. Drop a recording frame.");
         releaseRecordingFrame(dataPtr);
     }
diff --git a/camera/CameraBase.cpp b/camera/CameraBase.cpp
index 29096da..c25c5fd 100644
--- a/camera/CameraBase.cpp
+++ b/camera/CameraBase.cpp
@@ -176,41 +176,6 @@
     }
 }
 
-// callback from camera service when frame or image is ready
-template <typename TCam, typename TCamTraits>
-void CameraBase<TCam, TCamTraits>::dataCallback(int32_t msgType,
-                                                const sp<IMemory>& dataPtr,
-                                                camera_frame_metadata *metadata)
-{
-    sp<TCamListener> listener;
-    {
-        Mutex::Autolock _l(mLock);
-        listener = mListener;
-    }
-    if (listener != NULL) {
-        listener->postData(msgType, dataPtr, metadata);
-    }
-}
-
-// callback from camera service when timestamped frame is ready
-template <typename TCam, typename TCamTraits>
-bool CameraBase<TCam, TCamTraits>::dataCallbackTimestamp(nsecs_t timestamp,
-                                                         int32_t msgType,
-                                                   const sp<IMemory>& dataPtr)
-{
-    sp<TCamListener> listener;
-    {
-        Mutex::Autolock _l(mLock);
-        listener = mListener;
-    }
-    if (listener != NULL) {
-        listener->postDataTimestamp(timestamp, msgType, dataPtr);
-        return true;
-    }
-
-    return false;
-}
-
 template <typename TCam, typename TCamTraits>
 int CameraBase<TCam, TCamTraits>::getNumberOfCameras() {
     const sp<ICameraService> cs = getCameraService();
diff --git a/camera/IProCameraCallbacks.cpp b/camera/IProCameraCallbacks.cpp
index 6cd36bf..b9cd14d 100644
--- a/camera/IProCameraCallbacks.cpp
+++ b/camera/IProCameraCallbacks.cpp
@@ -34,8 +34,6 @@
 
 enum {
     NOTIFY_CALLBACK = IBinder::FIRST_CALL_TRANSACTION,
-    DATA_CALLBACK,
-    DATA_CALLBACK_TIMESTAMP,
     LOCK_STATUS_CHANGED,
     RESULT_RECEIVED,
 };
@@ -63,37 +61,6 @@
         remote()->transact(NOTIFY_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
     }
 
-    // generic data callback from camera service to app with image data
-    void dataCallback(int32_t msgType, const sp<IMemory>& imageData,
-                      camera_frame_metadata_t *metadata)
-    {
-        ALOGV("dataCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(IProCameraCallbacks::getInterfaceDescriptor());
-        data.writeInt32(msgType);
-        data.writeStrongBinder(imageData->asBinder());
-        if (metadata) {
-            data.writeInt32(metadata->number_of_faces);
-            data.write(metadata->faces,
-                            sizeof(camera_face_t) * metadata->number_of_faces);
-        }
-        remote()->transact(DATA_CALLBACK, data, &reply, IBinder::FLAG_ONEWAY);
-    }
-
-    // generic data callback from camera service to app with image data
-    void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType,
-                                                  const sp<IMemory>& imageData)
-    {
-        ALOGV("dataCallback");
-        Parcel data, reply;
-        data.writeInterfaceToken(IProCameraCallbacks::getInterfaceDescriptor());
-        data.writeInt64(timestamp);
-        data.writeInt32(msgType);
-        data.writeStrongBinder(imageData->asBinder());
-        remote()->transact(DATA_CALLBACK_TIMESTAMP, data, &reply,
-                                                          IBinder::FLAG_ONEWAY);
-    }
-
     void onLockStatusChanged(LockStatus newLockStatus) {
         ALOGV("onLockStatusChanged");
         Parcel data, reply;
@@ -132,33 +99,6 @@
             notifyCallback(msgType, ext1, ext2);
             return NO_ERROR;
         } break;
-        case DATA_CALLBACK: {
-            ALOGV("DATA_CALLBACK");
-            CHECK_INTERFACE(IProCameraCallbacks, data, reply);
-            int32_t msgType = data.readInt32();
-            sp<IMemory> imageData = interface_cast<IMemory>(
-                                                       data.readStrongBinder());
-            camera_frame_metadata_t *metadata = NULL;
-            if (data.dataAvail() > 0) {
-                metadata = new camera_frame_metadata_t;
-                metadata->number_of_faces = data.readInt32();
-                metadata->faces = (camera_face_t *) data.readInplace(
-                        sizeof(camera_face_t) * metadata->number_of_faces);
-            }
-            dataCallback(msgType, imageData, metadata);
-            if (metadata) delete metadata;
-            return NO_ERROR;
-        } break;
-        case DATA_CALLBACK_TIMESTAMP: {
-            ALOGV("DATA_CALLBACK_TIMESTAMP");
-            CHECK_INTERFACE(IProCameraCallbacks, data, reply);
-            nsecs_t timestamp = data.readInt64();
-            int32_t msgType = data.readInt32();
-            sp<IMemory> imageData = interface_cast<IMemory>(
-                                                       data.readStrongBinder());
-            dataCallbackTimestamp(timestamp, msgType, imageData);
-            return NO_ERROR;
-        } break;
         case LOCK_STATUS_CHANGED: {
             ALOGV("LOCK_STATUS_CHANGED");
             CHECK_INTERFACE(IProCameraCallbacks, data, reply);
diff --git a/camera/IProCameraUser.cpp b/camera/IProCameraUser.cpp
index c9d98aa..0c94bd4 100644
--- a/camera/IProCameraUser.cpp
+++ b/camera/IProCameraUser.cpp
@@ -40,8 +40,7 @@
     HAS_EXCLUSIVE_LOCK,
     SUBMIT_REQUEST,
     CANCEL_REQUEST,
-    REQUEST_STREAM,
-    CANCEL_STREAM,
+    DELETE_STREAM,
     CREATE_STREAM,
     CREATE_DEFAULT_REQUEST,
     GET_CAMERA_INFO,
@@ -200,22 +199,13 @@
         return reply.readInt32();
     }
 
-    virtual status_t requestStream(int streamId)
+    virtual status_t deleteStream(int streamId)
     {
         Parcel data, reply;
         data.writeInterfaceToken(IProCameraUser::getInterfaceDescriptor());
         data.writeInt32(streamId);
 
-        remote()->transact(REQUEST_STREAM, data, &reply);
-        return reply.readInt32();
-    }
-    virtual status_t cancelStream(int streamId)
-    {
-        Parcel data, reply;
-        data.writeInterfaceToken(IProCameraUser::getInterfaceDescriptor());
-        data.writeInt32(streamId);
-
-        remote()->transact(CANCEL_STREAM, data, &reply);
+        remote()->transact(DELETE_STREAM, data, &reply);
         return reply.readInt32();
     }
 
@@ -334,16 +324,10 @@
             reply->writeInt32(cancelRequest(requestId));
             return NO_ERROR;
         } break;
-        case REQUEST_STREAM: {
+        case DELETE_STREAM: {
             CHECK_INTERFACE(IProCameraUser, data, reply);
             int streamId = data.readInt32();
-            reply->writeInt32(requestStream(streamId));
-            return NO_ERROR;
-        } break;
-        case CANCEL_STREAM: {
-            CHECK_INTERFACE(IProCameraUser, data, reply);
-            int streamId = data.readInt32();
-            reply->writeInt32(cancelStream(streamId));
+            reply->writeInt32(deleteStream(streamId));
             return NO_ERROR;
         } break;
         case CREATE_STREAM: {
diff --git a/camera/ProCamera.cpp b/camera/ProCamera.cpp
index 3cfabf6..396b009 100644
--- a/camera/ProCamera.cpp
+++ b/camera/ProCamera.cpp
@@ -60,21 +60,6 @@
     return CameraBaseT::notifyCallback(msgType, ext1, ext2);
 }
 
-// callback from camera service when frame or image is ready
-void ProCamera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,
-                          camera_frame_metadata_t *metadata)
-{
-    return CameraBaseT::dataCallback(msgType, dataPtr, metadata);
-}
-
-// callback from camera service when timestamped frame is ready
-void ProCamera::dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType,
-                                   const sp<IMemory>& dataPtr)
-{
-    CameraBaseT::dataCallbackTimestamp(timestamp, msgType, dataPtr);
-}
-
-
 void ProCamera::onLockStatusChanged(
                                  IProCameraCallbacks::LockStatus newLockStatus)
 {
@@ -185,7 +170,7 @@
     sp <IProCameraUser> c = mCamera;
     if (c == 0) return NO_INIT;
 
-    status_t s = c->cancelStream(streamId);
+    status_t s = c->deleteStream(streamId);
 
     mStreams.removeItem(streamId);
 
@@ -330,10 +315,7 @@
     CpuConsumer::LockedBuffer buf;
 
     if (listener.get() != NULL) {
-        if (listener->useOnFrameAvailable()) {
-            listener->onFrameAvailable(streamId, stream.cpuConsumer);
-            return;
-        }
+        listener->onFrameAvailable(streamId, stream.cpuConsumer);
     }
 
     // Unblock waitForFrame(id) callers
diff --git a/camera/tests/ProCameraTests.cpp b/camera/tests/ProCameraTests.cpp
index 1a8564e..71813ae 100644
--- a/camera/tests/ProCameraTests.cpp
+++ b/camera/tests/ProCameraTests.cpp
@@ -271,13 +271,11 @@
         free_camera_metadata(request);
     }
 
-    // TODO: remove
-
-    virtual void notify(int32_t , int32_t , int32_t ) {}
-    virtual void postData(int32_t , const sp<IMemory>& ,
-                          camera_frame_metadata_t *) {}
-    virtual void postDataTimestamp(nsecs_t , int32_t , const sp<IMemory>& ) {}
-
+    virtual void notify(int32_t msg, int32_t ext1, int32_t ext2) {
+        dout << "Notify received: msg " << std::hex << msg
+             << ", ext1: " << std::hex << ext1 << ", ext2: " << std::hex << ext2
+             << std::endl;
+    }
 
     Vector<ProEvent> mProEventList;
     Mutex             mListenerMutex;
@@ -717,6 +715,7 @@
         return;
     }
 
+    // FIXME: Note this test is broken because onBufferReceived was removed
     mListener->SetEventMask(ProEvent_Mask(BUFFER_RECEIVED));
 
     int streamId = -1;
@@ -783,6 +782,7 @@
         return;
     }
 
+    // FIXME: Note this test is broken because onBufferReceived was removed
     mListener->SetEventMask(ProEvent_Mask(BUFFER_RECEIVED));
 
     int streamId = -1;
diff --git a/include/camera/CameraBase.h b/include/camera/CameraBase.h
index 2735a86..9b08c0f 100644
--- a/include/camera/CameraBase.h
+++ b/include/camera/CameraBase.h
@@ -91,12 +91,6 @@
     ////////////////////////////////////////////////////////
     virtual void         notifyCallback(int32_t msgType, int32_t ext,
                                         int32_t ext2);
-    virtual void         dataCallback(int32_t msgType,
-                                      const sp<IMemory>& dataPtr,
-                                      camera_frame_metadata *metadata);
-    bool                 dataCallbackTimestamp(nsecs_t timestamp,
-                                               int32_t msgType,
-                                               const sp<IMemory>& dataPtr);
 
     ////////////////////////////////////////////////////////
     // Common instance variables
@@ -115,7 +109,7 @@
 
     const int                        mCameraId;
 
-    typedef CameraBase<TCam>        CameraBaseT;
+    typedef CameraBase<TCam>         CameraBaseT;
 };
 
 }; // namespace android
diff --git a/include/camera/IProCameraCallbacks.h b/include/camera/IProCameraCallbacks.h
index fc24026..563ec17 100644
--- a/include/camera/IProCameraCallbacks.h
+++ b/include/camera/IProCameraCallbacks.h
@@ -28,19 +28,14 @@
 
 namespace android {
 
-class IProCameraCallbacks: public IInterface
+class IProCameraCallbacks : public IInterface
 {
 public:
     DECLARE_META_INTERFACE(ProCameraCallbacks);
 
-    virtual void            notifyCallback(int32_t msgType, int32_t ext1,
-                                                              int32_t ext2) = 0;
-    virtual void            dataCallback(int32_t msgType,
-                                         const sp<IMemory>& data,
-                                         camera_frame_metadata_t *metadata) = 0;
-    virtual void            dataCallbackTimestamp(nsecs_t timestamp,
-                                                  int32_t msgType,
-                                                  const sp<IMemory>& data) = 0;
+    virtual void            notifyCallback(int32_t msgType,
+                                           int32_t ext1,
+                                           int32_t ext2) = 0;
 
     enum LockStatus {
         LOCK_ACQUIRED,
@@ -53,12 +48,13 @@
     /** Missing by design: implementation is client-side in ProCamera.cpp **/
     // virtual void onBufferReceived(int streamId,
     //                               const CpuConsumer::LockedBufer& buf);
-    virtual void onResultReceived(int32_t frameId, camera_metadata* result) = 0;
+    virtual void            onResultReceived(int32_t frameId,
+                                             camera_metadata* result) = 0;
 };
 
 // ----------------------------------------------------------------------------
 
-class BnProCameraCallbacks: public BnInterface<IProCameraCallbacks>
+class BnProCameraCallbacks : public BnInterface<IProCameraCallbacks>
 {
 public:
     virtual status_t    onTransact( uint32_t code,
diff --git a/include/camera/IProCameraUser.h b/include/camera/IProCameraUser.h
index 7bddb0c..45b818c 100644
--- a/include/camera/IProCameraUser.h
+++ b/include/camera/IProCameraUser.h
@@ -61,8 +61,7 @@
                                           bool streaming = false) = 0;
     virtual status_t        cancelRequest(int requestId) = 0;
 
-    virtual status_t        requestStream(int streamId) = 0;
-    virtual status_t        cancelStream(int streamId) = 0;
+    virtual status_t        deleteStream(int streamId) = 0;
     virtual status_t        createStream(
                                       int width, int height, int format,
                                       const sp<IGraphicBufferProducer>& bufferProducer,
diff --git a/include/camera/ProCamera.h b/include/camera/ProCamera.h
index 5d6cfaa..3d1652f 100644
--- a/include/camera/ProCamera.h
+++ b/include/camera/ProCamera.h
@@ -40,9 +40,11 @@
 
 // All callbacks on this class are concurrent
 // (they come from separate threads)
-class ProCameraListener : public CameraListener
+class ProCameraListener : virtual public RefBase
 {
 public:
+    virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
+
     // Lock has been acquired. Write operations now available.
     virtual void onLockAcquired() = 0;
     // Lock has been released with exclusiveUnlock.
@@ -53,19 +55,9 @@
     // Lock free.
     virtual void onTriggerNotify(int32_t msgType, int32_t ext1, int32_t ext2)
                                                                             = 0;
-
-    // OnBufferReceived and OnRequestReceived can come in with any order,
+    // onFrameAvailable and OnResultReceived can come in with any order,
     // use android.sensor.timestamp and LockedBuffer.timestamp to correlate them
 
-    // TODO: remove onBufferReceived
-
-    // A new frame buffer has been received for this stream.
-    // -- This callback only fires for createStreamCpu streams
-    // -- Use buf.timestamp to correlate with metadata's
-    //    android.sensor.timestamp
-    // -- The buffer must not be accessed after this function call completes
-    virtual void onBufferReceived(int streamId,
-                                  const CpuConsumer::LockedBuffer& buf) = 0;
     /**
       * A new metadata buffer has been received.
       * -- Ownership of request passes on to the callee, free with
@@ -77,17 +69,14 @@
 
     // A new frame buffer has been received for this stream.
     // -- This callback only fires for createStreamCpu streams
-    // -- Use buf.timestamp to correlate with metadata's android.sensor.timestamp
+    // -- A buffer may be obtained by calling cpuConsumer->lockNextBuffer
+    // -- Use buf.timestamp to correlate with result's android.sensor.timestamp
     // -- The buffer should be accessed with CpuConsumer::lockNextBuffer
     //      and CpuConsumer::unlockBuffer
     virtual void onFrameAvailable(int /*streamId*/,
                                   const sp<CpuConsumer>& /*cpuConsumer*/) {
     }
 
-    // TODO: Remove useOnFrameAvailable
-    virtual bool useOnFrameAvailable() {
-        return false;
-    }
 };
 
 class ProCamera;
@@ -249,14 +238,10 @@
     ////////////////////////////////////////////////////////
     // IProCameraCallbacks implementation
     ////////////////////////////////////////////////////////
-    virtual void        notifyCallback(int32_t msgType, int32_t ext,
+    virtual void        notifyCallback(int32_t msgType,
+                                       int32_t ext,
                                        int32_t ext2);
-    virtual void        dataCallback(int32_t msgType,
-                                     const sp<IMemory>& dataPtr,
-                                     camera_frame_metadata_t *metadata);
-    virtual void        dataCallbackTimestamp(nsecs_t timestamp,
-                                              int32_t msgType,
-                                              const sp<IMemory>& dataPtr);
+
     virtual void        onLockStatusChanged(
                                 IProCameraCallbacks::LockStatus newLockStatus);
 
diff --git a/services/camera/libcameraservice/ProCamera2Client.cpp b/services/camera/libcameraservice/ProCamera2Client.cpp
index 1270751..575b075 100644
--- a/services/camera/libcameraservice/ProCamera2Client.cpp
+++ b/services/camera/libcameraservice/ProCamera2Client.cpp
@@ -230,14 +230,7 @@
     return INVALID_OPERATION;
 }
 
-//TODO: Remove
-status_t ProCamera2Client::requestStream(int streamId) {
-    ALOGE("%s: not implemented yet", __FUNCTION__);
-
-    return INVALID_OPERATION;
-}
-
-status_t ProCamera2Client::cancelStream(int streamId) {
+status_t ProCamera2Client::deleteStream(int streamId) {
     ATRACE_CALL();
     ALOGV("%s (streamId = 0x%x)", __FUNCTION__, streamId);
 
diff --git a/services/camera/libcameraservice/ProCamera2Client.h b/services/camera/libcameraservice/ProCamera2Client.h
index f69021e..1dec263 100644
--- a/services/camera/libcameraservice/ProCamera2Client.h
+++ b/services/camera/libcameraservice/ProCamera2Client.h
@@ -48,8 +48,7 @@
                                         bool streaming = false);
     virtual status_t      cancelRequest(int requestId);
 
-    virtual status_t      requestStream(int streamId);
-    virtual status_t      cancelStream(int streamId);
+    virtual status_t      deleteStream(int streamId);
 
     virtual status_t      createStream(
             int width,