Integrate CameraAnalyzer into CTS Verifier

Move the Java source to com.android.cts.verifier.camera.analyzer
and move the includes and libraries into a colorchecker subdirectory.

It didn't seem like libandroid was necessary to compile the
libraries, so I took out that dependency.

Some further work will be needed like providing instructions and
adding a pass fail condition.

Change-Id: Ic6f0400b299f1828e4a0bff7a0d5d8512a2bbb39
diff --git a/apps/CameraAnalyzer/Android.mk b/apps/CameraAnalyzer/Android.mk
deleted file mode 100644
index d26bed7..0000000
--- a/apps/CameraAnalyzer/Android.mk
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-#####################
-# Build image analysis library
-
-include $(CLEAR_VARS)
-include external/stlport/libstlport.mk
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libcolorchecker
-
-LOCAL_SRC_FILES += lib/colorchecker.cpp
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
-LOCAL_SHARED_LIBRARIES := libandroid \
-                          libstlport \
-                          libcutils \
-                          libutils
-
-include $(BUILD_STATIC_LIBRARY)
-
-#####################
-# Build JNI library
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libcameraanalyzer_jni
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := jni/com_android_cts_cameraanalyzer_colorchecker.cpp
-
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(JNI_H_INCLUDE)
-
-LOCAL_STATIC_LIBRARIES := libcolorchecker
-LOCAL_SHARED_LIBRARIES := libandroid \
-                          libjnigraphics \
-                          libstlport \
-                          libcutils \
-                          libutils
-
-include $(BUILD_SHARED_LIBRARY)
-
-#####################
-# Build test app
-
-include $(CLEAR_VARS)
-
-LOCAL_PACKAGE_NAME := CameraAnalyzer
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JNI_SHARED_LIBRARIES := libcameraanalyzer_jni
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-include $(BUILD_PACKAGE)
diff --git a/apps/CameraAnalyzer/AndroidManifest.xml b/apps/CameraAnalyzer/AndroidManifest.xml
deleted file mode 100644
index 35eaee9..0000000
--- a/apps/CameraAnalyzer/AndroidManifest.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-      android:versionCode="1"
-          android:versionName="1.0" package="com.android.cts.cameraanalyzer">
-  <uses-permission android:name="android.permission.CAMERA" />
-  <uses-feature android:name="android.hardware.camera" />
-  <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
-
-  <uses-sdk android:minSdkVersion="3" />
-  <application android:label="@string/app_name"
-               android:debuggable="true">
-    <activity android:name=".CameraAnalyzer"
-              android:label="@string/app_name">
-      <intent-filter>
-        <action android:name="android.intent.action.MAIN" />
-        <category android:name="android.intent.category.LAUNCHER" />
-      </intent-filter>
-    </activity>
-  </application>
-</manifest>
diff --git a/apps/CameraAnalyzer/res/values/strings.xml b/apps/CameraAnalyzer/res/values/strings.xml
deleted file mode 100644
index c7825c1..0000000
--- a/apps/CameraAnalyzer/res/values/strings.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!-- Copyright (C) 2011 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<resources>
-    <string name="app_name">CameraAnalyzer</string>
-    <string name="run_label">Find color checker</string>
-    <string name="result_label">Patch values will be here</string>
-</resources>
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index bbf7eaf..337ed2e 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -25,7 +25,7 @@
 
 LOCAL_PACKAGE_NAME := CtsVerifier
 
-LOCAL_JNI_SHARED_LIBRARIES := libctsverifier_jni libaudioquality
+LOCAL_JNI_SHARED_LIBRARIES := libctsverifier_jni libaudioquality libcameraanalyzer
 
 LOCAL_SDK_VERSION := current
 
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 9bdb37a..c5a45c5 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -24,6 +24,7 @@
 
     <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
     <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.CAMERA" />
     <uses-permission android:name="android.permission.RECORD_AUDIO" />
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     
@@ -109,6 +110,15 @@
 
         <service android:name=".audioquality.ExperimentService" />
 
+        <activity android:name=".camera.analyzer.CameraAnalyzerActivity"
+                android:label="@string/camera_analyzer">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_category" android:value="@string/test_category_camera" />
+        </activity>
+
    </application>
 
 </manifest> 
diff --git a/apps/CameraAnalyzer/include/colorchecker.h b/apps/CtsVerifier/include/colorchecker/colorchecker.h
similarity index 100%
rename from apps/CameraAnalyzer/include/colorchecker.h
rename to apps/CtsVerifier/include/colorchecker/colorchecker.h
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/Android.mk b/apps/CtsVerifier/jni/cameraanalyzer/Android.mk
new file mode 100644
index 0000000..ccc0998
--- /dev/null
+++ b/apps/CtsVerifier/jni/cameraanalyzer/Android.mk
@@ -0,0 +1,34 @@
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libcameraanalyzer
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := com_android_cts_verifier_camera_analyzer_ColorChecker.cpp
+
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include/colorchecker $(JNI_H_INCLUDE)
+
+LOCAL_STATIC_LIBRARIES := libcolorchecker
+LOCAL_SHARED_LIBRARIES := libjnigraphics \
+                          libstlport \
+                          libcutils \
+                          libutils
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/apps/CameraAnalyzer/jni/com_android_cts_cameraanalyzer_colorchecker.cpp b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorChecker.cpp
similarity index 96%
rename from apps/CameraAnalyzer/jni/com_android_cts_cameraanalyzer_colorchecker.cpp
rename to apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorChecker.cpp
index 1093418..4d247ab 100644
--- a/apps/CameraAnalyzer/jni/com_android_cts_cameraanalyzer_colorchecker.cpp
+++ b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorChecker.cpp
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-#include "com_android_cts_cameraanalyzer_colorchecker.h"
+#include "com_android_cts_verifier_camera_analyzer_ColorChecker.h"
 
 #include "utils/Log.h"
 #include "android/bitmap.h"
 #include "colorchecker.h"
 
-jboolean Java_com_android_cts_cameraanalyzer_ColorChecker_findNative(
+jboolean Java_com_android_cts_verifier_camera_analyzer_ColorChecker_findNative(
     JNIEnv*      env,
     jobject      thiz,
     jobject      inputBitmap) {
diff --git a/apps/CameraAnalyzer/jni/com_android_cts_cameraanalyzer_colorchecker.h b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorChecker.h
similarity index 92%
rename from apps/CameraAnalyzer/jni/com_android_cts_cameraanalyzer_colorchecker.h
rename to apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorChecker.h
index 163dca0..a9b4487 100644
--- a/apps/CameraAnalyzer/jni/com_android_cts_cameraanalyzer_colorchecker.h
+++ b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorChecker.h
@@ -25,7 +25,7 @@
 #endif
 
 JNIEXPORT jboolean JNICALL
-Java_com_android_cts_cameraanalyzer_ColorChecker_findNative(
+Java_com_android_cts_verifier_camera_analyzer_ColorChecker_findNative(
     JNIEnv *env,
     jobject thiz,
     jobject inputBitmap);
diff --git a/apps/CtsVerifier/lib/Android.mk b/apps/CtsVerifier/lib/Android.mk
new file mode 100644
index 0000000..56a3fa8
--- /dev/null
+++ b/apps/CtsVerifier/lib/Android.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+include $(call all-subdir-makefiles)
diff --git a/apps/CtsVerifier/lib/colorchecker/Android.mk b/apps/CtsVerifier/lib/colorchecker/Android.mk
new file mode 100644
index 0000000..97f0089
--- /dev/null
+++ b/apps/CtsVerifier/lib/colorchecker/Android.mk
@@ -0,0 +1,33 @@
+# Copyright (C) 2011 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+#####################
+# Build image analysis library
+
+include $(CLEAR_VARS)
+include external/stlport/libstlport.mk
+
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE := libcolorchecker
+
+LOCAL_SRC_FILES += colorchecker.cpp
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include/colorchecker
+LOCAL_SHARED_LIBRARIES := libstlport \
+                          libcutils \
+                          libutils
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/apps/CameraAnalyzer/lib/colorchecker.cpp b/apps/CtsVerifier/lib/colorchecker/colorchecker.cpp
similarity index 100%
rename from apps/CameraAnalyzer/lib/colorchecker.cpp
rename to apps/CtsVerifier/lib/colorchecker/colorchecker.cpp
diff --git a/apps/CameraAnalyzer/lib/grouping.h b/apps/CtsVerifier/lib/colorchecker/grouping.h
similarity index 100%
rename from apps/CameraAnalyzer/lib/grouping.h
rename to apps/CtsVerifier/lib/colorchecker/grouping.h
diff --git a/apps/CameraAnalyzer/res/layout/main.xml b/apps/CtsVerifier/res/layout/ca_main.xml
similarity index 91%
rename from apps/CameraAnalyzer/res/layout/main.xml
rename to apps/CtsVerifier/res/layout/ca_main.xml
index 325fd65..98ec049 100644
--- a/apps/CameraAnalyzer/res/layout/main.xml
+++ b/apps/CtsVerifier/res/layout/ca_main.xml
@@ -20,11 +20,11 @@
   android:layout_height="fill_parent">
 
   <Button android:id="@+id/runbutton" android:layout_width="fill_parent"
-    android:layout_height="wrap_content" android:text="@string/run_label" />
+    android:layout_height="wrap_content" android:text="@string/ca_run_label" />
 
   <TextView android:id="@+id/resulttext" android:layout_width="fill_parent"
             android:layout_height="wrap_content"
-            android:text="@string/result_label"
+            android:text="@string/ca_result_label"
             android:textSize="15sp" />
 
   <LinearLayout android:orientation="horizontal"
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 93b5078..90e8892 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -32,6 +32,7 @@
     <!-- Strings for TestListActivity -->
     <string name="test_list_title">Manual Test List</string>
     <string name="test_category_audio">Audio</string>
+    <string name="test_category_camera">Camera</string>
     <string name="test_category_networking">Networking</string>
     <string name="test_category_sensors">Sensors</string>
     <string name="test_category_security">Security</string>
@@ -195,6 +196,7 @@
     <string name="aq_level_report">RMS = %1$.0f, target = %2$.0f\nTolerance = %3$.1f%%\nDuration = %4$.1fs</string>
     <string name="aq_spectrum_report_error">Cannot perform test.\nCheck volume is sufficiently high?</string>
     <string name="aq_spectrum_report_normal">RMS deviation = %1$.2f\nMax allowed deviation = %2$.1f</string>
+
     <string name="aq_cold_latency_report">Latency = %1$dms, maximum allowed = %2$dms</string>
     <string name="aq_warm_latency_report_error">RMS = %1$.0f, target = %2$.0f</string>
     <string name="aq_warm_latency_report_normal">Latency = %1$dms</string>
@@ -207,4 +209,8 @@
     <string name="aq_recording_error">Error reading data from AudioRecord instance</string>
     <string name="aq_exception_error">Exception thrown during test: %1$s</string>
 
+    <!-- Strings for Camera Analyzer -->
+    <string name="camera_analyzer">Camera Analyzer</string>
+    <string name="ca_run_label">Find color checker</string>
+    <string name="ca_result_label">Patch values will be here</string>
 </resources>
diff --git a/apps/CameraAnalyzer/src/com/android/cts/cameraanalyzer/CameraAnalyzer.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraAnalyzerActivity.java
similarity index 95%
rename from apps/CameraAnalyzer/src/com/android/cts/cameraanalyzer/CameraAnalyzer.java
rename to apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraAnalyzerActivity.java
index fb2164c..b50dd9e 100644
--- a/apps/CameraAnalyzer/src/com/android/cts/cameraanalyzer/CameraAnalyzer.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraAnalyzerActivity.java
@@ -13,7 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.cameraanalyzer;
+package com.android.cts.verifier.camera.analyzer;
+
+import com.android.cts.verifier.R;
 
 import android.app.Activity;
 import android.graphics.Bitmap;
@@ -21,16 +23,15 @@
 import android.graphics.ImageFormat;
 import android.hardware.Camera;
 import android.os.Bundle;
-import android.view.View;
 import android.view.SurfaceHolder;
 import android.view.SurfaceView;
+import android.view.View;
 import android.widget.ImageView;
 import android.widget.TextView;
-import android.util.Log;
 
 import java.io.IOException;
 
-public class CameraAnalyzer extends Activity {
+public class CameraAnalyzerActivity extends Activity {
 
     Bitmap mInputImage;
     TextView mResultText;
@@ -42,7 +43,7 @@
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.main);
+        setContentView(R.layout.ca_main);
 
         findViewById(R.id.runbutton).setOnClickListener(mRunListener);
 
diff --git a/apps/CameraAnalyzer/src/com/android/cts/cameraanalyzer/ColorChecker.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ColorChecker.java
similarity index 95%
rename from apps/CameraAnalyzer/src/com/android/cts/cameraanalyzer/ColorChecker.java
rename to apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ColorChecker.java
index ac3b4eb..c9df24a 100644
--- a/apps/CameraAnalyzer/src/com/android/cts/cameraanalyzer/ColorChecker.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ColorChecker.java
@@ -14,12 +14,9 @@
  * limitations under the License.
  */
 
-package com.android.cts.cameraanalyzer;
+package com.android.cts.verifier.camera.analyzer;
 
 import android.graphics.Bitmap;
-import android.util.Log;
-
-import java.lang.RuntimeException;
 
 /** The ColorChecker class is used to locate a Xrite Classic Color Checker grid
  * pattern in an image, and return the average value of each color patch.
@@ -102,6 +99,6 @@
     native boolean findNative(Bitmap input);
 
     static {
-        System.loadLibrary("cameraanalyzer_jni");
+        System.loadLibrary("cameraanalyzer");
     }
 }
\ No newline at end of file