am 9afb6a53: am d7e59844: Merge "Fixed layout of info dialog of Hardware/Software Feature Summary for small screens to display all text without overlapping." into lmp-mr1-dev

* commit '9afb6a536e94db033c4e1204a8f6b6939da7e114':
  Fixed layout of info dialog of Hardware/Software Feature Summary for small screens to display all text without overlapping.
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index e8e7485..9f594df 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -110,6 +110,7 @@
     CtsAdminTestCases \
     CtsAnimationTestCases \
     CtsAppTestCases \
+    CtsAppWidgetTestCases \
     CtsBluetoothTestCases \
     CtsCalendarcommon2TestCases \
     CtsContentTestCases \
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index 87f962f..f6ece3b 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -32,8 +32,7 @@
 
 LOCAL_PACKAGE_NAME := CtsVerifier
 
-LOCAL_JNI_SHARED_LIBRARIES := libctsverifier_jni \
-	#libcameraanalyzer # Needed for the disabled CameraAnalyzer tests
+LOCAL_JNI_SHARED_LIBRARIES := libctsverifier_jni
 
 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
 
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index e67a5c1..4e1b756 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.cts.verifier"
       android:versionCode="5"
-      android:versionName="5.1_r0.5">
+      android:versionName="5.0_r1.91">
 
     <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="21"/>
 
@@ -870,23 +870,6 @@
 
             <meta-data android:name="test_required_features" android:value="android.hardware.camera.any"/>
         </activity>
-<!-- Experimental. If re-enabling, libcameraanalyzer must be included in the build
-        <activity android:name=".camera.analyzer.CameraAnalyzerActivity"
-                 android:label="@string/camera_analyzer"
-                 android:screenOrientation="landscape">
-            <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" />
-
-            <intent-filter>
-                <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
-            </intent-filter>
-            <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
-                android:resource="@xml/accessory_filter_adk" />
-        </activity>
--->
 
         <activity android:name=".camera.intents.CameraIntentsActivity"
                  android:label="@string/camera_intents">
@@ -1131,8 +1114,6 @@
             <meta-data android:name="test_category" android:value="@string/test_category_other" />
             <meta-data android:name="test_required_features"
                     android:value="android.software.app_widgets" />
-            <meta-data android:name="test_excluded_features"
-                       android:value="android.software.leanback" />
         </activity>
 
         <activity android:name=".deskclock.DeskClockTestsActivity"
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/Android.mk b/apps/CtsVerifier/jni/cameraanalyzer/Android.mk
deleted file mode 100644
index d595a20..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/Android.mk
+++ /dev/null
@@ -1,42 +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)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE := libcameraanalyzer
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := com_android_cts_verifier_camera_analyzer_CameraTests.cpp \
-                com_android_cts_verifier_camera_analyzer_ColorCheckerTest.cpp \
-                com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.cpp \
-                com_android_cts_verifier_camera_analyzer_AutoLockTest.cpp \
-                com_android_cts_verifier_camera_analyzer_MeteringTest.cpp \
-                com_android_cts_verifier_camera_analyzer_WhiteBalanceTest.cpp
-
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include/colorchecker $(JNI_H_INCLUDE)
-
-LOCAL_CXX_STL := libc++
-LOCAL_STATIC_LIBRARIES := libcolorchecker
-LOCAL_SHARED_LIBRARIES := \
-    libjnigraphics \
-    libcutils \
-    libutils \
-    liblog \
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_AutoLockTest.cpp b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_AutoLockTest.cpp
deleted file mode 100644
index fac39e1..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_AutoLockTest.cpp
+++ /dev/null
@@ -1,95 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "AutoLockJNI"
-#include <utils/Log.h>
-#include "com_android_cts_verifier_camera_analyzer_AutoLockTest.h"
-
-#include <vector>
-#include <string>
-#include <string.h>
-
-#include "testingimage.h"
-#include "autolocktest.h"
-#include "vec2.h"
-#include "android/bitmap.h"
-
-jlong Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_createAutoLockTest(
-        JNIEnv*      env,
-        jobject      thiz) {
-
-    AutoLockTest* testHandler = new AutoLockTest();
-    long handlerAddress = (long)testHandler;
-    return handlerAddress;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_createAutoLockClass(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputImageAddress,
-        jlong        inputHandlerAddress,
-        jlong        checkercenterAddress,
-        jlong        checkerradiusAddress) {
-
-    ALOGV("JNI createAutoLockClass starts!");
-    long imageAddress = (long)inputImageAddress;
-    long handlerAddress = (long)inputHandlerAddress;
-
-    TestingImage *image = (TestingImage*) imageAddress;
-    AutoLockTest *testHandler = (AutoLockTest*) handlerAddress;
-
-    std::vector<std::vector< Vec2f > >* checkerCenter =
-            (std::vector<std::vector< Vec2f > >*) (long) checkercenterAddress;
-    std::vector<std::vector< float > >* checkerRadius =
-            (std::vector<std::vector< float > >*) (long) checkerradiusAddress;
-    ALOGV("Classes recovered");
-
-    // Uses only the gray patches on the color checker for comparison.
-    testHandler->addDataToList(image->getColorChecker(3, 4, 0, 6,
-                                                      checkerCenter,
-                                                      checkerRadius));
-
-    delete image;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_processAutoLockTest(
-        JNIEnv*          env,
-        jobject          thiz,
-        jlong            inputHandlerAddress,
-        jbooleanArray    tempArray) {
-
-    ALOGV("Processing Auto Lock data!");
-
-    long handlerAddress = (long) inputHandlerAddress;
-    AutoLockTest *testHandler = (AutoLockTest*) handlerAddress;
-
-    testHandler->processData();
-
-    // Converts the native boolean array into a java boolean array.
-    const std::vector<bool>* nativeComparisonResults =
-            testHandler->getComparisonResults();
-    jboolean comparisonResults[nativeComparisonResults->size()];
-
-    for (int i = 0; i < nativeComparisonResults->size(); ++i) {
-        comparisonResults[i] = (jboolean) (*nativeComparisonResults)[i];
-    }
-
-    env->SetBooleanArrayRegion(tempArray,
-                               0, nativeComparisonResults->size(),
-                               comparisonResults);
-    testHandler->clearData();
-}
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_AutoLockTest.h b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_AutoLockTest.h
deleted file mode 100644
index dc40bc2..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_AutoLockTest.h
+++ /dev/null
@@ -1,52 +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.
- */
-
-#ifndef JNI_CAMERAANALYZER_AUTOLOCKTEST_H
-#define JNI_CAMERAANALYZER_AUTOLOCKTEST_H
-
-#include <jni.h>
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_createAutoLockTest(
-        JNIEnv*      env,
-        jobject      thiz);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_createAutoLockClass(
-        JNIEnv *env,
-        jobject thiz,
-        jlong inputImageAddress,
-        jlong inputHandlerAddress,
-        jlong checkercenterAddress,
-        jlong checkerradiusAddress);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_processAutoLockTest(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress,
-        jbooleanArray    tempArray);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_CameraTests.cpp b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_CameraTests.cpp
deleted file mode 100644
index ed91233..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_CameraTests.cpp
+++ /dev/null
@@ -1,223 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "CameraTestsJNI"
-#include <utils/Log.h>
-#include "com_android_cts_verifier_camera_analyzer_CameraTests.h"
-#include "android/bitmap.h"
-#include "testingimage.h"
-#include "imagetesthandler.h"
-
-#include <string.h>
-
-jlong Java_com_android_cts_verifier_camera_analyzer_CameraTests_findNative(
-        JNIEnv*      env,
-        jobject      thiz,
-        jobject      inputBitmap) {
-
-    ALOGV("JNI findNative starts!");
-
-    // Verify that we can handle the input bitmap
-    AndroidBitmapInfo inputInfo;
-    AndroidBitmap_getInfo(env, inputBitmap, &inputInfo);
-    if (inputInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888 &&
-        inputInfo.format != ANDROID_BITMAP_FORMAT_RGB_565) {
-        ALOGE("Only RGBA_8888 and RGB_565 bitmaps are supported, type was %d.",
-             inputInfo.format);
-    }
-
-    // Get some references to the fields and class type of ColorChecker
-    jclass thizCls = env->GetObjectClass(thiz);
-    ALOGV("ColorChecker field and classes reference finished!");
-
-    // Get raw inputs and outputs ready
-    uint8_t *inputBuffer = NULL;
-    int result = AndroidBitmap_lockPixels(
-            env,
-            inputBitmap,
-            reinterpret_cast<void**>(&inputBuffer));
-
-    if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
-        ALOGE("Unable to lock input bitmap");
-    }
-
-    uint8_t *outputImage = NULL;
-    int outputWidth, outputHeight;
-
-    ALOGV("Input and output images created!");
-
-    // Find the color checker
-    bool success;
-    uint8_t *inputBufferRGBA = NULL;
-    int inputStride;
-    bool freeInputRGBA = false;
-    switch (inputInfo.format) {
-        case ANDROID_BITMAP_FORMAT_RGB_565: {
-            // First convert to RGBA_8888
-            inputBufferRGBA = new uint8_t[inputInfo.width *
-                                          inputInfo.height *
-                                          4];
-            inputStride = inputInfo.width * 4;
-            uint8_t *outP = inputBufferRGBA;
-            for (int y = 0; y < inputInfo.height; y++ ) {
-                uint16_t *inP = (uint16_t*)(&inputBuffer[y * inputInfo.stride]);
-                for (int x = 0; x < inputInfo.width; x++) {
-                    *(outP++) = ( ((*inP) >> 0) & 0x001F) << 3;
-                    *(outP++) = ( ((*inP) >> 5) & 0x003F) << 2;
-                    *(outP++) = ( ((*inP) >> 11) & 0x001F) << 3;
-                    outP++;
-                    inP++;
-                }
-            }
-            freeInputRGBA = true;
-
-            ALOGV("RGB_565 Format with width, height and stride as %d, %d, %d",
-                 inputInfo.width, inputInfo.height, inputStride);
-            break;
-        }
-        case ANDROID_BITMAP_FORMAT_RGBA_8888: {
-            // Already in RGBA
-            inputBufferRGBA = inputBuffer;
-            inputStride = inputInfo.stride;
-            ALOGV("RGB_8888 Format with width, height and stride as %d, %d, %d",
-                 inputInfo.width, inputInfo.height, inputStride);
-            break;
-        }
-    }
-
-    TestingImage *input_testing_image =
-            new TestingImage(inputBufferRGBA, inputInfo.height, inputInfo.width,
-                             4, inputStride, 120, 160);
-
-    long lp = (long)input_testing_image;
-
-    result = AndroidBitmap_unlockPixels(env, inputBitmap);
-    if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
-        ALOGE("Unable to unlock input bitmap");
-    }
-
-    if (freeInputRGBA) {
-        ALOGV("Deleteing inputbufferRGBA");
-        delete[] inputBufferRGBA;
-    }
-
-    return lp;
-    ALOGV("Input format switched!");
-}
-
-jlong Java_com_android_cts_verifier_camera_analyzer_CameraTests_createImageTestHandler(
-        JNIEnv*      env,
-        jobject      thiz,
-        jint         debugHeight,
-        jint         debugWidth) {
-
-    ImageTestHandler* testHandler =
-            new ImageTestHandler(debugHeight, debugWidth);
-    long handlerAddress = (long)testHandler;
-    return handlerAddress;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_CameraTests_cleanUpHandler(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress) {
-
-    ImageTestHandler* testHandler = (ImageTestHandler*) (long) inputHandlerAddress;
-    delete testHandler;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_CameraTests_displayHandlerDebugOutput(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress) {
-
-    jclass thizCls = env->GetObjectClass(thiz);
-    jfieldID outputId = env->GetFieldID(thizCls, "mDebugOutput",
-                                        "Landroid/graphics/Bitmap;");
-
-    ImageTestHandler* testHandler = (ImageTestHandler*) (long) inputHandlerAddress;
-    uint8_t *outputImage =  new uint8_t[testHandler->getDebugHeight() *
-                                        testHandler->getDebugWidth() * 4];
-
-    const unsigned char *debugoutput = testHandler->debug_output();
-    memcpy(outputImage, debugoutput, testHandler->getDebugHeight() *
-            testHandler->getDebugWidth() * 4);
-
-    int outputWidth = testHandler->getDebugWidth();
-    int outputHeight = testHandler->getDebugHeight();
-    bool success = false;
-
-    if (outputImage == NULL) {
-        ALOGV("output Image is null!");
-    } else {
-        ALOGV("output Image is ready!");
-    }
-
-    // Create debug bitmap from output image data
-    if (outputImage != NULL) {
-        // Get method handles, create inputs to createBitmap
-        jclass bitmapClass =
-                env->FindClass("android/graphics/Bitmap");
-        jclass bitmapConfigClass =
-                env->FindClass("android/graphics/Bitmap$Config");
-
-        jmethodID createBitmap = env->GetStaticMethodID(
-            bitmapClass, "createBitmap",
-            "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
-
-        jmethodID getConfig = env->GetStaticMethodID(
-            bitmapConfigClass, "valueOf",
-            "(Ljava/lang/String;)Landroid/graphics/Bitmap$Config;");
-
-        // Create bitmap config and bitmap
-        jstring bitmapConfigValue = env->NewStringUTF("ARGB_8888");
-        jobject rgbaConfig = env->CallStaticObjectMethod(bitmapConfigClass,
-                                                         getConfig,
-                                                         bitmapConfigValue);
-        jobject outputBitmap = env->CallStaticObjectMethod(bitmapClass,
-                                                           createBitmap,
-                                                           outputWidth,
-                                                           outputHeight,
-                                                           rgbaConfig);
-        // Copy output image into it
-        uint8_t *outputBuffer;
-        int result = AndroidBitmap_lockPixels(
-                env,
-                outputBitmap,
-                reinterpret_cast<void**>(&outputBuffer) );
-
-        if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
-            ALOGE("Unable to lock output bitmap");
-        }
-
-        memcpy(outputBuffer, outputImage, outputWidth * outputHeight * 4);
-
-        result = AndroidBitmap_unlockPixels(env, outputBitmap);
-        if (result != ANDROID_BITMAP_RESULT_SUCCESS) {
-            ALOGE("Unable to unlock output bitmap");
-        }
-
-        // Write new Bitmap reference into mDebugOutput class member
-        env->SetObjectField(thiz, outputId, outputBitmap);
-        ALOGV("Copied to outputBitmap");
-        delete [] outputImage;
-        env->DeleteLocalRef(outputBitmap);
-        env->DeleteLocalRef(rgbaConfig);
-        env->DeleteLocalRef(bitmapClass);
-        env->DeleteLocalRef(bitmapConfigClass);
-    }
-}
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_CameraTests.h b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_CameraTests.h
deleted file mode 100644
index e071dc1..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_CameraTests.h
+++ /dev/null
@@ -1,57 +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.
- */
-
-#ifndef JNI_CAMERAANALYZER_CAMERATESTS_H
-#define JNI_CAMERAANALYZER_CAMERATESTS_H
-
-#include <jni.h>
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_CameraTests_findNative(
-        JNIEnv *env,
-        jobject thiz,
-        jobject inputBitmap);
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_CameraTests_createImageTestHandler(
-        JNIEnv*      env,
-        jobject      thiz,
-        jint         debugHeight,
-        jint         debugWidth);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_CameraTests_cleanUpHandler(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_CameraTests_displayHandlerDebugOutput(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorCheckerTest.cpp b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorCheckerTest.cpp
deleted file mode 100644
index 94e3ac2..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorCheckerTest.cpp
+++ /dev/null
@@ -1,84 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "FindColorCheckerJNI"
-#include <utils/Log.h>
-#include "com_android_cts_verifier_camera_analyzer_ColorCheckerTest.h"
-
-#include <string.h>
-#include "android/bitmap.h"
-#include "colorcheckertest.h"
-#include "testingimage.h"
-
-jlong Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_createColorCheckerTest(
-        JNIEnv*      env,
-        jobject      thiz,
-        jint         debugHeight,
-        jint         debugWidth) {
-    ColorCheckerTest* testHandler = new ColorCheckerTest(debugHeight,
-                                                         debugWidth);
-    long testHandlerAddress = (long)testHandler;
-    return testHandlerAddress;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_createColorCheckerClass(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputImageAddress,
-        jlong        inputHandlerAddress) {
-    ALOGV("JNI createColorCheckerClass starts!");
-
-    TestingImage *testImage = (TestingImage*) (long) inputImageAddress;
-    ColorCheckerTest *testHandler = (ColorCheckerTest*)
-            (long) inputHandlerAddress;
-
-    testHandler->addTestingImage(testImage);
-}
-
-jboolean Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_processColorCheckerTest(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress) {
-
-    ColorCheckerTest *testHandler = (ColorCheckerTest*)
-            (long) inputHandlerAddress;
-    testHandler->processData();
-    return testHandler->getSuccess();
-}
-
-jlong Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_getColorCheckerRadiusAdd(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress) {
-
-    ColorCheckerTest *testHandler = (ColorCheckerTest*)
-            (long) inputHandlerAddress;
-    long rtn = (long) testHandler->getCheckerRadiusAdd();
-    return rtn;
-}
-
-jlong Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_getColorCheckerCenterAdd(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress) {
-
-    ColorCheckerTest *testHandler = (ColorCheckerTest*)
-            (long) inputHandlerAddress;
-
-    long rtn = (long) testHandler->getCheckerCenterAdd();
-    return rtn;
-}
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorCheckerTest.h b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorCheckerTest.h
deleted file mode 100644
index fb87735..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ColorCheckerTest.h
+++ /dev/null
@@ -1,63 +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.
- */
-
-#ifndef JNI_CAMERAANALYZER_COLORCHECKERTEST_H
-#define JNI_CAMERAANALYZER_COLORCHECKERTEST_H
-
-#include <jni.h>
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_createColorCheckerTest(
-    JNIEnv*      env,
-    jobject      thiz,
-    jint         output_height,
-    jint         output_width);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_createColorCheckerClass(
-    JNIEnv *env,
-    jobject thiz,
-    jlong buffer_address,
-    jlong handler_address);
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_getColorCheckerRadiusAdd(
-    JNIEnv *env,
-    jobject thiz,
-    jlong handler_address);
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_getColorCheckerCenterAdd(
-    JNIEnv *env,
-    jobject thiz,
-    jlong handler_address);
-
-JNIEXPORT jboolean JNICALL
-Java_com_android_cts_verifier_camera_analyzer_ColorCheckerTest_processColorCheckerTest(
-    JNIEnv*      env,
-    jobject      thiz,
-    jlong        handler_address);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.cpp b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.cpp
deleted file mode 100644
index 0224639..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.cpp
+++ /dev/null
@@ -1,88 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "ExposureCompensationJNI"
-#include <utils/Log.h>
-#include <vector>
-#include <string.h>
-
-#include "android/bitmap.h"
-#include "testingimage.h"
-#include "exposurecompensationtest.h"
-#include "vec2.h"
-
-#include "com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.h"
-
-jlong Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_createExposureCompensationTest(
-      JNIEnv*      env,
-      jobject      thiz,
-      jint         debugHeight,
-      jint         debugWidth) {
-
-    ExposureCompensationTest* testHandler =
-            new ExposureCompensationTest(debugHeight, debugWidth);
-    long handlerAddress = (long)testHandler;
-
-    return handlerAddress;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_createExposureCompensationClass(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputImageAddress,
-        jlong        inputHandlerAddress,
-        jlong        checkerCenterAddress,
-        jlong        checkerRadiusAddress,
-        jfloat       exposureValue) {
-
-    ALOGV("JNI createExposureCompensationClass starts!");
-
-    long imageAddress = (long)inputImageAddress;
-    long handlerAddress = (long)inputHandlerAddress;
-
-    TestingImage *inputImage = (TestingImage*) imageAddress;
-    ExposureCompensationTest *testHandler =
-            (ExposureCompensationTest*) handlerAddress;
-
-    std::vector<std::vector< Vec2f > >* checkerCenter =
-            (std::vector<std::vector< Vec2f > >*) (long) checkerCenterAddress;
-    std::vector<std::vector< float > >* checkerRadius =
-            (std::vector<std::vector< float > >*) (long) checkerRadiusAddress;
-
-    const std::vector<Vec3f>* checkerValue =
-            inputImage->getColorChecker(3, 4, 0, 6,
-                                        checkerCenter, checkerRadius);
-    testHandler->addDataToList((float) exposureValue, checkerValue);
-    delete inputImage;
-    delete checkerValue;
-}
-
-jstring Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_processExposureCompensationTest(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress) {
-
-    long handlerAddress = (long) inputHandlerAddress;
-    ExposureCompensationTest *testHandler =
-            (ExposureCompensationTest*) handlerAddress;
-
-    testHandler->processData();
-
-    const char* nativeDebugText = testHandler->getDebugText();
-    ALOGV("%s", nativeDebugText);
-    return env->NewStringUTF(nativeDebugText);
-}
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.h b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.h
deleted file mode 100644
index 8e8761d..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_ExposureCompensationTest.h
+++ /dev/null
@@ -1,54 +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.
- */
-
-#ifndef JNI_CAMERAANALYZER_EXPOSURECOMPENSATIONTEST_H
-#define JNI_CAMERAANALYZER_EXPOSURECOMPENSATIONTEST_H
-
-#include <jni.h>
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_createExposureCompensationTest(
-        JNIEnv*      env,
-        jobject      thiz,
-        jint         debugHeight,
-        jint         debugWidth);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_createExposureCompensationClass(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputImageAddress,
-        jlong        inputHandlerAddress,
-        jlong        checkerCenterAddress,
-        jlong        checkerRadiusAddress,
-        jfloat       exposureValue);
-
-
-JNIEXPORT jstring JNICALL
-Java_com_android_cts_verifier_camera_analyzer_ExposureCompensationTest_processExposureCompensationTest(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputHandlerAddress);
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_MeteringTest.cpp b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_MeteringTest.cpp
deleted file mode 100644
index faebe21..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_MeteringTest.cpp
+++ /dev/null
@@ -1,142 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "MeteringJNI"
-#include <utils/Log.h>
-#include "com_android_cts_verifier_camera_analyzer_MeteringTest.h"
-
-#include <vector>
-#include <string>
-#include <string.h>
-#include <math.h>
-
-#include "testingimage.h"
-#include "meteringtest.h"
-#include "vec2.h"
-#include "android/bitmap.h"
-
-jlong Java_com_android_cts_verifier_camera_analyzer_MeteringTest_createMeteringTest(
-        JNIEnv*      env,
-        jobject      thiz) {
-
-    MeteringTest* testHandler = new MeteringTest();
-    long handlerAddress = (long)testHandler;
-    return handlerAddress;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_MeteringTest_createMeteringClass(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputImageAddress,
-        jlong        inputHandlerAddress,
-        jlong        checkercenterAddress,
-        jlong        checkerradiusAddress){
-
-    ALOGV("JNI createMeteringClass starts!");
-    long imageAddress = (long)inputImageAddress;
-    long handlerAddress = (long)inputHandlerAddress;
-
-    TestingImage *image = (TestingImage*) imageAddress;
-    MeteringTest *testHandler = (MeteringTest*) handlerAddress;
-
-    std::vector<std::vector< Vec2f > >* checkerCenter =
-            (std::vector<std::vector< Vec2f > >*) (long) checkercenterAddress;
-    std::vector<std::vector< float > >* checkerRadius =
-            (std::vector<std::vector< float > >*) (long) checkerradiusAddress;
-    ALOGV("Classes recovered");
-
-    testHandler->addDataToList(image->getColorChecker(3, 4, 0, 6,
-                                                      checkerCenter,
-                                                      checkerRadius));
-
-    delete image;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_MeteringTest_processMeteringTest(
-        JNIEnv*          env,
-        jobject          thiz,
-        jlong            inputHandlerAddress,
-        jbooleanArray    tempArray) {
-
-    ALOGV("Processing Auto Lock data!");
-
-    long handlerAddress = (long) inputHandlerAddress;
-    MeteringTest *testHandler = (MeteringTest*) handlerAddress;
-
-    testHandler->processData();
-
-    const std::vector<bool>* nativeComparisonResults =
-            testHandler->getComparisonResults();
-    jboolean jComparisonResults[nativeComparisonResults->size()];
-
-    for (int i = 0; i < nativeComparisonResults->size(); ++i) {
-        jComparisonResults[i] = (jboolean) (*nativeComparisonResults)[i];
-    }
-
-    env->SetBooleanArrayRegion(tempArray,
-                               0, nativeComparisonResults->size(),
-                               jComparisonResults);
-    testHandler->clearData();
-}
-
-// Find the gray checker borders from the native array of checker center and
-// radius. Convert the coordinate to the coordinates accepted by Android
-// Camera.Area type, which defines the top left corner to (-1000, -1000) and
-// bottom right corner to (1000, 1000).
-void Java_com_android_cts_verifier_camera_analyzer_MeteringTest_findGreyCoordinates(
-        JNIEnv*      env,
-        jobject      thiz,
-        jintArray    greyCoordinates,
-        jlong        checkercenterAddress,
-        jlong        checkerradiusAddress){
-
-    ALOGV("Start finding grey coordinates");
-
-    std::vector<std::vector< Vec2f > >* checkerCenter =
-            (std::vector<std::vector< Vec2f > >*) (long) checkercenterAddress;
-    std::vector<std::vector< float > >* checkerRadius =
-            (std::vector<std::vector< float > >*) (long) checkerradiusAddress;
-
-    ALOGV("Checker recovered!");
-    int nativeGreyCoordinates[24];
-
-    for (int i = 0; i < 6; ++i) {
-        float radius = sqrt((*checkerRadius)[3][i]);
-        nativeGreyCoordinates[i * 4] = static_cast<int>(
-                ((*checkerCenter)[3][i].y() - radius)
-                / 160.0 * 2000.0 - 1000.0);
-        nativeGreyCoordinates[i * 4 + 1] = static_cast<int>(
-                ((*checkerCenter)[3][i].x() - radius)
-                / 120.0 * 2000.0 - 1000.0);
-        nativeGreyCoordinates[i * 4 + 2] = static_cast<int>(
-                ((*checkerCenter)[3][i].y() + radius)
-                / 160.0 * 2000.0 - 1000.0);
-        nativeGreyCoordinates[i * 4 + 3] = static_cast<int>(
-                ((*checkerCenter)[3][i].x() + radius)
-                / 120.0 * 2000.0 - 1000.0);
-
-        ALOGV("checker is bounded by %f, %f, %f",
-             (*checkerCenter)[3][i].x(), (*checkerCenter)[3][i].y(), radius);
-
-        ALOGV("Square is bounded by %d, %d, %d, %d",
-             nativeGreyCoordinates[i * 4], nativeGreyCoordinates[i * 4 + 1],
-             nativeGreyCoordinates[i * 4 + 2],
-             nativeGreyCoordinates[i * 4 + 3]);
-    }
-
-    env->SetIntArrayRegion(greyCoordinates, 0, 24, nativeGreyCoordinates);
-}
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_MeteringTest.h b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_MeteringTest.h
deleted file mode 100644
index ecc1b96..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_MeteringTest.h
+++ /dev/null
@@ -1,60 +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.
- */
-
-#ifndef JNI_CAMERAANALYZER_METERINGTEST_H
-#define JNI_CAMERAANALYZER_METERINGTEST_H
-
-#include <jni.h>
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_MeteringTest_createMeteringTest(
-        JNIEnv*      env,
-        jobject      thiz);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_MeteringTest_createMeteringClass(
-        JNIEnv *env,
-        jobject thiz,
-        jlong inputAddress,
-        jlong handlerAddress,
-        jlong checkercenterAddress,
-        jlong checkerradiusAddress);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_MeteringTest_processMeteringTest(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        handlerAddress,
-        jbooleanArray    tempArray);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_MeteringTest_findGreyCoordinates(
-        JNIEnv*      env,
-        jobject      thiz,
-        jintArray    greyCoordinates,
-        jlong        checkercenterAddress,
-        jlong        checkerradiusAddress);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_WhiteBalanceTest.cpp b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_WhiteBalanceTest.cpp
deleted file mode 100644
index bce0fca..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_WhiteBalanceTest.cpp
+++ /dev/null
@@ -1,90 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "WhiteBalanceJNI"
-#include <utils/Log.h>
-#include "com_android_cts_verifier_camera_analyzer_WhiteBalanceTest.h"
-
-#include <vector>
-#include <string>
-#include <string.h>
-
-#include "testingimage.h"
-#include "whitebalancetest.h"
-#include "vec2.h"
-#include "android/bitmap.h"
-
-jlong Java_com_android_cts_verifier_camera_analyzer_WhiteBalanceTest_createWhiteBalanceTest(
-        JNIEnv*      env,
-        jobject      thiz) {
-
-    WhiteBalanceTest* testHandler = new WhiteBalanceTest();
-    long handlerAddress = (long)testHandler;
-    return handlerAddress;
-}
-
-void Java_com_android_cts_verifier_camera_analyzer_WhiteBalanceTest_createWhiteBalanceClass(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        inputImageAddress,
-        jlong        inputHandlerAddress,
-        jlong        checkercenterAddress,
-        jlong        checkerradiusAddress,
-        jstring      whiteBalance){
-
-    ALOGV("JNI createWhiteBalanceClass starts!");
-    long imageAddress = (long)inputImageAddress;
-    long handlerAddress = (long)inputHandlerAddress;
-
-    TestingImage *image = (TestingImage*) imageAddress;
-    WhiteBalanceTest *testHandler = (WhiteBalanceTest*) handlerAddress;
-
-    std::vector<std::vector< Vec2f > >* checkerCenter =
-        (std::vector<std::vector< Vec2f > >*) (long) checkercenterAddress;
-    std::vector<std::vector< float > >* checkerRadius =
-        (std::vector<std::vector< float > >*) (long) checkerradiusAddress;
-    ALOGV("Classes recovered");
-
-    jboolean isCopy;
-    const char* stringWhiteBalance =
-            env->GetStringUTFChars(whiteBalance, &isCopy);
-    ALOGV("White Balance is %s", stringWhiteBalance);
-
-    // Adds the gray checker's RGB values to the test handler.
-    testHandler->addDataToList(stringWhiteBalance,
-                               image->getColorChecker(3, 4, 0, 6,
-                                                      checkerCenter,
-                                                      checkerRadius));
-
-    env->ReleaseStringUTFChars(whiteBalance, stringWhiteBalance);
-    delete image;
-}
-
-jint Java_com_android_cts_verifier_camera_analyzer_WhiteBalanceTest_processWhiteBalanceTest(
-    JNIEnv*      env,
-    jobject      thiz,
-    jlong        inputHandlerAddress) {
-  ALOGV("Processing white balance test");
-
-  long handlerAddress = (long) inputHandlerAddress;
-  WhiteBalanceTest *testHandler = (WhiteBalanceTest*) handlerAddress;
-
-  testHandler->processData();
-
-  ALOGV("CCT is %d", testHandler->getCorrelatedColorTemp());
-  return testHandler->getCorrelatedColorTemp();
-}
diff --git a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_WhiteBalanceTest.h b/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_WhiteBalanceTest.h
deleted file mode 100644
index 88cf52e..0000000
--- a/apps/CtsVerifier/jni/cameraanalyzer/com_android_cts_verifier_camera_analyzer_WhiteBalanceTest.h
+++ /dev/null
@@ -1,53 +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.
- */
-
-#ifndef JNI_CAMERAANALYZER_WHITEBALANCETEST_H
-#define JNI_CAMERAANALYZER_WHITEBALANCETEST_H
-
-#include <jni.h>
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jlong JNICALL
-Java_com_android_cts_verifier_camera_analyzer_WhiteBalanceTest_createWhiteBalanceTest(
-        JNIEnv*      env,
-        jobject      thiz);
-
-JNIEXPORT void JNICALL
-Java_com_android_cts_verifier_camera_analyzer_WhiteBalanceTest_createWhiteBalanceClass(
-        JNIEnv *env,
-        jobject thiz,
-        jlong inputAddress,
-        jlong handlerAddress,
-        jlong checkercenterAddress,
-        jlong checkerradiusAddress,
-        jstring whiteBalance);
-
-JNIEXPORT jint JNICALL
-Java_com_android_cts_verifier_camera_analyzer_WhiteBalanceTest_processWhiteBalanceTest(
-        JNIEnv*      env,
-        jobject      thiz,
-        jlong        handlerAddress);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/apps/CtsVerifier/lib/Android.mk b/apps/CtsVerifier/lib/Android.mk
deleted file mode 100644
index 56a3fa8..0000000
--- a/apps/CtsVerifier/lib/Android.mk
+++ /dev/null
@@ -1,17 +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.
-#
-
-include $(call all-subdir-makefiles)
diff --git a/apps/CtsVerifier/lib/colorchecker/Android.mk b/apps/CtsVerifier/lib/colorchecker/Android.mk
deleted file mode 100644
index 48f1356..0000000
--- a/apps/CtsVerifier/lib/colorchecker/Android.mk
+++ /dev/null
@@ -1,43 +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)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libcolorchecker
-
-LOCAL_SRC_FILES += testingimage.cpp \
-                   vec3.cpp \
-                   vec2.cpp \
-                   imagetesthandler.cpp \
-                   colorcheckertest.cpp \
-                   exposurecompensationtest.cpp \
-                   autolocktest.cpp \
-                   meteringtest.cpp \
-                   whitebalancetest.cpp
-
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include/colorchecker
-LOCAL_CXX_STL := libc++
-LOCAL_SHARED_LIBRARIES := \
-    libcutils \
-    libutils \
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/apps/CtsVerifier/lib/colorchecker/autolocktest.cpp b/apps/CtsVerifier/lib/colorchecker/autolocktest.cpp
deleted file mode 100644
index 6bfa922..0000000
--- a/apps/CtsVerifier/lib/colorchecker/autolocktest.cpp
+++ /dev/null
@@ -1,101 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "AutoLockTest"
-#include <utils/Log.h>
-#include <utils/Timers.h>
-#include <cmath>
-#include <string>
-
-#include "vec2.h"
-#include "vec3.h"
-#include "autolocktest.h"
-
-const float kOverExposure = 230.f;
-const float kEqThreshold = 0.05f;
-// Processes the color checker values and compare the two values from
-// the same individual test.
-void AutoLockTest::processData() {
-    ALOGV("Start Processing Auto Lock Test Data!");
-
-    int numTests = mCheckerColors.size() / 2;
-    mNumPatches = 0;
-
-    if (numTests > 0) {
-        mNumPatches = mCheckerColors[0].size();
-    }
-
-    for (int i = 0; i < numTests; ++i) {
-        mComparisonResults.push_back(
-                IsBrighterThan((&mCheckerColors[i * 2]),
-                               (&mCheckerColors[i * 2 + 1])));
-        mComparisonResults.push_back(
-                IsEquivalentTo((&mCheckerColors[i * 2]),
-                               (&mCheckerColors[i * 2 + 1])));
-    }
-}
-
-// Compares whether one array of gray color patches is brighter than
-// another one.
-bool AutoLockTest::IsBrighterThan(
-        const std::vector<Vec3f>* colorCheckers1,
-        const std::vector<Vec3f>* colorCheckers2) const {
-    float meanRatio = 0.f;
-    int meanNumCount = 0;
-
-    for (int i = 0; i < mNumPatches; ++i) {
-        float luminance1 = (*colorCheckers1)[i].convertToLuminance();
-        float luminance2 = (*colorCheckers2)[i].convertToLuminance();
-
-        // Consider a 5% raise as a considerably large increase.
-        if ((luminance1 < kOverExposure) && (luminance2 != 0.f)) {
-            meanRatio += luminance1 / luminance2;
-            ++meanNumCount;
-        }
-    }
-    meanRatio = meanRatio / meanNumCount;
-
-    return (meanRatio > 1 + kEqThreshold);
-}
-
-// Compares whether one array of gray color patches is within a small range
-// of the other one to be considered equivalent.
-bool AutoLockTest::IsEquivalentTo(
-        const std::vector<Vec3f>* colorCheckers1,
-        const std::vector<Vec3f>* colorCheckers2) const {
-    float meanRatio = 0.f;
-    int meanNumCount = 0;
-
-    for (int i = 0; i < mNumPatches; ++i) {
-        float luminance1 = (*colorCheckers1)[i].convertToLuminance();
-        float luminance2 = (*colorCheckers2)[i].convertToLuminance();
-        ALOGV("Luma_1 and Luma_2 is %f, %f", luminance1, luminance2);
-
-        if ((luminance1 < kOverExposure) && (luminance2 < kOverExposure)) {
-              meanRatio += luminance2 / luminance1;
-              ++meanNumCount;
-        }
-    }
-    meanRatio = meanRatio / meanNumCount;
-
-    return ((meanRatio >= 1 - kEqThreshold) && (meanRatio <= 1 + kEqThreshold));
-}
-
-void AutoLockTest::clearData() {
-    mCheckerColors.clear();
-    mComparisonResults.clear();
-}
diff --git a/apps/CtsVerifier/lib/colorchecker/colorcheckertest.cpp b/apps/CtsVerifier/lib/colorchecker/colorcheckertest.cpp
deleted file mode 100644
index ef7d2c6..0000000
--- a/apps/CtsVerifier/lib/colorchecker/colorcheckertest.cpp
+++ /dev/null
@@ -1,979 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "ColorCheckerTest"
-#include <utils/Log.h>
-#include <utils/Timers.h>
-#include <cmath>
-#include <string>
-
-#include "vec2.h"
-#include "vec3.h"
-#include "colorcheckertest.h"
-
-const float GAMMA_CORRECTION = 2.2f;
-const float COLOR_ERROR_THRESHOLD = 200.f;
-ColorCheckerTest::~ColorCheckerTest() {
-    ALOGV("Deleting color checker test handler");
-
-    if (mImage != NULL) {
-        delete mImage;
-    }
-    ALOGV("Image deleted");
-
-    int numHorizontalLines = mCandidateColors.size();
-    int numVerticalLines = mCandidateColors[0].size();
-
-    for (int i = 0; i < numHorizontalLines; ++i) {
-        for (int j = 0; j < numVerticalLines; ++j) {
-            if (mCandidateColors[i][j] != NULL) {
-                delete mCandidateColors[i][j];
-            }
-            if (mCandidatePositions[i][j] != NULL) {
-                delete mCandidatePositions[i][j];
-            }
-        }
-    }
-    ALOGV("Candidates deleted!");
-
-    for (int i = 0; i < 4; ++i) {
-        for (int j = 0; j < 6; ++j) {
-            if (mMatchPositions[i][j] != NULL) {
-                delete mMatchPositions[i][j];
-            }
-            if (mReferenceColors[i][j] != NULL) {
-                delete mReferenceColors[i][j];
-            }
-            if (mMatchColors[i][j] != NULL) {
-                delete mMatchColors[i][j];
-            }
-        }
-    }
-}
-
-// Adds a new image to the test handler.
-void ColorCheckerTest::addTestingImage(TestingImage* inputImage) {
-    if (mImage != NULL) {
-        delete mImage;
-    }
-    mImage = NULL;
-    ALOGV("Original image deleted");
-    mImage = inputImage;
-
-    if ((mImage->getHeight() == getDebugHeight()) &&
-        (mImage->getWidth() == getDebugWidth())) {
-        copyDebugImage(getDebugHeight(), getDebugWidth(), mImage->getImage());
-    }
-}
-
-void ColorCheckerTest::processData() {
-    mSuccess = false;
-    initializeRefColor();
-    edgeDetection();
-}
-
-void ColorCheckerTest::initializeRefColor() {
-    mReferenceColors.resize(4, std::vector<Vec3i*>(6, NULL));
-    mMatchPositions.resize(4, std::vector<Vec2f*>(6, NULL));
-    mMatchColors.resize(4, std::vector<Vec3f*>(6, NULL));
-    mMatchRadius.resize(4, std::vector<float>(6, 0.f));
-
-    mReferenceColors[0][0]= new Vec3i(115, 82, 68);
-    mReferenceColors[0][1]= new Vec3i(194, 150, 130);
-    mReferenceColors[0][2]= new Vec3i(98, 122, 157);
-    mReferenceColors[0][3]= new Vec3i(87, 108, 67);
-    mReferenceColors[0][4]= new Vec3i(133, 128, 177);
-    mReferenceColors[0][5]= new Vec3i(103, 189, 170);
-    mReferenceColors[1][0]= new Vec3i(214, 126, 44);
-    mReferenceColors[1][1]= new Vec3i(80, 91, 166);
-    mReferenceColors[1][2]= new Vec3i(193, 90, 99);
-    mReferenceColors[1][3]= new Vec3i(94,  60, 108);
-    mReferenceColors[1][4]= new Vec3i(157, 188, 64);
-    mReferenceColors[1][5]= new Vec3i(224, 163, 46);
-    mReferenceColors[2][0]= new Vec3i(56, 61, 150);
-    mReferenceColors[2][1]= new Vec3i(70, 148, 73);
-    mReferenceColors[2][2]= new Vec3i(175, 54, 60);
-    mReferenceColors[2][3]= new Vec3i(231, 199, 31);
-    mReferenceColors[2][4]= new Vec3i(187, 86, 149);
-    mReferenceColors[2][5]= new Vec3i(8, 133, 161);
-    mReferenceColors[3][0]= new Vec3i(243, 243, 242);
-    mReferenceColors[3][1]= new Vec3i(200, 200, 200);
-    mReferenceColors[3][2]= new Vec3i(160, 160, 160);
-    mReferenceColors[3][3]= new Vec3i(122, 122, 121);
-    mReferenceColors[3][4]= new Vec3i(85, 85, 85);
-    mReferenceColors[3][5]= new Vec3i(52, 52, 52);
-}
-
-void ColorCheckerTest::edgeDetection() {
-    int width = mImage->getWidth();
-    int height = mImage->getHeight();
-
-    bool* edgeMap = new bool[height * width];
-    unsigned char* grayImage = new unsigned char[height * width];
-
-    // If the image is a color image and can be converted to a luminance layer
-    if (mImage->rgbToGrayScale(grayImage)) {
-        float* gradientMap = new float[height * width * 2];
-
-        // Computes the gradient image on the luminance layer.
-        computeGradient(grayImage, gradientMap);
-
-        float* gradientMagnitude = new float[height * width];
-        int* gradientDirectionInt = new int[height * width];
-        float* gradientDirection = new float[height * width];
-
-        // Computes the absolute gradient of the image without padding.
-        for (int i = 1; i < height - 1; ++i) {
-            for (int j = 1; j < width - 1; ++j) {
-                gradientMagnitude[i * width + j] =
-                        sqrt(gradientMap[(i * width + j) * 2] *
-                             gradientMap[(i * width + j) * 2] +
-                             gradientMap[(i * width + j ) * 2 + 1] *
-                             gradientMap[(i * width + j ) * 2 + 1]);
-
-                // Computes the gradient direction of the image.
-                if (gradientMap[(i * width + j) * 2] == 0 ) {
-                    // If the vertical gradient is 0, the edge is horizontal
-                    // Mark the gradient direction as 90 degrees.
-                    gradientDirectionInt[i * width + j] = 2;
-                    gradientDirection[i * width + j] = 90.0f;
-                } else {
-                    // Otherwise the atan operation is valid and can decide
-                    // the gradient direction of the edge.
-                    float gradient = atan(gradientMap[(i * width + j) * 2 + 1]
-                            / gradientMap[(i * width + j) * 2])
-                            / (M_PI / 4);
-
-                    gradientDirection[i * width + j] = gradient * 45.0f;
-
-                    // Maps the gradient direction to 4 major directions with
-                    // 0 mapped to up and 2 mapped to right.
-                    if (gradient - floor(gradient) > 0.5) {
-                        gradientDirectionInt[i * width + j] =
-                                (static_cast<int>(ceil(gradient)) + 4) % 4;
-                    } else {
-                        gradientDirectionInt[i * width + j] =
-                                (static_cast<int>(floor(gradient)) + 4) % 4;
-                    }
-                }
-            }
-        }
-
-        // Compute a boolean map to show whether a pixel is on the edge.
-        for (int i = 1; i < height - 1; ++i) {
-            for (int j = 1; j < width - 1; ++j) {
-                edgeMap[i * width + j] = false;
-
-                switch (gradientDirectionInt[i * width + j]) {
-                    case 0:
-                        // If the gradient points rightwards, the pixel is
-                        // on an edge if it has a larger absolute gradient than
-                        // pixels on its left and right sides.
-                        if ((gradientMagnitude[i * width + j] >=
-                                gradientMagnitude[i * width + j + 1]) &&
-                            (gradientMagnitude[i * width + j] >=
-                                gradientMagnitude[i * width + j - 1])) {
-                            edgeMap[i * width + j] = true;
-                        }
-                        break;
-                    case 1:
-                        // If the gradient points right-downwards, the pixel is
-                        // on an edge if it has a larger absolute gradient than
-                        // pixels on its upper left and bottom right sides.
-                        if ((gradientMagnitude[i * width + j] >=
-                                gradientMagnitude[(i + 1) * width + j + 1]) &&
-                            (gradientMagnitude[i * width + j] >=
-                                gradientMagnitude[(i - 1) * width + j - 1])) {
-                            edgeMap[i * width + j] = true;
-                        }
-                        break;
-                    case 2:
-                        // If the gradient points upwards, the pixel is
-                        // on an edge if it has a larger absolute gradient than
-                        // pixels on its up and down sides.
-                        if ((gradientMagnitude[i * width + j] >=
-                                gradientMagnitude[(i + 1) * width + j]) &&
-                            (gradientMagnitude[i * width + j] >=
-                                gradientMagnitude[(i - 1) * width + j])) {
-                            edgeMap[i * width + j] = true;
-                        }
-                        break;
-                    case 3:
-                        // If the gradient points right-upwards, the pixel is
-                        // on an edge if it has a larger absolute gradient than
-                        // pixels on its bottom left and upper right sides.
-                        if ((gradientMagnitude[i * width + j] >=
-                                gradientMagnitude[(i - 1) * width + j + 1]) &&
-                            (gradientMagnitude[i * width + j] >=
-                                gradientMagnitude[(i + 1) * width + j - 1])) {
-                            edgeMap[i * width + j] = true;
-                        }
-                  }
-
-             }
-        }
-
-        houghLineDetection(edgeMap, gradientMagnitude, gradientDirection);
-
-        // Cleans up
-        delete[] gradientMap;
-        delete[] gradientDirectionInt;
-        delete[] gradientMagnitude;
-        delete[] gradientDirection;
-
-    } else {
-        ALOGE("Not a color image!");
-    }
-
-    delete[] edgeMap;
-    delete[] grayImage;
-}
-
-// Runs the hough voting algorithm to find the grid of the color checker
-// with the edge map, gradient direction and gradient magnitude as inputs.
-void ColorCheckerTest::houghLineDetection(bool* edgeMap,
-                                          float* gradientMagnitude,
-                                          float* gradientDirection) {
-    // Constructs a graph for Hough voting. The vertical axis counts the vote
-    // for a certain angle. The horizontal axis counts the vote for the distance
-    // of a line from the origin of the image.
-    int houghHeight = 180;
-    int houghWidth = 200;
-    int houghCounts[houghHeight][houghWidth];
-    int houghSum[houghHeight][houghWidth];
-
-    int** houghVote;
-    houghVote = new int*[180];
-    for (int i = 0; i < 180; ++i) {
-        houghVote[i] = new int[200];
-    }
-
-    for (int i = 0; i < houghHeight; ++i) {
-        for (int j = 0; j < houghWidth; ++j) {
-            houghCounts[i][j] = 0;
-            houghVote[i][j] = 0;
-            houghSum[i][j] = 0;
-        }
-    }
-
-    // Vectors to record lines in two orthogonal directions.
-    // Each line is represented by its direction and its distance to the origin.
-    std::vector<std::vector<int> > verticalLines;
-    std::vector<std::vector<int> > horizontalLines;
-    float radius;
-    int height = mImage->getHeight();
-    int width = mImage->getWidth();
-
-    // Processes the signicant edge pixels and cast vote for the corresponding
-    // edge passing this pixel.
-    for (int i = 1; i < height - 1; ++i) {
-        for (int j = 1; j < width - 1; ++j) {
-            // Sets threashold for the gradient magnitude to discount noises
-            if (edgeMap[i * width + j] &&
-                (gradientMagnitude[i * width + j] > 15)) {
-                int shiftedAngle;
-
-                // Shifts angles for 45 degrees so the vertical and horizontal
-                // direction is mapped to 45 and 135 degrees to avoid padding.
-                // This uses the assumption that the color checker is placed
-                // roughly parallel to the image boarders. So that the edges
-                // at the angle of 45 will be rare.
-                shiftedAngle = (static_cast<int>(
-                        -gradientDirection[i * width + j]) + 225 % 180);
-                float shiftedAngleRad = static_cast<float>(shiftedAngle)
-                        * M_PI / 180.0f;
-
-                // Computes the distance of the line from the origin.
-                float a, b;
-                a = static_cast<float>(i - j) / sqrt(2.0f);
-                b = static_cast<float>(i + j) / sqrt(2.0f);
-                radius = a * sin(shiftedAngleRad) - b * cos(shiftedAngleRad);
-
-                // Adds one vote for the line. The line's angle is shifted by
-                // 45 degrees to avoid avoid padding for the vertical lines,
-                // which is more common than diagonal lines. The line's
-                // distance is mapped to [0, 200] from [-200, 200].
-                ++houghCounts[shiftedAngle][static_cast<int>((radius / 2.0f) +
-                                                              100.0f)];
-
-                drawPoint(i, j, Vec3i(255, 255, 255));
-            }
-        }
-    }
-
-    int houghAngleSum[houghHeight];
-    int primaryVerticalAngle, primaryHorizontalAngle;
-    int max1 = 0;
-    int max2 = 0;
-
-    // Looking for the two primary angles of the lines.
-    for (int i = 5; i < houghHeight - 5; ++i) {
-        houghAngleSum[i] = 0;
-        for (int j = 0; j < houghWidth; ++j) {
-            for (int l = -5; l <= 5; ++l) {
-                houghSum[i][j] += houghCounts[i + l][j];
-            }
-            houghAngleSum[i] += houghSum[i][j];
-        }
-
-        if ((i < houghHeight / 2) && (houghAngleSum[i] > max1)) {
-            max1 = houghAngleSum[i];
-            primaryVerticalAngle = i;
-        } else if ((i > houghHeight / 2) && (houghAngleSum[i] > max2)) {
-            max2 = houghAngleSum[i];
-            primaryHorizontalAngle = i;
-        }
-    }
-
-    ALOGV("Primary angles are %d, %d",
-         primaryVerticalAngle, primaryHorizontalAngle);
-
-    int angle;
-
-    // For each primary angle, look for the highest voted lines.
-    for (int k = 0; k < 2; ++k) {
-        if (k == 0) {
-            angle = primaryVerticalAngle;
-        } else {
-            angle = primaryHorizontalAngle;
-        }
-
-        std::vector<int> line(2);
-        for (int j = 2; j < houghWidth - 2; ++j) {
-            houghVote[angle][j] = houghSum[angle][j];
-            houghSum[angle][j] = 0;
-        }
-
-        // For each radius, average the vote with nearby ones.
-        for (int j = 2; j < houghWidth - 2; ++j) {
-            for (int m = -2; m <= 2; ++m) {
-                houghSum[angle][j] += houghVote[angle][j + m];
-            }
-        }
-
-        bool isCandidate[houghWidth];
-
-        // Find whether a lines is a candidate by rejecting the ones that have
-        // lower vote than others in the neighborhood.
-        for (int j = 2; j < houghWidth - 2; ++j) {
-            isCandidate[j] = true;
-            for (int m = -2; ((isCandidate[j]) && (m <= 2)); ++m) {
-                if ((houghSum[angle][j] < 20) ||
-                    (houghSum[angle][j] < houghSum[angle][j + m])) {
-                    isCandidate[j] = false;
-                }
-            }
-        }
-
-        int iter1 = 0;
-        int iter2 = 0;
-        int count = 0;
-
-        // Finds the lines that are not too close to each other and add to the
-        // detected lines.
-        while (iter2 < houghWidth) {
-            while ((!isCandidate[iter2]) && (iter2 < houghWidth)) {
-                ++iter2;
-            }
-            if ((isCandidate[iter2]) && (iter2 - iter1 < 5)) {
-                iter1 = (iter2 + iter1) / 2;
-                ++iter2;
-            } else {
-                line[0] = angle;
-                line[1] = (iter1 - 100) * 2;
-                if (iter1 != 0) {
-                    if (k == 0) {
-                        verticalLines.push_back(line);
-                        Vec3i color(verticalLines.size() * 20, 0, 0);
-                        drawLine(line[0], line[1], color);
-                    } else {
-                        horizontalLines.push_back(line);
-                        Vec3i color(0, horizontalLines.size() * 20, 0);
-                        drawLine(line[0], line[1], color);
-                    }
-                }
-                iter1 = iter2;
-                ++iter2;
-                ALOGV("pushing back line %d %d", line[0], line[1]);
-            }
-        }
-    }
-
-    ALOGV("Numbers of lines in each direction is %d, %d",
-         verticalLines.size(), horizontalLines.size());
-
-    for (int i = 0; i < 180; ++i) {
-        delete[] houghVote[i];
-    }
-    delete[] houghVote;
-
-    findCheckerBoards(verticalLines, horizontalLines);
-}
-
-// Computes the gradient in both x and y direction of a layer
-void ColorCheckerTest::computeGradient(unsigned char* layer,
-                                       float* gradientMap) {
-    int width = mImage->getWidth();
-    int height = mImage->getHeight();
-
-    // Computes the gradient in the whole image except the image boarders.
-    for (int i = 1; i < height - 1; ++i) {
-        for (int j = 1; j < width - 1; ++j) {
-            gradientMap[(i * width + j) * 2] =
-                    0.5f * (layer[i * width + j + 1] -
-                            layer[i * width + j - 1]);
-            gradientMap[(i * width + j) * 2 + 1] =
-                    0.5f * (layer[(i + 1) * width + j] -
-                           layer[(i - 1) * width + j]);
-        }
-    }
-}
-
-// Tries to find the checker boards with the highest voted lines
-void ColorCheckerTest::findCheckerBoards(
-        std::vector<std::vector<int> > verticalLines,
-        std::vector<std::vector<int> > horizontalLines) {
-    ALOGV("Start looking for Color checker");
-
-    int numHorizontalLines = mCandidateColors.size();
-    int numVerticalLines;
-    if (numHorizontalLines > 0) {
-        numVerticalLines = mCandidateColors[0].size();
-        for (int i = 0; i < numHorizontalLines; ++i) {
-            for (int j = 0; j < numVerticalLines; ++j) {
-                if (mCandidateColors[i][j] != NULL) {
-                    delete mCandidateColors[i][j];
-                }
-                if (mCandidatePositions[i][j] != NULL) {
-                    delete mCandidatePositions[i][j];
-                }
-            }
-            mCandidateColors[i].clear();
-            mCandidatePositions[i].clear();
-        }
-    }
-    mCandidateColors.clear();
-    mCandidatePositions.clear();
-
-    ALOGV("Candidates deleted!");
-
-    numVerticalLines = verticalLines.size();
-    numHorizontalLines = horizontalLines.size();
-    Vec2f pointUpperLeft;
-    Vec2f pointBottomRight;
-
-    mCandidateColors.resize(numHorizontalLines - 1);
-    mCandidatePositions.resize(numHorizontalLines - 1);
-
-    for (int i = numVerticalLines - 1; i >= 1; --i) {
-        for (int j = 0; j < numHorizontalLines - 1; ++j) {
-            // Finds the upper left and bottom right corner of each rectangle
-            // formed by two neighboring highest voted lines.
-            pointUpperLeft = findCrossing(verticalLines[i], horizontalLines[j]);
-            pointBottomRight = findCrossing(verticalLines[i - 1],
-                                            horizontalLines[j + 1]);
-
-            Vec3i* color = new Vec3i();
-            Vec2f* pointCenter = new Vec2f();
-            // Verifies if they are separated by a reasonable distance.
-            if (verifyPointPair(pointUpperLeft, pointBottomRight,
-                                pointCenter, color)) {
-                mCandidatePositions[j].push_back(pointCenter);
-                mCandidateColors[j].push_back(color);
-                ALOGV("Color at (%d, %d) is (%d, %d, %d)", j, i,color->r(), color->g(), color->b());
-
-            } else {
-                mCandidatePositions[j].push_back(NULL);
-                mCandidateColors[j].push_back(NULL);
-                delete color;
-                delete pointCenter;
-            }
-        }
-    }
-
-    ALOGV("Candidates Number (%d, %d)", mCandidateColors.size(), mCandidateColors[0].size());
-    // Verifies whether the current line candidates form a valid color checker.
-    verifyColorGrid();
-}
-
-// Returns the corssing point of two lines given the lines.
-Vec2f ColorCheckerTest::findCrossing(std::vector<int> line1,
-                                     std::vector<int> line2) {
-    Vec2f crossingPoint;
-    float r1 = static_cast<float>(line1[1]);
-    float r2 = static_cast<float>(line2[1]);
-    float ang1, ang2;
-    float y1, y2;
-
-    ang1 = static_cast<float>(line1[0]) / 180.0f * M_PI;
-    ang2 = static_cast<float>(line2[0]) / 180.0f * M_PI;
-
-    float x, y;
-    x = (r1 * cos(ang2) - r2 * cos(ang1)) / sin(ang1 - ang2);
-    y = (r1 * sin(ang2) - r2 * sin(ang1)) / sin(ang1 - ang2);
-
-    crossingPoint.set((x + y) / sqrt(2.0), (y - x) / sqrt(2.0));
-
-    //ALOGV("Crosspoint at (%f, %f)", crossingPoint.x(), crossingPoint.y());
-    return crossingPoint;
-}
-
-// Verifies whether two opposite corners on a quadrilateral actually can be
-// the two corners of a color checker.
-bool ColorCheckerTest::verifyPointPair(Vec2f pointUpperLeft,
-                                       Vec2f pointBottomRight,
-                                       Vec2f* pointCenter,
-                                       Vec3i* color) {
-    bool success = true;
-
-    /** 5 and 30 are the threshold tuned for resolution 640*480*/
-    if ((pointUpperLeft.x() < 0) ||
-        (pointUpperLeft.x() >= mImage->getHeight()) ||
-        (pointUpperLeft.y() < 0) ||
-        (pointUpperLeft.y() >= mImage->getWidth()) ||
-        (pointBottomRight.x() < 0) ||
-        (pointBottomRight.x() >= mImage->getHeight()) ||
-        (pointBottomRight.y() < 0) ||
-        (pointBottomRight.y() >= mImage->getWidth()) ||
-        (std::abs(pointUpperLeft.x() - pointBottomRight.x()) <= 5) ||
-        (std::abs(pointUpperLeft.y() - pointBottomRight.y()) <= 5) ||
-        (std::abs(pointUpperLeft.x() - pointBottomRight.x()) >= 30) ||
-        (std::abs(pointUpperLeft.y() - pointBottomRight.y()) >= 30)) {
-
-        // If any of the quadrilateral corners are out of the image or if
-        // the distance between them are too large or too big, the quadrilateral
-        // could not be one of the checkers
-        success = false;
-    } else {
-        // Find the checker center if the corners of the rectangle meet criteria
-        pointCenter->set((pointUpperLeft.x() + pointBottomRight.x()) / 2.0f,
-                       (pointUpperLeft.y() + pointBottomRight.y()) / 2.0f);
-        color->set(mImage->getPixelValue(*pointCenter).r(),
-                   mImage->getPixelValue(*pointCenter).g(),
-                   mImage->getPixelValue(*pointCenter).b());
-        ALOGV("Color at (%f, %f) is (%d, %d, %d)", pointCenter->x(), pointCenter->y(),color->r(), color->g(), color->b());
-    }
-    return success;
-}
-
-// Verifies the color checker centers and finds the match between the detected
-// color checker and the reference MacBeth color checker
-void ColorCheckerTest::verifyColorGrid() {
-    ALOGV("Start looking for Color Grid");
-    int numHorizontalLines = mCandidateColors.size();
-    int numVerticalLines = mCandidateColors[0].size();
-    bool success = false;
-
-    // Computes the standard deviation of one row/column of the proposed color
-    // checker. Discards the row/column if the std is below a threshold.
-    for (int i = 0; i < numHorizontalLines; ++i) {
-        Vec3f meanColor(0.f, 0.f, 0.f);
-        int numNonZero = 0;
-
-        for (int j = 0; j < numVerticalLines; ++j) {
-            if (mCandidateColors[i][j] != NULL) {
-                ALOGV("candidate color (%d, %d) is (%d, %d, %d)", i, j, mCandidateColors[i][j]->r(), mCandidateColors[i][j]->g(), mCandidateColors[i][j]->b());
-
-                meanColor = meanColor + (*mCandidateColors[i][j]);
-                ++numNonZero;
-            }
-        }
-        if (numNonZero > 0) {
-            meanColor = meanColor / numNonZero;
-        }
-        ALOGV("Mean color for vertical direction computed!");
-
-        float std = 0;
-        for (int j = 0; j < numVerticalLines; ++j) {
-            if (mCandidateColors[i][j] != NULL) {
-                std += mCandidateColors[i][j]->squareDistance<float>(meanColor);
-            }
-        }
-        if (numNonZero > 0) {
-            std = sqrt(std / (3 * numNonZero));
-        }
-        ALOGV("st. deviation for the %d dir1 is %d", i, static_cast<int>(std));
-
-        if ((std <= 30) && (numNonZero > 1)) {
-            for (int j = 0; j < numVerticalLines; ++j) {
-                if (mCandidateColors[i][j] != NULL) {
-                    delete mCandidateColors[i][j];
-                    mCandidateColors[i][j] = NULL;
-                }
-            }
-        }
-    }
-
-    // Discards the column/row of the color checker if the std is below a
-    // threshold.
-    for (int j = 0; j < numVerticalLines; ++j) {
-        Vec3f meanColor(0.f, 0.f, 0.f);
-        int numNonZero = 0;
-
-        for (int i = 0; i < numHorizontalLines; ++i) {
-            if (mCandidateColors[i][j] != NULL) {
-                meanColor = meanColor + (*mCandidateColors[i][j]);
-                ++numNonZero;
-            }
-        }
-        if (numNonZero > 0) {
-            meanColor = meanColor / numNonZero;
-        }
-
-        float std = 0;
-        for (int i = 0; i < numHorizontalLines; ++i) {
-            if (mCandidateColors[i][j] != NULL) {
-                std += mCandidateColors[i][j]->squareDistance<float>(meanColor);
-            }
-        }
-        if (numNonZero > 0) {
-            std = sqrt(std / (3 * numNonZero));
-        }
-
-        ALOGV("st. deviation for the %d dir2 is %d", j, static_cast<int>(std));
-
-        if ((std <= 30) && (numNonZero > 1)) {
-            for (int i = 0; i < numHorizontalLines; ++i) {
-                if (mCandidateColors[i][j] != NULL) {
-                    delete mCandidateColors[i][j];
-                    mCandidateColors[i][j] = NULL;
-                }
-            }
-        }
-    }
-
-    for (int i = 0; i < numHorizontalLines; ++i) {
-        for (int j = 0; j < numVerticalLines; ++j) {
-            if (mCandidateColors[i][j] != NULL) {
-                ALOGV("position (%d, %d) is at (%f, %f) with color (%d, %d, %d)",
-                     i, j,
-                     mCandidatePositions[i][j]->x(),
-                     mCandidatePositions[i][j]->y(),
-                     mCandidateColors[i][j]->r(),
-                     mCandidateColors[i][j]->g(),
-                     mCandidateColors[i][j]->b());
-            } else {
-                ALOGV("position (%d, %d) is 0", i, j);
-            }
-        }
-    }
-
-    // Finds the match between the detected color checker and the reference
-    // MacBeth color checker.
-    int rowStart = 0;
-    int rowEnd = 0;
-
-    // Loops until all dectected color checker has been processed.
-    while (!success) {
-        int columnStart = 0;
-        int columnEnd = 0;
-        bool isRowStart = false;
-        bool isRowEnd = true;
-
-        // Finds the row start of the next block of detected color checkers.
-        while ((!isRowStart) && (rowStart <  numHorizontalLines)) {
-            for (int j = 0; j < numVerticalLines; ++j) {
-                if (mCandidateColors[rowStart][j] != NULL) {
-                    isRowStart = true;
-                }
-            }
-            ++rowStart;
-        }
-        rowStart--;
-        rowEnd = rowStart;
-        ALOGV("rowStart is %d", rowStart);
-
-        // Finds the row end of the next block of detected color checkers.
-        while ((isRowEnd) && (rowEnd < numHorizontalLines)) {
-            isRowEnd = false;
-            for (int j = 0; j < numVerticalLines; ++j) {
-                if (mCandidateColors[rowEnd][j] != NULL) {
-                    isRowEnd= true;
-                }
-            }
-            if (isRowEnd) {
-                ++rowEnd;
-            }
-        }
-        if ((!isRowEnd) && isRowStart) {
-            rowEnd--;
-        }
-        if ((isRowEnd) && (rowEnd == numHorizontalLines)) {
-            rowEnd--;
-            isRowEnd = false;
-        }
-        ALOGV("rowEnd is %d", rowEnd);
-
-        // Matches color checkers between the start row and the end row.
-        bool successVertical = false;
-
-        while (!successVertical) {
-            bool isColumnEnd = true;
-            bool isColumnStart = false;
-
-            // Finds the start column of the next block of color checker
-            while ((!isColumnStart) && (columnStart < numVerticalLines)) {
-                if (mCandidateColors[rowStart][columnStart] != NULL) {
-                    isColumnStart = true;
-                }
-                ++columnStart;
-            }
-            columnStart--;
-            columnEnd = columnStart;
-
-            // Finds the end column of the next block of color checker
-            while ((isColumnEnd) && (columnEnd < numVerticalLines)) {
-                isColumnEnd = false;
-                if (mCandidateColors[rowStart][columnEnd] != NULL)
-                    isColumnEnd = true;
-                if (isColumnEnd) {
-                    ++columnEnd;
-                }
-            }
-
-            if ((!isColumnEnd) && isColumnStart) {
-                columnEnd--;
-            }
-            if ((isColumnEnd) && (columnEnd == numVerticalLines)) {
-                columnEnd--;
-                isColumnEnd = false;
-            }
-
-            // Finds the best match on the MacBeth reference color checker for
-            // the continuous block of detected color checker
-            if (isRowStart && (!isRowEnd) &&
-                isColumnStart && (!isColumnEnd)) {
-                findBestMatch(rowStart, rowEnd, columnStart, columnEnd);
-            }
-            ALOGV("FindBestMatch for %d, %d, %d, %d", rowStart,
-                 rowEnd, columnStart, columnEnd);
-
-            // If the column search finishes, go out of the loop
-            if (columnEnd >= numVerticalLines - 1) {
-                successVertical = true;
-            } else {
-                columnStart = columnEnd + 1;
-            }
-        }
-        ALOGV("Continuing to search for direction 1");
-
-        // If the row search finishes, go out of the loop
-        if (rowEnd >= numHorizontalLines - 1) {
-            success = true;
-        } else {
-            rowStart = rowEnd + 1;
-        }
-    }
-
-    for (int i = 0; i < 4; ++i) {
-        for (int j = 0; j < 6; ++j) {
-            if (mMatchPositions[i][j] != NULL) {
-                ALOGV("Reference Match position for (%d, %d) is (%f, %f)", i, j,
-                     mMatchPositions[i][j]->x(), mMatchPositions[i][j]->y());
-            }
-        }
-    }
-
-    fillRefColorGrid();
-}
-
-// Finds the best match on the MacBeth color checker for the continuous block of
-// detected color checkers bounded by row i1, row i2 and column j1 and column j2
-// Assumes that the subsample is less than 4*6.
-void ColorCheckerTest::findBestMatch(int i1, int i2, int j1, int j2) {
-    int numHorizontalGrid = i2 - i1 + 1;
-    int numVerticalGrid = j2 - j1 + 1;
-
-    if (((numHorizontalGrid > 1) || (numVerticalGrid > 1)) &&
-        (numHorizontalGrid <= 4) && (numVerticalGrid <= 6)) {
-        ALOGV("i1, j2, j1, j2 is %d, %d, %d, %d", i1, i2, j1, j2);
-        float minError;
-        float error = 0.f;
-        int horizontalMatch, verticalMatch;
-
-        // Finds the match start point where the error is minimized.
-        for (int i = 0; i < numHorizontalGrid; ++i) {
-            for (int j = 0; j < numVerticalGrid; ++j) {
-                if (mCandidateColors[i1 + i][j1 + j] != NULL) {
-                    error += mCandidateColors[i1 + i][j1 + j]->squareDistance<int>(
-                            *mReferenceColors[i][j]);
-                }
-            }
-        }
-        ALOGV("Error is %f", error);
-        minError = error;
-        horizontalMatch = 0;
-        verticalMatch = 0;
-
-        for (int i = 0; i <= 4 - numHorizontalGrid; ++i) {
-            for (int j = 0; j <= 6 - numVerticalGrid; ++j) {
-                error = 0.f;
-
-                for (int id = 0; id < numHorizontalGrid; ++id) {
-                    for (int jd = 0; jd < numVerticalGrid; ++jd) {
-                        if (mCandidateColors[i1 + id][j1 + jd] != NULL) {
-                            error += mCandidateColors[i1 + id][j1 + jd]->
-                                    squareDistance<int>(
-                                            *mReferenceColors[i + id][j + jd]);
-                        }
-                    }
-                }
-
-                if (error < minError) {
-                    minError = error;
-                    horizontalMatch = i;
-                    verticalMatch = j;
-                }
-                ALOGV("Processed %d, %d and error is %f", i, j, error );
-            }
-        }
-
-        for (int id = 0; id < numHorizontalGrid; ++id) {
-            for (int jd = 0; jd < numVerticalGrid; ++jd) {
-                if (mCandidatePositions[i1 + id][j1 + jd] != NULL) {
-                    mMatchPositions[horizontalMatch + id][verticalMatch + jd] =
-                            new Vec2f(mCandidatePositions[i1 + id][j1 + jd]->x(),
-                                      mCandidatePositions[i1 + id][j1 + jd]->y());
-                }
-            }
-        }
-        ALOGV("Grid match starts at %d, %d", horizontalMatch, verticalMatch);
-    }
-}
-
-// Finds the boundary of a color checker by its color similarity to the center.
-// Also predicts the location of unmatched checkers.
-void ColorCheckerTest::fillRefColorGrid() {
-    int rowStart = 0;
-    int columnStart = 0;
-    bool foundStart = true;
-
-    for (int i = 0; (i < 4) && foundStart; ++i) {
-        for (int j = 0; (j < 6) && foundStart; ++j) {
-            if (mMatchPositions[i][j] != NULL) {
-                rowStart = i;
-                columnStart = j;
-                foundStart = false;
-            }
-        }
-    }
-    ALOGV("First match found at (%d, %d)", rowStart, columnStart);
-
-    float rowDistance, columnDistance;
-    rowDistance = 0;
-    columnDistance = 0;
-    int numRowGrids = 0;
-    int numColumnGrids = 0;
-
-    for (int i = rowStart; i < 4; ++i) {
-        for (int j = columnStart; j < 6; ++j) {
-            if (mMatchPositions[i][j] != NULL) {
-                if (i > rowStart) {
-                    ++numRowGrids;
-                    rowDistance += (mMatchPositions[i][j]->x() -
-                                mMatchPositions[rowStart][columnStart]->x()) /
-                                static_cast<float>(i - rowStart);
-                }
-                if (j > columnStart) {
-                    ++numColumnGrids;
-                    columnDistance += (mMatchPositions[i][j]->y() -
-                                mMatchPositions[rowStart][columnStart]->y()) /
-                                static_cast<float>(j - columnStart);
-                }
-            }
-        }
-    }
-
-    if ((numRowGrids > 0) && (numColumnGrids > 0)) {
-        rowDistance = rowDistance / numRowGrids;
-        columnDistance = columnDistance / numColumnGrids;
-        ALOGV("delta is %f, %f", rowDistance, columnDistance);
-
-        for (int i = 0; i < 4; ++i) {
-            for (int j = 0 ; j < 6; ++j) {
-                if (mMatchPositions[i][j] == NULL) {
-                    mMatchPositions[i][j] = new Vec2f(
-                            mMatchPositions[rowStart][columnStart]->x() +
-                                    (i - rowStart) * rowDistance,
-                            mMatchPositions[rowStart][columnStart]->y() +
-                                    (j - columnStart) * columnDistance);
-                }
-            }
-        }
-        for (int i = 0; i < 4; ++i) {
-            for (int j = 0; j < 6; ++j) {
-                float radius = 0;
-                Vec3i color = mImage->getPixelValue(*mMatchPositions[i][j]);
-                Vec3f meanColor(0.f , 0.f, 0.f);
-
-                int numPixels = 0;
-                for (int ii  = static_cast<int>(mMatchPositions[i][j]->x() -
-                                                rowDistance/2);
-                     ii <= static_cast<int>(mMatchPositions[i][j]->x() +
-                                            rowDistance/2);
-                     ++ii) {
-                    for (int jj = static_cast<int>(mMatchPositions[i][j]->y() -
-                                                   columnDistance/2);
-                         jj <= static_cast<int>(mMatchPositions[i][j]->y() +
-                                                columnDistance/2);
-                         ++jj) {
-                        if ((ii >= 0) && (ii < mImage->getHeight()) &&
-                            (jj >= 0) && (jj < mImage->getWidth())) {
-                            Vec3i pixelColor = mImage->getPixelValue(ii,jj);
-                            float error = color.squareDistance<int>(pixelColor);
-
-                            if (error < COLOR_ERROR_THRESHOLD) {
-                                drawPoint(ii, jj, *mReferenceColors[i][j]);
-                                meanColor = meanColor + pixelColor;
-                                numPixels++;
-                                Vec2i pixelPosition(ii, jj);
-
-                                if (pixelPosition.squareDistance<float>(
-                                        *mMatchPositions[i][j]) > radius) {
-                                    radius = pixelPosition.squareDistance<float>(
-                                            *mMatchPositions[i][j]);
-                                }
-                            }
-                        }
-                    }
-                }
-
-                /** Computes the radius of the checker.
-                 * The above computed radius is the squared distance to the
-                 * furthest point with a matching color. To be conservative, we
-                 * only consider an area with radius half of the above computed
-                 * value. Since radius is computed as a squared root, the one
-                 * that will be recorded is 1/4 of the above computed value.
-                 */
-                mMatchRadius[i][j] = radius / 4.f;
-                mMatchColors[i][j] = new Vec3f(meanColor / numPixels);
-
-                ALOGV("Reference color at (%d, %d) is (%d, %d, %d)", i, j,
-                     mReferenceColors[i][j]->r(),
-                     mReferenceColors[i][j]->g(),
-                     mReferenceColors[i][j]->b());
-                ALOGV("Average color at (%d, %d) is (%f, %f, %f)", i, j,
-                     mMatchColors[i][j]->r(),
-                     mMatchColors[i][j]->g(),
-                     mMatchColors[i][j]->b());
-                ALOGV("Radius is %f", mMatchRadius[i][j]);
-            }
-        }
-
-        mSuccess = true;
-    }
-}
diff --git a/apps/CtsVerifier/lib/colorchecker/exposurecompensationtest.cpp b/apps/CtsVerifier/lib/colorchecker/exposurecompensationtest.cpp
deleted file mode 100644
index da9fc40..0000000
--- a/apps/CtsVerifier/lib/colorchecker/exposurecompensationtest.cpp
+++ /dev/null
@@ -1,96 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "ExposureCompensationTest"
-#include <utils/Log.h>
-#include <utils/Timers.h>
-#include <cmath>
-#include <string>
-#include <stdio.h>
-
-#include "vec2.h"
-#include "vec3.h"
-#include "exposurecompensationtest.h"
-
-const float GAMMA_CORRECTION = 2.2f;
-void ExposureCompensationTest::processData() {
-    ALOGV("Start Processing Exposure Compensation Test Data!");
-    clearDebugImage();
-
-    if (mDebugText != NULL) {
-        delete mDebugText;
-        mDebugText = NULL;
-    }
-
-    int numTests = mExposureValues.size();
-    int numPatches = mCheckerColors[0].size();
-    ALOGV("Processing %d tests with %d patches", numTests, numPatches);
-
-    mDebugText = new char[320 * numTests];
-    mDebugText[0] = 0;
-    char* debugText = new char[50];
-
-    Vec3i red(255, 0, 0);
-    Vec3i green(0, 255, 0);
-    Vec3i blue(0, 0, 255);
-
-    float minExposure = -3.0f;
-    float scale = 9.0f;
-    for (int i = 0; i < numTests; ++i) {
-        snprintf(debugText, 50, "Exposure is %f \n", mExposureValues[i]);
-        strcat(mDebugText, debugText);
-        for (int j = 0; j < numPatches; ++j) {
-            int exposureRed = static_cast<int>((
-                log(static_cast<float>(mReferenceColors[j].r()))
-                / log(2.0f) * GAMMA_CORRECTION +
-                mExposureValues[i] - minExposure) * scale);
-            int exposureGreen = static_cast<int>((
-                log(static_cast<float>(mReferenceColors[j].g()))
-                / log(2.0f) * GAMMA_CORRECTION +
-                mExposureValues[i] - minExposure) * scale);
-            int exposureBlue = static_cast<int>((
-                log(static_cast<float>(mReferenceColors[j].b()))
-                / log(2.0f) * GAMMA_CORRECTION +
-                mExposureValues[i] - minExposure) * scale);
-
-            snprintf(debugText, 50, "%d %f %d %f %d %f \n",
-                    exposureRed, mCheckerColors[i][j].r(),
-                    exposureGreen, mCheckerColors[i][j].g(),
-                    exposureBlue, mCheckerColors[i][j].b());
-
-            ALOGV("%s", debugText);
-            strcat(mDebugText, debugText);
-
-            drawPoint(200 - exposureRed, mCheckerColors[i][j].r(), red);
-            drawPoint(200 - exposureGreen, mCheckerColors[i][j].g(), green);
-            drawPoint(200 - exposureBlue, mCheckerColors[i][j].b(), blue);
-        }
-    }
-    mExposureValues.clear();
-    mCheckerColors.clear();
-}
-
-void ExposureCompensationTest::initializeReferenceColors() {
-    mReferenceColors.resize(6);
-
-    mReferenceColors[0].set(243, 243, 242);
-    mReferenceColors[1].set(200, 200, 200);
-    mReferenceColors[2].set(160, 160, 160);
-    mReferenceColors[3].set(122, 122, 121);
-    mReferenceColors[4].set(85, 85, 85);
-    mReferenceColors[5].set(52, 52, 52);
-}
diff --git a/apps/CtsVerifier/lib/colorchecker/imagetesthandler.cpp b/apps/CtsVerifier/lib/colorchecker/imagetesthandler.cpp
deleted file mode 100644
index 1c5bc17..0000000
--- a/apps/CtsVerifier/lib/colorchecker/imagetesthandler.cpp
+++ /dev/null
@@ -1,101 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "ImageTestHandler"
-#include <utils/Log.h>
-#include <utils/Timers.h>
-#include <cmath>
-
-#include "vec2.h"
-#include "vec3.h"
-#include "imagetesthandler.h"
-
-void ImageTestHandler::initDebugImage() {
-    mDebugOutput = NULL;
-}
-
-// Initializes the  debug image with a given height and width.
-void ImageTestHandler::initDebugImage(int debugHeight,
-                                      int debugWidth) {
-    mDebugOutput = NULL;
-    mDebugOutput = new unsigned char[debugHeight * debugWidth * 4];
-    memset(mDebugOutput, 0, debugHeight * debugWidth * 4);
-
-    mDebugHeight = debugHeight;
-    mDebugWidth = debugWidth;
-}
-
-// Copies an existing image to the debug image.
-void ImageTestHandler::copyDebugImage(int inputHeight, int inputWidth,
-                                      const unsigned char* inputImage) {
-    if ((inputHeight == mDebugHeight) && (inputWidth == mDebugWidth)) {
-        ALOGV("Copying debug images");
-        memcpy(mDebugOutput, inputImage, mDebugHeight * mDebugWidth * 4);
-    }
-}
-
-void ImageTestHandler::clearDebugImage() {
-    if (mDebugOutput != NULL) {
-        delete[] mDebugOutput;
-        mDebugOutput = new unsigned char[mDebugHeight * mDebugWidth * 4];
-        memset(mDebugOutput, 0, mDebugHeight * mDebugWidth * 4);
-    }
-}
-
-
-// Draws a point of a given color.
-void ImageTestHandler::drawPoint(int row, int column, const Vec3i &color) {
-    if ((row >= 0) && (column >= 0) &&
-        (column < mDebugWidth) && (row < mDebugHeight)) {
-        mDebugOutput[(row*mDebugWidth + column) * 4] = color.r();
-        mDebugOutput[(row*mDebugWidth + column) * 4+1] = color.g();
-        mDebugOutput[(row*mDebugWidth + column) * 4+2] = color.b();
-        mDebugOutput[(row*mDebugWidth + column) * 4+3] = 255;
-    }
-}
-
-// Draws a point in Vec2 format of a given color.
-void ImageTestHandler::drawPoint(const Vec2i &point, const Vec3i &color) {
-    drawPoint((int) point.y(), (int) point.x(), color);
-}
-
-// Draws a line of a given color.
-void ImageTestHandler::drawLine(int angle, int radius, const Vec3i &color) {
-    const int r = color.r();
-    const int g = color.g();
-    const int b = color.b();
-    const int a = 255;
-
-    int shiftedMin = -113;
-    int shiftedMax = 83;
-
-    float radiusDouble = static_cast<float>(radius);
-
-    float angleRad = static_cast<float>(angle) * M_PI / 180.0;
-
-    //ALOGV("draw line for (%d, %d)", angle, radius);
-    for (int i = shiftedMin; i <= shiftedMax; ++i) {
-        float j;
-
-        assert(angle != 0);
-        j = (i - radiusDouble / sin(angleRad)) * tan(angleRad);
-        float x = (static_cast<float>(i) + j) / sqrt(2.0);
-        float y = (j - static_cast<float>(i)) / sqrt(2.0);
-
-        drawPoint(x, y, color);
-    }
-}
diff --git a/apps/CtsVerifier/lib/colorchecker/meteringtest.cpp b/apps/CtsVerifier/lib/colorchecker/meteringtest.cpp
deleted file mode 100644
index 47de5d8..0000000
--- a/apps/CtsVerifier/lib/colorchecker/meteringtest.cpp
+++ /dev/null
@@ -1,102 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "MeteringTest"
-#include <utils/Log.h>
-#include <utils/Timers.h>
-#include <cmath>
-#include <string>
-
-#include "vec2.h"
-#include "vec3.h"
-#include "meteringtest.h"
-
-const float kOverExposure = 230.f;
-const float kEqThreshold = 0.05f;
-// Processes the checker colors stored by comparing the pixel values from the
-// two scenarios in a test.
-void MeteringTest::processData() {
-    ALOGV("Start Processing Metering Test Data!");
-
-    int numTests = mCheckerColors.size() / 2;
-    mNumPatches = 0;
-
-    if (numTests > 0) {
-        mNumPatches = mCheckerColors[0].size();
-    }
-
-    for (int i = 0; i < numTests; ++i) {
-        mComparisonResults.push_back(
-                isEquivalentTo((&mCheckerColors[i * 2]),
-                               (&mCheckerColors[i * 2 + 1])));
-        mComparisonResults.push_back(
-                isDarkerThan((&mCheckerColors[i * 2]),
-                             (&mCheckerColors[i * 2 + 1])));
-    }
-}
-
-void MeteringTest::clearData() {
-    mComparisonResults.clear();
-    mCheckerColors.clear();
-}
-
-// Compares two given arrays of pixel values and decide whether the first one is
-// significantly darker than the second one.
-bool MeteringTest::isDarkerThan(
-        const std::vector<Vec3f>* checkerColors1,
-        const std::vector<Vec3f>* checkerColors2) const {
-    float meanRatio = 0.f;
-    int meanNumCount = 0;
-
-    for (int i = 0; i < mNumPatches; ++i) {
-        float luminance1 = (*checkerColors1)[i].convertToLuminance();
-        float luminance2 = (*checkerColors2)[i].convertToLuminance();
-
-        // Out of the saturation rage, define 5% as a margin for being
-        // significantly brighter.
-        if ((luminance2 < kOverExposure) && (luminance1 != 0.f)) {
-            meanRatio += luminance2 / luminance1;
-            ++meanNumCount;
-        }
-    }
-    meanRatio = meanRatio / meanNumCount;
-
-    return (meanRatio > 1 + kEqThreshold);
-}
-
-// Compares the two givn arrays of pixel values and decide whether they are
-// equivalent within an acceptable range.
-bool MeteringTest::isEquivalentTo(
-        const std::vector<Vec3f>* checkerColors1,
-        const std::vector<Vec3f>* checkerColors2) const {
-    float meanRatio = 0.f;
-    int meanNumCount = 0;
-
-    for (int i = 0; i < mNumPatches; ++i) {
-        float luminance1 = (*checkerColors1)[i].convertToLuminance();
-        float luminance2 = (*checkerColors2)[i].convertToLuminance();
-        ALOGV("Luma_1 and Luma_2 is %f, %f", luminance1, luminance2);
-
-        if ((luminance1 < kOverExposure) && (luminance2 < kOverExposure)) {
-              meanRatio += luminance2 / luminance1;
-              ++meanNumCount;
-        }
-    }
-    meanRatio = meanRatio / meanNumCount;
-
-    return ((meanRatio >= 1 - kEqThreshold) && (meanRatio <= 1 + kEqThreshold));
-}
diff --git a/apps/CtsVerifier/lib/colorchecker/testingimage.cpp b/apps/CtsVerifier/lib/colorchecker/testingimage.cpp
deleted file mode 100644
index 28f025f..0000000
--- a/apps/CtsVerifier/lib/colorchecker/testingimage.cpp
+++ /dev/null
@@ -1,190 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "TestingImage"
-#include <utils/Log.h>
-#include <utils/Timers.h>
-#include <string.h>
-#include <cmath>
-#include <vector>
-#include <assert.h>
-#include "vec3.h"
-
-#include "testingimage.h"
-
-const float GAMMA_CORRECTION = 2.2f;
-
-// Constructs an instance with the given image byte array.
-TestingImage::TestingImage(const unsigned char* inputImage,
-                           int inputHeight, int inputWidth,
-                           int inputChannel, int inputRowSpan) {
-    mImage = new unsigned char[inputRowSpan * inputHeight];
-
-    ALOGV("mImage format created! with size as %d, %d, %d",
-         inputRowSpan, inputHeight, inputChannel);
-    mWidth = inputWidth;
-    mHeight = inputHeight;
-    mChannels = inputChannel;
-    mRowSpan = mWidth * mChannels;
-
-    for (int i = 0; i < mHeight; ++i) {
-        for (int j = 0; j < mWidth; ++j) {
-            for (int k = 0; k < mChannels; ++k) {
-                mImage[i * mRowSpan + j* mChannels + k] =
-                        inputImage[i * inputRowSpan + j * inputChannel + k];
-            }
-        }
-    }
-    ALOGV("mImage converted!");
-}
-
-// Constructs an instance with the given image and resize it to a new size.
-TestingImage::TestingImage(const unsigned char* inputImage,
-                           int inputHeight, int inputWidth,
-                           int inputChannel, int inputRowSpan,
-                           int newHeight, int newWidth) {
-    mImage = new unsigned char[newHeight * newWidth * inputChannel];
-
-    ALOGV("mImage format created! with size as %d, %d, %d",
-         newHeight, newWidth, inputChannel);
-    mHeight = newHeight;
-    mWidth = newWidth;
-    mChannels = inputChannel;
-    mRowSpan = mWidth * mChannels;
-
-    // Computes how many pixels in the original image corresponds to one pixel
-    // in the new image.
-    int heightScale = inputHeight / newHeight;
-    int widthScale = inputWidth / newWidth;
-
-    // Average the corresponding pixels in the original image to compute the
-    // pixel value of the new image.
-    for (int i = 0; i < mHeight; ++i) {
-        for (int j = 0; j < mWidth; ++j) {
-            for (int k = 0; k < mChannels; ++k) {
-                int pixelValue = 0;
-
-                for (int l = 0; l < heightScale; ++l) {
-                    for (int m = 0; m < widthScale; ++m) {
-                        pixelValue += inputImage[
-                                (i * heightScale + l) * inputRowSpan
-                                + (j * widthScale + m) * inputChannel + k];
-                    }
-                }
-                pixelValue = pixelValue / (heightScale * widthScale);
-                mImage[i * mRowSpan + j * mChannels + k] =
-                        (unsigned char) pixelValue;
-            }
-        }
-    }
-}
-
-TestingImage::~TestingImage() {
-    if (mImage!=NULL) {
-        delete[] mImage;
-    }
-}
-
-int TestingImage::getPixelValue(int row, int column, int channel) const {
-    assert ((row >= 0) && (row < mHeight));
-    assert ((column >= 0) && (column < mWidth));
-    assert ((channel >= 0) && (channel < mChannels));
-    return (int)mImage[row * mRowSpan + column * mChannels + channel];
-}
-
-Vec3i TestingImage::getPixelValue(int row, int column) const {
-    Vec3i current_color(getPixelValue(row, column, 0),
-                        getPixelValue(row, column, 1),
-                        getPixelValue(row, column, 2));
-    return current_color;
-}
-
-Vec3i TestingImage::getPixelValue(const Vec2i &pixelPosition) const {
-    return getPixelValue(pixelPosition.x(), pixelPosition.y());
-}
-
-Vec3i TestingImage::getPixelValue(const Vec2f &pixelPosition) const {
-    return getPixelValue(static_cast<int>(pixelPosition.x()),
-                         static_cast<int>(pixelPosition.y()));
-}
-
-// Returns a vector of the colors in the requested block of color checkers.
-// The vector is formatted by going through the block from left to right and
-// from top to bottom.
-const std::vector<Vec3f>* TestingImage::getColorChecker(
-      int rowStart, int rowEnd, int columnStart, int columnEnd,
-      const std::vector<std::vector< Vec2f > >* centerAddress,
-      const std::vector<std::vector< float > >* radiusAddress) const {
-    std::vector<Vec3f>* checkerColors = new std::vector<Vec3f>;
-
-    // Average the pixel values of the pixels within the given radius to the
-    // given center position.
-    for (int i = rowStart; i < rowEnd; ++i) {
-        for (int j = columnStart; j < columnEnd; ++j) {
-            float radius = sqrt((*radiusAddress)[i][j]);
-            Vec2f center((*centerAddress)[i][j].x(),
-                               (*centerAddress)[i][j].y());
-            Vec3f meanColor(0.f, 0.f, 0.f);
-            int numPixels = 0;
-
-            for (int ii = static_cast<int>(center.x() - radius);
-                 ii < static_cast<int>(center.x() + radius); ++ii) {
-                for (int jj = static_cast<int>(center.y() - radius);
-                     jj < static_cast<int>(center.y() + radius); ++jj) {
-
-                    Vec2i pixelPosition(ii,jj);
-                    if (pixelPosition.squareDistance<float>(center) <
-                        (*radiusAddress)[i][j]) {
-                        meanColor = meanColor + getPixelValue(pixelPosition);
-                        ++numPixels;
-                    }
-                }
-            }
-            meanColor = meanColor / numPixels;
-            checkerColors->push_back(meanColor);
-        }
-    }
-
-    return checkerColors;
-}
-
-bool TestingImage::rgbToGrayScale(unsigned char* grayLayer) const {
-    if (mChannels == 4) {
-        for (int i = 0; i < mWidth; i++) {
-            for (int j = 0; j < mHeight; j++) {
-                float redLinear = pow(getPixelValue(j, i, 0),
-                                       GAMMA_CORRECTION);
-                float greenLinear = pow(getPixelValue(j,i,1),
-                                         GAMMA_CORRECTION);
-                float blueLinear = pow(getPixelValue(j,i,2),
-                                        GAMMA_CORRECTION);
-
-                // Computes the luminance value
-                grayLayer[j * mWidth + i] =
-                        (unsigned char)((int)pow((0.299f * redLinear
-                                                  + 0.587f * greenLinear
-                                                  + 0.114f * blueLinear),
-                                                  1/GAMMA_CORRECTION));
-            }
-        }
-
-        return true;
-    } else {
-
-        return false;
-    }
-}
diff --git a/apps/CtsVerifier/lib/colorchecker/vec3.cpp b/apps/CtsVerifier/lib/colorchecker/vec3.cpp
deleted file mode 100644
index ac16620..0000000
--- a/apps/CtsVerifier/lib/colorchecker/vec3.cpp
+++ /dev/null
@@ -1,22 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "Vec3"
-#include <utils/Log.h>
-#include <utils/Timers.h>
-
-#include "vec3.h"
diff --git a/apps/CtsVerifier/lib/colorchecker/whitebalancetest.cpp b/apps/CtsVerifier/lib/colorchecker/whitebalancetest.cpp
deleted file mode 100644
index 6413a2b..0000000
--- a/apps/CtsVerifier/lib/colorchecker/whitebalancetest.cpp
+++ /dev/null
@@ -1,122 +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.
- */
-#define LOG_NDEBUG 0
-
-#define LOG_TAG "WhiteBalanceTest"
-#include <utils/Log.h>
-#include <utils/Timers.h>
-#include <cmath>
-#include <string>
-
-#include "vec2.h"
-#include "vec3.h"
-#include "whitebalancetest.h"
-
-// White point in XYZ color space under 5200k illumination.
-const Vec3f kDaylightWhitePoint(0.9781f, 1.f, 0.9021f);
-
-// Process the data of checker colors collected under different white balance.
-// Assuming the Daylight CCT is set to 5200k, compute the CCT of other white
-// balance modes.
-void WhiteBalanceTest::processData() {
-    ALOGV("Start Processing White Balance Test Data!");
-
-    int numPatches = mCheckerColors.size();
-    ALOGV("Processing %d tests with %d patches", 2, numPatches);
-
-    std::vector<Vec3f> xyzColors(numPatches);
-    for (int j = 0; j < numPatches; ++j) {
-        Vec3f xyzCheckerColor = initializeFromRGB(mCheckerColors[j]);
-        xyzColors[j] = xyzCheckerColor;
-        ALOGV("XYZ coordinate is %f, %f, %f", xyzCheckerColor.r(),
-              xyzCheckerColor.g(), xyzCheckerColor.b());
-    }
-
-    Vec3f meanScale(0.f, 0.f, 0.f);
-
-    if (mMode == "daylight") {
-        mXyzColorsDaylight = xyzColors;
-        // For testing the auto white balance mode. Compute a CCT that would
-        // map the gray checkers to a white point.
-        for (int j = 1; j < numPatches; ++j) {
-            meanScale = meanScale +
-                    (mXyzColorsDaylight[j] / kDaylightWhitePoint);
-        }
-    } else {
-        for (int j = 1; j < numPatches; ++j) {
-            meanScale = meanScale + (mXyzColorsDaylight[j] / xyzColors[j]);
-        }
-    }
-
-    meanScale = meanScale / (numPatches - 1);
-    ALOGV("Scale: %f, %f, %f", meanScale.r(), meanScale.g(), meanScale.b());
-
-    Vec3f whitePoint;
-    whitePoint = meanScale * kDaylightWhitePoint;
-
-    ALOGV("White point is %f, %f, %f", whitePoint.r(),
-         whitePoint.g(), whitePoint.b());
-
-    mCorrelatedColorTemp = findCorrelatedColorTemp(whitePoint);
-    ALOGV("CCT is %d", mCorrelatedColorTemp);
-}
-
-// Given a white point, find the correlated color temperature.
-// Formula taken from the paper "Calculating Correlated Color Temperatures
-// Across the Entire Gamut of Daylight and Skylight Chromaticities" by Hernandez
-// Andres et al. in 1999. The numbers are fitting parameters.
-int WhiteBalanceTest::findCorrelatedColorTemp(const Vec3f &whitePoint) {
-    Vec2f chromaOfWhitePoint(
-        whitePoint.r() / (whitePoint.r() + whitePoint.g() + whitePoint.b()),
-        whitePoint.g() / (whitePoint.r() + whitePoint.g() + whitePoint.b()));
-
-    float n = (chromaOfWhitePoint.x() - 0.3366f)
-                / (chromaOfWhitePoint.y() - 0.1735f);
-    float y = -949.86315f + 6253.80338f * exp(-n / 0.92159f)
-               + 28.70599f * exp(-n / 0.20039f) + 0.00004f * exp(-n / 0.07125f);
-
-    return static_cast<int>(y);
-}
-
-// Converts a RGB pixel value to XYZ color space.
-Vec3f WhiteBalanceTest::initializeFromRGB(const Vec3f &rgb) {
-    float linearRed = convertToLinear(rgb.r());
-    float linearGreen = convertToLinear(rgb.g());
-    float linearBlue = convertToLinear(rgb.b());
-
-    float x = 0.4124f * linearRed + 0.3576f * linearGreen +
-            0.1805f * linearBlue;
-    float y = 0.2126f * linearRed + 0.7152f * linearGreen +
-            0.0722f * linearBlue;
-    float z = 0.0193f * linearRed + 0.1192f * linearGreen +
-            0.9505f * linearBlue;
-
-    return Vec3f(x, y, z);
-}
-
-float WhiteBalanceTest::convertToLinear(float color) {
-    float norm = color/ 255.0f;
-    float linearColor;
-
-    // Convert from sRGB space to linear RGB value
-    if (norm > 0.04045f) {
-        linearColor = pow(((norm + 0.055f) / 1.055f), 2.4f);
-    } else {
-        linearColor = norm / 12.92f;
-    }
-
-    return linearColor;
-}
diff --git a/apps/CtsVerifier/proguard.flags b/apps/CtsVerifier/proguard.flags
index ca4680f..fe7eed8 100644
--- a/apps/CtsVerifier/proguard.flags
+++ b/apps/CtsVerifier/proguard.flags
@@ -19,3 +19,5 @@
 -dontwarn android.hardware.Sensor
 -dontwarn android.test.AndroidTestRunner
 -dontwarn java.util.concurrent.ConcurrentLinkedDeque
+-dontwarn android.cts.util.**
+-dontwarn junit.**
diff --git a/apps/CtsVerifier/res/layout/ca_main.xml b/apps/CtsVerifier/res/layout/ca_main.xml
deleted file mode 100644
index 274430d..0000000
--- a/apps/CtsVerifier/res/layout/ca_main.xml
+++ /dev/null
@@ -1,81 +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.
--->
-<android.support.wearable.view.BoxInsetLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-    <LinearLayout app:layout_box="all"
-      android:orientation="vertical" android:layout_width="fill_parent"
-      android:layout_height="fill_parent">
-
-
-      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-        android:orientation="horizontal" android:layout_width="fill_parent"
-        android:layout_height="wrap_content">
-        <!--Button android:id="@+id/focusmodesbutton" android:layout_width="0px"
-          android:layout_height="wrap_content" android:text="@string/ca_focus_modes_label"
-          android:layout_weight="1" /-->
-        <Button android:id="@+id/findcheckerboardbutton" android:layout_width="0px"
-          android:layout_height="wrap_content" android:text="@string/ca_find_checkerboard_label"
-          android:layout_weight="1" />
-
-        <Button android:id="@+id/meteringbutton" android:layout_width="0px"
-          android:layout_height="wrap_content" android:text="@string/ca_metering_label"
-          android:layout_weight="1" />
-
-        <Button android:id="@+id/exposurecompensationbutton" android:layout_width="0px"
-          android:layout_height="wrap_content" android:text="@string/ca_exposure_test_label"
-          android:layout_weight="1"/>
-
-        <Button android:id="@+id/whitebalancebutton" android:layout_width="0px"
-          android:layout_height="wrap_content" android:text="@string/ca_wb_test_label"
-          android:layout_weight="1" />
-
-        <Button android:id="@+id/lockbutton" android:layout_width="0px"
-          android:layout_height="wrap_content" android:text="@string/ca_lock_test_label"
-          android:layout_weight="1" />
-      </LinearLayout>
-
-      <LinearLayout android:orientation="horizontal"
-        android:layout_width="fill_parent" android:layout_height="0px"
-        android:layout_weight="1">
-
-        <SurfaceView android:id="@+id/cameraview" android:layout_height="fill_parent"
-          android:layout_width="wrap_content"
-          android:layout_weight="0" />
-
-        <LinearLayout android:orientation="vertical"
-          android:layout_width="fill_parent" android:layout_height="match_parent"
-          android:layout_weight="1">
-
-           <ListView android:id="@+id/ca_tests"
-                android:layout_width="fill_parent"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:layout_marginLeft="10px"/>
-
-          <ImageView android:id="@+id/resultview" android:layout_height="wrap_content"
-            android:layout_width="fill_parent"
-            android:layout_weight="1" />
-        </LinearLayout>
-
-      </LinearLayout>
-
-      <include layout="@layout/pass_fail_buttons" />
-
-    </LinearLayout>
-</android.support.wearable.view.BoxInsetLayout>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 0724e0f..49e1c1c 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -624,18 +624,6 @@
     <string name="congratulations">Congratulations!</string>
     <string name="no_suid_files">No unauthorized suid files detected!</string>
 
-    <!-- Strings for Camera Analyzer -->
-    <string name="camera_analyzer">Camera Analyzer</string>
-    <string name="ca_find_checkerboard_label">Find target</string>
-    <string name="ca_check_formats_label">Output formats</string>
-    <string name="ca_exposure_test_label">Exposure Comp.</string>
-    <string name="ca_result_label">Results will be here</string>
-    <string name="ca_wb_test_label">White Balance</string>
-    <string name="ca_lock_test_label">AE Lock</string>
-    <string name="ca_metering_label">Metering Area</string>
-    <string name="ca_focus_modes_label">Focus Modes</string>
-    <string name="ca_info">This test checks the image quality of the camera of this device. It requires a MacBeth 4x6 color checker. With an ADK board and a lamp connected to it on the Relay 1 port, all tests can be run automatically. Without the ADK board, all the tests except the Auto Exposure Lock Test can be run automatically and the Auto Exposure Lock Test will require users to turn on/off a lamp according to the instruction given. </string>
-
     <!-- Strings for Camera Orientation -->
     <string name="camera_orientation">Camera Orientation</string>
     <string name="co_info">This test verifies the orientation capabilities of
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/AutoLockTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/AutoLockTest.java
deleted file mode 100644
index 9181b29..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/AutoLockTest.java
+++ /dev/null
@@ -1,1078 +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.
- */
-
-package com.android.cts.verifier.camera.analyzer;
-
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.ImageFormat;
-import android.hardware.Camera;
-import android.hardware.usb.UsbAccessory;
-import android.hardware.usb.UsbManager;
-import android.os.ParcelFileDescriptor;
-import android.util.Log;
-import android.view.SurfaceView;
-import android.widget.ImageView;
-import android.widget.Toast;
-
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implements a test to verify whether the Auto Exposure Lock functions as
- * described in the API.
- *
- * The test consists three sub-categories. The first set of tests focus on
- * testing whether the auto exposure lock works in various situations.
- * For all tests in this set, the lock is set during the period when the camera
- * preview is open. In this way the lock locks exposure according to the
- * lighting at the moment of setting the lock. The second set of tests focus on
- * testing whether the auto exposure lock works as expected after turning the
- * preview off and on. The lock is set during the period when the camera
- * preview is turned off. The lock is expected to lock an exposure level
- * identical to the one before the preview is turned off. One special case in
- * this category is to set lock before the preview is turned on for the first
- * time.
- */
-public class AutoLockTest extends CameraTests {
-
-    private static final String TAG = "AutoLockTest";
-    /** USB permission to connect to ADK. */
-    private static final String ACTION_USB_PERMISSION = "com.android.cts.verifier.USB_PERMISSION";
-    /** Defines a long sleep period.*/
-    private static final int SHORT_SLEEP = 2000;
-    /** Defines a short sleep period. */
-    private static final int LONG_SLEEP = 4000;
-
-    /** Test results in text format. */
-    private String mDebugText = new String();
-    /** Detailed report. */
-    private String mResultText = new String();
-    /** Thread lock of the camera callbacks. */
-    private final Object mProcessingImage = new Object();
-    /** Memory address of the native test handler. */
-    private long mTestHandler;
-    /** Array storing the reference test results. */
-    private ArrayList<Boolean> mReferenceCompareResults;
-    /** Array storing the reference test scenario logs. */
-    private ArrayList<String> mReferenceLogs;
-    /** Number of tests so far. */
-    private int mTestCount;
-
-    /** Usb Manager of the USB connections. */
-    private UsbManager mUsbManager;
-    /** Intent for getting the permission to access the ADK. */
-    private PendingIntent mPermissionIntent;
-    /** Boolean to represent whether a permission is gained. */
-    private boolean mPermissionRequestPending;
-    /** USB accessory pointing to the ADK. */
-    private UsbAccessory mAccessory;
-    /** File descriptor of the USB communication port. */
-    private ParcelFileDescriptor mFileDescriptor;
-    /** Output stream to write commands for ADK to. */
-    private FileOutputStream mOutputStream;
-
-    /** Pointer to the CameraAnalyzerActivity activity. */
-    private CameraAnalyzerActivity mActivity;
-    /** Boolean to tell whether the accessory is opened. */
-    private boolean mSetupReady;
-    /** Thread lock for setting up the usb. */
-    private final Object mUsbSetup = new Object();
-    /** Boolean to indicate whether there is an ADK attached. */
-    private boolean mUsingUsb = false;
-    /** Test results.*/
-    private int[] mTestResults;
-    /** Number of tests. */
-    private int mNumTests;
-    /** Singleton test instance.*/
-    private static AutoLockTest singletonTest = null;
-
-    /**
-     * Receives the notice of whether the connection to ADK is granted or
-     * denied.
-     */
-    private final BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
-        @Override
-        public void onReceive(Context context, Intent intent) {
-            String action = intent.getAction();
-            Log.v(TAG, String.format("Received USB broadcast with action %s ", action));
-
-            if (ACTION_USB_PERMISSION.equals(action)) {
-                synchronized (this) {
-                    UsbAccessory accessory =
-                        (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
-
-                    if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
-                        // Grants the permission to connect to the ADK.
-                        Log.v(TAG, "Open accessory 3");
-                        openAccessory(accessory);
-                        // Overwrites the old camera instsance with the one currently opened
-                        // by the CameraAnalyzerActivity instance, since the permission
-                        // dialogue pauses the CameraAnalyzerActivity and forces the camera to
-                        // be released and reopened when the dialogue disappears.
-                        mTestCamera = mActivity.getCameraInstance();
-                    } else {
-                        // Denies the permission to connect to the ADK.
-                        Log.d(TAG, "permission denied for accessory " + accessory);
-                    }
-                    // Marks that the permission request has been processed.
-                    mPermissionRequestPending = false;
-                }
-            } else if (UsbManager.ACTION_USB_ACCESSORY_DETACHED.equals(action)) {
-                // Invokes when the USB is detached.
-                // Closes the accessory if it has not been closed.
-                Log.v(TAG, "Usb device detached");
-                mUsingUsb = false;
-                UsbAccessory accessory =
-                    (UsbAccessory) intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
-                if (accessory != null && accessory.equals(mAccessory)) {
-                    closeAccessory();
-                }
-            }
-        }
-    };
-
-    /**
-     * Opens the ADK from USB and attaches the output stream with it.
-     *
-     * Notifies the tread lock that the USB setup is ready.
-     */
-    private void openAccessory(UsbAccessory accessory) {
-        Log.d(TAG, "openAccessory: " + accessory);
-        mFileDescriptor = mUsbManager.openAccessory(accessory);
-
-        if (mFileDescriptor != null) {
-            mAccessory = accessory;
-            FileDescriptor fd = mFileDescriptor.getFileDescriptor();
-            mOutputStream = new FileOutputStream(fd);
-            Log.d(TAG, "accessory opened");
-        } else {
-            Log.d(TAG, "accessory open fail");
-        }
-
-        // Unlocks the thread lock of waiting for the USB to be ready.
-        synchronized (mUsbSetup) {
-            mSetupReady = true;
-            Log.v(TAG, "Setup ready");
-            mUsbSetup.notifyAll();
-        }
-    }
-
-    /**
-     * Closes the ADK and detaches the output stream from it.
-     */
-    private void closeAccessory() {
-        try {
-            if (mFileDescriptor != null) {
-                mFileDescriptor.close();
-            }
-        } catch (IOException e) {
-        } finally {
-            mFileDescriptor = null;
-            mAccessory = null;
-        }
-    }
-
-    /**
-     * Constructs the AutoLockTest class, which can execute a series of tests
-     * to verify whether the device's Auto Exposure Lock is working properly.
-     *
-     * The test uses the LED lights on an ADK device as light source to change
-     * the lighting condition of the environment. The usb connection to the
-     * ADK board is established in the constructor.
-     *
-     * @param hostActivity pointer to the <code>CameraAnalyzerActivity</code>
-     * that instructs the Auto Lock Test
-     * @param mCamera pointer to the current camera instance
-     */
-    private AutoLockTest(){
-        super();
-    }
-
-    public static synchronized AutoLockTest getSingletonTest() {
-        if (singletonTest == null) {
-            Log.v(TAG, "Creating a new AutoLockTest instance");
-            singletonTest = new AutoLockTest();
-            singletonTest.initializeTest();
-        }
-        return singletonTest;
-    }
-
-    private void initializeTest() {
-        // Creates a native test handler with a 120x160 pixel debug output
-        mTestHandler = createAutoLockTest();
-        mReferenceCompareResults = new ArrayList<Boolean>();
-        mReferenceLogs = new ArrayList<String>();
-        mNumTests = 4;
-        mTestResults = new int[mNumTests];
-        for (int i = 0; i < mNumTests; ++i) {
-            mTestResults[i] = CameraTests.CAMERA_TEST_NOT_RUN;
-        }
-    }
-
-    public void updateCamera() {}
-
-    public void setActivity(CameraAnalyzerActivity hostActivity){
-        if (mUsingUsb) {
-            closeConnection();
-        }
-
-        mActivity = hostActivity;
-
-        mSetupReady = false;
-
-        Log.v(TAG, "Start to test ADK connection");
-        // Starts to establish the connection to the ADK board.
-        mUsbManager = (UsbManager) mActivity.getSystemService(Context.USB_SERVICE);
-        mPermissionIntent = PendingIntent.getBroadcast(mActivity, 0,
-                                                       new Intent(ACTION_USB_PERMISSION), 0);
-        IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
-        filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED);
-        filter.addAction(UsbManager.ACTION_USB_ACCESSORY_ATTACHED);
-        mActivity.registerReceiver(mUsbReceiver, filter);
-
-        if (mActivity.getLastNonConfigurationInstance() != null) {
-            mAccessory = (UsbAccessory) mActivity.getLastNonConfigurationInstance();
-            Log.v(TAG, "Open acceossory 1");
-            openAccessory(mAccessory);
-        }
-
-        // Skips the permission listener if the user already grants the ADK
-        // permission previously in the app.
-        UsbAccessory[] accessories = mUsbManager.getAccessoryList();
-        UsbAccessory accessory = (accessories == null ? null : accessories[0]);
-        if (accessory != null) {
-            if (mUsbManager.hasPermission(accessory)) {
-                Log.v(TAG, "Open accessory 2");
-                openAccessory(accessory);
-            } else {
-                synchronized (mUsbReceiver) {
-                    if (!mPermissionRequestPending) {
-                        mUsbManager.requestPermission(accessory, mPermissionIntent);
-                        mPermissionRequestPending = true;
-                    }
-                }
-            }
-            mUsingUsb = true;
-        } else {
-            Log.d(TAG, "accessory is null");
-            mUsingUsb = false;
-        }
-
-    }
-
-    /**
-     * Closes the accessories and unregister the USB listener at the end of
-     * tests.
-     */
-    public void closeConnection() {
-        closeAccessory();
-        mActivity.unregisterReceiver(mUsbReceiver);
-    }
-
-    protected void finalize ()  {
-        if (mUsingUsb) {
-            closeConnection();
-        }
-    }
-
-    /**
-     * Runs the Auto Lock tests. A total of 19 tests have been coded and
-     * included. Developers can freely comment out tests not interested. In
-     * the release version, all tests will be executed.
-     */
-    @Override
-    public synchronized void run(int index){
-        if (index == 0) {
-            for (int i = 1; i < mNumTests; ++i) {
-                run(i);
-            }
-            return;
-        }
-
-        Log.v(TAG, "AutoLockTest thread started!");
-
-        if (mUsingUsb && (!mSetupReady)) {
-            // USB connection is not set up. Locks thread and wait.
-            Log.v(TAG, "Setup not ready, waiting");
-            synchronized (mUsbSetup) {
-                try{
-                    Log.v(TAG, "Start waiting for Image");
-                    mUsbSetup.wait();
-                } catch (InterruptedException e) {
-                    Log.v(TAG, "Callback wait fails!");
-                }
-            }
-        }
-
-        // Restarts the camera intance and attach the preview to the corrent
-        // UI elements.
-        restartCamera();
-        startPreview();
-
-        mTestCount = 0;
-        switch (index) {
-            case 1:
-                Log.v(TAG, "SP -> TP1 -> SP -> +1 -> Lock -> -1 -> TP2");
-                test0();
-                Log.v(TAG, "SP -> TP1 -> SP -> Lock -> +1 -> TP2 -> -1");
-                test1();
-                Log.v(TAG, "SP -> Lock -> +1 -> TP1 -> SP -> -1 -> Lock -> TP2");
-                test2();
-                Log.v(TAG, "SP -> Lock -> +1 -> TP1 -> SP -> Lock -> -1 -> TP2");
-                test3();
-                break;
-            case 2:
-                Log.v(TAG, "SP -> +1 -> TP1 -> -1 -> Lock -> SP -> TP2");
-                test4();
-                Log.v(TAG, "SP -> +1 -> TP1 -> Lock -> SP -> -1 -> TP2");
-                test5();
-                Log.v(TAG, "SP -> TP1 -> +1 -> Lock -> SP -> -1 -> TP2");
-                test6();
-                Log.v(TAG, "SP -> TP1 -> +1 -> Lock -> SP -> TP2");
-                test7();
-                Log.v(TAG, "SP -> TP1 -> Lock -> SP -> +1 -> TP2");
-                test8();
-                Log.v(TAG, "SP -> +1 -> Lock -> -1 -> TP1 -> Lock -> SP -> TP2");
-                test9();
-                Log.v(TAG, "SP -> +1 -> Lock -> TP1 -> -1 -> Lock -> SP -> TP2");
-                test10();
-                Log.v(TAG, "SP -> Lock -> TP1 -> +1 -> Lock -> SP -> -1 -> TP2");
-                test11();
-                break;
-            case 3:
-                Log.v(TAG, "Restart -> Lock -> SP -> TP1 -> Restart -> Lock -> SP -> +1 -> TP2");
-                test12();
-                Log.v(TAG, "Restart -> Lock -> SP -> +1 -> TP1 -> -1 -> Lock -> SP -> TP2");
-                test13();
-                Log.v(TAG, "Restart -> Lock -> SP -> +1 -> TP1 -> Lock -> SP -> -1 -> TP2");
-                test14();
-                Log.v(TAG, "Restart -> Lock -> SP -> TP1 -> +1 -> Lock -> SP -> -1 -> TP2");
-                test15();
-                Log.v(TAG, "Restart -> Lock -> SP -> TP1 -> +1 -> Lock -> SP -> TP2");
-                test16();
-                Log.v(TAG, "Restart -> Lock -> SP -> TP1 -> Lock -> SP -> +1 -> TP2");
-                test17();
-                Log.v(TAG, "Restart -> Lock -> SP -> TP1 -> Lock -> SP -> TP2");
-                test18();
-                break;
-            default:
-                break;
-        }
-
-        releaseLock();
-
-        Log.v(TAG, "Ready to process data");
-        boolean[] testCompareResults = new boolean[2 * mTestCount];
-
-        // Processes the data stored in the native test handler instance.
-        // Stores the test results into a boolean array.
-        processAutoLockTest(mTestHandler, testCompareResults);
-
-        // Prepares the test result text output with the booelan result array.
-        prepareDebugText(testCompareResults, index);
-        mReferenceCompareResults.clear();
-        mReferenceLogs.clear();
-    }
-
-    /**
-     * Compares two images taken under the same lighting, Image 1 without AE
-     * lock and Image 2 with AE locked under a bright light. Image 1 is
-     * expected to be brighter than Image 2.
-     * Tests whether AE lock works compared to no AE lock.
-     */
-    private void test0() {
-        releaseLock();
-        takePicture();
-        startPreview();
-        turnOnLight();
-        setLock();
-        turnOffLight();
-        takePicture();
-        startPreview();
-        releaseLock();
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Same lighting condition with one different lock");
-        ++mTestCount;
-    }
-
-    /**
-     * Compares two images taken under different lighting, Image 1 without AE
-     * lock and Image 2 with with AE locked under the same light Image 1 is
-     * taken. Image 2 is taken under a bright light. Image 1 is expected to be
-     * darker than Image 2.
-     * Tests whether AE lock works compared to no AE lock.
-     */
-    private void test1() {
-        releaseLock();
-        takePicture();
-        startPreview();
-        setLock();
-        turnOnLight();
-        takePicture();
-        turnOffLight();
-        startPreview();
-        releaseLock();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("One same lock with different lighting");
-        ++mTestCount;
-    }
-
-    /**
-     * Compares two images taken under different light, both with AE locked
-     * under the same lighting. Image 1 is taken under a brighter light.
-     * Image 1 is expected to be brighter than Image 2.
-     * Tests whether AE locks the exposure to the same level in the same
-     * lighting condition after preview restarts.
-     */
-     private void test2() {
-        releaseLock();
-        setLock();
-        turnOnLight();
-        takePicture();
-        startPreview();
-        turnOffLight();
-        setLock();
-        takePicture();
-        startPreview();
-        releaseLock();
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Same locking locations with different lighting");
-        ++mTestCount;
-    }
-
-    /**
-     * Compares two images taken under different light, Image 1 with AE locked
-     * under normal light and Image 2 with AE locked under a bright light.
-     * Image 1 is taken under a bright light and Image 2 is taken in the normal
-     * lighting. Image 1 is expected to be brighter than Image 2.
-     * Tests whether AE lock can adjust to change of lighting conditions.
-     */
-    private void test3() {
-        releaseLock();
-        setLock();
-        turnOnLight();
-        takePicture();
-        startPreview();
-        setLock();
-        turnOffLight();
-        takePicture();
-        startPreview();
-        releaseLock();
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Different locking locations with different lighting");
-        ++mTestCount;
-    }
-
-    /**
-     * Compares two images taken under different lighting, Image 1 without
-     * AE lock and Image 2 with AE lock set before camera preview resumes.
-     * Image 1 is taken under a bright light and the light is turned off before
-     * camera preview starts again. Image 1 is expected to be brighter than
-     * Image 2.
-     * Tests whether setting AE lock between camera preview stops and restarts
-     * can retain the exposure level of the previous AE-unlocked photo.
-     */
-    private void test4() {
-        releaseLock();
-        turnOnLight();
-        takePicture();
-        turnOffLight();
-        setLock();
-        startPreview();
-        takePicture();
-        startPreview();
-        releaseLock();
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock after takePicture and light change, before preview");
-        ++mTestCount;
-    }
-
-    /**
-     * Compares two images taken under different lighting, Image 1 without
-     * AE lock and Image 2 with AE lock set before camera preview resumes.
-     * Image 1 is taken under a bright light and the light is turned off after
-     * preview restars but before Image 2 is taken. Image 1 is expected to be
-     * brighter than Image 2.
-     * Tests whether setting AE lock between camera preview stops and restarts
-     * can retain the exposure level of the previous AE-unlocked photo.
-     */
-    private void test5() {
-        releaseLock();
-        turnOnLight();
-        takePicture();
-        setLock();
-        startPreview();
-        turnOffLight();
-        takePicture();
-        startPreview();
-        releaseLock();
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock between takePicture and light change, w/o light change");
-        ++mTestCount;
-    }
-
-    private void test6() {
-        releaseLock();
-        takePicture();
-        turnOnLight();
-        setLock();
-        startPreview();
-        turnOffLight();
-        takePicture();
-        startPreview();
-        releaseLock();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add("Lock after takePicture and light change, before preview.");
-        ++mTestCount;
-    }
-
-    private void test7() {
-        releaseLock();
-        takePicture();
-        turnOnLight();
-        setLock();
-        startPreview();
-        takePicture();
-        startPreview();
-        releaseLock();
-        turnOffLight();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock after takePicture and light change, before preview.");
-        ++mTestCount;
-    }
-
-    private void test8() {
-        releaseLock();
-        takePicture();
-        setLock();
-        startPreview();
-        turnOnLight();
-        takePicture();
-        startPreview();
-        releaseLock();
-        turnOffLight();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock after takePicture and before startPreview.");
-        ++mTestCount;
-    }
-
-    private void test9() {
-        releaseLock();
-        turnOnLight();
-        setLock();
-        turnOffLight();
-        takePicture();
-        setLock();
-        startPreview();
-        takePicture();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    private void test10() {
-        releaseLock();
-        turnOnLight();
-        setLock();
-        takePicture();
-        turnOffLight();
-        setLock();
-        startPreview();
-        takePicture();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    private void test11() {
-        releaseLock();
-        setLock();
-        takePicture();
-        turnOnLight();
-        setLock();
-        startPreview();
-        turnOffLight();
-        takePicture();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    private void test12() {
-        //"Restart -> Lock -> SP -> TP1 -> Restart -> Lock -> SP -> +1 -> TP2"
-        restartCamera();
-        setLock();
-        startPreview();
-        takePicture();
-        releaseLock();
-        restartCamera();
-        setLock();
-        startPreview();
-        turnOnLight();
-        takePicture();
-        releaseLock();
-        turnOffLight();
-        startPreview();
-        //mTestCamera.release();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock before first preview");
-        ++mTestCount;
-    }
-
-    private void test13() {
-        //"Restart -> Lock -> SP -> +1 -> TP1 -> -1 -> Lock -> SP -> TP2"
-        restartCamera();
-        setLock();
-        startPreview();
-        turnOnLight();
-        takePicture();
-        turnOffLight();
-        setLock();
-        startPreview();
-        takePicture();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    private void test14() {
-        //"Restart -> Lock -> SP -> +1 -> TP1 -> Lock -> SP -> -1 -> TP2"
-        restartCamera();
-        setLock();
-        startPreview();
-        turnOnLight();
-        takePicture();
-        setLock();
-        startPreview();
-        turnOffLight();
-        takePicture();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    private void test15() {
-        //"Restart -> Lock -> SP -> TP1 -> +1 -> Lock -> SP -> -1 -> TP2"
-         restartCamera();
-        setLock();
-        startPreview();
-        takePicture();
-        turnOnLight();
-        setLock();
-        startPreview();
-        turnOffLight();
-        takePicture();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    private void test16() {
-        //"Restart -> Lock -> SP -> TP1 -> +1 -> Lock -> SP -> TP2"
-        restartCamera();
-        setLock();
-        startPreview();
-        takePicture();
-        turnOnLight();
-        setLock();
-        startPreview();
-        takePicture();
-        turnOffLight();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    private void test17() {
-        //"Restart -> Lock -> SP -> TP1 -> Lock -> SP -> +1 -> TP2"
-        restartCamera();
-        setLock();
-        startPreview();
-        takePicture();
-        setLock();
-        startPreview();
-        turnOnLight();
-        takePicture();
-        turnOffLight();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    private void test18() {
-        //"Restart -> Lock -> SP -> TP1 -> Lock -> SP -> TP2"
-        restartCamera();
-        setLock();
-        startPreview();
-        takePicture();
-        setLock();
-        startPreview();
-        takePicture();
-        releaseLock();
-        startPreview();
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add("Lock after first lock with changing light");
-        ++mTestCount;
-    }
-
-    /**
-     * Restarts the camera by releasing the current instance and get a new
-     * instance. Also connects this new camera instance's preview to the proper
-     * UI surfaceview.
-     */
-    private void restartCamera() {
-        Log.v(TAG, "Restarting Camera");
-
-        mTestCamera.release();
-        Log.v(TAG, "Camera released");
-
-        try {
-            mTestCamera = Camera.open(mActivity.getCameraIdx());
-        } catch (RuntimeException e) {
-            throw new RuntimeException("Failed to open the camera", e);
-        }
-
-        Camera.Parameters params = mTestCamera.getParameters();
-        params.setPictureFormat(ImageFormat.JPEG);
-        params.setPictureSize(640, 480);
-        mTestCamera.setParameters(params);
-
-        try {
-            mTestCamera.setPreviewDisplay(super.getCameraView().getHolder());
-        } catch (IOException e) {
-            throw new RuntimeException("Unable to connect camera to display: " + e);
-        }
-    }
-
-    /**
-     * Starts Camera preview with a delay of 2 seconds to let it adjust to
-     * the lighting condition.
-     */
-    private void startPreview() {
-        mTestCamera.startPreview();
-        try{
-            Log.v(TAG, "Waiting");
-            Thread.sleep(2000);
-            Log.v(TAG, "END Waiting");
-        } catch (InterruptedException e){}
-    }
-
-    /**
-     * Sends command to ADK to turn on all the LED lights to white.
-     * Waits for 4 seconds for the camera to adjust to the new lighting.
-     */
-    private void turnOnLight() {
-        Log.v(TAG, "Turn on light");
-        if (mUsingUsb) {
-            byte[] buffer = new byte[3];
-
-            buffer[0] = (byte) 3;
-            buffer[1] = (byte) 0;
-            buffer[2] = (byte) 1;
-            if (mOutputStream != null && buffer[1] != -1) {
-                try {
-                    mOutputStream.write(buffer);
-                } catch (IOException e) {
-                    Log.e(TAG, "write failed", e);
-                }
-            }
-        } else {
-            mActivity.runOnUiThread(new Runnable() {
-                public void run() {
-                    Toast.makeText(mActivity.getApplicationContext(), "Turn on light!", 4).show();
-
-                }
-            });
-        }
-
-        try{
-            Log.v(TAG, "Waiting, Please Turn on light");
-            Thread.sleep(LONG_SLEEP);
-            Log.v(TAG, "END Waiting");
-        } catch (InterruptedException e){}
-    }
-
-    /**
-     * Sends command to ADK to turn off all LED lights.
-     * Waits for 4 seconds for the camera to adjust to the new lighting.
-     */
-    private void turnOffLight() {
-        Log.v(TAG, "Turn off light");
-        if (mUsingUsb) {
-            byte[] buffer = new byte[3];
-
-            buffer[0] = (byte) 3;
-            buffer[1] = (byte) 0;
-            buffer[2] = (byte) 0;
-            if (mOutputStream != null && buffer[1] != -1) {
-                try {
-                    mOutputStream.write(buffer);
-                } catch (IOException e) {
-                    Log.e(TAG, "write failed", e);
-                }
-            }
-        } else {
-            mActivity.runOnUiThread(new Runnable() {
-                public void run() {
-                    Toast.makeText(mActivity.getApplicationContext(), "Turn off light!", 4).show();
-
-                }
-            });
-        }
-
-        try{
-            Log.v(TAG, "Waiting, Please Turn off light");
-            Thread.sleep(LONG_SLEEP);
-            Log.v(TAG, "END Waiting");
-        } catch (InterruptedException e){}
-    }
-
-    /**
-     * Sets the Auto Exposure Lock.
-     * Waits for 2 seonds for the lock to function.
-     */
-    private void setLock() {
-        Camera.Parameters params = mTestCamera.getParameters();
-
-        params.setAutoExposureLock(true);
-        params.setAutoWhiteBalanceLock(true);
-        mTestCamera.setParameters(params);
-        try{
-            Log.v(TAG, "Waiting to set lock");
-            Thread.sleep(2000);
-            Log.v(TAG, "END Waiting");
-        } catch (InterruptedException e){}
-    }
-
-    /**
-     * Releases the Auto Exposure Lock.
-     * Waits for 4 seconds afterwards for the Auto Exposure to be adjusted
-     * to the lighting condition.
-     */
-    private void releaseLock() {
-        Camera.Parameters params = mTestCamera.getParameters();
-
-        params.setAutoExposureLock(false);
-        params.setAutoWhiteBalanceLock(false);
-        mTestCamera.setParameters(params);
-        try{
-            Log.v(TAG, "Waiting to release lock");
-            Thread.sleep(LONG_SLEEP);
-            Log.v(TAG, "END Waiting");
-        } catch (InterruptedException e){}
-
-    }
-
-    /**
-     * Takes a picture and locks thread until the picture callback finishes.
-     */
-    private void takePicture(){
-        mTestCamera.takePicture(null, null, null, mTestJpegListener);
-
-        synchronized (mProcessingImage) {
-            try{
-                Log.v(TAG, "Start waiting for Image");
-              //  System.gc();
-                mProcessingImage.wait();
-            } catch (InterruptedException e){
-                 Log.v(TAG, "Callback wait fails!");
-            }
-        }
-    }
-
-    /**
-     * Prepare for the result to be shown in the UI. The result for each single
-     * test is shown in green if it matches the reference result. It is shown
-     * in red otherwise.
-     */
-    private void prepareDebugText(boolean[] testCompareResults, int index) {
-        boolean groupTestPassed = true;
-         for (int i = 0; i < mTestCount; ++i) {
-              String testLog;
-              boolean testPassed = true;
-              testLog = mReferenceLogs.get(i);
-              mDebugText += (testLog + "<br/>");
-
-              if (testCompareResults[i * 2] == mReferenceCompareResults.get(i * 2)) {
-                  mDebugText += String.format(
-                      "Picture 1 brighter than Picture 2 is %b \n",
-                      testCompareResults[i * 2]);
-              } else {
-                  mDebugText += String.format(
-                      "Picture 1 brighter than Picture 2 is %b \n",
-                      testCompareResults[i * 2]);
-                  testPassed = false;
-              }
-
-              if (testCompareResults[i * 2 + 1] == mReferenceCompareResults.get(i * 2 + 1)) {
-                  mDebugText += String.format(
-                      "Picture 1 is equivalent to Picture 2 is %b \n",
-                      testCompareResults[i * 2 + 1]);
-              } else {
-                  mDebugText += String.format(
-                      "Picture 1 is equivalent to Picture 2 is %b \n",
-                      testCompareResults[i * 2 + 1]);
-                  testPassed = false;
-              }
-
-              if (testPassed) {
-                  mDebugText += "Test passed! \n";
-              } else {
-                  mDebugText += "Test failed! \n";
-                  groupTestPassed = false;
-              }
-         }
-        if (groupTestPassed) {
-            mTestResults[index] = CameraTests.CAMERA_TEST_SUCCESS;
-        } else {
-            mTestResults[index] = CameraTests.CAMERA_TEST_FAILURE;
-        }
-    }
-
-    /**
-     * Clears the debug text so that new test results can be added.
-     */
-    public void clearDebugText() {
-        mDebugText = "";
-    }
-
-    @Override
-    public String getDebugText() {
-        return mDebugText;
-    }
-
-    @Override
-    public String getResultText() {
-        return mDebugText;
-    }
-
-    @Override
-    public String getTestName() {
-        return "Auto Exposure Lock test: \n";
-    }
-
-    @Override
-    public String getTestName(int index) {
-        switch (index) {
-            case 0:
-                return "Run all tests";
-            case 1:
-                return "Compulsory tests";
-            case 2:
-                return "Recommended tests (preview behavior)";
-            case 3:
-                return "Optional tests (default lock)";
-            default:
-                return "";
-        }
-    }
-
-    @Override
-    public int getResult(int index) {
-        return mTestResults[index];
-    }
-
-    @Override
-    public int getNumTests() {
-        return mNumTests;
-    }
-
-    private Camera.PictureCallback mTestJpegListener = new Camera.PictureCallback() {
-        public void onPictureTaken(byte[] data, Camera mCamera) {
-            Log.v(TAG, "Shutter pressed down!");
-            Bitmap inputImage;
-
-            // Decodes the camera input data into Bitmap.
-            // Constructs a native image class with the image.
-            inputImage = BitmapFactory.decodeByteArray(data, 0, data.length);
-            long bufferAddress = findNative(inputImage);
-            Log.v(TAG, "findNative method finishes");
-
-            // Cleans up memory taken by the Bitmap.
-            data = null;
-            inputImage.recycle();
-            inputImage = null;
-            System.gc();
-
-            // Passes data from the native image class to the native
-            // test handler.
-            createAutoLockClass(bufferAddress, mTestHandler,
-                                getCheckerCenter(), getCheckerRadius());
-
-            // Unlocks the thread lock.
-            synchronized (mProcessingImage) {
-                mProcessingImage.notifyAll();
-            }
-        }
-    };
-
-    private native long createAutoLockTest();
-
-    private native void createAutoLockClass(long bufferAddress, long handlerAddress,
-                                            long checkerCenterAddress,
-                                            long checkerRadiusAddress);
-
-    private native void processAutoLockTest(long handlerAddress, boolean[] testCompareResults);
-
-    static {
-        System.loadLibrary("cameraanalyzer");
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraAnalyzerActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraAnalyzerActivity.java
deleted file mode 100644
index 34e8d2d..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraAnalyzerActivity.java
+++ /dev/null
@@ -1,500 +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.
- */
-package com.android.cts.verifier.camera.analyzer;
-
-import com.android.cts.verifier.PassFailButtons;
-import com.android.cts.verifier.R;
-
-import android.app.Activity;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Color;
-import android.graphics.ImageFormat;
-import android.hardware.Camera;
-import android.hardware.Camera.CameraInfo;
-import android.hardware.Camera.Size;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.text.Html;
-import android.text.method.ScrollingMovementMethod;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Button;
-import android.os.PowerManager;
-import android.os.PowerManager.WakeLock;
-import android.content.Context;
-
-import java.io.IOException;
-import java.lang.Thread;
-import java.util.List;
-
-/**
- * Controls the UI activities of the camera quality test app. It is created
- * as soon as the app started. Users can launch different quality tests with
- * the buttons in the UI. This class will manage the threading for different
- * tests. Also it will provide debug output or debug text results for tests.
- */
-public class CameraAnalyzerActivity extends PassFailButtons.Activity {
-
-    private static final String TAG = "CameraAnalyzer";
-    private SurfaceView mCameraView;
-    private ImageView mResultView;
-    private Button mFindCheckerButton;
-    private Button mExposureCompensationButton;
-    private Button mWhiteBalanceButton;
-    private Button mAutoLockButton;
-    private Button mMeteringButton;
-    private ListView mTestList;
-    private TwoColumnAdapter mAdapter;
-
-    private Camera mCamera;
-    private int mCameraIdx = 0;
-    private boolean mIsCameraOpen = false;
-
-    private PowerManager mPowerManager;
-    private PowerManager.WakeLock mWakeLock;
-
-    private boolean mProcessingPicture = false;
-    private boolean mTestInProgress = false;
-    private final Object mProcessingTest = new Object();
-    private CameraTests mCurrentTest = null;
-
-    private long mCheckerCenterAddress;
-    private long mCheckerRadiusAddress;
-
-    private String mResultReport = "";
-    static final String[] TESTS = new String[] {"Test1", "Test2"};
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.ca_main);
-        setPassFailButtonClickListeners();
-        setInfoResources(R.string.camera_analyzer, R.string.ca_info, -1);
-
-        mFindCheckerButton = (Button) findViewById(R.id.findcheckerboardbutton);
-        mExposureCompensationButton = (Button) findViewById(R.id.exposurecompensationbutton);
-        mWhiteBalanceButton = (Button) findViewById(R.id.whitebalancebutton);
-        mAutoLockButton = (Button) findViewById(R.id.lockbutton);
-        mMeteringButton = (Button) findViewById(R.id.meteringbutton);
-        mCameraView = (SurfaceView) findViewById(R.id.cameraview);
-        mResultView = (ImageView) findViewById(R.id.resultview);
-        mTestList = (ListView) findViewById(R.id.ca_tests);
-        mAdapter = new TwoColumnAdapter(this);
-
-        // Initialize the list view.
-        initializeAdapter();
-        mTestList.setAdapter(mAdapter);
-        mTestList.setOnItemClickListener(mListListener);
-
-        mFindCheckerButton.setOnClickListener(mFindCheckerListener);
-        mExposureCompensationButton.setOnClickListener(mExposureCompensationListener);
-        mWhiteBalanceButton.setOnClickListener(mWhiteBalanceListener);
-        mAutoLockButton.setOnClickListener(mAutoLockListener);
-        mMeteringButton.setOnClickListener(mMeteringListener);
-        mCameraView.getHolder().addCallback(mSurfaceChangeListener);
-
-        // Disables all test buttons except the color checker test one.
-        // They will be enabled after the color checker is located.
-        mExposureCompensationButton.setEnabled(false);
-        mWhiteBalanceButton.setEnabled(false);
-        mAutoLockButton.setEnabled(false);
-        mMeteringButton.setEnabled(false);
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-
-        openCamera(mCameraIdx);
-        Camera.Parameters params = mCamera.getParameters();
-        params.setPictureFormat(ImageFormat.JPEG);
-        params.setPictureSize(640, 480);
-        mCamera.setParameters(params);
-        Log.v(TAG, "Set resolution to 640*480");
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-        CameraTests.getCamera().release();
-        mIsCameraOpen = false;
-    }
-
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        MenuInflater inflater = getMenuInflater();
-        inflater.inflate(R.menu.ca_menu, menu);
-
-        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
-        int cameraCount = Camera.getNumberOfCameras();
-        for (int camIdx = 0; camIdx < cameraCount; ++camIdx) {
-            MenuItem cameraMenuItem = menu.add(0, camIdx, Menu.NONE,
-                                               String.format("Open Camera %d", camIdx));
-        }
-      return true;
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        if (item.getItemId() != mCameraIdx) {
-            mCameraIdx = item.getItemId();
-            new SwitchCameraTask().execute(mCameraIdx);
-        }
-        return false;
-    }
-
-    private class SwitchCameraTask extends AsyncTask<Integer, Void, Void> {
-        @Override
-        protected Void doInBackground(Integer... camIdx) {
-            if (mTestInProgress) {
-                synchronized (mProcessingTest) {
-                    try{
-                        Log.v(TAG, "Waiting for test to finish");
-                        mProcessingTest.wait();
-                    } catch (InterruptedException e){
-                         Log.v(TAG, "test wait fails!");
-                    }
-                }
-            }
-
-            openCamera((int)camIdx[0]);
-            return null;
-        }
-    }
-
-    private synchronized void openCamera(int camIdx) {
-        if (mIsCameraOpen) {
-            CameraTests.getCamera().release();
-            Log.v(TAG, "Releasing the cameratests camera");
-        }
-        try {
-            mCamera = Camera.open(camIdx);
-            mIsCameraOpen = true;
-        } catch (RuntimeException e) {
-            throw new RuntimeException("Failed to open the camera", e);
-        }
-
-        try {
-            mCamera.setPreviewDisplay(mCameraView.getHolder());
-        } catch (IOException e) {
-            throw new RuntimeException("Unable to connect camera to display: " + e);
-        }
-        mCamera.startPreview();
-        CameraTests.setCamera(mCamera);
-
-        ColorCheckerTest.getSingletonTest().updateCamera();
-        WhiteBalanceTest.getSingletonTest().updateCamera();
-        ExposureCompensationTest.getSingletonTest().updateCamera();
-        MeteringTest.getSingletonTest().updateCamera();
-        AutoLockTest.getSingletonTest().updateCamera();
-    }
-
-    public Camera getCameraInstance() {
-        return mCamera;
-    }
-
-    public void disableAll() {
-        mExposureCompensationButton.setEnabled(false);
-        mWhiteBalanceButton.setEnabled(false);
-        mAutoLockButton.setEnabled(false);
-        mMeteringButton.setEnabled(false);
-        mFindCheckerButton.setEnabled(false);
-    }
-
-    public void enableAll() {
-        mExposureCompensationButton.setEnabled(true);
-        mWhiteBalanceButton.setEnabled(true);
-        mAutoLockButton.setEnabled(true);
-        mMeteringButton.setEnabled(true);
-        mFindCheckerButton.setEnabled(true);
-    }
-
-    /**
-     * Provides an abstraction for the Camera tests. The camera tests will
-     * run in the background and the results will be shown in the UI thread
-     * after the tests are processed.
-     */
-    private class DebugOutputProcessingTask extends AsyncTask<Integer,
-                                                              Integer,
-                                                              Integer> {
-        @Override
-        protected Integer doInBackground(Integer... cameraTestIndex) {
-            Log.v(TAG, "Do in Background started!");
-
-            mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
-            mWakeLock = mPowerManager.newWakeLock(
-                    PowerManager.SCREEN_DIM_WAKE_LOCK, "CameraQualityTest");
-            mWakeLock.acquire();
-
-            mTestInProgress = true;
-
-            // Processes the camera tests one by one and publishes their
-            // debug output or debug text results after each test is done.
-            mCurrentTest.run((int)cameraTestIndex[0]);
-            publishProgress(cameraTestIndex);
-
-            Log.v(TAG, "Do in Background thread returns!");
-            return cameraTestIndex[0];
-        }
-
-        @Override
-        protected void onProgressUpdate(Integer... cameraTestIndex) {
-            Log.v(TAG, "Prepare to get debug output!");
-
-            // Copies the debug output image or text results to the UI.
-            mResultView.setImageBitmap(mCurrentTest.getDebugOutput());
-            mResultReport += (mCurrentTest.getTestName() + mCurrentTest.getDebugText());
-            mAdapter.notifyDataSetChanged();
-        }
-
-        @Override
-        protected void onPostExecute(Integer cameraTestIndex) {
-
-            // If the test is to find the color checker, copy the memory
-            // address of the found color checker centers and radius to the
-            // CameraTests class' static fields.
-            if (mCurrentTest.copyCheckerAddress()) {
-                mCheckerCenterAddress = CameraTests.getCheckerCenter();
-                mCheckerRadiusAddress = CameraTests.getCheckerRadius();
-            }
-
-            if (mCurrentTest.copyCheckerAddress() ||
-                !mCurrentTest.getTestName().contains("Color Checker")) {
-                // Enables the button of all other tests after the color checker
-                // is found. Now the user can start all other available tests.
-                enableAll();
-            }
-
-            mWakeLock.release();
-            mTestInProgress = false;
-            synchronized (mProcessingTest) {
-                mProcessingTest.notifyAll();
-            }
-
-        }
-    }
-
-    // Creates and runs a new test to find color checker in the captured image.
-    // It is invoked when users press the Find color checker button in the UI.
-    private View.OnClickListener mFindCheckerListener = new View.OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            Log.v(TAG, "Running new color checker finding tests!");
-            ColorCheckerTest colorCheckerTest = ColorCheckerTest.getSingletonTest();
-
-            mCurrentTest = colorCheckerTest;
-            initializeAdapter();
-        }
-    };
-
-    // Creates and runs a new test to test the exposure compensation function.
-    // It is invoked when users press the Exposure Compensation Test button
-    // in the UI.
-    private View.OnClickListener mExposureCompensationListener = new View.OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            Log.v(TAG, "Running new exposure compensation tests!");
-
-            ExposureCompensationTest exposureCompensationTest =
-                    ExposureCompensationTest.getSingletonTest();
-
-            mCurrentTest = exposureCompensationTest;
-            initializeAdapter();
-
-            // Loads the memory address of the checker centers and radius
-            // from the this class and set the two values for the new test.
-            ExposureCompensationTest.setCheckerAddress(mCheckerCenterAddress,
-                                                   mCheckerRadiusAddress);
-        }
-    };
-
-    // Creates and runs a new test to test the white balance function.
-    // It is invoked when users press the White Balance Test button in the UI.
-    private View.OnClickListener mWhiteBalanceListener = new View.OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            Log.v(TAG, "Running new white balance tests!");
-
-            WhiteBalanceTest whiteBalanceTest = WhiteBalanceTest.getSingletonTest();
-
-            mCurrentTest = whiteBalanceTest;
-            initializeAdapter();
-
-            // Loads the memory address of the checker centers and radius
-            // from the this class and set the two values for the new test.
-            WhiteBalanceTest.setCheckerAddress(mCheckerCenterAddress, mCheckerRadiusAddress);
-        }
-    };
-
-    // Creates and runs a new test to test the camera metering function.
-    // It is invoked when users press the Metering Test button in the UI.
-    private View.OnClickListener mMeteringListener = new View.OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            Log.v(TAG, "Running new metering tests!");
-
-            MeteringTest meteringTest = MeteringTest.getSingletonTest();
-
-            mCurrentTest = meteringTest;
-            initializeAdapter();
-
-            // Loads the memory address of the checker centers and radius
-            // from the this class and set the two values for the new test.
-            MeteringTest.setCheckerAddress(mCheckerCenterAddress, mCheckerRadiusAddress);
-        }
-    };
-
-    // Creates and runs new tests to test the camera auto exposure lock.
-    // It is invoked when users press the AWB and AE Lock Test button
-    // in the UI.
-    private View.OnClickListener mAutoLockListener = new View.OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            Log.v(TAG, "Running New auto exposure/wb lock tests!");
-
-            // Loads the memory address of the checker centers and radius
-            // from the this class and set the two values for the new test.
-            AutoLockTest.setCheckerAddress(mCheckerCenterAddress, mCheckerRadiusAddress);
-
-            // Construct all base case test scenearios for the Auto Lock test.
-            // Detailed documentation on each test can be found in native code.
-            AutoLockTest autoLockTest = AutoLockTest.getSingletonTest();
-            autoLockTest.setActivity(CameraAnalyzerActivity.this);
-
-            mCurrentTest = autoLockTest;
-            initializeAdapter();
-
-        }
-    };
-
-    // Creates a list listner that launches the experiment with the user's click
-    private AdapterView.OnItemClickListener mListListener = new AdapterView.OnItemClickListener() {
-        @Override
-        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-            Log.v(TAG, String.format("Item %d selected!", position));
-            if (!mTestInProgress) {
-                DebugOutputProcessingTask captureTask = new DebugOutputProcessingTask();
-                disableAll();
-                captureTask.execute(position);
-            }
-        }
-    };
-
-    private SurfaceHolder.Callback mSurfaceChangeListener =
-            new SurfaceHolder.Callback() {
-
-        // Sets the aspect ratio of the camera preview to 4:3
-        @Override
-        public void surfaceChanged(SurfaceHolder holder,
-                                   int format,
-                                   int width,
-                                   int height) {
-            int x = mCameraView.getWidth();
-            int y = mCameraView.getHeight();
-            Log.v(TAG, String.format("Measures are %d, %d", x, y));
-
-            if ( x > 4.0 / 3.0 * y) {
-                android.view.ViewGroup.LayoutParams lp = mCameraView.getLayoutParams();
-                lp.height =  y;
-                lp.width = (int)(4.0 / 3.0 * lp.height);
-                Log.v(TAG, String.format("params are %d, %d", lp.width, lp.height));
-                mCameraView.setLayoutParams(lp);
-            }
-
-            try {
-                mCamera.setPreviewDisplay(mCameraView.getHolder());
-            } catch (IOException e) {
-                throw new RuntimeException("Unable to connect camera to display: " + e);
-            }
-            CameraTests.setCameraView(mCameraView);
-            mCamera.startPreview();
-        }
-
-        @Override
-        public void surfaceCreated(SurfaceHolder holder) {}
-
-        @Override
-        public void surfaceDestroyed(SurfaceHolder holder) {}
-    };
-
-    @Override
-    public String getTestDetails() {
-        return mResultReport;
-    }
-
-    class TwoColumnAdapter extends ArrayAdapter<String> {
-        TwoColumnAdapter(Context context) {
-            super(context, R.layout.ca_row);
-        }
-
-        @Override
-        public View getView(int position, View convertView, ViewGroup parent) {
-            LayoutInflater inflater = getLayoutInflater();
-            View row = inflater.inflate(R.layout.ca_row, parent, false);
-            ImageView iconField = (ImageView) row.findViewById(R.id.caTestIcon);
-            TextView nameField = (TextView) row.findViewById(R.id.caTestName);
-            TextView resultField = (TextView) row.findViewById(R.id.caTestResult);
-            if (mCurrentTest != null) {
-                nameField.setText(mCurrentTest.getTestName(position));
-                int result = mCurrentTest.getResult(position);
-                switch (result) {
-                    case CameraTests.CAMERA_TEST_SUCCESS:
-                        resultField.setText("Success");
-                        iconField.setBackgroundColor(Color.rgb(0x99,0xCC,00));
-                        resultField.setTextColor(Color.rgb(0x99,0xCC,00));
-                        break;
-                    case CameraTests.CAMERA_TEST_FAILURE:
-                        resultField.setText("Failed!");
-                        iconField.setBackgroundColor(Color.rgb(0xFF,0x44,0x44));
-                        resultField.setTextColor(Color.rgb(0xFF,0x44,0x44));
-                        break;
-                    case CameraTests.CAMERA_TEST_NOT_RUN:
-                        resultField.setText("Tap to run");
-                        iconField.setBackgroundColor(Color.rgb(0x00,0x99,0xCC));
-                        resultField.setTextColor(Color.rgb(0x33,0xB5,0xE5));
-                        break;
-                }
-            }
-            return row;
-        }
-    }
-
-    private void initializeAdapter() {
-        mAdapter.clear();
-        if (mCurrentTest != null) {
-            for (int i = 0; i < mCurrentTest.getNumTests(); ++i) {
-                mAdapter.add(mCurrentTest.getTestName(i));
-            }
-        }
-    }
-
-    public int getCameraIdx() {
-        return mCameraIdx;
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraTests.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraTests.java
deleted file mode 100644
index ed99524..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/CameraTests.java
+++ /dev/null
@@ -1,201 +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.
- */
-
-package com.android.cts.verifier.camera.analyzer;
-
-import android.graphics.Bitmap;
-import android.hardware.Camera;
-import android.os.Environment;
-import android.util.Log;
-import android.view.SurfaceView;
-
-import java.io.FileOutputStream;
-import java.io.File;
-import java.lang.Runnable;
-
-/**
- * Provides an abstraction for all camera tests and allows communication
- * between camera test classes with the UI thread. This base class provides
- * functions to contruct and access debug output images. It can access and
- * set the pointer address of checkerboard centers and radius. It also provides
- * native methods to convert an image shot by the camera into a native
- * character array. Another native method it provides is to create a native
- * test handler with desired debug height and width.
- */
-public abstract class CameraTests{
-
-    public static final int CAMERA_TEST_NOT_RUN = 0;
-    public static final int CAMERA_TEST_SUCCESS = 1;
-    public static final int CAMERA_TEST_FAILURE = 2;
-
-    private static final String TAG = "CameraTests";
-
-    /** Memory address of the color checker centers. */
-    private static long sCheckerCenterAddress = 0;
-    /** Memory address of the color checker radius. */
-    private static long sCheckerRadiusAddress = 0;
-    /** The surface view linked with the camera preview. */
-    private static SurfaceView sCameraView;
-    /** Image debug output. */
-    private Bitmap mDebugOutput;
-    /** Shared camera instance. */
-    protected static Camera mTestCamera = null;
-
-    /**
-     * Constructs the base CameraTests class.
-     */
-    public CameraTests() {}
-
-    /**
-     * Returns debug Bitmap image. In the test to find the color checker,
-     * the debug image will be the captured image with a matched color checker
-     * overlay on top. In the exposure compensation test, the debug image
-     * will be the response curve of the camera.
-     * @return A low-resolution Bitmap to be displayed in the UI.
-     */
-    public Bitmap getDebugOutput() {
-        return mDebugOutput;
-    }
-
-    public String getDebugText() {
-        return "";
-    }
-
-    public abstract String getTestName();
-
-    /**
-     * Gets the detailed report for CTS output.
-     */
-    public String getResultText(){
-        return "Details not available \n";
-    }
-
-    /**
-     * Provides a polymorphism to start the run() method for all child classes.
-     */
-    public abstract void run(int index);
-
-    public SurfaceView getCameraView() {
-        return sCameraView;
-    }
-
-    public static void setCameraView(SurfaceView cameraView) {
-        sCameraView = cameraView;
-    }
-
-    /**
-     * Refreshes the camera instance when the activity opens a new camera.
-     */
-    public static void setCamera(Camera newCamera) {
-        mTestCamera = newCamera;
-    }
-
-    public static Camera getCamera() {
-        return mTestCamera;
-    }
-
-    /**
-     * Sets the memory address of the checker centers and checker radius.
-     *
-     * @param inputCenterAddress the new memory address of
-     *                           the color checker centers
-     * @param inputRadiusAddress the new memory address of
-     *                           the color checker radius
-     */
-    public static void setCheckerAddress(long inputCenterAddress, long inputRadiusAddress) {
-        sCheckerCenterAddress = inputCenterAddress;
-        sCheckerRadiusAddress = inputRadiusAddress;
-    }
-
-    /**
-     * Provides polymorphism to indicate whether the checker memory addresses
-     * should be copied.
-     *
-     * @return <code>true</code> if the class invoking the method needs to
-     *                           update the memory address of the color checker
-     *                           centers and radius;
-     *         <code>false</code> if the class invoking the method does NOT
-     *                           update the memory address of the color checker
-     *                           centers and radius.
-     */
-    public boolean copyCheckerAddress() {
-        return false;
-    }
-
-    public void cleanUp() {
-    }
-
-    public static long getCheckerCenter() {
-        return sCheckerCenterAddress;
-    }
-
-    public static long getCheckerRadius() {
-        return sCheckerRadiusAddress;
-    }
-
-    public abstract String getTestName(int index);
-
-    public abstract int getResult(int index);
-
-    public abstract int getNumTests();
-
-    /**
-     * Provides a native method to convert the input Bitmap of the captured
-     * image into a native character array and constructs a native image class
-     * with this character array. This method currently supports conversion
-     * of Bitmaps in the formats of RGB_565 and RGB_8888.
-     *
-     * @param input the input Bitmap, which is decoded from the camrea data.
-     *
-     * @return the memory address of the native image class which contains
-     * the character array.
-     */
-    public native long findNative(Bitmap input);
-
-    /**
-     * Provides a native method to create a native image handler class. The
-     * native image handler class is the base class for all test classes and
-     * contains the debug output as a character array.
-     *
-     * @param outputHeight the desired height for the debug output
-     * @param outputWidth the desired width for the debug output
-     *
-     * @return the memory address of the native test handler class.
-     */
-    public native long createImageTestHandler(int outputHeight, int outputWidth);
-
-    /**
-     * Provides a native method to clean up the memory taken by the handler.
-     *
-     * @param handlerAddress the memory address of the native test handler,
-     * which contains the debug output.
-     */
-    public native void cleanUpHandler(long handlerAddress);
-
-    /**
-     * Provides a native method to convert the native debug output from
-     * character array back to Bitmap and copy it to the debug output of this
-     * class.
-     *
-     * @param handlerAddress the memory address of the native test handler,
-     * which contains the debug output.
-     */
-    public native void displayHandlerDebugOutput(long handlerAddress);
-
-    static {
-        System.loadLibrary("cameraanalyzer");
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ColorCheckerTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ColorCheckerTest.java
deleted file mode 100644
index ad171b4..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ColorCheckerTest.java
+++ /dev/null
@@ -1,299 +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.
- */
-
-package com.android.cts.verifier.camera.analyzer;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.hardware.Camera;
-import android.util.Log;
-import android.widget.ImageView;
-
-import java.util.List;
-
-/** Locates a Xrite Classic Color Checker grid pattern in an image, stores the
- * center positions and the color checker radius, and provides a function to
- * get the memory address of these two properties.
- *
- * The pattern is a 6x4 grid of square color patches. The detection routine
- * assumes the pattern is placed roughly facing the camera, with the long size
- * roughly horizontal. It also assumes that the grey squares are in the bottom
- * row.
- */
-public class ColorCheckerTest extends CameraTests {
-
-    private static final String TAG = "ColorCheckerTest";
-
-    /** Memory address of the image class instance that contains the image. */
-    private long mClassAddress;
-    /** Memory address of the image test class instance. */
-    private long mTestHandler;
-    /** Thread lock. */
-    private final Object mProcessingImage = new Object();
-    /** Boolean to tell whether auto focus has succeded.*/
-    private boolean mAutoFocusSuccess;
-    /** Boolean to tell whether auto focus is supported.*/
-    private boolean mAutoFocusEnabled = false;
-    /** Singleton instance of the class.*/
-    private static ColorCheckerTest singletonTest = null;
-
-    private boolean mFindCheckerSuccess = false;
-    private boolean mHasRunOnce = false;
-
-    /**
-     * Constructs a <code>ColorCheckerTest</code> instance with a given
-     * Camera pointer.
-     */
-    private ColorCheckerTest() {
-        super();
-    }
-
-    /**
-     * Updates the camera and parameter when the activity switches camera.
-     */
-    public void updateCamera() {
-        Camera.Parameters params = mTestCamera.getParameters();
-        List<String> supportedFocusModes = params.getSupportedFocusModes();
-
-        // Sets camera focus mode to Auto focus if it is supported.
-        if (supportedFocusModes.contains(params.FOCUS_MODE_AUTO)) {
-            Log.v(TAG, "Auto focus possible");
-            params.setFocusMode(params.FOCUS_MODE_AUTO);
-            mTestCamera.setParameters(params);
-            mAutoFocusEnabled = true;
-        } else {
-            mAutoFocusEnabled = false;
-        }
-    }
-
-    public static synchronized ColorCheckerTest getSingletonTest() {
-        if (singletonTest == null) {
-            Log.v(TAG, "Creating a new ColorCheckerTest instance");
-            singletonTest = new ColorCheckerTest();
-            singletonTest.initializeTest();
-        }
-        return singletonTest;
-    }
-
-    private void initializeTest() {
-        // Creates a native test handler with a 120x160 pixel debug output
-        mTestHandler = createColorCheckerTest(120, 160);
-    }
-
-    @Override
-    public synchronized void run(int index) {
-        Log.v(TAG, "ColorCheckerTest thread started!");
-        mAutoFocusSuccess = false;
-        mFindCheckerSuccess = false;
-        mHasRunOnce = true;
-        // Sets camera focus mode to Auto focus if it is supported.
-        if (mAutoFocusEnabled) {
-            while (!mAutoFocusSuccess) {
-                // Starts the auto focus process of the camera.
-                mTestCamera.autoFocus(mAutoFocusListener);
-
-                // Locks thread until the camera finishes taking picture.
-                synchronized (mProcessingImage) {
-                    try{
-                        Log.v(TAG, "Start waiting for Image");
-                        mProcessingImage.wait();
-                    } catch (InterruptedException e) {
-                        Log.v(TAG, "Callback wait fails!");
-                    }
-                }
-            }
-        } else {
-            mTestCamera.takePicture(null, null, null, mTestJpegListener);
-            synchronized (mProcessingImage) {
-                try{
-                    Log.v(TAG, "Start waiting for Image");
-                    mProcessingImage.wait();
-                } catch (InterruptedException e) {
-                    Log.v(TAG, "Callback wait fails!");
-                }
-            }
-        }
-
-        // Launches the native method to find the color checker in the image.
-        mFindCheckerSuccess = processColorCheckerTest(mTestHandler);
-        // Displays the debug output from the native test handler instance.
-        displayHandlerDebugOutput(mTestHandler);
-
-        Log.v(TAG, "Callback has returned!");
-    }
-
-    private Camera.AutoFocusCallback mAutoFocusListener = new Camera.AutoFocusCallback() {
-        public void onAutoFocus(boolean mSuccess, Camera mCamera) {
-            if (mSuccess) {
-                mAutoFocusSuccess = true;
-                Log.v(TAG, "Autofocus success!");
-                mCamera.takePicture(null, null, null, mTestJpegListener);
-            } else {
-                try{
-                    Log.v(TAG, "Autofocus failed. Please adjust!");
-                    Thread.sleep(4000);
-                    Log.v(TAG, "END Waiting");
-                } catch (InterruptedException e){}
-
-                synchronized (mProcessingImage) {
-                    mProcessingImage.notifyAll();
-                }
-            }
-        }
-    };
-
-    private Camera.PictureCallback mTestJpegListener = new Camera.PictureCallback() {
-        public void onPictureTaken(byte[] data, Camera mCamera) {
-            Log.v(TAG, "Shutter pressed down!");
-
-            // Changes the focus mode to fixed to avoid focus shift after
-            // auto focus is successful.
-            //Camera.Parameters params = mCamera.getParameters();
-            //params.setFocusMode(params.FOCUS_MODE_FIXED);
-            //mCamera.setParameters(params);
-
-            // Decodes the camera data to Bitmap and creates a native image
-            // class with the Bitmap.
-            Bitmap inputImage;
-            inputImage = BitmapFactory.decodeByteArray(data, 0, data.length);
-            long bufferAddress = findNative(inputImage);
-            Log.v(TAG, "findNative method finishes");
-
-            // Cleans up the Bitmap memory space.
-            inputImage.recycle();
-            data = null;
-            inputImage = null;
-            System.gc();
-
-            // Constructs a test handler class to handle the image.
-            createColorCheckerClass(bufferAddress, mTestHandler);
-
-            mCamera.startPreview();
-
-            // Notifies the thread lock the image capture is done.
-            synchronized (mProcessingImage) {
-                mProcessingImage.notifyAll();
-            }
-        }
-    };
-
-    /**
-     * Overrides the base class method and use the memory addresses of the
-     * checker centers and radius computed by the native test handler class
-     * to update the values stored in the base class.
-     *
-     * @return <code>true</code> indicating a memory address upload is needed.
-     */
-    @Override
-    public boolean copyCheckerAddress() {
-        if (mFindCheckerSuccess) {
-            setCheckerAddress(getColorCheckerCenterAdd(mTestHandler),
-                              getColorCheckerRadiusAdd(mTestHandler));
-            return true;
-        } else {
-            return false;
-        }
-    }
-
-    @Override
-    public void cleanUp() {
-        cleanUpHandler(mTestHandler);
-    }
-
-    @Override
-    public String getTestName() {
-        return "Color Checker test: \n";
-    }
-
-    @Override
-    public String getTestName(int index) {
-        return "Find color checker";
-    }
-
-    @Override
-    public int getResult(int index) {
-        if (mFindCheckerSuccess) {
-            return CameraTests.CAMERA_TEST_SUCCESS;
-        } else {
-            if (mHasRunOnce) {
-                return CameraTests.CAMERA_TEST_FAILURE;
-            } else {
-                return CameraTests.CAMERA_TEST_NOT_RUN;
-            }
-        }
-    }
-
-    @Override
-    public int getNumTests() {
-        return 1;
-    }
-
-    /**
-     * Gets the memory address of the vector storing the color checker centers
-     * from the native test handler instance.
-     *
-     * @param handlerAddress the memory address of the native test handler
-     * instance
-     *
-     * @return memory address of the native vector storing the color checker
-     * centers' coordinates
-     */
-    private native long getColorCheckerRadiusAdd(long handlerAddress);
-
-    /**
-     * Gets the memory address of the vector storing the color checker radius
-     * from the native test handler instance.
-     *
-     * @param handlerAddress the memory address of the native test handler
-     * instance.
-     *
-     * @return memory address of the native vector storing the color checker
-     * centers' coordinates
-     */
-    private native long getColorCheckerCenterAdd(long handlerAddress);
-
-    /**
-     * Creates a native color checker test handler instance.
-     *
-     * @param outputWidth the desired width for the debug output
-     * @param outputHeight the desired height of the debug output
-     *
-     * @return memory address of the native test handler instance
-     */
-    private native long createColorCheckerTest(int outputWidth, int outputHeight);
-
-    /**
-     * Loads a native image class instances and extracts data from it to add
-     * to the test handler.
-     *
-     * @param bufferAddress the memory address of the image class instance
-     * @param handlerAddress the memory address of the test handler instance
-     */
-    private native void createColorCheckerClass(long bufferAddress, long handlerAddress);
-
-    /**
-     * Processes the data in the native test handler instance. Computes test
-     * results with all the data and construct a debug image or debug text
-     * outputs.
-     *
-     * @param handlerAddress the memory address of the test handler instance
-     */
-    private native boolean processColorCheckerTest(long handlerAddress);
-
-    static {
-        System.loadLibrary("cameraanalyzer");
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ExposureCompensationTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ExposureCompensationTest.java
deleted file mode 100644
index 9a8d9f0..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/ExposureCompensationTest.java
+++ /dev/null
@@ -1,215 +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.
- */
-
-package com.android.cts.verifier.camera.analyzer;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.ImageFormat;
-import android.hardware.Camera;
-import android.util.Log;
-import android.widget.ImageView;
-
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Random;
-
-public class ExposureCompensationTest extends CameraTests {
-
-    private static final String TAG = "ExposureCompensationTest";
-
-    /** Records the current exposure level. */
-    private float mExposureLevel;
-    /** Lock for the camera object.*/
-    private final Object mProcessingImage = new Object();
-    /** Lock for the camera's auto focusing task.*/
-    private final Object mAutoFocusing = new Object();
-    /** Memory address of the native test handler.*/
-    private long mTestHandler;
-    /** Test results. */
-    private int[] mTestResults;
-    /** Number of sub-tests. */
-    private int mNumTests;
-    /** Camera Parameters. */
-    private Camera.Parameters mParams;
-    /** Debug results in text. */
-    private String mDebugText;
-
-    private static ExposureCompensationTest singletonTest = null;
-
-    private ExposureCompensationTest(){
-        super();
-    }
-
-    /** Prepares the camera and the related parameters for the test.*/
-    public void updateCamera() {
-        mParams = mTestCamera.getParameters();
-        Log.v(TAG, String.format("Exposure level is from %d to %d",
-                                 mParams.getMinExposureCompensation(),
-                                 mParams.getMaxExposureCompensation()));
-        mNumTests = (int) ((float) (mParams.getMaxExposureCompensation() -
-                                    mParams.getMinExposureCompensation())
-                            * mParams.getExposureCompensationStep());
-        mTestResults = new int[mNumTests + 1];
-        for (int i = 0; i < mNumTests + 1; ++i) {
-            mTestResults[i] = CameraTests.CAMERA_TEST_NOT_RUN;
-        }
-    }
-
-    public static synchronized ExposureCompensationTest getSingletonTest() {
-        if (singletonTest == null) {
-            Log.v(TAG, "Creating a new ExposureCompensationTest instance");
-            singletonTest = new ExposureCompensationTest();
-            singletonTest.initializeTest();
-        }
-        return singletonTest;
-    }
-
-    private void initializeTest() {
-        mDebugText = new String();
-        // Creates a native test handler with a 120x160 pixel debug output
-        mTestHandler = createExposureCompensationTest(200, 280);
-    }
-
-    @Override
-    public synchronized void run(int index){
-        Log.v(TAG, "ExposureCompensationTest thread started!");
-
-        int testRangeMin, testRangeMax;
-        if (index == 0) {
-            testRangeMin = mParams.getMinExposureCompensation();
-            testRangeMax = mParams.getMaxExposureCompensation();
-        } else {
-            testRangeMin = (int) ((float)(index - 1) / mParams.getExposureCompensationStep())
-                    + mParams.getMinExposureCompensation();
-            testRangeMax = (int) ((float)(index) / mParams.getExposureCompensationStep())
-                    + mParams.getMinExposureCompensation();
-        }
-
-        /** Checks for each exposure compensation setting within the test range.*/
-        for (int i = testRangeMin;
-                i <= testRangeMax; i += 1){
-            mExposureLevel = i * mParams.getExposureCompensationStep();
-            Log.v(TAG, String.format("Current exposure level is %d", i));
-            int mCameraExposure;
-
-            do{
-                mParams.setExposureCompensation(i);
-                mTestCamera.setParameters(mParams);
-
-                try{
-                    Log.v(TAG, "Waiting");
-                    Thread.sleep(4000);
-                    Log.v(TAG, "END Waiting");
-                } catch (InterruptedException e){
-                    //TODO: error handling.
-                }
-
-                mParams = mTestCamera.getParameters();
-                mCameraExposure = mParams.getExposureCompensation();
-                Log.v(TAG, String.format("Camera exposure level is %d", mCameraExposure));
-            } while (mCameraExposure != i);
-
-            mTestCamera.takePicture(null, null, null, mTestJpegListener);
-
-            synchronized (mProcessingImage) {
-                try{
-                    Log.v(TAG, "Start waiting for Image");
-                    mProcessingImage.wait();
-                } catch (InterruptedException e){
-                    Log.v(TAG, "Callback wait fails!");
-                }
-            }
-        }
-
-        mDebugText = processExposureCompensationTest(mTestHandler);
-        displayHandlerDebugOutput(mTestHandler);
-
-        Log.v(TAG, "Callback has returned!");
-        mParams.setExposureCompensation(0);
-        mTestCamera.setParameters(mParams);
-    }
-
-    private Camera.PictureCallback mTestJpegListener = new Camera.PictureCallback() {
-        public void onPictureTaken(byte[] data, Camera mCamera) {
-            Log.v(TAG, "Shutter pressed down!");
-            Log.v(TAG, String.format("Current exposure is %f", mExposureLevel));
-
-            Bitmap inputImage;
-
-            inputImage = BitmapFactory.decodeByteArray(data, 0, data.length);
-            long bufferAddress = findNative(inputImage);
-            Log.v(TAG, "findNative method finishes");
-
-            inputImage.recycle();
-            data = null;
-            inputImage = null;
-            System.gc();
-
-            createExposureCompensationClass(bufferAddress, mTestHandler,
-                                            getCheckerCenter(), getCheckerRadius(),
-                                            mExposureLevel);
-            mCamera.startPreview();
-
-            synchronized (mProcessingImage) {
-                mProcessingImage.notifyAll();
-            }
-        }
-    };
-
-    @Override
-    public String getTestName(int index) {
-        switch (index) {
-            case 0:
-                return "EC All Range";
-            default:
-                return String.format("EC %d -> %d", (index - mNumTests / 2 - 1) * 10,
-                                     (index - mNumTests / 2) * 10);
-        }
-    }
-
-    @Override
-    public int getResult(int index) {
-        return mTestResults[index];
-    }
-
-    @Override
-    public int getNumTests() {
-        return mNumTests + 1;
-    }
-
-    @Override
-    public String getTestName() {
-        return "Exposure Compensation Test: \n";
-    }
-
-    @Override
-    public String getDebugText() {
-        return mDebugText;
-    }
-
-    private native long createExposureCompensationTest(int outputHeight, int outputWidth);
-
-    private native void createExposureCompensationClass(long bufferAddress, long handlerAddress,
-            long checkerCenterAddress, long checkerAadiusAddress, float mExposureLevel);
-
-    private native String processExposureCompensationTest(long handlerAddress);
-
-    static {
-        System.loadLibrary("cameraanalyzer");
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/MeteringTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/MeteringTest.java
deleted file mode 100644
index 9ff559f..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/MeteringTest.java
+++ /dev/null
@@ -1,685 +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.
- */
-
-package com.android.cts.verifier.camera.analyzer;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.ImageFormat;
-import android.graphics.Rect;
-import android.hardware.Camera;
-import android.hardware.Camera.Area;
-import android.util.Log;
-import android.widget.ImageView;
-
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-
-/**
- * Implements a test to verify whether the camera metering system works as
- * described in the API.
- *
- * The test consists two sub-categories. The first one has tests with only
- * one metering area defined. The second one has tests with two metering areas
- * defined. For each single sub-test, we use a random number generator to
- * decide where to put some of the metering areas to and how much weight should
- * be assigned to each area. For different tests, we use different ways to
- * define other metering areas and their weight, in order to cover all possible
- * fail cases. The metering areas are contrained to the grey squares in the
- * bottom of the color checker.
- */
-public class MeteringTest extends CameraTests {
-
-    private static final String TAG = "MeteringTest";
-
-    /** A long wait.*/
-    private static final int LONG_SLEEP = 4000;
-    /** Debug result in text. */
-    private String mDebugText;
-    /** Thread lock. */
-    private final Object mProcessingImage = new Object();
-    /** Memory address of the native test handler. */
-    private long mTestHandler;
-    /** The maximum number of metering area the device supports. */
-    private int mMaxNumMeteringArea;
-    /** The metering areas. */
-    private List<Camera.Area> mGreyAreas;
-    /** The coordinates of the grey squares on the color checker. */
-    private int[] mGreyCoordinates = new int[24];
-    /** Random number generator. */
-    private final Random mRandomGenerator = new Random();
-    /** Reference comparison result for tests. */
-    private ArrayList<Boolean>  mReferenceCompareResults;
-    /** Number of tests in the same instance. */
-    private int mTestCount;
-    /** Reference test logs. */
-    private ArrayList<String> mReferenceLogs;
-    /** Test result to show. */
-    private int[] mTestResults;
-    /** Number of tests. */
-    private int mNumTests;
-    /** Camera Parameters. */
-    private Camera.Parameters mParams;
-    /** Singleton test instance. */
-    private static MeteringTest singletonTest = null;
-
-    /** Constructs a <code>MeteringTest</code> instance with the given
-     * camera pointer.
-     */
-    private MeteringTest() {
-        super();
-    }
-
-    public void updateCamera() {
-        // Looks up how many metering area the device supports.
-        mParams = mTestCamera.getParameters();
-        mMaxNumMeteringArea = mParams.getMaxNumMeteringAreas();
-        Log.v(TAG, String.format("Maximum number if metering area is %d", mMaxNumMeteringArea));
-        if (mMaxNumMeteringArea == 0) {
-            mDebugText = "Custom Metering not supported!";
-            Log.v(TAG, "Custom Metering not supported");
-        }
-    }
-
-    public static synchronized MeteringTest getSingletonTest() {
-        if (singletonTest == null) {
-            Log.v(TAG, "Creating a new MeteringTest instance");
-            singletonTest = new MeteringTest();
-            singletonTest.initializeTest();
-        }
-        return singletonTest;
-    }
-
-    private void initializeTest() {
-        // Creates a native metering test handler.
-        mTestHandler = createMeteringTest();
-        mDebugText = new String();
-        mReferenceCompareResults = new ArrayList<Boolean>();
-        mReferenceLogs = new ArrayList<String>();
-        mNumTests = 3;
-        mTestResults = new int[mNumTests];
-        for (int i = 0; i < mNumTests; ++i) {
-            mTestResults[i] = CameraTests.CAMERA_TEST_NOT_RUN;
-        }
-    }
-
-    /**
-     * Runs the metering test instance.
-     */
-    @Override
-    public synchronized void run(int index) {
-        if (index == 0) {
-            run(1);
-            run(2);
-            return;
-        }
-        Log.v(TAG, "MeteringTest thread started!");
-
-        // Finds the coordinates of the grey squares on the color checker.
-        // The coordinate system has (-1000, -1000) on the upper left corner.
-        // And (1000, 1000) on the bottom right corner.
-        findGreyCoordinates(mGreyCoordinates, getCheckerCenter(), getCheckerRadius());
-
-        if (mMaxNumMeteringArea > 0) {
-            mTestCount = 0;
-            // Runs the metering tests category by category.
-            switch (index) {
-                case 1:
-                    runOneAreaTest();
-                    break;
-                case 2:
-                    if (mMaxNumMeteringArea > 1) {
-                        runTwoAreasTest();
-                    }
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        mParams = mTestCamera.getParameters();
-        mParams.setMeteringAreas(null);
-        mTestCamera.setParameters(mParams);
-
-        boolean[] testCompareResults = new boolean[2 * mTestCount];
-
-        // Processes the image data taken so far and stores the test results.
-        processMeteringTest(mTestHandler, testCompareResults);
-        // Prepares debug output based on the test results.
-        prepareDebugText(testCompareResults, index);
-
-        mReferenceCompareResults.clear();
-        mReferenceLogs.clear();
-    }
-
-    /**
-     * Prepares the test results in HTML text string to show in the UI.
-     *
-     * If the test result is the same as the reference result, the text will be
-     * shown in green. Otherwise it would be shown as red.
-     *
-     * @param testCompareResults the array storing the comparison results from
-     * the data taken by the camera so far.
-     */
-    private void prepareDebugText(boolean[] testCompareResults, int index) {
-        mDebugText = "";
-        boolean groupTestPassed = true;
-        for (int i = 0; i < mTestCount; ++i) {
-              String testLog;
-              boolean testPassed = true;
-              testLog = mReferenceLogs.get(i);
-              mDebugText += (testLog + "<br/>");
-
-              if (testCompareResults[i * 2] == mReferenceCompareResults.get(i * 2)) {
-                  mDebugText += String.format(
-                      "Picture 1 equivalent to Picture 2 is %b \n",
-                      testCompareResults[i * 2]);
-              } else {
-                  mDebugText += String.format(
-                      "Picture 1 equivalent to Picture 2 is %b \n",
-                      testCompareResults[i * 2]);
-                  testPassed = false;
-              }
-
-              if (testCompareResults[i * 2 + 1] == mReferenceCompareResults.get(i * 2 + 1)) {
-                  mDebugText += String.format(
-                      "Picture 1 darker than Picture 2 is %b \n",
-                      testCompareResults[i * 2 + 1]);
-              } else {
-                  mDebugText += String.format(
-                      "Picture 1 darker than Picture 2 is %b \n",
-                      testCompareResults[i * 2 + 1]);
-                  testPassed = false;
-              }
-
-              if (testPassed) {
-                  mDebugText += "Test passed! \n";
-              } else {
-                  mDebugText += "Test failed! \n";
-                  groupTestPassed = false;
-              }
-              Log.v(TAG, String.format("%s", mDebugText));
-         }
-
-        if (groupTestPassed) {
-            mTestResults[index] = CameraTests.CAMERA_TEST_SUCCESS;
-        } else {
-            mTestResults[index] = CameraTests.CAMERA_TEST_FAILURE;
-        }
-
-    }
-
-    /**
-     * Runs tests to check whether the metering functionalities work properly
-     * when one metering area is added.
-     */
-    private void runOneAreaTest() {
-        int weight1;
-        int weight2;
-        int square1;
-        int square2;
-
-        Log.v(TAG, "Running one area Test");
-
-        // Test case 1: Two images have the same metering area. Image 1 has
-        // a diffent weight than Image 2. The result images should be
-        // identical.
-        // Tests whether weight normalization works.
-        square1 = mRandomGenerator.nextInt(6);
-        weight1 = mRandomGenerator.nextInt(100) + 1;
-        runSingleTest(square1, square1, weight1);
-
-        square2 = square1;
-        weight2 = mRandomGenerator.nextInt(100) + 901;
-        runSingleTest(square2, square2, weight2);
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        Log.v(TAG, String.format("Running test for %d square with weights %d, %d",
-                                 square1, weight1, weight2));
-        mReferenceLogs.add(String.format(
-            "Running test for %d 1x1 square with weights %d, %d", square1, weight1, weight2));
-        ++mTestCount;
-
-        // Test case 2: Two images have different metering areas. Image 1 has
-        // one of the grey squares as its metering area. Image 2 has a darker
-        // grey square as its metering area. The weights for both images are
-        // the same. Image 1 is expected to be darker than Image 2.
-        // Tests whether metering on uni-brightness patches work.
-        square1 = mRandomGenerator.nextInt(5);
-        weight1 = mRandomGenerator.nextInt(1000) + 1;
-        runSingleTest(square1, square1, weight1);
-
-        square2 = mRandomGenerator.nextInt(6 - square1 - 1) + square1 + 1;
-        weight2 = weight1;
-        runSingleTest(square2, square2, weight2);
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add(String.format(
-            "Running test for %d, %d 1x1 square with weight %d", square1, square2, weight1));
-        ++mTestCount;
-
-        // Test case 3: Two images have different metering areas. Image one has
-        // one of the grey squares as its metering area. Image 2 has a
-        // rectangle which contains Image 1's metering area and the neighboring
-        // darker grey square. The weights for both tests are the same. Image 1
-        // is expected to be darker than Image 2.
-        // Tests whether metering on patches with different brightness works.
-        square1 = mRandomGenerator.nextInt(5);
-        weight1 = mRandomGenerator.nextInt(1000) + 1;
-        runSingleTest(square1, square1, weight1);
-
-        square2 = square1;
-        weight2 = weight1;
-        runSingleTest(square2, square2 + 1, weight2);
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add(String.format(
-            "Running test for %d 1x1, 1x2 square with weight %d", square1, weight1));
-        ++mTestCount;
-
-        // Test case 4: Two images have different metering areas. Image one has
-        // two neighboring grey squares as its metering area. Image 2 has two
-        // darker neighboring grey squares as its metering area. Weights are
-        // the same for both images. Image 1 is expected to be darker than
-        // Image 2.
-        // Tests whether metering on two mixed-brightness patches work.
-        square1 = mRandomGenerator.nextInt(4);
-        weight1 = mRandomGenerator.nextInt(1000) + 1;
-        runSingleTest(square1, square1 + 1, weight1);
-
-        square2 = mRandomGenerator.nextInt(5 - square1 - 1) + square1 + 1;
-        weight2 = weight1;
-        runSingleTest(square2, square2 + 1, weight2);
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add(String.format(
-            "Running test for %d, %d 1x2 square with weight %d", square1, square2, weight1));
-        ++mTestCount;
-
-        // Test case 5: Two images have different metering areas. Image one has
-        // three neighboring grey squares as its metering area. Image 2 has
-        // three darker neighboring grey squares as its metering area. Weights
-        // are the same. Image 1 is expected to be darker than Image 2.
-        // Tests whether metering on three mixed-brightness patches work.
-        square1 = mRandomGenerator.nextInt(3);
-        weight1 = mRandomGenerator.nextInt(1000) + 1;
-        runSingleTest(square1, square1 + 2, weight1);
-
-        square2 = mRandomGenerator.nextInt(4 - square1 - 1) + square1 + 1;
-        weight2 = weight1;
-        runSingleTest(square2, square2 + 2, weight2);
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add(String.format(
-            "Running test for %d, %d 1x3 square with weight %d", square1, square2, weight1));
-        ++mTestCount;
-    }
-
-    /**
-     * Runs metering tests to verify the functionalities when there are two
-     * areas set as the metering area.
-     */
-    private void runTwoAreasTest() {
-        int[] weight1 = new int[2];
-        int[] weight2 = new int[2];
-        int[] square1Start = new int[2];
-        int[] square2Start = new int[2];
-        int[] square1End = new int[2];
-        int[] square2End = new int[2];
-
-        Log.v(TAG, "Running two-area Test");
-
-        // Test case 1: Image 1 has two metering areas. They are two adjacent
-        // grey squares (each set as a metering area). The two areas have the
-        // same weight. Image 2 has one metering area, which is the combination
-        // of Image 1's two metering areas as a rectangle. The weight is the
-        // same as that of Image 1's individual area. Image 1 is expected to
-        // be equivalent to Image 2.
-        // Tests whether having seperating a metering area into two will yield
-        // the same result.
-        square1Start[0] = mRandomGenerator.nextInt(5);
-        square1End[0] = square1Start[0];
-        weight1[0] = mRandomGenerator.nextInt(1000) + 1;
-        square1Start[1] = square1Start[0] + 1;
-        square1End[1] = square1Start[1];
-        weight1[1] = weight1[0];
-        runMultipleAreaTest(square1Start, square1End, weight1);
-
-        square2Start[0] = square1Start[0];
-        weight2[0] = weight1[0];
-        runSingleTest(square2Start[0], square2Start[0] + 1, weight2[0]);
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add(String.format(
-            "Running test for %d, %d 1x1 square with weight %d",
-            square1Start[0], square1Start[1], weight1[0]));
-        ++mTestCount;
-
-        // Test case 2: Image 1 has two metering areas. They are two random
-        // grey squareson the color checker. The brighter square has a larger
-        // weight than the darker square. Image 2 has the same two metering
-        // areas as Image 1. The weights for both are equal to the weight of
-        // the darker square in Image 1, which is smaller than the weight of
-        // the brighter square in Image 1. Image 1 is expected to be darker
-        // than Image 2.
-        // Tests whether giving one of the two metering areas a different
-        // weight would change the image in the correct way.
-        square1Start[0] = mRandomGenerator.nextInt(4);
-        square1End[0] = square1Start[0];
-        weight1[0] = mRandomGenerator.nextInt(100) + 901;
-        square1Start[1] = mRandomGenerator.nextInt(5 - square1Start[0] - 1) + square1Start[0] + 1;
-        square1End[1] = square1Start[1];
-        weight1[1] = mRandomGenerator.nextInt(100) + 1;
-        runMultipleAreaTest(square1Start, square1End, weight1);
-
-        square2Start[0] = square1Start[0];
-        square2End[0] = square2Start[0];
-        weight2[0] = weight1[1];
-        square2Start[1] = square1Start[1];
-        square2End[1] = square1End[1];
-        weight2[1] = weight2[0];
-        runMultipleAreaTest(square2Start, square2End, weight2);
-        mReferenceCompareResults.add(false);
-        mReferenceCompareResults.add(true);
-        mReferenceLogs.add(String.format(
-            "Running test for %d, %d 1x1 square with weight %d, %d",
-            square1Start[0], square1Start[1], weight1[0], weight2[1]));
-        ++mTestCount;
-
-        // Test case 3: Image 1 has two metering areas. Both are set to the
-        // same random grey square on the color checker. The weight for both
-        // are the same. Image 2 has one meterig area, which is the same as
-        // Image 1's chosen grey square. The weight for it is the same as
-        // Image 1's weight for one metering area. Image 1 is expected to be
-        // equivalent to Image 2.
-        // Tests whether defining overlapping metering area works.
-        square1Start[0] = mRandomGenerator.nextInt(6);
-        square1End[0] = square1Start[0];
-        weight1[0] = mRandomGenerator.nextInt(1000) + 1;
-        square1Start[1] = square1Start[0];
-        square1End[1] = square1Start[1];
-        weight1[1] = weight1[0];
-        runMultipleAreaTest(square1Start, square1End, weight1);
-
-        square2Start[0] = square1Start[0];
-        square2End[0] = square2Start[0];
-        weight2[0] = weight1[0];
-        runSingleTest(square2Start[0], square2End[0], weight2[0]);
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add(String.format(
-            "Running test for %d 1x1 square with weight %d,", square1Start[0], weight1[0]));
-        ++mTestCount;
-
-        // Test case 4: Image 1 has two metering areas. The first one is a
-        // grey square on the color checker. The second one is a rectangle
-        // containing the first metering area's grey square and its neighboring
-        // darker square. The weights for both metering area are the same.
-        // Image 2 has two metering areas. The first one is the same grey
-        // square as Image 1's first metering area. The second one is the
-        // neighboring darker grey square. The weight for the brighter square
-        // is double the weight of Image 1's weights for each metering area.
-        // The weight for the Image 2's darker grey square is the same as
-        // Image 1's weight for each of its metering areas. Image 1 is expected
-        // to be equivalent to Image 2.
-        // Tests whether the weights for overlapping metering area add up.
-        square1Start[0] = mRandomGenerator.nextInt(2);
-        square1End[0] = square1Start[0];
-        weight1[0] = mRandomGenerator.nextInt(500) + 1;
-        square1Start[1] = square1Start[0];
-        square1End[1] = square1Start[1] + 1;
-        weight1[1] = weight1[0];
-        runMultipleAreaTest(square1Start, square1End, weight1);
-
-        square2Start[0] = square1Start[0];
-        square2End[0] = square1End[0];
-        weight2[0] = weight1[0] * 2;
-        square2Start[1] = square2Start[0] + 1;
-        square2End[1] = square2Start[1];
-        weight2[1] = weight1[1];
-        runMultipleAreaTest(square2Start, square2End, weight2);
-        mReferenceCompareResults.add(true);
-        mReferenceCompareResults.add(false);
-        mReferenceLogs.add(String.format(
-            "Running test for %d 1x2 1x1 and 1x2 square with weight %d,",
-            square1Start[0], weight1[0]));
-        ++mTestCount;
-    }
-
-    /**
-     * Runs the metering test when multiple metering areas are defined.
-     *
-     * @param startIndex the array storing the index of the grey square where
-     * one metering area starts
-     * @param endIndex the array storing the index of the grey square where one
-     * metering area ends.
-     * @param weight the array storing the weight for each metering area.
-     */
-    private void runMultipleAreaTest(int[] startIndex, int[] endIndex, int[] weight) {
-        int numAreas = startIndex.length;
-        mParams = mTestCamera.getParameters();
-        List<Camera.Area> meteringAreas = new ArrayList<Camera.Area>();
-
-        for (int i = 0; i < numAreas; ++i) {
-            meteringAreas.add(makeArea(startIndex[i], endIndex[i], weight[i]));
-            Log.v(TAG, String.format("Add metering area for %d, %d, %d",
-                                     startIndex[i], endIndex[i], weight[i]));
-        }
-        mParams.setMeteringAreas(meteringAreas);
-        mTestCamera.setParameters(mParams);
-        takePicture();
-    }
-
-    /**
-     * Runs the metering test when one metering area is defined.
-     *
-     * @param startIndex the index of the grey square where the metering area
-     * starts
-     * @param endIndex the index of the grey square where the metering area
-     * ends.
-     * @param weight the weight for the metering area.
-     */
-    private void runSingleTest(int startIndex, int endIndex, int weight) {
-        mParams = mTestCamera.getParameters();
-        List<Camera.Area> meteringAreas = new ArrayList<Camera.Area>();
-
-        Log.v(TAG, String.format("Single test for %d, %d, %d", startIndex, endIndex, weight));
-        meteringAreas.add(makeArea(startIndex, endIndex, weight));
-        mParams.setMeteringAreas(meteringAreas);
-        mTestCamera.setParameters(mParams);
-        takePicture();
-    }
-
-    /**
-     * Takes picture with the camera instance linked to this test class.
-     */
-    private void takePicture() {
-        // Waits for the metering to be stable
-        try{
-            Log.v(TAG, "Waiting for metering");
-            Thread.sleep(LONG_SLEEP);
-            Log.v(TAG, "END Waiting");
-        } catch (InterruptedException e) {}
-
-        mTestCamera.takePicture(null, null, null, mTestJpegListener);
-
-        // Locks thread until picture is taken and ready for processing.
-        synchronized (mProcessingImage) {
-            try{
-                Log.v(TAG, "Start waiting for Image");
-
-                mProcessingImage.wait();
-            } catch (InterruptedException e) {
-                Log.v(TAG, "Callback wait fails!");
-            }
-        }
-    }
-
-    /**
-     * Constructs a <code>Camera.Area</code> object of the metering area.
-     * Given the start and end index of one metering area, it takes the upper
-     * left corner of the starting square and the bottom right corner of the
-     * end square to construct an Area.
-     *
-     * @param startIndex the index of the grey square where the metering area
-     * starts
-     * @param endIndex the index of the grey square where the metering area
-     * ends
-     * @param weight the weight of this metering area.
-     *
-     * @return a <code>Camera.Area</code> object which represents this metering
-     * area
-     */
-    private Camera.Area makeArea(int startIndex, int endIndex, int weight) {
-        Rect areaRect = new Rect(mGreyCoordinates[startIndex * 4],
-                                 mGreyCoordinates[startIndex * 4 + 1],
-                                 mGreyCoordinates[endIndex * 4 + 2],
-                                 mGreyCoordinates[endIndex * 4 + 3]);
-        Camera.Area area = new Camera.Area(areaRect, weight);
-
-        return area;
-    }
-
-    @Override
-    public String getDebugText() {
-        return mDebugText;
-    }
-
-    @Override
-    public String getResultText() {
-        return mDebugText;
-    }
-
-    @Override
-    public String getTestName() {
-        return "Metering Test: \n";
-    }
-
-    @Override
-    public String getTestName(int index) {
-        switch (index) {
-            case 0:
-                return "Run all tests";
-            case 1:
-                return "One metering area tests";
-            case 2:
-                return "Multiple metering areas tests";
-            default:
-                return "";
-        }
-    }
-
-    @Override
-    public int getResult(int index) {
-        return mTestResults[index];
-    }
-
-    @Override
-    public int getNumTests() {
-        return mNumTests;
-    }
-
-    private Camera.PictureCallback mTestJpegListener = new Camera.PictureCallback() {
-        public void onPictureTaken(byte[] data, Camera mCamera) {
-            Log.v(TAG, "Shutter pressed down!");
-            Bitmap inputImage;
-            try {
-                FileOutputStream outStream = new FileOutputStream(
-                    String.format("/sdcard/metering%d.jpg", System.currentTimeMillis()));
-                outStream.write(data);
-                outStream.close();
-            } catch (FileNotFoundException e) {
-            } catch (IOException e) {}
-
-            // Decodes the input data of the camera.
-            inputImage = BitmapFactory.decodeByteArray(data, 0, data.length);
-
-            // Records the memory address of the native image class instance.
-            long bufferAddress = findNative(inputImage);
-            Log.v(TAG, "findNative method finishes");
-
-            // Cleans up the memory taken by the bitmap.
-            inputImage.recycle();
-            data = null;
-            inputImage = null;
-            System.gc();
-
-            // Add the image data to the native test handler.
-            createMeteringClass(bufferAddress, mTestHandler,
-                                getCheckerCenter(), getCheckerRadius());
-            mCamera.startPreview();
-
-            // Releases thread lock after the image is processed.
-            synchronized (mProcessingImage) {
-                mProcessingImage.notifyAll();
-            }
-        }
-    };
-
-    /**
-     * Finds the coordinates of the grey squares on the color checker.
-     * The coordinates are computed by using the checker center and radius.
-     * The coordinates are converted to a system with (-1000, -1000) in the
-     * upper left corner and (1000, 1000) in the  bottom right corner.
-     *
-     * @param greyCoordinates the array to store the coordinates of the grey
-     * squares
-     * @param checkerCenterAddress the memory address pointing to the vector
-     * storing the color checker's centers.
-     * @param checkerRadiusAddress the memory address pointing to the vetor
-     * storing the color checker's radius.
-     */
-    private native void findGreyCoordinates(int[] greyCoordinates,
-                                            long checkerCenterAddress, long checkerRadiusAddress);
-
-    /**
-     * Creates the native metering test handler with no debug image.
-     *
-     * @return the memory address pointing to the native test handler instance
-     */
-    private native long createMeteringTest();
-
-    /**
-     * Adds the data from the native image class instance to the native test
-     * handler.
-     *
-     * @param bufferAddress the meory address of the native image class
-     * @param handlerAddress the memory address of the native test handler
-     * @param checkerCenterAddress the memory address of the checker cneters
-     * @param checkerRadiusAddress the meory address of the checker radius
-     */
-    private native void createMeteringClass(long bufferAddress, long handlerAddress,
-                                            long checkerCenterAddress,
-                                            long checkerRadiusAddress);
-
-    /**
-     * Process the data stored in the native test handler and stores the
-     * comparison results.
-     *
-     * @param handlerAddress the memory address of the native test handler
-     * @param testCompareResults the boolean array to store the test comparison
-     * results
-     */
-    private native void processMeteringTest(long handlerAddress, boolean[] testCompareResults);
-
-    static {
-        System.loadLibrary("cameraanalyzer");
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/WhiteBalanceTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/WhiteBalanceTest.java
deleted file mode 100644
index a4111eb..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/analyzer/WhiteBalanceTest.java
+++ /dev/null
@@ -1,398 +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.
- */
-
-package com.android.cts.verifier.camera.analyzer;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.ImageFormat;
-import android.hardware.Camera;
-import android.util.Log;
-import android.widget.ImageView;
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-import java.util.List;
-
-/**
- * Implements a test to verify whether the correlated color temperatures (CTT)
- * of the supported white balance modes are inside the range camera
- * manufacturers generally agree on.
- *
- * The test assumes that the Daylight white balance mode has a CCT of 5200K,
- * which is widely agreed in industry and academics. It then use this as a
- * benchmark and compare images taken with other white balance settings.
- * Using the pixel values of the grey squares on the color checker, the CCT
- * of other white balance modes can be computed. The reference ranges were
- * summarized with the help of online resources. For the Auto mode, the
- * reference CCT is computed as the CCT that will keep the grey squares appear
- * grey in the result image.
- */
-public class WhiteBalanceTest extends CameraTests {
-
-    private static final String TAG = "WhiteBalanceTest";
-
-    /** Current white balance mode. */
-    private String mWhiteBalance;
-    /** Array to store the reference CCT's of each mode. */
-    private int[][] mReferenceTemperature;
-    /** List of supported white balance mode on a device. */
-    private List<String> mWhiteBalanceList;
-    /** The index of the white balance mode "Auto". */
-    private int mAutoId;
-
-    /** Debug results in text. */
-    private String mDebugText;
-    /** Memory address of the native test handler instance. */
-    private long mTestHandler;
-    /** Thread lock. */
-    private final Object mProcessingImage = new Object();
-    /** Test result to show. */
-    private int[] mTestResults;
-    /** Number of test. */
-    private int mNumTests;
-    /** Camera Parameters. */
-    private Camera.Parameters mParams;
-    /** Singleton test instance. */
-    private static WhiteBalanceTest singletonTest = null;
-    /** Boolean to check whehter daylight wb has been recorded. */
-    private boolean mHasDaylight = false;
-
-    /**
-     * Constructs a <code>WhiteBalanceTest</code> instance with a given
-     * Camera pointer.
-     */
-    private WhiteBalanceTest() {
-        super();
-    }
-
-    public void updateCamera() {
-        mAutoId = 0;
-        mHasDaylight = false;
-        mParams = mTestCamera.getParameters();
-        mWhiteBalanceList = mParams.getSupportedWhiteBalance();
-        mNumTests = mWhiteBalanceList.size() + 1;
-        mTestResults = new int[mNumTests];
-        for (int i = 0; i < mNumTests; ++i) {
-            mTestResults[i] = CameraTests.CAMERA_TEST_NOT_RUN;
-        }
-
-        if (mWhiteBalanceList != null) {
-            mReferenceTemperature = new int[mWhiteBalanceList.size()][2];
-
-            // Sets the reference CCT of the supported white balance modes
-            for (int i = 0; i < mWhiteBalanceList.size(); i++) {
-                setReferenceTemperature(i, mWhiteBalanceList.get(i));
-                if (mWhiteBalanceList.get(i).equals("auto")) {
-                    mAutoId = i;
-                }
-            }
-        }
-    }
-
-    public static synchronized WhiteBalanceTest getSingletonTest() {
-        if (singletonTest == null) {
-            Log.v(TAG, "Creating a new WhiteBalanceTest instance");
-            singletonTest = new WhiteBalanceTest();
-            singletonTest.initializeTest();
-        }
-        return singletonTest;
-    }
-
-    private void initializeTest() {
-        mDebugText = new String();
-        // Creates a native white balance test handler.
-        // mTestHandler stores the memory address of this instance.
-        mTestHandler = createWhiteBalanceTest();
-    }
-
-    private void initializeWhiteBalanceTest() {
-        mWhiteBalance = "daylight";
-        takePicture(mWhiteBalance);
-        int colorTemperature = processWhiteBalanceTest(mTestHandler);
-
-        setReferenceTemperature(mAutoId, colorTemperature);
-        mHasDaylight = true;
-    }
-
-    private void takePicture(String whiteBalance) {
-        mParams.setWhiteBalance(whiteBalance);
-        mTestCamera.setParameters(mParams);
-
-        try{
-            Log.v(TAG, "Waiting for white balance to adjust");
-            Thread.sleep(4000);
-            Log.v(TAG, "END Waiting");
-        } catch (InterruptedException e) {}
-
-        mTestCamera.takePicture(null, null, null, mTestJpegListener);
-
-        // Thread locks until image capture is done
-        synchronized (mProcessingImage) {
-            try{
-                Log.v(TAG, "Start waiting for Image");
-                mProcessingImage.wait();
-            } catch (InterruptedException e) {
-                Log.v(TAG, "Callback wait fails!");
-            }
-        }
-    }
-
-    /**
-     * Runs the white balance camera test instance.
-     */
-    @Override
-    public synchronized void run(int index) {
-        Log.v(TAG, "WhiteBalanceTest thread started!");
-
-        if (!mHasDaylight) {
-            initializeWhiteBalanceTest();
-        }
-
-        if (index != 0) {
-            // Retrieves the list of supported white balance mode.
-            mParams = mTestCamera.getParameters();
-
-            int i = index - 1;
-            mWhiteBalance = mWhiteBalanceList.get(i);
-
-            Log.v(TAG, "Current white balance is " + mWhiteBalance);
-
-            takePicture(mWhiteBalance);
-
-            // Processes the white balance test data in the native code.
-            // Returns an array of CCT of each white balance modes, given the CCT
-            // of the "Daylight" mode is 5200K.
-            int colorTemperature = 0;
-
-            Log.v(TAG, "Finished taking picture, ready to process");
-            colorTemperature = processWhiteBalanceTest(mTestHandler);
-
-            // Records the index of the "Auto" white balance mode
-            if (mWhiteBalance.equals("daylight")) {
-                setReferenceTemperature(mAutoId, colorTemperature);
-                prepareDebugText(5200, index);
-                // Computes the reference CCT range of the "Auto" mode. Assuming that
-                // all grey squares on the color checker should be imaged as grey under
-                // a CCT, this CCT is used as a middle point to provide a range.
-                //setReferenceTemperature(mAutoId, colorTemperature[mWhiteBalanceList.size()]);
-            } else {
-                // Prepares the debug output.
-                prepareDebugText(colorTemperature, index);
-            }
-        } else {
-            for (int i = 0; i < mWhiteBalanceList.size(); i++) {
-                run(i + 1);
-            }
-        }
-
-        mParams.setWhiteBalance("auto");
-        mTestCamera.setParameters(mParams);
-    }
-
-    /**
-     * Prepares the debug results in HTML text. For each white balance mode,
-     * the CCT will be printed in green if it is in the reference range and
-     * red otherwise. The reference CCT range is also printed below, with
-     * green meaning the CCT range is satisfied and red otherwise.
-     *
-     * @param colorTemperature the CCT of the supported white balance modes
-     */
-    private void prepareDebugText(int colorTemperature, int index) {
-        mDebugText += String.format("CCT Ref is %d, %d, and CCT is %d",
-                                  mReferenceTemperature[index - 1][0],
-                                  mReferenceTemperature[index - 1][1],
-                                  colorTemperature);
-        Log.v(TAG, String.format("CCT Ref is %d, %d, and CCT is %d",
-                                  mReferenceTemperature[index - 1][0],
-                                  mReferenceTemperature[index - 1][1],
-                                  colorTemperature));
-        if ((colorTemperature >= mReferenceTemperature[index - 1][0]) &&
-                (colorTemperature <= mReferenceTemperature[index - 1][1])) {
-            mTestResults[index] = CameraTests.CAMERA_TEST_SUCCESS;
-        } else {
-            mTestResults[index] = CameraTests.CAMERA_TEST_FAILURE;
-        }
-
-    }
-
-    @Override
-    public String getDebugText() {
-        return mDebugText;
-    }
-
-    @Override
-    public String getResultText() {
-        return mDebugText;
-    }
-
-    @Override
-    public String getTestName() {
-        return "White Balance Test: \n";
-    }
-
-    @Override
-    public String getTestName(int index) {
-        if (index != 0){
-            return String.format("%s mode test", mWhiteBalanceList.get(index - 1));
-        } else {
-            return "Run all tests";
-        }
-    }
-
-    @Override
-    public int getResult(int index) {
-        return mTestResults[index];
-    }
-
-    @Override
-    public int getNumTests() {
-        return mNumTests;
-    }
-
-    /**
-     * Sets the reference temperatures for the white balance modes of
-     * incandescent, fluorescent, warm-fluorescent, daylight, cloudy, shade
-     * and twilight. These are the currently supported White balance mode
-     * listed on the Android camera API.
-     *
-     * The reference range are summarized based on the published settings of
-     * Canon, Nikon and the references from Wikipedia on color temperature.
-     *
-     * @param i the index of the current white balance mode
-     * @param referenceWhiteBalance the name of the white balance mode.
-     */
-    private void setReferenceTemperature(int i, String referenceWhiteBalance) {
-        if (referenceWhiteBalance.equals("incandescent")) {
-            mReferenceTemperature[i][0] = 2500;
-            mReferenceTemperature[i][1] = 3500;
-        } else if (referenceWhiteBalance.equals("fluorescent")) {
-            mReferenceTemperature[i][0] = 3000;
-            mReferenceTemperature[i][1] = 6500;
-        } else if (referenceWhiteBalance.equals("warm-fluorescent")) {
-            mReferenceTemperature[i][0] = 2500;
-            mReferenceTemperature[i][1] = 3000;
-        } else if (referenceWhiteBalance.equals("daylight")) {
-            mReferenceTemperature[i][0] = 5000;
-            mReferenceTemperature[i][1] = 5400;
-        } else if (referenceWhiteBalance.equals("cloudy-daylight")) {
-            mReferenceTemperature[i][0] = 5500;
-            mReferenceTemperature[i][1] = 7500;
-        } else if (referenceWhiteBalance.equals("shade")) {
-            mReferenceTemperature[i][0] = 6800;
-            mReferenceTemperature[i][1] = 8000;
-        } else if (referenceWhiteBalance.equals("twilight")) {
-            mReferenceTemperature[i][0] = 10000;
-            mReferenceTemperature[i][1] = 14000;
-        }
-    }
-
-    /** Sets a reference range of CCT based on a given middle point CCT.
-     * The rerence range is from -10% of the CCT value to +10%.
-     *
-     * @param i the index of the current white balance mode
-     * @param t the middle point CCT.
-     */
-    private void setReferenceTemperature(int i, int t) {
-        mReferenceTemperature[i][0] = (int)((double)t * 0.9);
-        mReferenceTemperature[i][1] = (int)((double)t * 1.1);
-    }
-
-    private Camera.PictureCallback mTestJpegListener = new Camera.PictureCallback() {
-        public void onPictureTaken(byte[] data, Camera mCamera) {
-            Log.v(TAG, "Shutter pressed down!");
-            Bitmap inputImage;
-            try {
-                FileOutputStream outStream = new FileOutputStream(
-                        String.format("/sdcard/wb%d.jpg", System.currentTimeMillis()));
-                outStream.write(data);
-                outStream.close();
-            } catch (FileNotFoundException e) {
-            } catch (IOException e) {}
-            // Decodes the camera data to Bitmap and creates a native image
-            // class with the Bitmap.
-            inputImage = BitmapFactory.decodeByteArray(data, 0, data.length);
-            long bufferAddress = findNative(inputImage);
-            Log.v(TAG, "findNative method finishes");
-
-            // Cleans up the Bitmap memory space.
-            inputImage.recycle();
-            data = null;
-            inputImage = null;
-            System.gc();
-
-            // Adds the data from the current image base class to the native
-            // white balance test handler.
-            createWhiteBalanceClass(bufferAddress, mTestHandler,
-                                    getCheckerCenter(), getCheckerRadius(), mWhiteBalance);
-
-            mCamera.startPreview();
-
-            // Notifies the thread lock that the image capture is finished
-            synchronized (mProcessingImage) {
-                mProcessingImage.notifyAll();
-            }
-        }
-    };
-
-    /**
-     * Creates a native white balance test handler.
-     *
-     * @return the memory address of the test handler
-     */
-    private native long createWhiteBalanceTest();
-
-    /**
-     * Adds the data of interest from the image class pointed by
-     * <code>bufferAddress</code> to the handler class pointed by
-     * <code>handlerAddress</code> by using the color checker coordinates.
-     * Also sets the white balance of this test.
-     *
-     * @param bufferAddress the memory address of the native image class
-     * containing the current camera captured image
-     * @param handlerAddress the memory address of the native white balance
-     * test handler instance
-     * @param checkerCenterAddress the memory address of the color checker
-     * center coordinates
-     * @param checkerRadiusAddress the memory address of the color checker
-     * radius
-     * @param whiteBalance the white balance mode used for shooting the image
-     */
-    private native void createWhiteBalanceClass(long bufferAddress, long handlerAddress,
-                                                long checkerCenterAddress,
-                                                long checkerRadiusAddress,
-                                                String whiteBalance);
-
-    /**
-     * Processes the white balance test in the native code. This is executed
-     * after the images are taken with all possible white balance modes. It
-     * uses the "Daylight" white balance mode as reference and computes the
-     * CCT of other white balance modes.
-     *
-     * @param handlerAddress the memory address of the native white balance
-     * test handler instance.
-     * @param colorTemperature the array to store the computed CCT of all white
-     * balance modes.
-     */
-    private native int processWhiteBalanceTest(long handlerAddress);
-
-    private native int getAutoTemperature(long handlerAddress);
-
-    static {
-        System.loadLibrary("cameraanalyzer");
-    }
-}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index d829314..f6e5231 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -188,6 +188,9 @@
         if (!mHasFeature) {
             return;
         }
+        // If adb is running as root, then the adb uid is 0 instead of SHELL_UID,
+        // so the DISALLOW_DEBUGGING_FEATURES restriction does not work and this test
+        // fails.
         String restriction = "no_debugging_features";  // UserManager.DISALLOW_DEBUGGING_FEATURES
         String command = "add-restriction";
 
@@ -262,7 +265,7 @@
 
     private void setProfileOwner(String componentName, int userId)
             throws DeviceNotAvailableException {
-        String command = "dpm set-profile-owner '" + componentName + "' " + userId;
+        String command = "dpm set-profile-owner --user " + userId + " '" + componentName + "'";
         String commandOutput = getDevice().executeShellCommand(command);
         CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
         assertTrue(commandOutput + " expected to start with \"Success:\"",
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index d21fdc1..3a94f50 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -7,13 +7,6 @@
   bug: 17536113
 },
 {
-  description: "the ConnectivityConstraintTest are not yet stable",
-  names: [
-    "android.jobscheduler.cts.ConnectivityConstraintTest"
-  ],
-  bug: 18117279
-},
-{
   description: "tests a fragile by nature as they rely on hardcoded behavior",
   names: [
     "android.accessibilityservice.cts.AccessibilityTextTraversalTest#testActionNextAndPreviousAtGranularityPageOverText",
@@ -76,6 +69,26 @@
   bug: 16720689
 },
 {
+  description: "test can only run properly on a user build device when the bug is resolved",
+  names: [
+    "android.appwidget.cts.AppWidgetTest#testAppWidgetProviderCallbacks",
+    "android.appwidget.cts.AppWidgetTest#testBindAppWidget",
+    "android.appwidget.cts.AppWidgetTest#testCollectionWidgets",
+    "android.appwidget.cts.AppWidgetTest#testDeleteHost",
+    "android.appwidget.cts.AppWidgetTest#testDeleteHosts",
+    "android.appwidget.cts.AppWidgetTest#testGetAppWidgetIds",
+    "android.appwidget.cts.AppWidgetTest#testGetAppWidgetInfo",
+    "android.appwidget.cts.AppWidgetTest#testGetAppWidgetOptions",
+    "android.appwidget.cts.AppWidgetTest#testPartiallyUpdateAppWidgetViaWidgetId",
+    "android.appwidget.cts.AppWidgetTest#testPartiallyUpdateAppWidgetViaWidgetIds",
+    "android.appwidget.cts.AppWidgetTest#testTwoAppWidgetProviderCallbacks",
+    "android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaComponentName",
+    "android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaWidgetId",
+    "android.appwidget.cts.AppWidgetTest#testUpdateAppWidgetViaWidgetIds"
+  ],
+  bug: 17993121
+},
+{
   description: "A few WebGL tests are known to fail in WebView",
   names: [
     "android.webgl.cts.WebGLTest#test_conformance_extensions_oes_texture_float_with_video_html",
diff --git a/tests/tests/graphics/res/drawable/vector_icon_clip_path_1.xml b/tests/tests/graphics/res/drawable/vector_icon_clip_path_1.xml
index c2ab429..53a9660 100644
--- a/tests/tests/graphics/res/drawable/vector_icon_clip_path_1.xml
+++ b/tests/tests/graphics/res/drawable/vector_icon_clip_path_1.xml
@@ -14,10 +14,10 @@
      limitations under the License.
 -->
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
-        android:height="64dp"
-        android:width="64dp"
-        android:viewportHeight="12.25"
-        android:viewportWidth="7.30625" >
+    android:height="64dp"
+    android:viewportHeight="12.25"
+    android:viewportWidth="7.30625"
+    android:width="64dp" >
 
     <group
         android:pivotX="3.65"
@@ -31,14 +31,18 @@
                 l 0, 12.25
                 l -7.3, 0
                 z" />
-    </group>
-    <group>
-        <path
-            android:name="one"
-            android:fillColor="#ff88ff"
-            android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0-6.671875 -2.109375,0.421875 0.0-1.078125
+
+        <group
+            android:pivotX="3.65"
+            android:pivotY="6.125"
+            android:rotation="30" >
+            <path
+                android:name="one"
+                android:fillColor="#ff88ff"
+                android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0-6.671875 -2.109375,0.421875 0.0-1.078125
                 l 2.09375-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
                 l -5.046875,0.0 0.0-1.0Z" />
+        </group>
     </group>
     <group
         android:pivotX="3.65"
@@ -52,12 +56,15 @@
                 l 0, 6.125
                 l -7.3, 0
                 z" />
-    </group>
-    <group>
-        <path
-            android:name="two"
-            android:fillColor="#ff88ff"
-            android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0-1.0q 0.671875-0.6875 1.828125-1.859375
+
+        <group
+            android:pivotX="3.65"
+            android:pivotY="6.125"
+            android:rotation="30" >
+            <path
+                android:name="two"
+                android:fillColor="#ff88ff"
+                android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0-1.0q 0.671875-0.6875 1.828125-1.859375
                         q 1.1718752-1.1875 1.4687502-1.53125 0.578125-0.625 0.796875-1.0625
                         q 0.234375-0.453125 0.234375-0.875 0.0-0.703125 -0.5-1.140625
                         q -0.484375-0.4375 -1.2656252-0.4375 -0.5625,0.0 -1.1875,0.1875
@@ -66,6 +73,7 @@
                         q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625
                         q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375
                         q -0.78125024,0.8125 -2.2187502,2.265625Z" />
+        </group>
     </group>
 
 </vector>
\ No newline at end of file
diff --git a/tests/tests/graphics/res/drawable/vector_icon_delete.xml b/tests/tests/graphics/res/drawable/vector_icon_delete.xml
index 8d9c21c..7b8f2aa 100644
--- a/tests/tests/graphics/res/drawable/vector_icon_delete.xml
+++ b/tests/tests/graphics/res/drawable/vector_icon_delete.xml
@@ -24,6 +24,6 @@
 
     <path
         android:fillColor="#FF000000"
-        android:pathData="M6.0,19.0c0.0,1.104 0.896,2.0 2.0,2.0l8.0,0.0c1.104,0.0 2.0-0.896 2.0-2.0l0.0-12.0L6.0,7.0L6.0,19.0zM18.0,4.0l-2.5,0.0l-1.0-1.0l-5.0,0.0l-1.0,1.0L6.0,4.0C5.4469986,4.0 5.0,4.4469986 5.0,5.0l0.0,1.0l14.0,0.0l0.0-1.0C19.0,4.4469986 18.552002,4.0 18.0,4.0z" />
+        android:pathData="M6.0,19.0c0.0,1.104 896e-3,2.0 2.0,2.0l8.0,0.0c1.104,0.0 2.0-896e-3 2.0-2.0l0.0-12.0L6.0,7.0L6.0,19.0zM18.0,4.0l-2.5,0.0l-1.0-1.0l-5.0,0.0l-1.0,1.0L6.0,4.0C5.4469986,4.0 5.0,4.4469986 5.0,5.0l0.0,1.0l14.0,0.0l0.0-1.0C19.0,4.4469986 18.552002,4.0 18.0,4.0z" />
 
 </vector>
\ No newline at end of file
diff --git a/tests/tests/graphics/res/drawable/vector_icon_heart.xml b/tests/tests/graphics/res/drawable/vector_icon_heart.xml
index ff55fe5..ad991c9 100644
--- a/tests/tests/graphics/res/drawable/vector_icon_heart.xml
+++ b/tests/tests/graphics/res/drawable/vector_icon_heart.xml
@@ -24,6 +24,6 @@
 
     <path
         android:fillColor="#FF000000"
-        android:pathData="M16.0,5.0c-1.955,0.0 -3.83,1.268 -4.5,3.0c-0.67-1.732 -2.547-3.0 -4.5-3.0C4.4570007,5.0 2.5,6.931999 2.5,9.5c0.0,3.529 3.793,6.258 9.0,11.5c5.207-5.242 9.0-7.971 9.0-11.5C20.5,6.931999 18.543,5.0 16.0,5.0z" />
+        android:pathData="M16.0,5.0c-1.955.0 -3.83,1.268 -4.5,3.0c-0.67-1.732 -2.547-3.0 -4.5-3.0C4.4570007,5.0 2.5,6.931999 2.5,9.5c0.0,3.529 3.793,6.258 9.0,11.5c5.207-5.242 9.0-7.971 9.0-11.5C20.5,6.931999 18.543,5.0 16.0,5.0z" />
 
 </vector>
\ No newline at end of file
diff --git a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
index 1f709d3..bac72b2 100644
--- a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
@@ -19,6 +19,7 @@
 
 import android.graphics.ColorFilter;
 import android.graphics.MaskFilter;
+import android.graphics.Matrix;
 import android.graphics.Paint;
 import android.graphics.Paint.Align;
 import android.graphics.Paint.Cap;
@@ -28,6 +29,8 @@
 import android.graphics.PathEffect;
 import android.graphics.Rasterizer;
 import android.graphics.Shader;
+import android.graphics.Bitmap;
+import android.graphics.BitmapShader;
 import android.graphics.Typeface;
 import android.graphics.Xfermode;
 import android.os.Build;
@@ -190,7 +193,7 @@
         assertEquals(m, p2.getMaskFilter());
         assertEquals(e, p2.getPathEffect());
         assertEquals(r, p2.getRasterizer());
-        assertNotSame(s, p2.getShader());
+        assertEquals(s, p2.getShader());
         assertEquals(t, p2.getTypeface());
         assertEquals(x, p2.getXfermode());
 
@@ -199,7 +202,7 @@
         assertEquals(m, p2.getMaskFilter());
         assertEquals(e, p2.getPathEffect());
         assertEquals(r, p2.getRasterizer());
-        assertNotSame(s, p2.getShader());
+        assertEquals(s, p2.getShader());
         assertEquals(t, p2.getTypeface());
         assertEquals(x, p2.getXfermode());
 
@@ -271,6 +274,35 @@
         assertNull(p.getShader());
     }
 
+    public void testShaderLocalMatrix() {
+        int width = 80;
+        int height = 120;
+        int[] color = new int[width * height];
+        Bitmap bitmap = Bitmap.createBitmap(color, width, height, Bitmap.Config.RGB_565);
+
+        Paint p = new Paint();
+        Matrix m = new Matrix();
+        Shader s = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+
+        // set the shaders matrix to a non identity value and attach to paint
+        m.setScale(10, 0);
+        s.setLocalMatrix(m);
+        p.setShader(s);
+
+        Matrix m2 = new Matrix();
+        assertTrue(p.getShader().getLocalMatrix(m2));
+        assertEquals(m, m2);
+
+        // updated the matrix again and set it on the shader but NOT the paint
+        m.setScale(0, 10);
+        s.setLocalMatrix(m);
+
+        // assert that the matrix on the paint's shader also changed
+        Matrix m3 = new Matrix();
+        assertTrue(p.getShader().getLocalMatrix(m3));
+        assertEquals(m, m3);
+    }
+
     public void testSetAntiAlias() {
         Paint p = new Paint();
 
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java
new file mode 100644
index 0000000..a64ceb9
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java
@@ -0,0 +1,721 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.camera2.cts;
+
+import static android.hardware.camera2.cts.CameraTestUtils.*;
+
+import android.graphics.ImageFormat;
+import android.graphics.Rect;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CaptureRequest;
+import android.hardware.camera2.CaptureRequest.Builder;
+import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.cts.CameraTestUtils.SimpleCaptureCallback;
+import android.hardware.camera2.cts.CameraTestUtils.SimpleImageReaderListener;
+import android.hardware.camera2.cts.testcases.Camera2SurfaceViewTestCase;
+import android.hardware.camera2.params.StreamConfigurationMap;
+import android.media.Image;
+import android.util.Log;
+import android.util.Range;
+import android.util.Size;
+
+import java.util.ArrayList;
+
+/**
+ * Basic tests for burst capture in RAW10/16.
+ */
+public class BurstCaptureRawTest extends Camera2SurfaceViewTestCase {
+    private static final String TAG = "BurstCaptureRawTest";
+    private static final int RAW_FORMATS[] = {
+            ImageFormat.RAW10, ImageFormat.RAW_SENSOR };
+    private static final long EXPOSURE_MULTIPLIERS[] = {
+            1, 3, 5 };
+    private static final int SENSITIVITY_MLTIPLIERS[] = {
+            1, 3, 5 };
+    private static final int MAX_FRAMES_BURST =
+            EXPOSURE_MULTIPLIERS.length * SENSITIVITY_MLTIPLIERS.length;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /**
+     * Verify raw sensor size information is correctly configured.
+     */
+    public void testRawSensorSize() throws Exception {
+        Log.i(TAG, "Begin testRawSensorSize");
+        for (String id : mCameraIds) {
+            try {
+                openDevice(id);
+
+                ArrayList<Integer> supportedRawList = new ArrayList<Integer>(RAW_FORMATS.length);
+                if (!checkCapability(supportedRawList)) {
+                    Log.i(TAG, "Capability is not supported on camera " + id
+                            + ". Skip the test.");
+                    continue;
+                }
+
+                Size[] rawSizes = mStaticInfo.getRawOutputSizesChecked();
+                assertTrue("No capture sizes available for RAW format!", rawSizes.length != 0);
+
+                Rect activeArray = mStaticInfo.getActiveArraySizeChecked();
+                Size size = new Size(activeArray.width(), activeArray.height());
+                mCollector.expectTrue("Missing ActiveArraySize",
+                        activeArray.width() > 0 && activeArray.height() > 0);
+                mCollector.expectContains(
+                        "Available sizes for RAW format must include ActiveArraySize",
+                        rawSizes, size);
+
+            } finally {
+                closeDevice();
+            }
+        }
+        Log.i(TAG, "End testRawSensorSize");
+    }
+
+    /**
+     * Round [exposure, gain] down, rather than to the nearest, in RAW 10/16
+     * <p>
+     * Verify the value of metadata (exposure and sensitivity) is rounded down if the request cannot
+     * be honored.
+     * </p>
+     */
+    public void testMetadataRoundDown() throws Exception {
+        Log.i(TAG, "Begin testMetadataRoundDown");
+
+        performTestRoutine(new TestMetaDataRoundDownRoutine());
+
+        Log.i(TAG, "End testMetadataRoundDown");
+    }
+
+    /**
+     * Manual and Auto setting test in RAW10/16
+     * <p>
+     * Make sure switching between manual and auto setting would not make the capture results out of
+     * sync.
+     * </p>
+     */
+    public void testManualAutoSwitch() throws Exception {
+        Log.i(TAG, "Begin testManualAutoSwitch");
+
+        performTestRoutine(new TestManualAutoSwitch());
+
+        Log.i(TAG, "End testManualAutoSwitch");
+    }
+
+    /**
+     * Per frame timestamp test in RAW10/16
+     */
+    public void testTimestamp() throws Exception {
+        Log.i(TAG, "Begin testTimestamp");
+
+        performTestRoutine(new TestTimestamp());
+
+        Log.i(TAG, "End testTimestamp");
+    }
+
+    /*
+     * Below are private infrastructure for all tests
+     */
+
+    /**
+     * A structure encapsulates all the parameters for setting up preview, and RAW capture.
+     */
+    class CaptureSetup
+    {
+        public CaptureSetup(Size previewCaptureSize, Size rawCaptureSize,
+                CaptureRequest.Builder previewRequestBuilder,
+                CaptureRequest.Builder rawRequestBuilder,
+                SimpleCaptureCallback previewCaptureCallback,
+                SimpleCaptureCallback rawCaptureCallback,
+                SimpleImageReaderListener rawReaderListener)
+        {
+            mPreviewCaptureSize = previewCaptureSize;
+            mRawCaptureSize = rawCaptureSize;
+            mPreviewRequestBuilder = previewRequestBuilder;
+            mRawRequestBuilder = rawRequestBuilder;
+            mPreviewCaptureCallback = previewCaptureCallback;
+            mRawCaptureCallback = rawCaptureCallback;
+            mRawReaderListener = rawReaderListener;
+        }
+
+        public Size getPreviewCaptureSize()
+        {
+            return mPreviewCaptureSize;
+        }
+
+        public Size getRawCaptureSize()
+        {
+            return mRawCaptureSize;
+        }
+
+        public CaptureRequest.Builder getPreviewRequestBuilder()
+        {
+            return mPreviewRequestBuilder;
+        }
+
+        public CaptureRequest.Builder getRawRequestBuilder() {
+            return mRawRequestBuilder;
+        }
+
+        public SimpleCaptureCallback getPreviewCaptureCallback() {
+            return mPreviewCaptureCallback;
+        }
+
+        public SimpleCaptureCallback getRawCaptureCallback() {
+            return mRawCaptureCallback;
+        }
+
+        public SimpleImageReaderListener getRawReaderListener() {
+            return mRawReaderListener;
+        }
+
+        private Size mPreviewCaptureSize;
+        private Size mRawCaptureSize;
+        private CaptureRequest.Builder mPreviewRequestBuilder;
+        private CaptureRequest.Builder mRawRequestBuilder;
+
+        /** all the non-testing requests are sent to here */
+        private SimpleCaptureCallback mPreviewCaptureCallback;
+        /** all the testing requests are sent to here */
+        private SimpleCaptureCallback mRawCaptureCallback;
+        /** all the testing framebuffers are sent to here */
+        private SimpleImageReaderListener mRawReaderListener;
+    }
+
+    /**
+     * Interface for the test routines that are being called by performTestRoutines(). Implement
+     * different test cases in execute().
+     */
+    interface TestRoutine {
+        public void execute(CaptureRequest.Builder rawBurstBuilder,
+                SimpleCaptureCallback rawCaptureCallback,
+                SimpleImageReaderListener rawReaderListener, int rawFormat) throws Exception;
+    }
+
+    /**
+     * Implementation of metadata round down test.
+     */
+    class TestMetaDataRoundDownRoutine implements TestRoutine
+    {
+        @Override
+        public void execute(CaptureRequest.Builder rawBurstBuilder,
+                SimpleCaptureCallback rawCaptureCallback,
+                SimpleImageReaderListener rawReaderListener, int rawFormat) throws Exception
+        {
+            // build burst capture
+            ArrayList<CaptureRequest> rawRequestList = createBurstRequest(rawBurstBuilder);
+
+            // submit captrue
+            Log.i(TAG, "Submitting Burst Request.");
+            mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+            // verify metadata
+            for (int i = 0; i < MAX_FRAMES_BURST; i++) {
+                CaptureResult result = rawCaptureCallback.getCaptureResult(
+                        CAPTURE_IMAGE_TIMEOUT_MS);
+
+                long resultExposure = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
+                int resultSensitivity = result.get(CaptureResult.SENSOR_SENSITIVITY);
+                long desiredExposure = rawRequestList.get(i).get(
+                        CaptureRequest.SENSOR_EXPOSURE_TIME);
+                int desiredSensitivity = rawRequestList.get(i).get(
+                        CaptureRequest.SENSOR_SENSITIVITY);
+
+                Log.i(TAG, String.format(
+                        "Received capture result, exposure = %d, sensitivity = %d. "
+                                + "Requested exposure = %d, sensitivity = %d.",
+                        resultExposure,
+                        resultSensitivity, desiredExposure, desiredSensitivity));
+
+                mCollector.expectTrue(
+                        String.format("Exposure value is greater than requested: "
+                                + "requested = %d, result = %d.",
+                                desiredExposure, resultExposure),
+                                resultExposure <= desiredExposure);
+
+                mCollector.expectTrue(
+                        String.format("Sensitivity value is greater than requested: "
+                                + "requested = %d, result = %d.",
+                                desiredSensitivity, resultSensitivity),
+                                resultSensitivity <= desiredSensitivity);
+            }
+        }
+    }
+
+    /**
+     * Implementation of manual-auto switching test.
+     */
+    class TestManualAutoSwitch implements TestRoutine
+    {
+        @Override
+        public void execute(CaptureRequest.Builder rawBurstBuilder,
+                SimpleCaptureCallback rawCaptureCallback,
+                SimpleImageReaderListener rawReaderListener, int rawFormat) throws Exception
+        {
+            // create a capture request builder to preserve all the original values
+            CaptureRequest.Builder originBuilder = mCamera.createCaptureRequest(
+                    CameraDevice.TEMPLATE_STILL_CAPTURE);
+            copyBurstRequetBuilder(originBuilder, rawBurstBuilder);
+
+            // build burst capture
+            ArrayList<CaptureRequest> rawRequestList = createBurstRequest(rawBurstBuilder);
+
+            // submit captrue but ignore
+            mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+            // drain the capture result
+            drainQueues(rawReaderListener, rawCaptureCallback);
+
+            // reset and build capture with 3A
+            copyBurstRequetBuilder(rawBurstBuilder, originBuilder);
+            rawRequestList = createBurstRequestWith3A(rawBurstBuilder);
+
+            // submit captrue but ignore
+            mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+            // drain the capture result
+            drainQueues(rawReaderListener, rawCaptureCallback);
+
+            // reset and rebuild manual raw burst capture
+            copyBurstRequetBuilder(rawBurstBuilder, originBuilder);
+            rawRequestList = createBurstRequest(rawBurstBuilder);
+
+            // submit capture
+            Log.i(TAG, "Submitting Burst Request.");
+            mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+            // verify metadata
+            for (int i = 0; i < MAX_FRAMES_BURST; i++) {
+                CaptureResult result = rawCaptureCallback.getCaptureResult(
+                        CAPTURE_IMAGE_TIMEOUT_MS);
+
+                long resultExposure = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
+                int resultSensitivity = result.get(CaptureResult.SENSOR_SENSITIVITY);
+                int resultEdgeMode = result.get(CaptureResult.EDGE_MODE);
+                int resultNoiseReductionMode = result.get(
+                        CaptureResult.NOISE_REDUCTION_MODE);
+                long desiredExposure = rawRequestList.get(i).get(
+                        CaptureRequest.SENSOR_EXPOSURE_TIME);
+                int desiredSensitivity = rawRequestList.get(i).get(
+                        CaptureRequest.SENSOR_SENSITIVITY);
+
+                Log.i(TAG, String.format(
+                        "Received capture result, exposure = %d, sensitivity = %d. "
+                                + "Requested exposure = %d, sensitivity = %d.",
+                        resultExposure,
+                        resultSensitivity, desiredExposure, desiredSensitivity));
+
+                mCollector.expectTrue(String.format("Edge mode is not turned off."),
+                        resultEdgeMode == CaptureRequest.EDGE_MODE_OFF);
+
+                mCollector.expectTrue(String.format("Noise reduction is not turned off."),
+                        resultNoiseReductionMode
+                        == CaptureRequest.NOISE_REDUCTION_MODE_OFF);
+
+                mCollector.expectTrue(
+                        String.format("Exposure value is greater than requested: "
+                                + "requested = %d, result = %d.",
+                                desiredExposure, resultExposure),
+                                resultExposure <= desiredExposure);
+
+                mCollector.expectTrue(
+                        String.format("Sensitivity value is greater than requested: "
+                                + "requested = %d, result = %d.",
+                                desiredSensitivity, resultSensitivity),
+                                resultSensitivity <= desiredSensitivity);
+            }
+
+        }
+    }
+
+    /**
+     * Implementation of timestamp test
+     */
+    class TestTimestamp implements TestRoutine
+    {
+        private final double THRESHOLD = 5000000.0; // 5ms
+        private final long EXPOSURE_MULTIPLIERS_PRIVATE[] = {
+                1, 1, 1 };
+        private final int SENSITIVITY_MLTIPLIERS_PRIVATE[] = {
+                1, 1, 1 };
+        private final int MAX_FRAMES_BURST_PRIVATE =
+                EXPOSURE_MULTIPLIERS_PRIVATE.length * SENSITIVITY_MLTIPLIERS_PRIVATE.length;
+
+        @Override
+        public void execute(Builder rawBurstBuilder, SimpleCaptureCallback rawCaptureCallback,
+                SimpleImageReaderListener rawReaderListener, int rawFormat) throws Exception {
+            // prepare some local variables
+            ArrayList<Long> sensorTime = new ArrayList<Long>(MAX_FRAMES_BURST_PRIVATE);
+
+            // build burst capture
+            ArrayList<CaptureRequest> rawRequestList = createBurstRequest(rawBurstBuilder,
+                    EXPOSURE_MULTIPLIERS_PRIVATE, SENSITIVITY_MLTIPLIERS_PRIVATE);
+
+            // submit capture while recording timestamp
+            Log.i(TAG, "Submitting Burst Request.");
+            mSession.captureBurst(rawRequestList, rawCaptureCallback, mHandler);
+
+            // receive frames while recording timestamp
+            for (int i = 0; i < MAX_FRAMES_BURST_PRIVATE; i++) {
+                CaptureResult result = rawCaptureCallback.getCaptureResult(
+                        CAPTURE_IMAGE_TIMEOUT_MS);
+                long resultExposure = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
+                int resultSensitivity = result.get(CaptureResult.SENSOR_SENSITIVITY);
+                long resultTimestamp = result.get(CaptureResult.SENSOR_TIMESTAMP);
+                Log.i(TAG, String.format(
+                        "Received capture result, exposure = %d, sensitivity = %d, timestamp = %d",
+                        resultExposure, resultSensitivity, resultTimestamp));
+
+                sensorTime.add(resultTimestamp);
+            }
+
+            // compare sensor time and compute the difference
+            ArrayList<Long> deltaList = new ArrayList<Long>();
+            for (int i = 1; i < MAX_FRAMES_BURST_PRIVATE; i++)
+            {
+                deltaList.add(sensorTime.get(i) - sensorTime.get(i - 1));
+            }
+
+            // compute the average and standard deviation of the differences
+            double average = 0.0;
+            for (int i = 0; i < deltaList.size(); i++)
+            {
+                average += deltaList.get(i);
+            }
+            average /= deltaList.size();
+
+            double stddev = 0.0;
+            for (int i = 0; i < deltaList.size(); i++)
+            {
+                double diff = deltaList.get(i) - average;
+                stddev += diff * diff;
+            }
+            stddev = Math.sqrt(stddev / deltaList.size());
+
+            Log.i(TAG, String.format("average = %.2f, stddev = %.2f", average, stddev));
+
+            StringBuilder sensorTimestampMessage = new StringBuilder();
+            for (int i = 0; i < sensorTime.size(); i++)
+            {
+                sensorTimestampMessage.append("frame [");
+                sensorTimestampMessage.append(i);
+                sensorTimestampMessage.append("] SENSOR_TIMESTAMP = ");
+                sensorTimestampMessage.append(sensorTime.get(i));
+                sensorTimestampMessage.append("\n");
+            }
+
+            mCollector.expectLessOrEqual(
+                    "The standard deviation of frame interval is larger then threshold: " +
+                    String.format("stddev = %.2f, threshold = %.2f.\n", stddev, THRESHOLD) +
+                    sensorTimestampMessage.toString(),
+                    THRESHOLD, stddev);
+        }
+    }
+
+    /**
+     * Check sensor capability prior to the test.
+     *
+     * @return true if the it is has the capability to execute the test.
+     */
+    private boolean checkCapability(ArrayList<Integer> supportedRawList) {
+        // make sure the sensor has manual support
+        if (!mStaticInfo.isCapabilitySupported(
+                CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL)) {
+            Log.w(TAG, "Full hardware level is not supported");
+            return false;
+        }
+
+        // get the list of supported RAW format
+        StreamConfigurationMap config = mStaticInfo.getValueFromKeyNonNull(
+                CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+
+        // check for the RAW support
+        supportedRawList.clear();
+        for (int rawFormat : RAW_FORMATS) {
+            if (!config.isOutputSupportedFor(rawFormat)) {
+                continue;
+            }
+            supportedRawList.add(rawFormat);
+        }
+
+        if (supportedRawList.size() == 0)
+        {
+            Log.w(TAG, "RAW output is not supported!");
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * Return the sensor format to human readable string.
+     *
+     * @param format Sensor image format.
+     * @return Human readable string.
+     */
+    private String imageFormatToString(int format) {
+        switch (format) {
+            case ImageFormat.RAW10:
+                return "RAW10";
+            case ImageFormat.RAW_SENSOR:
+                return "RAW_SENSOR";
+        }
+
+        return "Unknown";
+    }
+
+    /**
+     * Setting up various classes prior to the request, e.g.: capture size, builder, callback and
+     * listener
+     *
+     * @return initialized variables that can be directly fed into prepareCaptureAndStartPreview().
+     */
+    private CaptureSetup initCaptureSetupForPreviewAndRaw() throws Exception
+    {
+        // capture size
+        Size previewSize = mOrderedPreviewSizes.get(0);
+        Rect activeArray = mStaticInfo.getActiveArraySizeChecked();
+        Size rawSize = new Size(activeArray.width(), activeArray.height());
+
+        // builder
+        CaptureRequest.Builder previewCaptureBuilder = mCamera.createCaptureRequest(
+                CameraDevice.TEMPLATE_PREVIEW);
+        CaptureRequest.Builder rawCaptureBuilder = mCamera.createCaptureRequest(
+                CameraDevice.TEMPLATE_STILL_CAPTURE);
+
+        // callback
+        SimpleCaptureCallback previewCaptureCallback = new SimpleCaptureCallback();
+        SimpleCaptureCallback rawCaptureCallback = new SimpleCaptureCallback();
+        SimpleImageReaderListener rawReaderListener = new SimpleImageReaderListener();
+
+        CaptureSetup setup = new CaptureSetup(previewSize, rawSize, previewCaptureBuilder,
+                rawCaptureBuilder, previewCaptureCallback, rawCaptureCallback, rawReaderListener);
+
+        return setup;
+    }
+
+    /**
+     * Construct an array of burst request with manual exposure and sensitivity.
+     * <p>
+     * For each capture request, 3A and post processing (noise reduction, sharpening, etc) will be
+     * turned off. Then exposure and sensitivity value will be configured, which are determined by
+     * EXPOSURE_MULIPLIERS and SENSITIVITY_MULTIPLIERS.
+     * </p>
+     *
+     * @param rawBurstBuilder The builder needs to have targets setup.
+     * @return An array list capture request for burst.
+     */
+    private ArrayList<CaptureRequest> createBurstRequest(CaptureRequest.Builder rawBurstBuilder)
+    {
+        return createBurstRequest(rawBurstBuilder, EXPOSURE_MULTIPLIERS, SENSITIVITY_MLTIPLIERS);
+    }
+
+    private ArrayList<CaptureRequest> createBurstRequest(CaptureRequest.Builder rawBurstBuilder,
+            long[] exposureMultipliers, int[] sensitivityMultipliers) {
+        // set manual mode
+        rawBurstBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_OFF);
+        rawBurstBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_OFF);
+        rawBurstBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE,
+                CaptureRequest.NOISE_REDUCTION_MODE_OFF);
+        rawBurstBuilder.set(CaptureRequest.EDGE_MODE, CaptureRequest.EDGE_MODE_OFF);
+        // exposure has higher priority over frame duration; therefore the frame readout time:
+        // exposure time + overhead
+        rawBurstBuilder.set(CaptureRequest.SENSOR_FRAME_DURATION, 0L);
+
+        // get the exposure and sensitivity range
+        Range<Long> exposureRangeNs = new Range<Long>(mStaticInfo.getExposureMinimumOrDefault(),
+                mStaticInfo.getExposureMaximumOrDefault());
+
+        Range<Integer> isoRange = new Range<Integer>(mStaticInfo.getSensitivityMinimumOrDefault(),
+                mStaticInfo.getSensitivityMaximumOrDefault());
+
+        Log.i(TAG, String.format("Exposure time - max: %d, min: %d.", exposureRangeNs.getUpper(),
+                exposureRangeNs.getLower()));
+        Log.i(TAG, String.format("Sensitivity - max: %d, min: %d.", isoRange.getUpper(),
+                isoRange.getLower()));
+
+        // building burst request
+        int maxFramesBurst = exposureMultipliers.length * sensitivityMultipliers.length;
+        Log.i(TAG, String.format("Setting up burst = %d frames.", maxFramesBurst));
+        ArrayList<CaptureRequest> rawRequestList = new ArrayList<CaptureRequest>(maxFramesBurst);
+
+        for (int i = 0; i < exposureMultipliers.length; i++) {
+            for (int j = 0; j < sensitivityMultipliers.length; j++) {
+                long desiredExposure = Math.min(
+                        exposureRangeNs.getLower() * exposureMultipliers[i],
+                        exposureRangeNs.getUpper());
+
+                int desiredSensitivity =
+                        Math.min(isoRange.getLower() * sensitivityMultipliers[j],
+                                isoRange.getUpper());
+
+                rawBurstBuilder.set(CaptureRequest.SENSOR_EXPOSURE_TIME, desiredExposure);
+                rawBurstBuilder.set(CaptureRequest.SENSOR_SENSITIVITY, desiredSensitivity);
+
+                rawRequestList.add(rawBurstBuilder.build());
+            }
+        }
+        return rawRequestList;
+    }
+
+    /**
+     * Construct an array of burst request with 3A
+     * <p>
+     * For each capture request, 3A and post processing (noise reduction, sharpening, etc) will be
+     * turned on.
+     * </p>
+     *
+     * @param rawBurstBuilder The builder needs to have targets setup.
+     * @return An array list capture request for burst.
+     */
+    private ArrayList<CaptureRequest> createBurstRequestWith3A(
+            CaptureRequest.Builder rawBurstBuilder)
+    {
+        // set 3A mode to simulate regular still capture
+        rawBurstBuilder.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
+        rawBurstBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_AUTO);
+        rawBurstBuilder.set(CaptureRequest.NOISE_REDUCTION_MODE,
+                CaptureRequest.NOISE_REDUCTION_MODE_HIGH_QUALITY);
+        rawBurstBuilder.set(CaptureRequest.EDGE_MODE, CaptureRequest.EDGE_MODE_HIGH_QUALITY);
+
+        // building burst request
+        Log.i(TAG, String.format("Setting up burst = %d frames.", MAX_FRAMES_BURST));
+        ArrayList<CaptureRequest> rawRequestList = new ArrayList<CaptureRequest>(MAX_FRAMES_BURST);
+
+        for (int i = 0; i < MAX_FRAMES_BURST; i++) {
+            rawRequestList.add(rawBurstBuilder.build());
+        }
+
+        return rawRequestList;
+    }
+
+    /**
+     * An utility method to copy capture request builders. This is used for recovery purpose to
+     * reverse the changes we made to the builder.
+     *
+     * @param dst the builder to write into.
+     * @param src the builder that needs to be copied.
+     */
+    private void copyBurstRequetBuilder(CaptureRequest.Builder dst, CaptureRequest.Builder src)
+    {
+        dst.set(CaptureRequest.CONTROL_AE_MODE, src.get(CaptureRequest.CONTROL_AE_MODE));
+        dst.set(CaptureRequest.CONTROL_AWB_MODE, src.get(CaptureRequest.CONTROL_AWB_MODE));
+        dst.set(CaptureRequest.NOISE_REDUCTION_MODE, src.get(CaptureRequest.NOISE_REDUCTION_MODE));
+        dst.set(CaptureRequest.EDGE_MODE, src.get(CaptureRequest.EDGE_MODE));
+        dst.set(CaptureRequest.SENSOR_FRAME_DURATION,
+                src.get(CaptureRequest.SENSOR_FRAME_DURATION));
+        dst.set(CaptureRequest.SENSOR_EXPOSURE_TIME, src.get(CaptureRequest.SENSOR_EXPOSURE_TIME));
+        dst.set(CaptureRequest.SENSOR_SENSITIVITY, src.get(CaptureRequest.SENSOR_SENSITIVITY));
+    }
+
+    /**
+     * Draining the image reader and capture callback queue
+     *
+     * @param readerListener Image reader listener needs to be drained.
+     * @param captureCallback Capture callback needs to be drained.
+     * @throws Exception Exception from the queue.
+     */
+    private void drainQueues(SimpleImageReaderListener readerListener,
+            SimpleCaptureCallback captureCallback) throws Exception
+    {
+        for (int i = 0; i < MAX_FRAMES_BURST; i++) {
+            Image image = readerListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS);
+            image.close();
+
+            CaptureResult result = captureCallback.getCaptureResult(
+                    CAPTURE_IMAGE_TIMEOUT_MS);
+            long timestamp = result.get(CaptureResult.SENSOR_TIMESTAMP);
+            Log.d(TAG, String.format("timestamp = %d", timestamp));
+        }
+    }
+
+    /**
+     * Stop preview and remove the target surfaces inside the CaptureRequest.Builder.
+     *
+     * @param previewBuilder Configured builder for preview.
+     * @param rawBurstBuilder Configured builder for RAW.
+     * @throws Exception Exceptions from stopPreview.
+     */
+    private void stopPreviewAndClearSurface(CaptureRequest.Builder previewBuilder,
+            CaptureRequest.Builder rawBurstBuilder) throws Exception
+    {
+        previewBuilder.removeTarget(mPreviewSurface);
+        rawBurstBuilder.removeTarget(mPreviewSurface);
+        rawBurstBuilder.removeTarget(mReaderSurface);
+
+        stopPreview();
+    }
+
+    private void performTestRoutine(TestRoutine routine) throws Exception
+    {
+        for (String id : mCameraIds) {
+            try {
+                openDevice(id);
+
+                ArrayList<Integer> supportedRawList = new ArrayList<Integer>(RAW_FORMATS.length);
+                if (!checkCapability(supportedRawList)) {
+                    Log.i(TAG, "Capability is not supported on camera " + id
+                            + ". Skip the test.");
+                    continue;
+                }
+
+                // test each supported RAW format
+                for (int rawFormat : supportedRawList) {
+                    Log.i(TAG, "Testing format " + imageFormatToString(rawFormat) + ".");
+
+                    // prepare preview and still RAW capture
+                    CaptureSetup captureSetup = initCaptureSetupForPreviewAndRaw();
+
+                    Size previewCaptureSize = captureSetup.getPreviewCaptureSize();
+                    Size rawCaptureSize = captureSetup.getRawCaptureSize();
+
+                    CaptureRequest.Builder previewBuilder = captureSetup.getPreviewRequestBuilder();
+                    CaptureRequest.Builder rawBurstBuilder = captureSetup.getRawRequestBuilder();
+
+                    SimpleCaptureCallback previewCaptureCallback =
+                            captureSetup.getPreviewCaptureCallback();
+                    SimpleCaptureCallback rawCaptureCallback = captureSetup.getRawCaptureCallback();
+                    SimpleImageReaderListener rawReaderListener = captureSetup
+                            .getRawReaderListener();
+
+                    // start preview and prepare RAW capture
+                    prepareCaptureAndStartPreview(previewBuilder, rawBurstBuilder,
+                            previewCaptureSize, rawCaptureSize, rawFormat, previewCaptureCallback,
+                            MAX_FRAMES_BURST, rawReaderListener);
+
+                    // execute test routine
+                    routine.execute(rawBurstBuilder, rawCaptureCallback, rawReaderListener,
+                            rawFormat);
+
+                    // clear out the surface and camera session
+                    stopPreviewAndClearSurface(previewBuilder, rawBurstBuilder);
+                    closeImageReader();
+                }
+            } finally {
+                closeDevice();
+            }
+        }
+    }
+}
diff --git a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
index 67473e1..dbb609d 100644
--- a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
+++ b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
@@ -1310,13 +1310,11 @@
 
             /* test if the explicitly named codec is present on the system */
             if (explicitCodecName != null) {
-                try {
-                    MediaCodec codec = MediaCodec.createByCodecName(explicitCodecName);
-                    if (codec != null) {
-                        codec.release();
-                        add(new Codec(explicitCodecName, null, mediaList));
-                    }
-                } catch (Exception e) {}
+                MediaCodec codec = MediaCodec.createByCodecName(explicitCodecName);
+                if (codec != null) {
+                    codec.release();
+                    add(new Codec(explicitCodecName, null, mediaList));
+                }
             }
         } catch (Throwable t) {
             Log.wtf("Constructor failed", t);
diff --git a/tests/tests/media/src/android/media/cts/AudioTrackTest.java b/tests/tests/media/src/android/media/cts/AudioTrackTest.java
index 4f6d27f..cea6b81 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrackTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrackTest.java
@@ -1396,18 +1396,18 @@
                     final long MILLISECONDS_PER_SECOND = 1000;
                     AudioTrack track = new AudioTrack(TEST_STREAM_TYPE, TEST_SR,
                             TEST_CONF, TEST_FORMAT, bufferSize, TEST_MODE);
-                    assertEquals(TEST_NAME, track.getState(), AudioTrack.STATE_NO_STATIC_DATA);
+                    assertEquals(TEST_NAME, AudioTrack.STATE_NO_STATIC_DATA, track.getState());
 
                     // -------- test --------------
 
                     // test setLoopPoints and setPosition can be called here.
                     assertEquals(TEST_NAME,
-                            track.setPlaybackHeadPosition(bufferFrames/2),
-                            android.media.AudioTrack.SUCCESS);
+                            android.media.AudioTrack.SUCCESS,
+                            track.setPlaybackHeadPosition(bufferFrames/2));
                     assertEquals(TEST_NAME,
+                            android.media.AudioTrack.SUCCESS,
                             track.setLoopPoints(
-                                    0 /*startInFrames*/, bufferFrames, 10 /*loopCount*/),
-                            android.media.AudioTrack.SUCCESS);
+                                    0 /*startInFrames*/, bufferFrames, 10 /*loopCount*/));
                     // only need to write once to the static track
                     switch (TEST_FORMAT) {
                     case AudioFormat.ENCODING_PCM_8BIT: {
@@ -1415,35 +1415,35 @@
                                 bufferSamples, TEST_SR,
                                 testFrequency, TEST_SWEEP);
                         assertEquals(TEST_NAME,
-                                track.write(data, 0 /*offsetInBytes*/, data.length),
-                                bufferSamples);
+                                bufferSamples,
+                                track.write(data, 0 /*offsetInBytes*/, data.length));
                         } break;
                     case AudioFormat.ENCODING_PCM_16BIT: {
                         short data[] = createSoundDataInShortArray(
                                 bufferSamples, TEST_SR,
                                 testFrequency, TEST_SWEEP);
                         assertEquals(TEST_NAME,
-                                track.write(data, 0 /*offsetInBytes*/, data.length),
-                                bufferSamples);
+                                bufferSamples,
+                                track.write(data, 0 /*offsetInBytes*/, data.length));
                         } break;
                     case AudioFormat.ENCODING_PCM_FLOAT: {
                         float data[] = createSoundDataInFloatArray(
                                 bufferSamples, TEST_SR,
                                 testFrequency, TEST_SWEEP);
                         assertEquals(TEST_NAME,
+                                bufferSamples,
                                 track.write(data, 0 /*offsetInBytes*/, data.length,
-                                        AudioTrack.WRITE_BLOCKING),
-                                bufferSamples);
+                                        AudioTrack.WRITE_BLOCKING));
                         } break;
                     }
-                    assertEquals(TEST_NAME, track.getState(), AudioTrack.STATE_INITIALIZED);
+                    assertEquals(TEST_NAME, AudioTrack.STATE_INITIALIZED, track.getState());
                     // test setLoopPoints and setPosition can be called here.
                     assertEquals(TEST_NAME,
-                            track.setPlaybackHeadPosition(0 /*positionInFrames*/),
-                            android.media.AudioTrack.SUCCESS);
+                            android.media.AudioTrack.SUCCESS,
+                            track.setPlaybackHeadPosition(0 /*positionInFrames*/));
                     assertEquals(TEST_NAME,
-                            track.setLoopPoints(0 /*startInFrames*/, bufferFrames, TEST_LOOPS),
-                            android.media.AudioTrack.SUCCESS);
+                            android.media.AudioTrack.SUCCESS,
+                            track.setLoopPoints(0 /*startInFrames*/, bufferFrames, TEST_LOOPS));
 
                     track.play();
                     Thread.sleep(seconds * MILLISECONDS_PER_SECOND * (TEST_LOOPS + 1));
@@ -1452,7 +1452,7 @@
                     // Check position after looping. AudioTrack.getPlaybackHeadPosition() returns
                     // the running count of frames played, not the actual static buffer position.
                     int position = track.getPlaybackHeadPosition();
-                    assertEquals(TEST_NAME, position, bufferFrames * (TEST_LOOPS + 1));
+                    assertEquals(TEST_NAME, bufferFrames * (TEST_LOOPS + 1), position);
 
                     track.stop();
                     Thread.sleep(WAIT_MSEC);
@@ -1802,6 +1802,70 @@
         }
     }
 
+    public void testVariableRatePlayback() throws Exception {
+        final String TEST_NAME = "testVariableRatePlayback";
+        final int TEST_SR = 24000;
+        final int TEST_FINAL_SR = 96000;
+        final int TEST_CONF = AudioFormat.CHANNEL_OUT_MONO;
+        final int TEST_FORMAT = AudioFormat.ENCODING_PCM_8BIT; // required for test
+        final int TEST_MODE = AudioTrack.MODE_STATIC; // required for test
+        final int TEST_STREAM_TYPE = AudioManager.STREAM_MUSIC;
+
+        final int minBuffSize = AudioTrack.getMinBufferSize(TEST_SR, TEST_CONF, TEST_FORMAT);
+        final int bufferSizeInBytes = minBuffSize * 100;
+        final int numChannels =  AudioFormat.channelCountFromOutChannelMask(TEST_CONF);
+        final int bytesPerSample = AudioFormat.getBytesPerSample(TEST_FORMAT);
+        final int bytesPerFrame = numChannels * bytesPerSample;
+        final int frameCount = bufferSizeInBytes / bytesPerFrame;
+
+        AudioTrack track = new AudioTrack(TEST_STREAM_TYPE, TEST_SR, TEST_CONF,
+                TEST_FORMAT, bufferSizeInBytes, TEST_MODE);
+
+        // create byte array and write it
+        byte[] vai = createSoundDataInByteArray(bufferSizeInBytes, TEST_SR, 600);
+        assertEquals(vai.length, track.write(vai, 0 /* offsetInBytes */, vai.length));
+
+        // sweep up test and sweep down test
+        int[] sampleRates = {TEST_SR, TEST_FINAL_SR};
+        int[] deltaMss = {10, 10};
+        int[] deltaFreqs = {200, -200};
+
+        for (int i = 0; i < 2; ++i) {
+            int remainingTime;
+            int sampleRate = sampleRates[i];
+            final int deltaMs = deltaMss[i];
+            final int deltaFreq = deltaFreqs[i];
+            final int lastCheckMs = 500; // check the last 500 ms
+
+            assertEquals(TEST_NAME, AudioTrack.SUCCESS, track.setPlaybackRate(sampleRate));
+            track.play();
+            do {
+                Thread.sleep(deltaMs);
+                final int position = track.getPlaybackHeadPosition();
+                sampleRate += deltaFreq;
+                sampleRate = Math.min(TEST_FINAL_SR, Math.max(TEST_SR, sampleRate));
+                assertEquals(TEST_NAME, AudioTrack.SUCCESS, track.setPlaybackRate(sampleRate));
+                remainingTime = (int)((double)(frameCount - position) * 1000
+                        / sampleRate / bytesPerFrame);
+            } while (remainingTime >= lastCheckMs + deltaMs);
+
+            // ensure the final frequency set is constant and plays frames as expected
+            final int position1 = track.getPlaybackHeadPosition();
+            Thread.sleep(lastCheckMs);
+            final int position2 = track.getPlaybackHeadPosition();
+
+            final int tolerance60MsInFrames = sampleRate * 60 / 1000;
+            final int expected = lastCheckMs * sampleRate / 1000;
+            final int actual = position2 - position1;
+
+            // Log.d(TAG, "Variable Playback: expected(" + expected + ")  actual(" + actual
+            //        + ")  diff(" + (expected - actual) + ")");
+            assertEquals(expected, actual, tolerance60MsInFrames);
+            track.stop();
+        }
+        track.release();
+    }
+
 /* Do not run in JB-MR1. will be re-opened in the next platform release.
     public void testResourceLeakage() throws Exception {
         final int BUFFER_SIZE = 600 * 1024;
diff --git a/tests/tests/media/src/android/media/cts/AudioTrack_ListenerTest.java b/tests/tests/media/src/android/media/cts/AudioTrack_ListenerTest.java
index eb675fc..88ac4b4 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrack_ListenerTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrack_ListenerTest.java
@@ -16,7 +16,9 @@
 
 package android.media.cts;
 
+import java.util.Vector;
 
+import android.cts.util.CtsAndroidTestCase;
 import android.media.AudioFormat;
 import android.media.AudioManager;
 import android.media.AudioTrack;
@@ -24,17 +26,24 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
-import android.test.AndroidTestCase;
+import android.util.Log;
+import com.android.cts.util.ReportLog;
+import com.android.cts.util.ResultType;
+import com.android.cts.util.ResultUnit;
 
-public class AudioTrack_ListenerTest extends AndroidTestCase {
-    private boolean mOnMarkerReachedCalled;
-    private boolean mOnPeriodicNotificationCalled;
+public class AudioTrack_ListenerTest extends CtsAndroidTestCase {
+    private final static String TAG = "AudioTrack_ListenerTest";
+    private final static int TEST_SR = 11025;
+    private final static int TEST_CONF = AudioFormat.CHANNEL_OUT_MONO;
+    private final static int TEST_FORMAT = AudioFormat.ENCODING_PCM_8BIT;
+    private final static int TEST_STREAM_TYPE = AudioManager.STREAM_MUSIC;
+    private final static int TEST_LOOP_FACTOR = 2; // # loops (>= 1) for static tracks
+                                                   // simulated for streaming.
+    private final static int TEST_BUFFER_FACTOR = 25;
     private boolean mIsHandleMessageCalled;
-    private final int TEST_SR = 11025;
-    private final int TEST_CONF = AudioFormat.CHANNEL_CONFIGURATION_MONO;
-    private final int TEST_FORMAT = AudioFormat.ENCODING_PCM_8BIT;
-    private final int TEST_MODE = AudioTrack.MODE_STREAM;
-    private final int TEST_STREAM_TYPE1 = AudioManager.STREAM_MUSIC;
+    private int mMarkerPeriodInFrames;
+    private int mMarkerPosition;
+    private int mFrameCount;
     private Handler mHandler = new Handler(Looper.getMainLooper()) {
         @Override
         public void handleMessage(Message msg) {
@@ -42,73 +51,199 @@
             super.handleMessage(msg);
         }
     };
-    private final int mMinBuffSize = AudioTrack.getMinBufferSize(TEST_SR, TEST_CONF, TEST_FORMAT);
-    private AudioTrack mAudioTrack;
-    private OnPlaybackPositionUpdateListener mListener =
-                                new MockOnPlaybackPositionUpdateListener();
-    private MakeSomethingAsynchronouslyAndLoop<AudioTrack> mMakeSomething;
-
-    @Override
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        if (mAudioTrack == null) {
-            mMakeSomething = new MakeSomethingAsynchronouslyAndLoop<AudioTrack>(
-                new MakesSomething<AudioTrack>() {
-                    @Override
-                    public AudioTrack makeSomething()
-                    {
-                        return new AudioTrack(TEST_STREAM_TYPE1, TEST_SR, TEST_CONF,
-                            TEST_FORMAT, 2 * mMinBuffSize, TEST_MODE);
-                    }
-                }
-            );
-            mAudioTrack = mMakeSomething.make();
-        }
-    }
 
     public void testAudioTrackCallback() throws Exception {
-        mAudioTrack.setPlaybackPositionUpdateListener(mListener);
-        doTest(false /*customHandler*/);
+        doTest("Streaming Local Looper", true /*localTrack*/, false /*customHandler*/,
+                30 /*periodsPerSecond*/, 2 /*markerPeriodsPerSecond*/, AudioTrack.MODE_STREAM);
     }
 
     public void testAudioTrackCallbackWithHandler() throws Exception {
-        mAudioTrack.setPlaybackPositionUpdateListener(mListener, mHandler);
-        doTest(true /*customHandler*/);
-        // ToBeFixed: Handler#handleMessage() is never called
-        // FIXME possibly because the new Handler() is missing the Looper parameter
+        // with 100 periods per second, trigger back-to-back notifications.
+        doTest("Streaming Private Handler", false /*localTrack*/, true /*customHandler*/,
+                100 /*periodsPerSecond*/, 10 /*markerPeriodsPerSecond*/, AudioTrack.MODE_STREAM);
+        // verify mHandler is used only for accessing its associated Looper
         assertFalse(mIsHandleMessageCalled);
     }
 
-    private void doTest(boolean customHandler) throws Exception {
-        mOnMarkerReachedCalled = false;
-        mOnPeriodicNotificationCalled = false;
-        byte[] vai = AudioTrackTest.createSoundDataInByteArray(2 * mMinBuffSize, TEST_SR, 1024);
-        int markerInFrames = vai.length / 4;
-        assertEquals(AudioTrack.SUCCESS, mAudioTrack.setNotificationMarkerPosition(markerInFrames));
-        int periodInFrames = vai.length / 2;
-        assertEquals(AudioTrack.SUCCESS, mAudioTrack.setPositionNotificationPeriod(periodInFrames));
+    public void testStaticAudioTrackCallback() throws Exception {
+        doTest("Static", false /*localTrack*/, false /*customHandler*/,
+                100 /*periodsPerSecond*/, 10 /*markerPeriodsPerSecond*/, AudioTrack.MODE_STATIC);
+    }
 
-        boolean hasPlayed = false;
-        int written = 0;
-        while (written < vai.length) {
-            written += mAudioTrack.write(vai, written, vai.length - written);
-            if (!hasPlayed) {
-                mAudioTrack.play();
-                hasPlayed = true;
+    public void testStaticAudioTrackCallbackWithHandler() throws Exception {
+        doTest("Static Private Handler", false /*localTrack*/, true /*customHandler*/,
+                30 /*periodsPerSecond*/, 2 /*markerPeriodsPerSecond*/, AudioTrack.MODE_STATIC);
+        // verify mHandler is used only for accessing its associated Looper
+        assertFalse(mIsHandleMessageCalled);
+    }
+
+    private class Stat {
+        public void add(double value) {
+            final double absValue = Math.abs(value);
+            mSum += value;
+            mSumAbs += absValue;
+            mMaxAbs = Math.max(mMaxAbs, absValue);
+            ++mCount;
+        }
+
+        public double getAvg() {
+            if (mCount == 0) {
+                return 0;
             }
+            return mSum / mCount;
         }
 
-        final int numChannels = (TEST_CONF == AudioFormat.CHANNEL_CONFIGURATION_STEREO) ? 2 : 1;
-        final int bytesPerSample = (TEST_FORMAT == AudioFormat.ENCODING_PCM_16BIT) ? 2 : 1;
-        final int bytesPerFrame = numChannels * bytesPerSample;
-        final int sampleLengthMs = (int)(1000 * ((float)vai.length / TEST_SR / bytesPerFrame));
-        Thread.sleep(sampleLengthMs + 1000);
-        if (!customHandler) {
-            assertTrue(mOnMarkerReachedCalled);
-            assertTrue(mOnPeriodicNotificationCalled);
+        public double getAvgAbs() {
+            if (mCount == 0) {
+                return 0;
+            }
+            return mSumAbs / mCount;
         }
-        mAudioTrack.stop();
+
+        public double getMaxAbs() {
+            return mMaxAbs;
+        }
+
+        private int mCount = 0;
+        private double mSum = 0;
+        private double mSumAbs = 0;
+        private double mMaxAbs = 0;
+    }
+
+    private void doTest(String reportName, boolean localTrack, boolean customHandler,
+            int periodsPerSecond, int markerPeriodsPerSecond, final int mode) throws Exception {
+        mIsHandleMessageCalled = false;
+        final int minBuffSize = AudioTrack.getMinBufferSize(TEST_SR, TEST_CONF, TEST_FORMAT);
+        final int bufferSizeInBytes;
+        if (mode == AudioTrack.MODE_STATIC && TEST_LOOP_FACTOR > 1) {
+            // use setLoopPoints for static mode
+            bufferSizeInBytes = minBuffSize * TEST_BUFFER_FACTOR;
+            mFrameCount = bufferSizeInBytes * TEST_LOOP_FACTOR;
+        } else {
+            bufferSizeInBytes = minBuffSize * TEST_BUFFER_FACTOR * TEST_LOOP_FACTOR;
+            mFrameCount = bufferSizeInBytes;
+        }
+
+        final AudioTrack track;
+        final MakeSomethingAsynchronouslyAndLoop<AudioTrack> makeSomething;
+        if (localTrack) {
+            makeSomething = null;
+            track = new AudioTrack(TEST_STREAM_TYPE, TEST_SR, TEST_CONF,
+                    TEST_FORMAT, bufferSizeInBytes, mode);
+        } else {
+            makeSomething =
+                    new MakeSomethingAsynchronouslyAndLoop<AudioTrack>(
+                    new MakesSomething<AudioTrack>() {
+                        @Override
+                        public AudioTrack makeSomething() {
+                            return new AudioTrack(TEST_STREAM_TYPE, TEST_SR, TEST_CONF,
+                                TEST_FORMAT, bufferSizeInBytes, mode);
+                        }
+                    }
+                );
+           // create audiotrack on different thread's looper.
+           track = makeSomething.make();
+        }
+        final MockOnPlaybackPositionUpdateListener listener;
+        if (customHandler) {
+            listener = new MockOnPlaybackPositionUpdateListener(track, mHandler);
+        } else {
+            listener = new MockOnPlaybackPositionUpdateListener(track);
+        }
+
+        byte[] vai = AudioTrackTest.createSoundDataInByteArray(bufferSizeInBytes, TEST_SR, 1024);
+        int markerPeriods = Math.max(3, mFrameCount * markerPeriodsPerSecond / TEST_SR);
+        mMarkerPeriodInFrames = mFrameCount / markerPeriods;
+        markerPeriods = mFrameCount / mMarkerPeriodInFrames; // recalculate due to round-down
+        mMarkerPosition = mMarkerPeriodInFrames;
+        assertEquals(AudioTrack.SUCCESS,
+                track.setNotificationMarkerPosition(mMarkerPosition));
+        int updatePeriods = Math.max(3, mFrameCount * periodsPerSecond / TEST_SR);
+        final int updatePeriodInFrames = mFrameCount / updatePeriods;
+        updatePeriods = mFrameCount / updatePeriodInFrames; // recalculate due to round-down
+        assertEquals(AudioTrack.SUCCESS,
+                track.setPositionNotificationPeriod(updatePeriodInFrames));
+        // set NotificationPeriod before running to ensure better period positional accuracy.
+
+        if (mode == AudioTrack.MODE_STATIC && TEST_LOOP_FACTOR > 1) {
+            track.setLoopPoints(0, vai.length, TEST_LOOP_FACTOR - 1);
+        }
+        // write data with single blocking write, then play.
+        assertEquals(vai.length, track.write(vai, 0 /* offsetInBytes */, vai.length));
+        track.play();
+
+        // sleep until track completes playback - it must complete within 1 second
+        // of the expected length otherwise the periodic test should fail.
+        final int numChannels =  AudioFormat.channelCountFromOutChannelMask(TEST_CONF);
+        final int bytesPerSample = AudioFormat.getBytesPerSample(TEST_FORMAT);
+        final int bytesPerFrame = numChannels * bytesPerSample;
+        final int trackLengthMs = (int)((double)mFrameCount * 1000 / TEST_SR / bytesPerFrame);
+        Thread.sleep(trackLengthMs + 1000);
+
+        // stop listening - we should be done.
+        listener.stop();
+
+        // Beware: stop() resets the playback head position for both static and streaming
+        // audio tracks, so stop() cannot be called while we're still logging playback
+        // head positions. We could recycle the track after stop(), which isn't done here.
+        track.stop();
+
+        // clean up
+        if (makeSomething != null) {
+            makeSomething.join();
+        }
+        listener.release();
+        track.release();
+
+        // collect statistics
+        final Vector<Integer> markerList = listener.getMarkerList();
+        final Vector<Integer> periodicList = listener.getPeriodicList();
+        // verify count of markers and periodic notifications.
+        assertEquals(markerPeriods, markerList.size());
+        assertEquals(updatePeriods, periodicList.size());
+        // verify actual playback head positions returned.
+        // the max diff should really be around 24 ms,
+        // but system load and stability will affect this test;
+        // we use 80ms limit here for failure.
+        final int tolerance80MsInFrames = TEST_SR * 80 / 1000;
+
+        Stat markerStat = new Stat();
+        for (int i = 0; i < markerPeriods; ++i) {
+            final int expected = mMarkerPeriodInFrames * (i + 1) * 1;
+            final int actual = markerList.get(i);
+            // Log.d(TAG, "Marker: expected(" + expected + ")  actual(" + actual
+            //        + ")  diff(" + (actual - expected) + ")");
+            assertEquals(expected, actual, tolerance80MsInFrames);
+            markerStat.add((double)(actual - expected) * 1000 / TEST_SR);
+        }
+
+        Stat periodicStat = new Stat();
+        for (int i = 0; i < updatePeriods; ++i) {
+            final int expected = updatePeriodInFrames * (i + 1);
+            final int actual = periodicList.get(i);
+            // Log.d(TAG, "Update: expected(" + expected + ")  actual(" + actual
+            //        + ")  diff(" + (actual - expected) + ")");
+            assertEquals(expected, actual, tolerance80MsInFrames);
+            periodicStat.add((double)(actual - expected) * 1000 / TEST_SR);
+        }
+
+        // report this
+        ReportLog log = getReportLog();
+        log.printValue(reportName + ": Average Marker diff", markerStat.getAvg(),
+                ResultType.LOWER_BETTER, ResultUnit.MS);
+        log.printValue(reportName + ": Maximum Marker abs diff", markerStat.getMaxAbs(),
+                ResultType.LOWER_BETTER, ResultUnit.MS);
+        log.printValue(reportName + ": Average Marker abs diff", markerStat.getAvgAbs(),
+                ResultType.LOWER_BETTER, ResultUnit.MS);
+        log.printValue(reportName + ": Average Periodic diff", periodicStat.getAvg(),
+                ResultType.LOWER_BETTER, ResultUnit.MS);
+        log.printValue(reportName + ": Maximum Periodic abs diff", periodicStat.getMaxAbs(),
+                ResultType.LOWER_BETTER, ResultUnit.MS);
+        log.printValue(reportName + ": Average Periodic abs diff", periodicStat.getAvgAbs(),
+                ResultType.LOWER_BETTER, ResultUnit.MS);
+        log.printSummary(reportName + ": Unified abs diff",
+                (periodicStat.getAvgAbs() + markerStat.getAvgAbs()) / 2,
+                ResultType.LOWER_BETTER, ResultUnit.MS);
     }
 
     // lightweight java.util.concurrent.Future*
@@ -195,27 +330,58 @@
 
     private class MockOnPlaybackPositionUpdateListener
                                         implements OnPlaybackPositionUpdateListener {
-
-        public void onMarkerReached(AudioTrack track) {
-            mOnMarkerReachedCalled = true;
+        public MockOnPlaybackPositionUpdateListener(AudioTrack track) {
+            mAudioTrack = track;
+            track.setPlaybackPositionUpdateListener(this);
         }
 
-        public void onPeriodicNotification(AudioTrack track) {
-            mOnPeriodicNotificationCalled = true;
+        public MockOnPlaybackPositionUpdateListener(AudioTrack track, Handler handler) {
+            mAudioTrack = track;
+            track.setPlaybackPositionUpdateListener(this, handler);
         }
 
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        if (mMakeSomething != null) {
-            mMakeSomething.join();
+        public synchronized void onMarkerReached(AudioTrack track) {
+            if (mIsTestActive) {
+                int position = mAudioTrack.getPlaybackHeadPosition();
+                mOnMarkerReachedCalled.add(position);
+                mMarkerPosition += mMarkerPeriodInFrames;
+                if (mMarkerPosition <= mFrameCount) {
+                    assertEquals(AudioTrack.SUCCESS,
+                            mAudioTrack.setNotificationMarkerPosition(mMarkerPosition));
+                }
+            } else {
+                fail("onMarkerReached called when not active");
+            }
         }
-        if (mAudioTrack != null) {
-            mAudioTrack.release();
+
+        public synchronized void onPeriodicNotification(AudioTrack track) {
+            if (mIsTestActive) {
+                mOnPeriodicNotificationCalled.add(mAudioTrack.getPlaybackHeadPosition());
+            } else {
+                fail("onPeriodicNotification called when not active");
+            }
+        }
+
+        public synchronized void stop() {
+            mIsTestActive = false;
+        }
+
+        public Vector<Integer> getMarkerList() {
+            return mOnMarkerReachedCalled;
+        }
+
+        public Vector<Integer> getPeriodicList() {
+            return mOnPeriodicNotificationCalled;
+        }
+
+        public synchronized void release() {
+            mAudioTrack.setPlaybackPositionUpdateListener(null);
             mAudioTrack = null;
         }
-        super.tearDown();
-    }
 
+        private boolean mIsTestActive = true;
+        private AudioTrack mAudioTrack;
+        private Vector<Integer> mOnMarkerReachedCalled = new Vector<Integer>();
+        private Vector<Integer> mOnPeriodicNotificationCalled = new Vector<Integer>();
+    }
 }
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index 3002ca3..6069ee6 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -28,8 +28,7 @@
 public class BuildVersionTest extends TestCase {
 
     private static final String LOG_TAG = "BuildVersionTest";
-    private static final Set<String> EXPECTED_RELEASES =
-            new HashSet<String>(Arrays.asList("5.0.1", "5.0.2"));
+    private static final Set<String> EXPECTED_RELEASES = new HashSet<String>(Arrays.asList("5.0"));
     private static final int EXPECTED_SDK = 21;
     private static final String EXPECTED_BUILD_VARIANT = "user";
     private static final String EXPECTED_TAG = "release-keys";
diff --git a/tests/tests/os/src/android/os/cts/StrictModeTest.java b/tests/tests/os/src/android/os/cts/StrictModeTest.java
new file mode 100644
index 0000000..797f91f
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/StrictModeTest.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+package android.os.cts;
+
+import android.os.StrictMode;
+import android.os.SystemClock;
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+import libcore.io.Streams;
+
+import java.io.ByteArrayOutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Tests for {@link StrictMode}
+ */
+public class StrictModeTest extends AndroidTestCase {
+    private static final String TAG = "StrictModeTest";
+
+    private StrictMode.VmPolicy mPolicy;
+
+    @Override
+    protected void setUp() {
+        mPolicy = StrictMode.getVmPolicy();
+    }
+
+    @Override
+    protected void tearDown() {
+        StrictMode.setVmPolicy(mPolicy);
+    }
+
+    public void testCleartextNetwork() throws Exception {
+        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
+                .detectCleartextNetwork()
+                .penaltyLog()
+                .build());
+
+        final long millis = System.currentTimeMillis();
+        final String msg = "Detected cleartext network traffic from UID "
+                + android.os.Process.myUid();
+
+        // Insecure connection should be detected
+        ((HttpURLConnection) new URL("http://android.com/").openConnection()).getResponseCode();
+
+        // Give system enough time to finish logging
+        SystemClock.sleep(5000);
+        assertTrue("Expected cleartext to be caught", readLogSince(millis).contains(msg));
+    }
+
+    public void testEncryptedNetwork() throws Exception {
+        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
+                .detectCleartextNetwork()
+                .penaltyLog()
+                .build());
+
+        final long millis = System.currentTimeMillis();
+        final String msg = "Detected cleartext network traffic from UID "
+                + android.os.Process.myUid();
+
+        // Secure connection should be ignored
+        ((HttpURLConnection) new URL("https://android.com/").openConnection()).getResponseCode();
+
+        // Give system enough time to finish logging
+        SystemClock.sleep(5000);
+        assertFalse("Expected encrypted to be ignored", readLogSince(millis).contains(msg));
+    }
+
+    private String readLogSince(long millis) throws Exception {
+        final SimpleDateFormat format = new SimpleDateFormat("MM-DD HH:mm:ss.SSS");
+        final Process proc = new ProcessBuilder("logcat", "-t", format.format(new Date(millis)))
+                .redirectErrorStream(true).start();
+
+        final ByteArrayOutputStream buf = new ByteArrayOutputStream();
+        Streams.copy(proc.getInputStream(), buf);
+        final int res = proc.waitFor();
+
+        Log.d(TAG, "Log output was " + buf.size() + " bytes, exit code " + res);
+        return new String(buf.toByteArray());
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
index f3163be..7edd659 100644
--- a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
+++ b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
@@ -115,6 +115,25 @@
 
     private static native boolean supportsXattr();
 
+    /**
+     * ICMP redirects should be disabled.
+     */
+    public void testNoIcmpRedirects() throws IOException {
+        try {
+            assertEquals("ICMP redirects are enabled for IPv4.",
+                    "0", getFile("/proc/sys/net/ipv4/conf/all/accept_redirects"));
+        } catch (FileNotFoundException e) {
+            // Odd. The file doesn't exist... Assume we're ok.
+        }
+
+        try {
+            assertEquals("ICMP redirects are enabled for IPv6.",
+                    "0", getFile("/proc/sys/net/ipv6/conf/all/accept_redirects"));
+        } catch (FileNotFoundException e) {
+            // Odd. The file doesn't exist... Assume we're ok.
+        }
+    }
+
     private String getFile(String filename) throws IOException {
         BufferedReader in = null;
         try {
diff --git a/tests/tests/speech/Android.mk b/tests/tests/speech/Android.mk
index 6bec012..3ab78b8 100755
--- a/tests/tests/speech/Android.mk
+++ b/tests/tests/speech/Android.mk
@@ -27,6 +27,7 @@
 
 LOCAL_PACKAGE_NAME := CtsSpeechTestCases
 
-LOCAL_SDK_VERSION := current
+# Needed for testing M API
+#LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/speech/src/android/speech/tts/cts/StubTextToSpeechService.java b/tests/tests/speech/src/android/speech/tts/cts/StubTextToSpeechService.java
index 5e6bb41..7b5baca 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/StubTextToSpeechService.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/StubTextToSpeechService.java
@@ -20,12 +20,17 @@
 import android.speech.tts.SynthesisRequest;
 import android.speech.tts.TextToSpeech;
 import android.speech.tts.TextToSpeechService;
+import android.util.Log;
 
 /**
  * Stub implementation of {@link TextToSpeechService}. Used for testing the
  * TTS engine API.
  */
 public class StubTextToSpeechService extends TextToSpeechService {
+    private static final String LOG_TAG = "StubTextToSpeechService";
+
+    // Object that onSynthesizeText will #wait on, if set to non-null
+    public static volatile Object sSynthesizeTextWait;
 
     @Override
     protected String[] onGetLanguage() {
@@ -51,6 +56,18 @@
         if (callback.start(16000, AudioFormat.ENCODING_PCM_16BIT, 1) != TextToSpeech.SUCCESS) {
             return;
         }
+
+        final Object synthesizeTextWait = sSynthesizeTextWait;
+        if (synthesizeTextWait != null) {
+            synchronized (synthesizeTextWait) {
+                try {
+                    synthesizeTextWait.wait(10000);  // 10s timeout
+                } catch (InterruptedException e) {
+                    Log.e(LOG_TAG, "onSynthesizeText wait interrupted", e);
+                }
+            }
+        }
+
         byte[] data = { 0x01, 0x2 };
         if (callback.audioAvailable(data, 0, data.length) != TextToSpeech.SUCCESS) {
             return;
diff --git a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechServiceTest.java b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechServiceTest.java
index c19f6c0..7425ecf 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechServiceTest.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechServiceTest.java
@@ -37,6 +37,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+        StubTextToSpeechService.sSynthesizeTextWait = null;
         mTts = TextToSpeechWrapper.createTextToSpeechMockWrapper(getContext());
         assertNotNull(mTts);
     }
@@ -74,6 +75,31 @@
         assertTrue("speak() completion timeout", waitForUtterance());
     }
 
+    public void testSpeakStop() throws Exception {
+        final Object synthesizeTextWait = new Object();
+        StubTextToSpeechService.sSynthesizeTextWait = synthesizeTextWait;
+
+        getTts().stop();
+        final int iterations = 20;
+        for (int i = 0; i < iterations; i++) {
+            int result = getTts().speak(UTTERANCE, TextToSpeech.QUEUE_ADD, null,
+                    UTTERANCE_ID + Integer.toString(i));
+            assertEquals("speak() failed", TextToSpeech.SUCCESS, result);
+        }
+        getTts().stop();
+
+        // Wake up the Stubs #onSynthesizeSpeech (one that will be stopped in-progress)
+        synchronized (synthesizeTextWait) {
+          synthesizeTextWait.notify();
+        }
+
+        for (int i = 0; i < iterations; i++) {
+            assertTrue("speak() stop callback timeout", mTts.waitForStop(
+                    UTTERANCE_ID + Integer.toString(i)));
+        }
+    }
+
+
     public void testMediaPlayerFails() throws Exception {
         File sampleFile = new File(Environment.getExternalStorageDirectory(), "notsound.wav");
         try {
diff --git a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
index 69acdd0..c83304c 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechTest.java
@@ -124,6 +124,22 @@
         assertTrue("speak() completion timeout", waitForUtterance());
     }
 
+
+    public void testSpeakStop() throws Exception {
+        getTts().stop();
+        final int iterations = 20;
+        for (int i = 0; i < iterations; i++) {
+            int result = getTts().speak(SAMPLE_TEXT, TextToSpeech.QUEUE_ADD, null,
+                    UTTERANCE_ID + Integer.toString(i));
+            assertEquals("speak() failed", TextToSpeech.SUCCESS, result);
+        }
+        getTts().stop();
+        for (int i = 0; i < iterations; i++) {
+            assertTrue("speak() stop callback timeout", mTts.waitForStop(
+                    UTTERANCE_ID + Integer.toString(i)));
+        }
+    }
+
     public void testGetEnginesIncludesDefault() throws Exception {
         if (mTts == null) {
             return;
diff --git a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechWrapper.java b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechWrapper.java
index f0d55bf..9d460e2 100644
--- a/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechWrapper.java
+++ b/tests/tests/speech/src/android/speech/tts/cts/TextToSpeechWrapper.java
@@ -19,9 +19,10 @@
 import android.media.MediaPlayer;
 import android.speech.tts.TextToSpeech;
 import android.speech.tts.TextToSpeech.OnInitListener;
-import android.speech.tts.TextToSpeech.OnUtteranceCompletedListener;
+import android.speech.tts.UtteranceProgressListener;
 import android.util.Log;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;
@@ -65,7 +66,7 @@
         if (!mInitListener.waitForInit()) {
             return false;
         }
-        mTts.setOnUtteranceCompletedListener(mUtteranceListener);
+        mTts.setOnUtteranceProgressListener(mUtteranceListener);
         return true;
     }
 
@@ -73,6 +74,10 @@
         return mUtteranceListener.waitForComplete(utteranceId);
     }
 
+    public boolean waitForStop(String utteranceId) throws InterruptedException {
+        return mUtteranceListener.waitForStop(utteranceId);
+    }
+
     public TextToSpeech getTts() {
         return mTts;
     }
@@ -139,12 +144,16 @@
     /**
      * Listener for waiting for utterance completion.
      */
-    private static class UtteranceWaitListener implements OnUtteranceCompletedListener {
+    private static class UtteranceWaitListener extends UtteranceProgressListener {
         private final Lock mLock = new ReentrantLock();
         private final Condition mDone  = mLock.newCondition();
+        private final HashSet<String> mStartedUtterances = new HashSet<String>();
+        private final HashSet<String> mStoppedUtterances = new HashSet<String>();
+        private final HashMap<String, Integer> mErredUtterances = new HashMap<String, Integer>();
         private final HashSet<String> mCompletedUtterances = new HashSet<String>();
 
-        public void onUtteranceCompleted(String utteranceId) {
+        @Override
+        public void onDone(String utteranceId) {
             mLock.lock();
             try {
                 mCompletedUtterances.add(utteranceId);
@@ -154,6 +163,49 @@
             }
         }
 
+        @Override
+        public void onError(String utteranceId) {
+            mLock.lock();
+            try {
+                mErredUtterances.put(utteranceId, -1);
+                mDone.signal();
+            } finally {
+                mLock.unlock();
+            }
+        }
+
+        @Override
+        public void onError(String utteranceId, int errorCode) {
+            mLock.lock();
+            try {
+                mErredUtterances.put(utteranceId, errorCode);
+                mDone.signal();
+            } finally {
+                mLock.unlock();
+            }
+        }
+
+        @Override
+        public void onStart(String utteranceId) {
+            mLock.lock();
+            try {
+                mStartedUtterances.add(utteranceId);
+            } finally {
+                mLock.unlock();
+            }
+        }
+
+        @Override
+        public void onStop(String utteranceId, boolean isStarted) {
+            mLock.lock();
+            try {
+                mStoppedUtterances.add(utteranceId);
+                mDone.signal();
+            } finally {
+                mLock.unlock();
+            }
+        }
+
         public boolean waitForComplete(String utteranceId)
                 throws InterruptedException {
             long timeOutNanos = TimeUnit.MILLISECONDS.toNanos(TTS_INIT_MAX_WAIT_TIME);
@@ -170,6 +222,23 @@
                 mLock.unlock();
             }
         }
+
+        public boolean waitForStop(String utteranceId)
+                throws InterruptedException {
+            long timeOutNanos = TimeUnit.MILLISECONDS.toNanos(TTS_INIT_MAX_WAIT_TIME);
+            mLock.lock();
+            try {
+                while (!mStoppedUtterances.remove(utteranceId)) {
+                    if (timeOutNanos <= 0) {
+                        return false;
+                    }
+                    timeOutNanos = mDone.awaitNanos(timeOutNanos);
+                }
+                return true;
+            } finally {
+                mLock.unlock();
+            }
+        }
     }
 
     /**
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
new file mode 100644
index 0000000..5b88525
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/CellInfoTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+package android.telephony.cts;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.telephony.CellInfo;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
+import android.test.AndroidTestCase;
+import android.util.Log;
+
+import java.util.List;
+
+/**
+ * Test TelephonyManager.getAllCellInfo()
+ * <p>
+ * TODO(chesnutt): test onCellInfoChanged() once the implementation
+ * of async callbacks is complete (see http://b/13788638)
+ */
+public class CellInfoTest extends AndroidTestCase{
+    private final Object mLock = new Object();
+    private TelephonyManager mTelephonyManager;
+    private static ConnectivityManager mCm;
+    private static final String TAG = "android.telephony.cts.CellInfoTest";
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mTelephonyManager =
+                (TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE);
+        mCm = (ConnectivityManager)getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+    }
+
+    public void testCellInfo() throws Throwable {
+        if (mCm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) == null) {
+            Log.d(TAG, "Skipping test that requires ConnectivityManager.TYPE_MOBILE");
+            return;
+        }
+
+        // getAllCellInfo should never return null, and there should
+        // be at least one entry.
+        List<CellInfo> allCellInfo = mTelephonyManager.getAllCellInfo();
+        assertNotNull("TelephonyManager.getAllCellInfo() returned NULL!", allCellInfo);
+        assertTrue("TelephonyManager.getAllCellInfo() returned zero-length list!",
+            allCellInfo.size() > 0);
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java b/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
index c1f5757..9205f0e 100644
--- a/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
@@ -60,6 +60,14 @@
             return;
         }
 
+        // getCellLocation should never return null,
+        // but that is allowed if the cell network type
+        // is LTE (since there is no LteCellLocation class)
+        if (mTelephonyManager.getNetworkType() != TelephonyManager.NETWORK_TYPE_LTE) {
+            assertNotNull("TelephonyManager.getCellLocation() returned null!",
+                mTelephonyManager.getCellLocation());
+        }
+
         CellLocation cl = CellLocation.getEmpty();
         if (cl instanceof GsmCellLocation) {
             GsmCellLocation gcl = (GsmCellLocation) cl;
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
index c612886..856b4aa 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
@@ -319,8 +319,6 @@
         assertFalse(anyDeleted.get());
     }
 
-    /*
-    TODO: uncomment when acceptThirdPartyCookies implementation lands
     public void testThirdPartyCookie() throws Throwable {
         if (!NullWebViewUtils.isWebViewAvailable()) {
             return;
@@ -377,7 +375,6 @@
             mOnUiThread.getSettings().setJavaScriptEnabled(false);
         }
     }
-    */
 
     public void testb3167208() throws Exception {
         if (!NullWebViewUtils.isWebViewAvailable()) {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 1e22acc..f72a70d 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -122,6 +122,11 @@
      */
     private static final long SCROLL_WAIT_INTERVAL_MS = 200;
 
+    /**
+     * Epsilon used in page scale value comparisons.
+     */
+    private static final float PAGE_SCALE_EPSILON = 0.0001f;
+
     private WebView mWebView;
     private CtsTestServer mWebServer;
     private WebViewOnUiThread mOnUiThread;
@@ -330,7 +335,7 @@
         // that a scale change does *not* happen.
         Thread.sleep(500);
         currScale = mOnUiThread.getScale();
-        assertEquals(currScale, previousScale);
+        assertEquals(currScale, previousScale, PAGE_SCALE_EPSILON);
 
         assertTrue(mOnUiThread.zoomOut());
         previousScale = currScale;
@@ -354,7 +359,7 @@
         // that a scale change does *not* happen.
         Thread.sleep(500);
         currScale = mOnUiThread.getScale();
-        assertEquals(currScale, previousScale);
+        assertEquals(currScale, previousScale, PAGE_SCALE_EPSILON);
 
         mOnUiThread.zoomBy(1.25f);
         previousScale = currScale;
@@ -378,7 +383,7 @@
         // that a scale change does *not* happen.
         Thread.sleep(500);
         currScale = mOnUiThread.getScale();
-        assertEquals(currScale, previousScale);
+        assertEquals(currScale, previousScale, PAGE_SCALE_EPSILON);
 
         mOnUiThread.zoomBy(0.8f);
         previousScale = currScale;
@@ -402,7 +407,7 @@
         // that a scale change does *not* happen.
         Thread.sleep(500);
         currScale = mOnUiThread.getScale();
-        assertEquals(currScale, previousScale);
+        assertEquals(currScale, previousScale, PAGE_SCALE_EPSILON);
     }
 
     @UiThreadTest
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index 8544a93..2ee649d 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
     @Option(name="cts-install-path", description="the path to the cts installation to use")
     private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
 
-    public static final String CTS_BUILD_VERSION = "5.1_r0.5";
+    public static final String CTS_BUILD_VERSION = "5.0_r1.91";
 
     /**
      * {@inheritDoc}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/PrintTestRemoteTestRunner.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/PrintTestRemoteTestRunner.java
index 72dccd4..8c43031 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/PrintTestRemoteTestRunner.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/PrintTestRemoteTestRunner.java
@@ -184,7 +184,6 @@
         addBooleanArg(COVERAGE_ARG_NAME, coverage);
     }
 
-    @Override
     public void setTestCollection(boolean b) {
         throw new UnsupportedOperationException("Test Collection mode is not supported");
     }
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index 88f2a53..059ac75 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -14,6 +14,29 @@
 
 LOCAL_PATH := $(call my-dir)
 
+# test dex library
+# ============================================================
+include $(CLEAR_VARS)
+
+# custom variables used to generate test description. do not touch!
+LOCAL_SRC_FILES := $(call all-java-files-under, src/dot)
+
+LOCAL_MODULE := cts-tf-dalvik-lib
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_MODULE_TAGS := optional
+LOCAL_JAVA_LIBRARIES := junit-hostdex
+LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
+
+include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
+
+cts-tf-dalvik-lib.jack := $(full_classes_jack)
+
+private_jill_jarjar_asm := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,jill-jarjar-asm.jar)
+$(private_jill_jarjar_asm) : PRIVATE_JARJAR_RULES := $(LOCAL_PATH)/jill-jarjar-rules.txt
+$(private_jill_jarjar_asm) : $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,jill.jar) | $(JARJAR)
+	@echo JarJar: $@
+	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
+
 # buildutil java library
 # ============================================================
 include $(CLEAR_VARS)
@@ -29,16 +52,53 @@
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_JAVA_LIBRARIES := dx dasm cfassembler junit
-LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
+LOCAL_JAVA_LIBRARIES += jack
+
+LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR) $(private_jill_jarjar_asm)
 
 include $(BUILD_HOST_JAVA_LIBRARY)
 
 # Buid android.core.vm-tests-tf.jar
 # ============================================================
 #
+
 intermediates := $(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
 vmteststf_jar := $(intermediates)/android.core.vm-tests-tf.jar
 vmteststf_dep_jars := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, cts-tf-dalvik-buildutil.jar dasm.jar dx.jar cfassembler.jar junit.jar)
+vmteststf_dep_jars += $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, jack.jar)
+vmteststf_dep_jars += $(private_jill_jarjar_asm)
+
+$(vmteststf_jar): PRIVATE_JACK_VM_ARGS := $(DEFAULT_JACK_VM_ARGS)
+ifneq ($(ANDROID_JACK_VM_ARGS),)
+$(vmteststf_jar): PRIVATE_JACK_VM_ARGS := $(ANDROID_JACK_VM_ARGS)
+endif
+ifneq ($(LOCAL_JACK_VM_ARGS),)
+$(vmteststf_jar): PRIVATE_JACK_VM_ARGS := $(LOCAL_JACK_VM_ARGS)
+endif
+
+$(vmteststf_jar): PRIVATE_JACK_EXTRA_ARGS := $(DEFAULT_JACK_EXTRA_ARGS)
+ifneq ($(ANDROID_JACK_EXTRA_ARGS),)
+$(vmteststf_jar): PRIVATE_JACK_EXTRA_ARGS := $(ANDROID_JACK_EXTRA_ARGS)
+endif
+ifneq ($(LOCAL_JACK_EXTRA_ARGS),)
+$(vmteststf_jar): PRIVATE_JACK_EXTRA_ARGS := $(LOCAL_JACK_EXTRA_ARGS)
+endif
+
+$(vmteststf_jar): PRIVATE_JACK_VM := $(DEFAULT_JACK_VM)
+ifneq ($(strip $(ANDROID_JACK_VM)),)
+$(vmteststf_jar): PRIVATE_JACK_VM := $(ANDROID_JACK_VM)
+endif
+
+ifeq ($(strip $(LOCAL_USE_JACK)),true)
+    vmteststf_dep_jars += $(cts-tf-dalvik-lib.jack)
+endif
+
+$(intermediates)/junit.jack:$(LOCAL_PATH)/lib/junit.jar | $(JILL_JAR) $(JACK_JAR)
+	$(transform-jar-to-jack)
+
+$(intermediates)/tradefed-prebuilt.jack:$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar | $(JILL_JAR) $(JACK_JAR)
+	$(transform-jar-to-jack)
+
 $(vmteststf_jar): PRIVATE_SRC_FOLDER := $(LOCAL_PATH)/src
 $(vmteststf_jar): PRIVATE_LIB_FOLDER := $(LOCAL_PATH)/lib
 $(vmteststf_jar): PRIVATE_INTERMEDIATES_CLASSES := $(call intermediates-dir-for,JAVA_LIBRARIES,cts-tf-dalvik-buildutil,HOST)/classes
@@ -47,7 +107,8 @@
 $(vmteststf_jar): PRIVATE_INTERMEDIATES_MAIN_FILES := $(intermediates)/main_files
 $(vmteststf_jar): PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES := $(intermediates)/hostjunit_files
 $(vmteststf_jar): PRIVATE_CLASS_PATH := $(subst $(space),:,$(vmteststf_dep_jars)):$(HOST_JDK_TOOLS_JAR)
-$(vmteststf_jar) : $(vmteststf_dep_jars) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
+ifneq ($(strip $(LOCAL_USE_JACK)),true)
+$(vmteststf_jar) : $(vmteststf_dep_jars) $(JACK_JAR) $(JILL_JAR) $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
 	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
 	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
 	# generated and compile the host side junit tests
@@ -62,6 +123,26 @@
 		$(if $(NO_OPTIMIZE_DX), --no-optimize) $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jar
 	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../android.core.vm-tests-tf.jar .
 	$(hide) cd $(dir $@) && zip -q -r android.core.vm-tests-tf.jar tests
+else # LOCAL_USE_JACK
+$(vmteststf_jar) : $(vmteststf_dep_jars) $(JACK_JAR) $(JILL_JAR) out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jack $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar $(LOCAL_PATH)/lib/junit.jar $(intermediates)/tradefed-prebuilt.jack $(intermediates)/junit.jack
+	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
+	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/dot/junit $(dir $(PRIVATE_INTERMEDIATES_DEXCORE_JAR))
+	# generated and compile the host side junit tests
+	@echo "Write generated Main_*.java files to $(PRIVATE_INTERMEDIATES_MAIN_FILES)"
+	$(hide) java -cp $(PRIVATE_CLASS_PATH) util.build.JackBuildDalvikSuite $(PRIVATE_SRC_FOLDER) $(PRIVATE_INTERMEDIATES) \
+		out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.jack:$(cts-tf-dalvik-lib.jack):$(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar:$(LOCAL_PATH)/lib/junit.jar:$(PRIVATE_INTERMEDIATES)/junit.jack:$(PRIVATE_INTERMEDIATES)/tradefed-prebuilt.jack \
+		$(PRIVATE_INTERMEDIATES_MAIN_FILES) $(PRIVATE_INTERMEDIATES_CLASSES) $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES) $$RUN_VM_TESTS_RTO
+	@echo "Generate $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)"
+	$(hide) jar -cf $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar \
+		$(addprefix -C $(PRIVATE_INTERMEDIATES_CLASSES) , dot/junit/DxUtil.class dot/junit/DxAbstractMain.class)
+	$(hide) $(JILL) --output $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)-class.jar
+	$(hide) mkdir -p $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp
+	$(hide) $(call call-jack,$(PRIVATE_JACK_VM),$(PRIVATE_JACK_VM_ARGS),$(PRIVATE_JACK_EXTRA_ARGS)) --output-dex $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
+		$(if $(NO_OPTIMIZE_DX), -D jack.dex.optimize "false") --import $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack && rm -f $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).jack
+	$(hide) cd $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp && zip -q -r $(abspath $(PRIVATE_INTERMEDIATES_DEXCORE_JAR)) .
+	$(hide) cd $(PRIVATE_INTERMEDIATES_HOSTJUNIT_FILES)/classes && zip -q -r ../../android.core.vm-tests-tf.jar .
+	$(hide) cd $(dir $@) && zip -q -r android.core.vm-tests-tf.jar tests
+endif # LOCAL_USE_JACK
 
 # Clean up temp vars
 intermediates :=
diff --git a/tools/vm-tests-tf/jill-jarjar-rules.txt b/tools/vm-tests-tf/jill-jarjar-rules.txt
new file mode 100644
index 0000000..ee6f403
--- /dev/null
+++ b/tools/vm-tests-tf/jill-jarjar-rules.txt
@@ -0,0 +1 @@
+rule org.objectweb.** com.android.jill.@0
\ No newline at end of file
diff --git a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
index c772c33..4ce8c38 100644
--- a/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
+++ b/tools/vm-tests-tf/src/util/build/BuildDalvikSuite.java
@@ -78,6 +78,7 @@
 
     private int testClassCnt = 0;
     private int testMethodsCnt = 0;
+    private boolean useJack;
 
     /*
      * using a linked hashmap to keep the insertion order for iterators.
@@ -101,39 +102,47 @@
      */
     public static void main(String[] args) throws IOException {
 
-        if (args.length > 5) {
-            JAVASRC_FOLDER = args[0];
-            OUTPUT_FOLDER = args[1];
-            CLASS_PATH = args[2];
-            MAIN_SRC_OUTPUT_FOLDER = args[3];
-            CLASSES_OUTPUT_FOLDER = MAIN_SRC_OUTPUT_FOLDER + "/classes";
-
-            COMPILED_CLASSES_FOLDER = args[4];
-
-            HOSTJUNIT_SRC_OUTPUT_FOLDER = args[5];
-            HOSTJUNIT_CLASSES_OUTPUT_FOLDER = HOSTJUNIT_SRC_OUTPUT_FOLDER + "/classes";
-
-            if (args.length > 6) {
-                // optional: restrict to e.g. "opcodes.add_double"
-                restrictTo = args[6];
-                System.out.println("restricting build to: " + restrictTo);
-            }
-
-        } else {
-            System.out.println("usage: java-src-folder output-folder classpath " +
-                    "generated-main-files compiled_output generated-main-files " +
-            "[restrict-to-opcode]");
-            System.exit(-1);
-        }
+        parseArgs(args);
 
         long start = System.currentTimeMillis();
-        BuildDalvikSuite cat = new BuildDalvikSuite();
+        BuildDalvikSuite cat = new BuildDalvikSuite(false);
         cat.compose();
         long end = System.currentTimeMillis();
 
         System.out.println("elapsed seconds: " + (end - start) / 1000);
     }
 
+    public static void parseArgs(String[] args) {
+      if (args.length > 5) {
+          JAVASRC_FOLDER = args[0];
+          OUTPUT_FOLDER = args[1];
+          CLASS_PATH = args[2];
+          MAIN_SRC_OUTPUT_FOLDER = args[3];
+          CLASSES_OUTPUT_FOLDER = MAIN_SRC_OUTPUT_FOLDER + "/classes";
+
+          COMPILED_CLASSES_FOLDER = args[4];
+
+          HOSTJUNIT_SRC_OUTPUT_FOLDER = args[5];
+          HOSTJUNIT_CLASSES_OUTPUT_FOLDER = HOSTJUNIT_SRC_OUTPUT_FOLDER + "/classes";
+
+          if (args.length > 6) {
+              // optional: restrict to e.g. "opcodes.add_double"
+              restrictTo = args[6];
+              System.out.println("restricting build to: " + restrictTo);
+          }
+
+      } else {
+          System.out.println("usage: java-src-folder output-folder classpath " +
+                  "generated-main-files compiled_output generated-main-files " +
+          "[restrict-to-opcode]");
+          System.exit(-1);
+      }
+    }
+
+    public BuildDalvikSuite(boolean useJack) {
+      this.useJack = useJack;
+    }
+
     public void compose() throws IOException {
         System.out.println("Collecting all junit tests...");
         new TestRunner() {
@@ -182,19 +191,21 @@
         li.add(method);
     }
     private String curJunitFileName = null;
+    private String curJunitName = null;
     private String curJunitFileData = "";
 
-    private JavacBuildStep javacHostJunitBuildStep;
+    private SourceBuildStep hostJunitBuildStep;
 
     private void flushHostJunitFile() {
         if (curJunitFileName != null) {
             File toWrite = new File(curJunitFileName);
             String absPath = toWrite.getAbsolutePath();
             // add to java source files for later compilation
-            javacHostJunitBuildStep.addSourceFile(absPath);
+            hostJunitBuildStep.addSourceFile(absPath);
             // write file
             curJunitFileData += "\n}\n";
             writeToFileMkdir(toWrite, curJunitFileData);
+
             curJunitFileName = null;
             curJunitFileData = "";
         }
@@ -267,11 +278,11 @@
         String datafileContent = "";
         Set<BuildStep> targets = new TreeSet<BuildStep>();
 
-        javacHostJunitBuildStep = new JavacBuildStep(HOSTJUNIT_CLASSES_OUTPUT_FOLDER, CLASS_PATH);
+        SourceBuildStep srcBuildStep;
+        hostJunitBuildStep = new JavacBuildStep(
+            HOSTJUNIT_CLASSES_OUTPUT_FOLDER, CLASS_PATH);
 
-
-        JavacBuildStep javacBuildStep = new JavacBuildStep(
-                CLASSES_OUTPUT_FOLDER, CLASS_PATH);
+        srcBuildStep = new JavacBuildStep(CLASSES_OUTPUT_FOLDER, CLASS_PATH);
 
         for (Entry<String, List<String>> entry : map.entrySet()) {
 
@@ -334,19 +345,25 @@
                 "    public static void main(String[] args) throws Exception {" +
                 methodContent + "\n}\n";
 
-                String fileName = getFileName(pName, method, ".java");
                 File sourceFile = getFileFromPackage(pName, method);
 
-                File classFile = new File(CLASSES_OUTPUT_FOLDER + "/" +
-                        getFileName(pName, method, ".class"));
-                // if (sourceFile.lastModified() > classFile.lastModified()) {
                 writeToFile(sourceFile, content);
-                javacBuildStep.addSourceFile(sourceFile.getAbsolutePath());
+                if (useJack) {
+                    File jackFile = new File(CLASSES_OUTPUT_FOLDER + "/" +
+                            getFileName(pName, method, ".jack"));
+                    JackBuildStep step = new JackBuildStep(jackFile.getAbsolutePath(), CLASS_PATH);
+                    step.addSourceFile(sourceFile.getAbsolutePath());
+                    if (!step.build()) {
+                        System.out.println("main src dalvik-cts-buildutil build step failed");
+                        System.exit(1);
+                    }
+                } else {
+                    srcBuildStep.addSourceFile(sourceFile.getAbsolutePath());
+                }
 
                 BuildStep dexBuildStep = generateDexBuildStep(
-                        CLASSES_OUTPUT_FOLDER, getFileName(pName, method, ""));
+                        CLASSES_OUTPUT_FOLDER, getFileName(pName, method, ""), null);
                 targets.add(dexBuildStep);
-                // }
 
 
                 // prepare the entry in the data file for the bash script.
@@ -442,22 +459,23 @@
         scriptDataDir.mkdirs();
         writeToFile(new File(scriptDataDir, "scriptdata"), datafileContent);
 
-        if (!javacHostJunitBuildStep.build()) {
+        if (!hostJunitBuildStep.build()) {
             System.out.println("main javac cts-host-hostjunit-classes build step failed");
             System.exit(1);
         }
 
-        if (javacBuildStep.build()) {
-            for (BuildStep buildStep : targets) {
-                if (!buildStep.build()) {
-                    System.out.println("building failed. buildStep: " +
-                            buildStep.getClass().getName() + ", " + buildStep);
-                    System.exit(1);
-                }
+        if (!useJack) {
+            if (!srcBuildStep.build()) {
+                System.out.println("main src dalvik-cts-buildutil build step failed");
+                System.exit(1);
             }
-        } else {
-            System.out.println("main javac dalvik-cts-buildutil build step failed");
-            System.exit(1);
+        }
+        for (BuildStep buildStep : targets) {
+            if (!buildStep.build()) {
+                System.out.println("building failed. buildStep: " +
+                        buildStep.getClass().getName() + ", " + buildStep);
+                System.exit(1);
+            }
         }
     }
 
@@ -514,19 +532,37 @@
             return;
         }
 
-        if (new File(sourceFolder, fileName + ".java").exists()) {
-
+        File srcFile = new File(sourceFolder, fileName + ".java");
+        if (srcFile.exists()) {
+            JackBuildStep jackBuildStep = null;
+            if (useJack) {
+                jackBuildStep = new JackBuildStep(
+                        COMPILED_CLASSES_FOLDER + File.separator + fileName + ".jack",
+                        CLASS_PATH);
+                jackBuildStep.addSourceFile(srcFile.getAbsolutePath());
+            }
             BuildStep dexBuildStep = generateDexBuildStep(
-                    COMPILED_CLASSES_FOLDER, fileName);
+                COMPILED_CLASSES_FOLDER, fileName, jackBuildStep);
             targets.add(dexBuildStep);
             return;
         }
 
         try {
             if (Class.forName(dependentTestClassName) != null) {
+                JillBuildStep jillBuildStep = null;
+                if (useJack) {
+                    BuildStep.BuildFile classFile = new BuildStep.BuildFile(
+                        COMPILED_CLASSES_FOLDER, fileName + ".class");
 
+                    BuildStep.BuildFile jackFile = new BuildStep.BuildFile(
+                        COMPILED_CLASSES_FOLDER,
+                        fileName + ".jack");
+
+                    jillBuildStep = new JillBuildStep(classFile,
+                        jackFile);
+                }
                 BuildStep dexBuildStep = generateDexBuildStep(
-                        COMPILED_CLASSES_FOLDER, fileName);
+                    COMPILED_CLASSES_FOLDER, fileName, jillBuildStep);
                 targets.add(dexBuildStep);
                 return;
             }
@@ -539,24 +575,50 @@
     }
 
     private BuildStep generateDexBuildStep(String classFileFolder,
-            String classFileName) {
-        BuildStep.BuildFile classFile = new BuildStep.BuildFile(
-                classFileFolder, classFileName + ".class");
+            String classFileName, BuildStep dependency) {
+        if (!useJack) {
+            BuildStep.BuildFile classFile = new BuildStep.BuildFile(
+                    classFileFolder, classFileName + ".class");
 
-        BuildStep.BuildFile tmpJarFile = new BuildStep.BuildFile(OUTPUT_FOLDER,
-                classFileName + "_tmp.jar");
+            BuildStep.BuildFile tmpJarFile = new BuildStep.BuildFile(
+                    OUTPUT_FOLDER,
+                    classFileName + "_tmp.jar");
 
-        JarBuildStep jarBuildStep = new JarBuildStep(classFile, classFileName +
-                ".class", tmpJarFile, false);
+            JarBuildStep jarBuildStep = new JarBuildStep(classFile,
+                    classFileName + ".class", tmpJarFile, false);
 
-        BuildStep.BuildFile outputFile = new BuildStep.BuildFile(OUTPUT_FOLDER,
-                classFileName + ".jar");
+            if (dependency != null) {
+                jarBuildStep.addChild(dependency);
+            }
 
-        DexBuildStep dexBuildStep = new DexBuildStep(tmpJarFile, outputFile,
-                true);
+            BuildStep.BuildFile outputFile = new BuildStep.BuildFile(
+                    OUTPUT_FOLDER,
+                    classFileName + ".jar");
 
-        dexBuildStep.addChild(jarBuildStep);
-        return dexBuildStep;
+            DxBuildStep dexBuildStep = new DxBuildStep(tmpJarFile,
+                    outputFile,
+                    true);
+
+            dexBuildStep.addChild(jarBuildStep);
+            return dexBuildStep;
+        } else {
+          BuildStep.BuildFile jackFile = new BuildStep.BuildFile(
+              classFileFolder, classFileName + ".jack");
+
+          BuildStep.BuildFile outputFile = new BuildStep.BuildFile(
+                  OUTPUT_FOLDER,
+                  classFileName + ".jar");
+
+          JackDexBuildStep dexBuildStep = new JackDexBuildStep(jackFile,
+                  outputFile,
+                  true);
+
+          if (dependency != null) {
+              dexBuildStep.addChild(dependency);
+          }
+          return dexBuildStep;
+
+        }
 
     }
 
@@ -747,7 +809,7 @@
 
     private void writeToFile(File file, String content) {
         try {
-            if (file.length() == content.length()) {
+            if (file.exists() && file.length() == content.length()) {
                 FileReader reader = new FileReader(file);
                 char[] charContents = new char[(int) file.length()];
                 reader.read(charContents);
diff --git a/tools/vm-tests-tf/src/util/build/DexBuildStep.java b/tools/vm-tests-tf/src/util/build/DxBuildStep.java
similarity index 93%
rename from tools/vm-tests-tf/src/util/build/DexBuildStep.java
rename to tools/vm-tests-tf/src/util/build/DxBuildStep.java
index 6aba51c..6e347b2 100644
--- a/tools/vm-tests-tf/src/util/build/DexBuildStep.java
+++ b/tools/vm-tests-tf/src/util/build/DxBuildStep.java
@@ -19,11 +19,11 @@
 import com.android.dx.command.dexer.Main;
 import java.io.IOException;
 
-public class DexBuildStep extends BuildStep {
+public class DxBuildStep extends BuildStep {
 
     private final boolean deleteInputFileAfterBuild;
 
-    DexBuildStep(BuildFile inputFile, BuildFile outputFile,
+    DxBuildStep(BuildFile inputFile, BuildFile outputFile,
             boolean deleteInputFileAfterBuild) {
         super(inputFile, outputFile);
         this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
@@ -71,7 +71,7 @@
     @Override
     public boolean equals(Object obj) {
         if (super.equals(obj)) {
-            DexBuildStep other = (DexBuildStep) obj;
+            DxBuildStep other = (DxBuildStep) obj;
 
             return inputFile.equals(other.inputFile)
                     && outputFile.equals(other.outputFile);
diff --git a/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java b/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java
new file mode 100644
index 0000000..a508e5b
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/JackBuildDalvikSuite.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package util.build;
+
+import java.io.IOException;
+
+public class JackBuildDalvikSuite {
+
+    public static void main(String[] args) throws IOException {
+
+        BuildDalvikSuite.parseArgs(args);
+
+        long start = System.currentTimeMillis();
+        BuildDalvikSuite cat = new BuildDalvikSuite(true);
+        cat.compose();
+        long end = System.currentTimeMillis();
+
+        System.out.println("elapsed seconds: " + (end - start) / 1000);
+    }
+}
diff --git a/tools/vm-tests-tf/src/util/build/JackBuildStep.java b/tools/vm-tests-tf/src/util/build/JackBuildStep.java
new file mode 100644
index 0000000..9e93475
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/JackBuildStep.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package util.build;
+
+import com.android.jack.Jack;
+import com.android.jack.Main;
+import com.android.jack.Options;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class JackBuildStep extends SourceBuildStep {
+
+    private final String destPath;
+    private final String classPath;
+    private final Set<String> sourceFiles = new HashSet<String>();
+
+    public JackBuildStep(String destPath, String classPath) {
+        this.destPath = destPath;
+        this.classPath = classPath;
+    }
+
+    @Override
+    public void addSourceFile(String sourceFile) {
+        sourceFiles.add(sourceFile);
+    }
+
+    @Override
+    boolean build() {
+        if (super.build()) {
+            if (sourceFiles.isEmpty()) {
+                return true;
+            }
+
+            File outDir = new File(destPath).getParentFile();
+            if (!outDir.exists() && !outDir.mkdirs()) {
+                System.err.println("failed to create output dir: "
+                        + outDir.getAbsolutePath());
+                return false;
+            }
+            List<String> commandLine = new ArrayList(4 + sourceFiles.size());
+            commandLine.add("--classpath");
+            commandLine.add(classPath);
+            commandLine.add("--output-jack");
+            commandLine.add(destPath);
+            commandLine.addAll(sourceFiles);
+
+            try {
+                Options options = Main.parseCommandLine(commandLine);
+                Jack.run(options);
+            } catch (Throwable ex) {
+                ex.printStackTrace();
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (super.equals(obj)) {
+            JackBuildStep other = (JackBuildStep) obj;
+            return destPath.equals(other.destPath) && classPath.equals(other.classPath)
+                    && sourceFiles.equals(other.sourceFiles);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return destPath.hashCode() ^ classPath.hashCode() ^ sourceFiles.hashCode();
+    }
+}
diff --git a/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java b/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java
new file mode 100644
index 0000000..8d9771c
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/JackDexBuildStep.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2008 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.
+ */
+
+package util.build;
+
+import com.android.jack.Jack;
+import com.android.jack.Main;
+import com.android.jack.Options;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JackDexBuildStep extends BuildStep {
+
+    private final boolean deleteInputFileAfterBuild;
+
+    JackDexBuildStep(BuildFile inputFile, BuildFile outputFile,
+            boolean deleteInputFileAfterBuild) {
+        super(inputFile, outputFile);
+        this.deleteInputFileAfterBuild = deleteInputFileAfterBuild;
+    }
+
+    @Override
+    boolean build() {
+
+        if (super.build()) {
+            String outputFilePath = outputFile.fileName.getAbsolutePath();
+            if (outputFilePath.endsWith(".dex")) {
+              throw new AssertionError(
+                  "DexBuildStep does not support dex output outside of an archive");
+            }
+
+            File outDir = outputFile.fileName.getParentFile();
+            if (!outDir.exists() && !outDir.mkdirs()) {
+                System.err.println("failed to create output dir: "
+                        + outDir.getAbsolutePath());
+                return false;
+            }
+
+            List<String> commandLine = new ArrayList<String>(4);
+            commandLine.add("--output-dex-zip");
+            commandLine.add(outputFilePath);
+            commandLine.add("--import");
+            commandLine.add(inputFile.fileName.getAbsolutePath());
+
+            try {
+               Options options = Main.parseCommandLine(commandLine);
+               Jack.run(options);
+                if (deleteInputFileAfterBuild) {
+                    inputFile.fileName.delete();
+                }
+                return true;
+            } catch (Throwable ex) {
+                System.err.println("exception while dexing "
+                        + inputFile.fileName.getAbsolutePath() + " to "
+                        + outputFile.fileName.getAbsolutePath());
+                ex.printStackTrace();
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return inputFile.hashCode() ^ outputFile.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (super.equals(obj)) {
+            JackDexBuildStep other = (JackDexBuildStep) obj;
+
+            return inputFile.equals(other.inputFile)
+                    && outputFile.equals(other.outputFile);
+        }
+        return false;
+    }
+
+
+}
diff --git a/tools/vm-tests-tf/src/util/build/JavacBuildStep.java b/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
index 7d7033f..d08a2c6 100644
--- a/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
+++ b/tools/vm-tests-tf/src/util/build/JavacBuildStep.java
@@ -23,7 +23,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
-public class JavacBuildStep extends BuildStep {
+public class JavacBuildStep extends SourceBuildStep {
 
     private final String destPath;
     private final String classPath;
@@ -32,12 +32,13 @@
         this.destPath = destPath;
         this.classPath = classPath;
     }
-    
+
+    @Override
     public void addSourceFile(String sourceFile)
     {
         sourceFiles.add(sourceFile);
     }
-    
+
     @Override
     boolean build() {
         if (super.build())
@@ -46,7 +47,7 @@
             {
                 return true;
             }
-            
+
             File destFile = new File(destPath);
             if (!destFile.exists() && !destFile.mkdirs())
             {
@@ -59,13 +60,12 @@
             commandLine[1] = classPath;
             commandLine[2] = "-d";
             commandLine[3] = destPath;
-             
+
             String[] files = new String[sourceFiles.size()];
             sourceFiles.toArray(files);
-            
+
             System.arraycopy(files, 0, commandLine, args, files.length);
-            
-            
+
             return Main.compile(commandLine, new PrintWriter(System.err)) == 0;
         }
         return false;
@@ -73,17 +73,16 @@
 
     @Override
     public boolean equals(Object obj) {
-        // TODO Auto-generated method stub
         if (super.equals(obj))
         {
             JavacBuildStep other = (JavacBuildStep) obj;
-            return destPath.equals(other.destPath) 
+            return destPath.equals(other.destPath)
                 && classPath.equals(other.classPath)
                 && sourceFiles.equals(other.sourceFiles);
         }
         return false;
     }
-    
+
     @Override
     public int hashCode() {
         return destPath.hashCode() ^ classPath.hashCode() ^ sourceFiles.hashCode();
diff --git a/tools/vm-tests-tf/src/util/build/JillBuildStep.java b/tools/vm-tests-tf/src/util/build/JillBuildStep.java
new file mode 100644
index 0000000..aff3bb0
--- /dev/null
+++ b/tools/vm-tests-tf/src/util/build/JillBuildStep.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package util.build;
+
+import com.android.jill.Main;
+import com.android.jill.Options;
+
+import java.io.File;
+
+public class JillBuildStep extends BuildStep {
+
+    JillBuildStep(BuildFile inputFile, BuildFile outputFile) {
+        super(inputFile, outputFile);
+    }
+
+    @Override
+    boolean build() {
+        if (super.build()) {
+
+            File outDir = outputFile.fileName.getParentFile();
+            if (!outDir.exists() && !outDir.mkdirs()) {
+                System.err.println("failed to create output dir: "
+                        + outDir.getAbsolutePath());
+                return false;
+            }
+
+            int args = 3;
+            String[] commandLine = new String[args];
+            commandLine[0] = "--output";
+            commandLine[1] = outputFile.fileName.getAbsolutePath();
+            commandLine[2] = inputFile.fileName.getAbsolutePath();
+
+            try {
+                Options options = Main.getOptions(commandLine);
+                Main.run(options);
+            } catch (Throwable ex) {
+                ex.printStackTrace();
+                return false;
+            }
+
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (super.equals(obj)) {
+            JillBuildStep other = (JillBuildStep) obj;
+
+            return inputFile.equals(other.inputFile) && outputFile.equals(other.outputFile);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return inputFile.hashCode() ^ outputFile.hashCode();
+    }
+}
diff --git a/apps/CtsVerifier/lib/colorchecker/vec2.cpp b/tools/vm-tests-tf/src/util/build/SourceBuildStep.java
similarity index 73%
rename from apps/CtsVerifier/lib/colorchecker/vec2.cpp
rename to tools/vm-tests-tf/src/util/build/SourceBuildStep.java
index 29736bb..4a68a05 100644
--- a/apps/CtsVerifier/lib/colorchecker/vec2.cpp
+++ b/tools/vm-tests-tf/src/util/build/SourceBuildStep.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2008 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.
@@ -13,10 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#define LOG_NDEBUG 0
 
-#define LOG_TAG "Vec2"
-#include <utils/Log.h>
-#include <utils/Timers.h>
+package util.build;
 
-#include "vec2.h"
+public abstract class SourceBuildStep extends BuildStep {
+
+  public abstract void addSourceFile(String sourceFile);
+
+}