Update ANativeWindow client code for sync

This change updates all the uses of ANativeWindow to use the new ANW functions
that accept and return Sync HAL fence file descriptors.

Change-Id: Id7db42d8d6380f8b440d88476ce9211c6225fb16
diff --git a/services/camera/libcameraservice/Camera2Device.cpp b/services/camera/libcameraservice/Camera2Device.cpp
index 5a37c8d..8d07eee 100644
--- a/services/camera/libcameraservice/Camera2Device.cpp
+++ b/services/camera/libcameraservice/Camera2Device.cpp
@@ -758,7 +758,7 @@
     ANativeWindowBuffer **anwBuffers = new ANativeWindowBuffer*[mTotalBuffers];
     uint32_t bufferIdx = 0;
     for (; bufferIdx < mTotalBuffers; bufferIdx++) {
-        res = mConsumerInterface->dequeueBuffer(mConsumerInterface.get(),
+        res = native_window_dequeue_buffer_and_wait(mConsumerInterface.get(),
                 &anwBuffers[bufferIdx]);
         if (res != OK) {
             ALOGE("%s: Unable to dequeue buffer %d for initial registration for"
@@ -766,15 +766,6 @@
             goto cleanUpBuffers;
         }
 
-        res = mConsumerInterface->lockBuffer(mConsumerInterface.get(),
-                anwBuffers[bufferIdx]);
-        if (res != OK) {
-            ALOGE("%s: Unable to lock buffer %d for initial registration for"
-                    "stream %d", __FUNCTION__, bufferIdx, mId);
-            bufferIdx++;
-            goto cleanUpBuffers;
-        }
-
         buffers[bufferIdx] = anwBuffers[bufferIdx]->handle;
     }
 
@@ -792,7 +783,7 @@
 cleanUpBuffers:
     for (uint32_t i = 0; i < bufferIdx; i++) {
         res = mConsumerInterface->cancelBuffer(mConsumerInterface.get(),
-                anwBuffers[i]);
+                anwBuffers[i], -1);
         if (res != OK) {
             ALOGE("%s: Unable to cancel buffer %d after registration",
                     __FUNCTION__, i);
@@ -878,9 +869,7 @@
 
     ANativeWindow *a = toANW(w);
     ANativeWindowBuffer* anb;
-    res = a->dequeueBuffer(a, &anb);
-    if (res != OK) return res;
-    res = a->lockBuffer(a, anb);
+    res = native_window_dequeue_buffer_and_wait(a, &anb);
     if (res != OK) return res;
 
     *buffer = &(anb->handle);
@@ -911,7 +900,7 @@
         return err;
     }
     err = a->queueBuffer(a,
-            container_of(buffer, ANativeWindowBuffer, handle));
+            container_of(buffer, ANativeWindowBuffer, handle), -1);
     if (err != OK) {
         ALOGE("%s: Error queueing buffer to native window: %s (%d)",
                 __FUNCTION__, strerror(-err), err);
@@ -933,7 +922,7 @@
     stream->mActiveBuffers--;
     ANativeWindow *a = toANW(w);
     return a->cancelBuffer(a,
-            container_of(buffer, ANativeWindowBuffer, handle));
+            container_of(buffer, ANativeWindowBuffer, handle), -1);
 }
 
 int Camera2Device::StreamAdapter::set_crop(const camera2_stream_ops_t* w,