Fix a potential bug of CameraTest.

Looper.quit() is asynchronous. The looper may still has some
preview callbacks in the queue after quit is called. The preview
callback still uses the camera object (setHasPreviewCallback).
After camera is released, RuntimeException will be thrown from
the method. So we need to join the looper thread here.

bug:2521202
Change-Id: I0ab74f657e3df3ff624a10763cb0a71cc07c691f
diff --git a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
index 979d24c..96dc6cf 100644
--- a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
@@ -127,8 +127,14 @@
     /*
      * Terminates the message looper thread.
      */
-    private void terminateMessageLooper() {
+    private void terminateMessageLooper() throws Exception {
         mLooper.quit();
+        // Looper.quit() is asynchronous. The looper may still has some
+        // preview callbacks in the queue after quit is called. The preview
+        // callback still uses the camera object (setHasPreviewCallback).
+        // After camera is released, RuntimeException will be thrown from
+        // the method. So we need to join the looper thread here.
+        mLooper.getThread().join();
         mCamera.release();
     }