Camera2Tests: update SmartCamera for async api

Change-Id: I6eb541c96ee50756c35e7785fdae63e8e45e2726
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk b/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
index ed0c294..4e3675f 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/Android.mk
@@ -25,6 +25,8 @@
 # comment it out for now since we need use some hidden APIs
 LOCAL_SDK_VERSION := current
 
+LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2
+
 LOCAL_SRC_FILES := \
     $(call all-java-files-under, src) \
     $(call all-renderscript-files-under, src)
diff --git a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
index c553b6d..3bfe787 100644
--- a/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
+++ b/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/samples/simplecamera/Camera2Source.java
@@ -33,6 +33,8 @@
 import android.renderscript.Type;
 import android.util.Log;
 import android.view.Surface;
+import com.android.ex.camera2.blocking.BlockingCameraManager;
+import com.android.ex.camera2.blocking.BlockingCameraManager.BlockingOpenException;
 import androidx.media.filterfw.Filter;
 import androidx.media.filterfw.Frame;
 import androidx.media.filterfw.FrameImage2D;
@@ -132,12 +134,26 @@
 
     @Override
     protected void onOpen() {
+        mLooperThread = new CameraTestThread();
+        Handler mHandler;
+        try {
+            mHandler = mLooperThread.start();
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+            throw new RuntimeException(e);
+        }
+
         try {
             String backCameraId = "0";
-            mCamera = mCameraManager.openCamera(backCameraId);
+            BlockingCameraManager blkManager = new BlockingCameraManager(mCameraManager);
+            mCamera = blkManager.openCamera(backCameraId, /*listener*/null, mHandler);
         } catch (CameraAccessException e) {
             e.printStackTrace();
             throw new RuntimeException(e);
+        } catch (BlockingOpenException e) {
+            e.printStackTrace();
+            throw new RuntimeException(e);
         }
 
         Element ele = Element.createPixel(mRS, Element.DataType.UNSIGNED_8,
@@ -172,15 +188,7 @@
             e.printStackTrace();
             throw new RuntimeException(e);
         }
-        mLooperThread = new CameraTestThread();
-        Handler mHandler;
-        try {
-            mHandler = mLooperThread.start();
-        } catch (Exception e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-            throw new RuntimeException(e);
-        }
+
         try {
             mCamera.setRepeatingRequest(mCaptureRequest.build(), new MyCaptureListener(),
                     mHandler);