am 3822bcc2: am 6c630a33: am 122d508c: am 3d0a35ac: am d114860e: Merge "videoperf: compute measured fps from frame time diff" into mnc-dev

* commit '3822bcc23c5bfae3c152120e11b1a9032f2d2e06':
  videoperf: compute measured fps from frame time diff
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index 5042a74..520afc2 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -69,7 +69,6 @@
     CtsKeySetSigningEcAUpgradeA
 
 cts_support_packages := \
-    CtsAccelerationTestStubs \
     CtsAlarmClockService \
     CtsAppTestStubs \
     CtsAtraceTestApp \
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index 48a8318..0472a29 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -27,7 +27,7 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := android-ex-camera2 \
                                android-support-v4 \
-                               compatibility-common-util-devicesidelib_v2 \
+                               compatibility-common-util-devicesidelib \
                                cts-sensors-tests \
                                ctstestrunner \
                                apache-commons-math \
@@ -37,7 +37,7 @@
                                android-support-v4  \
                                mockito-target \
                                mockwebserver \
-                               compatibility-device-util_v2 \
+                               compatibility-device-util \
 
 LOCAL_PACKAGE_NAME := CtsVerifier
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsReport.java b/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsReport.java
index 05c5e77..ff6bc76 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsReport.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/TestResultsReport.java
@@ -16,17 +16,17 @@
 
 package com.android.cts.verifier;
 
+import android.content.Context;
+import android.os.Build;
+import android.text.TextUtils;
+import android.util.Xml;
+
 import com.android.compatibility.common.util.MetricsXmlSerializer;
 import com.android.compatibility.common.util.ReportLog;
 import com.android.cts.verifier.TestListAdapter.TestListItem;
 
 import org.xmlpull.v1.XmlSerializer;
 
-import android.content.Context;
-import android.os.Build;
-import android.text.TextUtils;
-import android.util.Xml;
-
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.text.DateFormat;
@@ -131,6 +131,7 @@
                     xml.endTag(null, TEST_DETAILS_TAG);
                 }
 
+                // TODO(stuartscott): For v2: ReportLog.serialize(xml, mAdapter.getReportLog(i));
                 ReportLog reportLog = mAdapter.getReportLog(i);
                 if (reportLog != null) {
                     MetricsXmlSerializer metricsXmlSerializer = new MetricsXmlSerializer(xml);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sample/SampleTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sample/SampleTestActivity.java
index 41bc303..678aeca 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sample/SampleTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sample/SampleTestActivity.java
@@ -77,14 +77,15 @@
         double[] metricValues = new double[] {1, 11, 21, 1211, 111221};
 
         // Record metric results
-        getReportLog().setSummary(
-                "Sample Summary", 1.0, ResultType.HIGHER_BETTER, ResultUnit.BYTE);
-        getReportLog().addValues("Sample Values", metricValues, ResultType.NEUTRAL, ResultUnit.FPS);
+        getReportLog().setSummary("Sample Summary", 1.0, ResultType.HIGHER_BETTER,
+                ResultUnit.BYTE);
+        getReportLog().addValues("Sample Values", metricValues, ResultType.NEUTRAL,
+                ResultUnit.FPS);
 
         // Alternatively, activities can invoke TestResult directly to record metrics
         ReportLog reportLog = new PassFailButtons.CtsVerifierReportLog();
         reportLog.setSummary("Sample Summary", 1.0, ResultType.HIGHER_BETTER, ResultUnit.BYTE);
-        getReportLog().addValues("Sample Values", metricValues, ResultType.NEUTRAL, ResultUnit.FPS);
+        reportLog.addValues("Sample Values", metricValues, ResultType.NEUTRAL, ResultUnit.FPS);
         TestResult.setPassedResult(this, "manualSample", "manualDetails", reportLog);
     }
 
diff --git a/build/config.mk b/build/config.mk
index 56d4ae6..cded802 100644
--- a/build/config.mk
+++ b/build/config.mk
@@ -16,6 +16,8 @@
 # directory before creating the final CTS distribution.
 CTS_TESTCASES_OUT := $(HOST_OUT)/cts/android-cts/repository/testcases
 
+COMPATIBILITY_TESTCASES_OUT_cts_v2 := $(HOST_OUT)/cts_v2/android-cts_v2/testcases
+
 # Scanners of source files for tests which are then inputed into
 # the XML generator to produce test XMLs.
 CTS_NATIVE_TEST_SCANNER := $(HOST_OUT_EXECUTABLES)/cts-native-scanner
diff --git a/build/module_test_config.mk b/build/module_test_config.mk
index 6584ef2..fec4893 100644
--- a/build/module_test_config.mk
+++ b/build/module_test_config.mk
@@ -12,10 +12,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-cts_module_test_config := $(if $(wildcard \
-	$(LOCAL_PATH)/$(CTS_MODULE_TEST_CONFIG)), \
-	$(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).config)
-ifneq ($(cts_module_test_config),)
-$(cts_module_test_config): $(LOCAL_PATH)/$(CTS_MODULE_TEST_CONFIG) | $(ACP)
+ifneq ($(LOCAL_CTS_MODULE_CONFIG),)
+cts_module_test_config := $(CTS_TESTCASES_OUT)/$(LOCAL_MODULE).config
+$(cts_module_test_config): $(LOCAL_CTS_MODULE_CONFIG) | $(ACP)
 	$(call copy-file-to-target)
 endif
+# clear var
+LOCAL_CTS_MODULE_CONFIG :=
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivity.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivity.java
index 62e512c..e737ab6 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivity.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivity.java
@@ -401,4 +401,3 @@
         return value;
     }
 }
-
diff --git a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoInstrument.java b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoInstrument.java
index f3af0bc..700d426 100644
--- a/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoInstrument.java
+++ b/common/device-side/device-info/src/com/android/compatibility/common/deviceinfo/DeviceInfoInstrument.java
@@ -86,4 +86,3 @@
         }
     }
 }
-
diff --git a/common/device-side/device-info/tests/Android.mk b/common/device-side/device-info/tests/Android.mk
index e24c5c1..a8d9e038 100644
--- a/common/device-side/device-info/tests/Android.mk
+++ b/common/device-side/device-info/tests/Android.mk
@@ -27,4 +27,3 @@
 LOCAL_MODULE := compatibility-device-info-tests
 
 include $(BUILD_STATIC_JAVA_LIBRARY)
-
diff --git a/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivityTest.java b/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivityTest.java
index 8a8a66c..4d93416 100644
--- a/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivityTest.java
+++ b/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/DeviceInfoActivityTest.java
@@ -75,5 +75,4 @@
         bufferedReader.close();
         return stringBuilder.toString();
     }
-}
-
+}
\ No newline at end of file
diff --git a/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/SampleDeviceInfo.java b/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/SampleDeviceInfo.java
index 7da9951..0ba0c3a 100644
--- a/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/SampleDeviceInfo.java
+++ b/common/device-side/device-info/tests/src/com/android/compatibility/common/deviceinfo/SampleDeviceInfo.java
@@ -70,4 +70,3 @@
         endGroup(); // foo
     }
 }
-
diff --git a/common/device-side/device-setup/Android.mk b/common/device-side/device-setup/Android.mk
deleted file mode 100644
index bc7c504..0000000
--- a/common/device-side/device-setup/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := compatibility-device-setup_v2
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-###############################################################################
-# Build the tests
-###############################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, tests/src)
-
-LOCAL_JAVA_LIBRARIES := junit
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := compatibility-device-setup-tests_v2
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/device-side/device-setup/src/com/android/compatibility/common/devicesetup/DeviceInfoConstants.java b/common/device-side/device-setup/src/com/android/compatibility/common/devicesetup/DeviceInfoConstants.java
deleted file mode 100644
index 7b19b00..0000000
--- a/common/device-side/device-setup/src/com/android/compatibility/common/devicesetup/DeviceInfoConstants.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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 com.android.compatibility.common.devicesetup;
-
-/**
- * Constants for device info attributes to be sent as instrumentation keys.
- */
-public interface DeviceInfoConstants {
-
-    public static final String BUILD_ABI = "buildAbi";
-    public static final String BUILD_ABI2 = "buildAbi2";
-    public static final String BUILD_BOARD = "buildBoard";
-    public static final String BUILD_BRAND = "buildBrand";
-    public static final String BUILD_DEVICE = "buildDevice";
-    public static final String BUILD_FINGERPRINT = "buildFingerprint";
-    public static final String BUILD_ID = "buildId";
-    public static final String BUILD_MANUFACTURER = "buildManufacturer";
-    public static final String BUILD_MODEL = "buildModel";
-    public static final String BUILD_TAGS = "buildTags";
-    public static final String BUILD_TYPE = "buildType";
-    public static final String BUILD_VERSION = "buildVersion";
-
-    public static final String FEATURES = "features";
-
-    public static final String GRAPHICS_RENDERER = "graphicsRenderer";
-    public static final String GRAPHICS_VENDOR = "graphicsVendor";
-
-    public static final String IMEI = "imei";
-    public static final String IMSI = "imsi";
-
-    public static final String KEYPAD = "keypad";
-
-    public static final String LOCALES = "locales";
-
-    public static final String MULTI_USER = "multiUser";
-
-    public static final String NAVIGATION = "navigation";
-    public static final String NETWORK = "network";
-
-    public static final String OPEN_GL_ES_VERSION = "openGlEsVersion";
-    public static final String OPEN_GL_EXTENSIONS = "openGlExtensions";
-    public static final String OPEN_GL_COMPRESSED_TEXTURE_FORMATS =
-            "openGlCompressedTextureFormats";
-
-    public static final String PARTITIONS = "partitions";
-    public static final String PHONE_NUMBER = "phoneNumber";
-    public static final String PROCESSES = "processes";
-    public static final String PRODUCT_NAME = "productName";
-
-    public static final String RESOLUTION = "resolution";
-
-    public static final String SCREEN_DENSITY = "screenDensity";
-    public static final String SCREEN_DENSITY_BUCKET = "screenDensityBucket";
-    public static final String SCREEN_DENSITY_X = "screenDensityX";
-    public static final String SCREEN_DENSITY_Y = "screenDensityY";
-    public static final String SCREEN_SIZE = "screenSize";
-    public static final String SERIAL_NUMBER = "deviceId";
-    public static final String STORAGE_DEVICES = "storageDevices";
-    public static final String SYS_LIBRARIES = "systemLibraries";
-
-    public static final String TOUCH = "touch";
-
-    public static final String VERSION_RELEASE = "versionRelease";
-    public static final String VERSION_SDK_INT = "versionSdkInt";
-}
diff --git a/common/device-side/device-setup/tests/src/com/android/compatibility/common/devicesetup/DeviceSetupTest.java b/common/device-side/device-setup/tests/src/com/android/compatibility/common/devicesetup/DeviceSetupTest.java
deleted file mode 100644
index ee55a66..0000000
--- a/common/device-side/device-setup/tests/src/com/android/compatibility/common/devicesetup/DeviceSetupTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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 com.android.compatibility.common.devicesetup;
-
-import junit.framework.TestCase;
-
-public class DeviceSetupTest extends TestCase {
-
-    // TODO(stuartscott): Add tests when there is something to test.
-
-}
diff --git a/common/device-side/test-app/Android.mk b/common/device-side/test-app/Android.mk
new file mode 100755
index 0000000..6adce97
--- /dev/null
+++ b/common/device-side/test-app/Android.mk
@@ -0,0 +1,40 @@
+# 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.
+
+# Build an APK which contains the device-side libraries and their tests,
+# this then gets instrumented in order to test the aforementioned libraries.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+# and when built explicitly put it in the data partition
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test\
+    compatibility-common-util-devicesidelib\
+    compatibility-device-info-tests\
+    compatibility-device-info\
+    compatibility-device-util-tests\
+    compatibility-device-util
+
+LOCAL_PACKAGE_NAME := CompatibilityTestApp
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/common/device-side/test-app/AndroidManifest.xml b/common/device-side/test-app/AndroidManifest.xml
new file mode 100755
index 0000000..a4b4b82
--- /dev/null
+++ b/common/device-side/test-app/AndroidManifest.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.compatibility.common">
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <application>
+        <uses-library android:name="android.test.runner" />
+        <activity android:name="com.android.compatibility.common.deviceinfo.SampleDeviceInfo" />
+    </application>
+
+    <!--  self-instrumenting test package. -->
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+                     android:targetPackage="com.android.compatibility.common"
+                     android:label="Tests for device-side Compatibility common code">
+    </instrumentation>
+
+</manifest>
+
diff --git a/common/device-side/util/Android.mk b/common/device-side/util/Android.mk
index c8104bf..350c2db 100644
--- a/common/device-side/util/Android.mk
+++ b/common/device-side/util/Android.mk
@@ -12,34 +12,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-common-util-devicesidelib_v2
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-common-util-devicesidelib
 
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_MODULE := compatibility-device-util_v2
+LOCAL_MODULE := compatibility-device-util
 
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
-################################################################################
-# Build the tests
-###############################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, tests/src)
-
-LOCAL_JAVA_LIBRARIES := junit
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := compatibility-device-util-tests_v2
-
-include $(BUILD_HOST_JAVA_LIBRARY)
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/DeviceReportLog.java b/common/device-side/util/src/com/android/compatibility/common/util/DeviceReportLog.java
index 273cdf5..d87ebbc 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/DeviceReportLog.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/DeviceReportLog.java
@@ -22,6 +22,10 @@
 
 import com.android.compatibility.common.util.ReportLog;
 
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+
 /**
  * Handles adding results to the report for device side tests.
  *
@@ -30,13 +34,20 @@
  */
 public class DeviceReportLog extends ReportLog {
     private static final String TAG = DeviceReportLog.class.getSimpleName();
-    private static final String RESULT = "RESULT";
+    private static final String RESULT = "COMPATIBILITY_TEST_RESULT";
+    private static final int INST_STATUS_ERROR = -1;
     private static final int INST_STATUS_IN_PROGRESS = 2;
 
     public void submit(Instrumentation instrumentation) {
-        Log.i(TAG, "submit");
-        Bundle output = new Bundle();
-        output.putSerializable(RESULT, this);
-        instrumentation.sendStatus(INST_STATUS_IN_PROGRESS, output);
+        Log.i(TAG, "Submit");
+        try {
+            Bundle output = new Bundle();
+            output.putString(RESULT, serialize(this));
+            instrumentation.sendStatus(INST_STATUS_IN_PROGRESS, output);
+        } catch (IllegalArgumentException | IllegalStateException | XmlPullParserException
+                | IOException e) {
+            Log.e(TAG, "Submit Failed", e);
+            instrumentation.sendStatus(INST_STATUS_ERROR, null);
+        }
     }
 }
diff --git a/common/device-side/util/src/com/android/compatibility/common/util/EvaluateJsResultPollingCheck.java b/common/device-side/util/src/com/android/compatibility/common/util/EvaluateJsResultPollingCheck.java
index 521dc40..61f1bb8 100644
--- a/common/device-side/util/src/com/android/compatibility/common/util/EvaluateJsResultPollingCheck.java
+++ b/common/device-side/util/src/com/android/compatibility/common/util/EvaluateJsResultPollingCheck.java
@@ -18,7 +18,7 @@
 
 import android.webkit.ValueCallback;
 
-public class EvaluateJsResultPollingCheck  extends PollingCheck
+public class EvaluateJsResultPollingCheck extends PollingCheck
         implements ValueCallback<String> {
     private String mActualResult;
     private String mExpectedResult;
diff --git a/tests/tests/acceleration/Android.mk b/common/device-side/util/tests/Android.mk
similarity index 64%
copy from tests/tests/acceleration/Android.mk
copy to common/device-side/util/tests/Android.mk
index d417371..fa7424d 100644
--- a/tests/tests/acceleration/Android.mk
+++ b/common/device-side/util/tests/Android.mk
@@ -1,10 +1,10 @@
-# Copyright (C) 2011 The Android Open Source Project
+# 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
+# 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,
@@ -16,18 +16,12 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util
 
-LOCAL_INSTRUMENTATION_FOR := CtsAccelerationTestStubs
+LOCAL_MODULE_TAGS := optional
 
-LOCAL_SDK_VERSION := current
+LOCAL_MODULE := compatibility-device-util-tests
 
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/common/device-side/util/tests/src/com/android/compatibility/common/util/DeviceReportTest.java b/common/device-side/util/tests/src/com/android/compatibility/common/util/DeviceReportTest.java
new file mode 100644
index 0000000..7dbece0
--- /dev/null
+++ b/common/device-side/util/tests/src/com/android/compatibility/common/util/DeviceReportTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import android.app.Instrumentation;
+import android.os.Bundle;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for {@line DeviceReportLog}.
+ */
+public class DeviceReportTest extends TestCase {
+
+    /**
+     * A stub of {@link Instrumentation}
+     */
+    public class TestInstrumentation extends Instrumentation {
+
+        private int mResultCode = -1;
+        private Bundle mResults = null;
+
+        @Override
+        public void sendStatus(int resultCode, Bundle results) {
+            mResultCode = resultCode;
+            mResults = results;
+        }
+    }
+
+    private static final int RESULT_CODE = 2;
+    private static final String RESULT_KEY = "COMPATIBILITY_TEST_RESULT";
+    private static final String TEST_MESSAGE_1 = "Foo";
+    private static final double TEST_VALUE_1 = 3;
+    private static final ResultType TEST_TYPE_1 = ResultType.HIGHER_BETTER;
+    private static final ResultUnit TEST_UNIT_1 = ResultUnit.SCORE;
+    private static final String TEST_MESSAGE_2 = "Bar";
+    private static final double TEST_VALUE_2 = 5;
+    private static final ResultType TEST_TYPE_2 = ResultType.LOWER_BETTER;
+    private static final ResultUnit TEST_UNIT_2 = ResultUnit.COUNT;
+
+    public void testSubmit() throws Exception {
+        DeviceReportLog log = new DeviceReportLog();
+        log.addValue(TEST_MESSAGE_1, TEST_VALUE_1, TEST_TYPE_1, TEST_UNIT_1);
+        log.setSummary(TEST_MESSAGE_2, TEST_VALUE_2, TEST_TYPE_2, TEST_UNIT_2);
+        TestInstrumentation inst = new TestInstrumentation();
+        log.submit(inst);
+        assertEquals("Incorrect result code", RESULT_CODE, inst.mResultCode);
+        assertNotNull("Bundle missing", inst.mResults);
+        String metrics = inst.mResults.getString(RESULT_KEY);
+        assertNotNull("Metrics missing", metrics);
+        ReportLog result = ReportLog.parse(metrics);
+        assertNotNull("Metrics could not be decoded", result);
+    }
+}
diff --git a/common/device-side/util/tests/src/com/android/compatibility/common/util/DeviceUtilTest.java b/common/device-side/util/tests/src/com/android/compatibility/common/util/DeviceUtilTest.java
deleted file mode 100644
index a7e81d7..0000000
--- a/common/device-side/util/tests/src/com/android/compatibility/common/util/DeviceUtilTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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 com.android.compatibility.common.util;
-
-import junit.framework.TestCase;
-
-public class DeviceUtilTest extends TestCase {
-
-}
diff --git a/common/host-side/java-scanner/Android.mk b/common/host-side/java-scanner/Android.mk
deleted file mode 100644
index 7c101ff..0000000
--- a/common/host-side/java-scanner/Android.mk
+++ /dev/null
@@ -1,47 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := compatibility-common-util-hostsidelib_v2
-
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
-
-LOCAL_MODULE := compatibility-java-scanner_v2
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-################################################################################
-# Build the tests
-###############################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, tests/src)
-
-LOCAL_JAVA_LIBRARIES := compatibility-tradefed_v2 compatibility-java-scanner_v2 junit
-
-LOCAL_MODULE := compatibility-java-scanner-tests_v2
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/host-side/java-scanner/MANIFEST.mf b/common/host-side/java-scanner/MANIFEST.mf
deleted file mode 100644
index 975b1ef..0000000
--- a/common/host-side/java-scanner/MANIFEST.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.compatibility.common.scanner.JavaScanner
-Class-Path: compatibility-common-util-hostsidelib_v2.jar
diff --git a/common/host-side/java-scanner/src/com/android/compatibility/common/scanner/JavaScanner.java b/common/host-side/java-scanner/src/com/android/compatibility/common/scanner/JavaScanner.java
deleted file mode 100644
index f3f8a49..0000000
--- a/common/host-side/java-scanner/src/com/android/compatibility/common/scanner/JavaScanner.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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 com.android.compatibility.common.scanner;
-
-import com.android.compatibility.common.util.KeyValueArgsParser;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * Scans a source directory for java tests and outputs a list of test classes and methods.
- */
-public class JavaScanner {
-
-    static final String[] SOURCE_PATHS = {
-        "./frameworks/base/core/java",
-        "./frameworks/base/test-runner/src",
-        "./external/junit/src",
-        "./development/tools/hosttestlib/src",
-        "./libcore/dalvik/src/main/java",
-        "./common/device-side/util/src",
-        "./common/host-side/tradefed/src",
-        "./common/util/src"
-    };
-    static final String[] CLASS_PATHS = {
-        "./prebuilts/misc/common/tradefed/tradefed-prebuilt.java",
-        "./prebuilts/misc/common/ub-uiautomator/ub-uiautomator.java"
-    };
-    private final File mSourceDir;
-    private final File mDocletDir;
-
-    /**
-     * @param sourceDir The directory holding the source to scan.
-     * @param docletDir The directory holding the doclet (or its jar).
-     */
-    JavaScanner(File sourceDir, File docletDir) {
-        this.mSourceDir = sourceDir;
-        this.mDocletDir = docletDir;
-    }
-
-    int scan() throws Exception {
-        final ArrayList<String> args = new ArrayList<String>();
-        args.add("javadoc");
-        args.add("-doclet");
-        args.add("com.android.compatibility.common.scanner.JavaScannerDoclet");
-        args.add("-sourcepath");
-        args.add(getSourcePath(mSourceDir));
-        args.add("-classpath");
-        args.add(getClassPath());
-        args.add("-docletpath");
-        args.add(mDocletDir.toString());
-        args.addAll(getSourceFiles(mSourceDir));
-
-        // Dont want p to get blocked due to a full pipe.
-        final Process p = new ProcessBuilder(args).redirectErrorStream(true).start();
-        final BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
-        try {
-            String line = null;
-            while ((line = in.readLine()) != null) {
-                if (line.startsWith("suite:") ||
-                    line.startsWith("case:") ||
-                    line.startsWith("test:")) {
-                    System.out.println(line);
-                }
-            }
-        } finally {
-          if (in != null) {
-              in.close();
-          }
-        }
-
-        return p.waitFor();
-    }
-
-    private static String getSourcePath(File sourceDir) {
-        final ArrayList<String> sourcePath = new ArrayList<String>(Arrays.asList(SOURCE_PATHS));
-        sourcePath.add(sourceDir.toString());
-        return join(sourcePath, ":");
-    }
-
-    private static String getClassPath() {
-        return join(Arrays.asList(CLASS_PATHS), ":");
-    }
-
-    private static ArrayList<String> getSourceFiles(File sourceDir) {
-        final ArrayList<String> sourceFiles = new ArrayList<String>();
-        final File[] files = sourceDir.listFiles(new FileFilter() {
-            public boolean accept(File pathname) {
-                return pathname.isDirectory() || pathname.toString().endsWith(".java");
-            }
-        });
-        for (File f : files) {
-            if (f.isDirectory()) {
-                sourceFiles.addAll(getSourceFiles(f));
-            } else {
-                sourceFiles.add(f.toString());
-            }
-        }
-        return sourceFiles;
-    }
-
-    private static String join(List<String> list, String delimiter) {
-        final StringBuilder builder = new StringBuilder();
-        for (String s : list) {
-            builder.append(s);
-            builder.append(delimiter);
-        }
-        // Adding the delimiter each time and then removing the last one at the end is more
-        // efficient than doing a check in each iteration of the loop.
-        return builder.substring(0, builder.length() - delimiter.length());
-    }
-
-    public static void main(String[] args) throws Exception {
-        final HashMap<String, String> argsMap = KeyValueArgsParser.parse(args);
-        final String sourcePath = argsMap.get("-s");
-        final String docletPath = argsMap.get("-d");
-        if (sourcePath == null || docletPath == null) {
-            usage(args);
-        }
-        System.exit(new JavaScanner(new File(sourcePath), new File(docletPath)).scan());
-    }
-
-    private static void usage(String[] args) {
-        System.err.println("Arguments: " + Arrays.toString(args));
-        System.err.println("Usage: javascanner -s SOURCE_DIR -d DOCLET_PATH");
-        System.exit(1);
-    }
-}
diff --git a/common/host-side/java-scanner/src/com/android/compatibility/common/scanner/JavaScannerDoclet.java b/common/host-side/java-scanner/src/com/android/compatibility/common/scanner/JavaScannerDoclet.java
deleted file mode 100644
index 94eccd0..0000000
--- a/common/host-side/java-scanner/src/com/android/compatibility/common/scanner/JavaScannerDoclet.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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 com.android.compatibility.common.scanner;
-
-import com.sun.javadoc.ClassDoc;
-import com.sun.javadoc.Doclet;
-import com.sun.javadoc.MethodDoc;
-import com.sun.javadoc.RootDoc;
-
-import java.io.PrintWriter;
-
-/**
- * Doclet that scans java files looking for tests.
- *
- * Sample Ouput;
- * suite:com.android.sample.cts
- * case:SampleDeviceTest
- * test:testSharedPreferences
- */
-public class JavaScannerDoclet extends Doclet {
-
-    private static final String JUNIT_TEST_CASE_CLASS_NAME = "junit.framework.testcase";
-
-    public static boolean start(RootDoc root) {
-        ClassDoc[] classes = root.classes();
-        if (classes == null) {
-            return false;
-        }
-
-        PrintWriter writer = new PrintWriter(System.out);
-
-        for (ClassDoc clazz : classes) {
-            if (clazz.isAbstract() || !isValidJUnitTestCase(clazz)) {
-                continue;
-            }
-            writer.append("suite:").println(clazz.containingPackage().name());
-            writer.append("case:").println(clazz.name());
-            for (; clazz != null; clazz = clazz.superclass()) {
-                for (MethodDoc method : clazz.methods()) {
-                    if (method.name().startsWith("test")) {
-                        writer.append("test:").println(method.name());
-                    }
-                }
-            }
-        }
-
-        writer.close();
-        return true;
-    }
-
-    private static boolean isValidJUnitTestCase(ClassDoc clazz) {
-        while ((clazz = clazz.superclass()) != null) {
-            if (JUNIT_TEST_CASE_CLASS_NAME.equals(clazz.qualifiedName().toLowerCase())) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
diff --git a/common/host-side/java-scanner/tests/src/com/android/compatibility/common/scanner/JavaScannerTest.java b/common/host-side/java-scanner/tests/src/com/android/compatibility/common/scanner/JavaScannerTest.java
deleted file mode 100644
index 4159f0e..0000000
--- a/common/host-side/java-scanner/tests/src/com/android/compatibility/common/scanner/JavaScannerTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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 com.android.compatibility.common.scanner;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-
-import junit.framework.TestCase;
-
-public class JavaScannerTest extends TestCase {
-
-    private static final String JAR = "out/host/linux-x86/framework/compatibility-java-scanner_v2.jar";
-    private static final String VALID_RESULT =
-        "suite:com.android.test" +
-        "case:ValidTest" +
-        "test:testA";
-
-    private static final String VALID_FILENAME = "ValidTest";
-    private static final String VALID =
-        "package com.android.test;" +
-        "import junit.framework.TestCase;" +
-        "public class ValidTest extends TestCase {" +
-        "  public void testA() throws Exception {" +
-        "    helper();" +
-        "  }" +
-        "  public void helper() {" +
-        "    fail();" +
-        "  }" +
-        "}";
-
-    // TestCases must have TestCase in their hierarchy
-    private static final String INVALID_A_FILENAME = "NotTestCase";
-    private static final String INVALID_A =
-        "package com.android.test;" +
-        "public class NotTestCase {" +
-        "  public void testA() throws Exception {" +
-        "    helper();" +
-        "  }" +
-        "  public void helper() {" +
-        "    fail();" +
-        "  }" +
-        "}";
-
-    // TestCases cant be abstract classes
-    private static final String INVALID_B_FILENAME = "AbstractClass";
-    private static final String INVALID_B =
-        "package com.android.test;" +
-        "import junit.framework.TestCase;" +
-        "public abstract class AbstractClass extends TestCase {" +
-        "  public void testA() throws Exception {" +
-        "    helper();" +
-        "  }" +
-        "  public void helper() {" +
-        "    fail();" +
-        "  }" +
-        "}";
-
-    public void testValidFile() throws Exception {
-        String result = runScanner(VALID_FILENAME, VALID);
-        assertEquals(VALID_RESULT, result);
-    }
-
-    public void testInvalidFileA() throws Exception {
-        assertEquals("", runScanner(INVALID_A_FILENAME, INVALID_A));
-    }
-
-    public void testInvalidFileB() throws Exception {
-        assertEquals("", runScanner(INVALID_B_FILENAME, INVALID_B));
-    }
-
-    private static String runScanner(String filename, String content) throws Exception {
-        final File parent0 = new File(System.getProperty("java.io.tmpdir"));
-        final File parent1 = new File(parent0, "tmp" + System.currentTimeMillis());
-        final File parent2 = new File(parent1, "com");
-        final File parent3 = new File(parent2, "android");
-        final File parent4 = new File(parent3, "test");
-        File f = null;
-        try {
-            parent4.mkdirs();
-            f = new File(parent4, filename + ".java");
-            final PrintWriter out = new PrintWriter(f);
-            out.print(content);
-            out.flush();
-            out.close();
-            ArrayList<String> args = new ArrayList<String>();
-            args.add("java");
-            args.add("-jar");
-            args.add(JAR);
-            args.add("-s");
-            args.add(parent1.toString());
-            args.add("-d");
-            args.add(JAR);
-
-            final Process p = new ProcessBuilder(args).start();
-            final StringBuilder output = new StringBuilder();
-            final BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
-            String line = null;
-            while ((line = in.readLine()) != null) {
-                output.append(line);
-            }
-            int ret = p.waitFor();
-            if (ret == 0) {
-                return output.toString();
-            }
-        } finally {
-            if (f != null) {
-                f.delete();
-            }
-            parent4.delete();
-            parent3.delete();
-            parent2.delete();
-            parent1.delete();
-        }
-        return null;
-    }
-}
diff --git a/common/host-side/manifest-generator/Android.mk b/common/host-side/manifest-generator/Android.mk
index ca08928..859708d 100644
--- a/common/host-side/manifest-generator/Android.mk
+++ b/common/host-side/manifest-generator/Android.mk
@@ -18,6 +18,8 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
+LOCAL_JAVA_LIBRARIES := compatibility-host-util
+
 LOCAL_STATIC_JAVA_LIBRARIES := kxml2-2.3.0
 
 LOCAL_JAR_MANIFEST := MANIFEST.mf
@@ -30,4 +32,4 @@
 
 include $(BUILD_HOST_JAVA_LIBRARY)
 
-include $(call all-makefiles-under,$(LOCAL_PATH))
+include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/common/host-side/manifest-generator/MANIFEST.mf b/common/host-side/manifest-generator/MANIFEST.mf
index 4f62631..be8a6fa 100644
--- a/common/host-side/manifest-generator/MANIFEST.mf
+++ b/common/host-side/manifest-generator/MANIFEST.mf
@@ -1,2 +1,3 @@
 Manifest-Version: 1.0
 Main-Class: com.android.compatibility.common.generator.ManifestGenerator
+Class-Path: compatibility-common-util-hostsidelib.jar
diff --git a/common/host-side/manifest-generator/tests/Android.mk b/common/host-side/manifest-generator/tests/Android.mk
index 2eb5d2f..0fb4b16 100644
--- a/common/host-side/manifest-generator/tests/Android.mk
+++ b/common/host-side/manifest-generator/tests/Android.mk
@@ -18,10 +18,10 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_JAVA_LIBRARIES := compatibility-manifest-generator junit
+LOCAL_JAVA_LIBRARIES := compatibility-tradefed compatibility-manifest-generator junit
 
 LOCAL_MODULE := compatibility-manifest-generator-tests
 
 LOCAL_MODULE_TAGS := optional
 
-include $(BUILD_HOST_JAVA_LIBRARY)
+include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/common/host-side/native-scanner/Android.mk b/common/host-side/native-scanner/Android.mk
deleted file mode 100644
index 184cdc0..0000000
--- a/common/host-side/native-scanner/Android.mk
+++ /dev/null
@@ -1,47 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
-
-LOCAL_JAVA_LIBRARIES := compatibility-common-util-hostsidelib_v2
-
-LOCAL_MODULE := compatibility-native-scanner_v2
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-################################################################################
-# Build the tests
-###############################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, tests/src)
-
-LOCAL_JAVA_LIBRARIES := compatibility-tradefed_v2 compatibility-native-scanner_v2 junit
-
-LOCAL_MODULE := compatibility-native-scanner-tests_v2
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/host-side/native-scanner/MANIFEST.mf b/common/host-side/native-scanner/MANIFEST.mf
deleted file mode 100644
index c5641ca..0000000
--- a/common/host-side/native-scanner/MANIFEST.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.compatibility.common.scanner.NativeScanner
-Class-Path: compatibility-common-util-hostsidelib_v2.jar
diff --git a/common/host-side/native-scanner/src/com/android/compatibility/common/scanner/NativeScanner.java b/common/host-side/native-scanner/src/com/android/compatibility/common/scanner/NativeScanner.java
deleted file mode 100644
index 7b9e447..0000000
--- a/common/host-side/native-scanner/src/com/android/compatibility/common/scanner/NativeScanner.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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 com.android.compatibility.common.scanner;
-
-import com.android.compatibility.common.util.KeyValueArgsParser;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * Passes the gtest output and outputs a list of test classes and methods.
- */
-public final class NativeScanner {
-
-    private static final String TEST_SUITE_ARG = "t";
-    private static final String USAGE = "Usage: compatibility-native-scanner -t TEST_SUITE"
-        + "  This code reads from stdin the list of tests."
-        + "  The format expected:"
-        + "    TEST_CASE_NAME."
-        + "      TEST_NAME";
-
-    /**
-     * @return An {@link ArrayList} of suites, classes and method names.
-     */
-    static ArrayList<String> getTestNames(BufferedReader reader, String testSuite)
-            throws IOException {
-        ArrayList<String> testNames = new ArrayList<String>();
-        testNames.add("suite:" + testSuite);
-
-        String testCaseName = null;
-        String line;
-        while ((line = reader.readLine()) != null) {
-            if (line.length() == 0) {
-                continue;
-            }
-            if (line.charAt(0) == ' ') {
-                if (testCaseName == null) {
-                    throw new RuntimeException("TEST_CASE_NAME not defined before first test.");
-                }
-                testNames.add("test:" + line.trim());
-            } else {
-                testCaseName = line.trim();
-                if (testCaseName.endsWith(".")) {
-                    testCaseName = testCaseName.substring(0, testCaseName.length()-1);
-                }
-                testNames.add("case:" + testCaseName);
-            }
-        }
-        return testNames;
-    }
-
-    /** Lookup test suite argument and scan {@code System.in} for test cases */
-    public static void main(String[] args) throws IOException {
-        HashMap<String, String> argMap = KeyValueArgsParser.parse(args);
-        if (!argMap.containsKey(TEST_SUITE_ARG)) {
-            System.err.println(USAGE);
-            System.exit(1);
-        }
-
-        String testSuite = argMap.get(TEST_SUITE_ARG);
-
-        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
-        for (String name : getTestNames(reader, testSuite)) {
-            System.out.println(name);
-        }
-    }
-}
diff --git a/common/host-side/native-scanner/tests/src/com/android/compatibility/common/scanner/NativeScannerTest.java b/common/host-side/native-scanner/tests/src/com/android/compatibility/common/scanner/NativeScannerTest.java
deleted file mode 100644
index c5d3157..0000000
--- a/common/host-side/native-scanner/tests/src/com/android/compatibility/common/scanner/NativeScannerTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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 com.android.compatibility.common.scanner;
-
-import com.android.compatibility.common.scanner.NativeScanner;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.List;
-import java.util.Iterator;
-
-public class NativeScannerTest extends TestCase {
-
-    public void testSingleTestNamesCase() throws Exception {
-        StringReader singleTestString = new StringReader("FakeTestCase.\n  FakeTestName\n");
-        BufferedReader reader = new BufferedReader(singleTestString);
-
-        List<String> names = NativeScanner.getTestNames(reader, "TestSuite");
-        Iterator<String> it = names.iterator();
-        assertEquals("suite:TestSuite", it.next());
-        assertEquals("case:FakeTestCase", it.next());
-        assertEquals("test:FakeTestName", it.next());
-        assertFalse(it.hasNext());
-    }
-
-    public void testMultipleTestNamesCase() throws Exception {
-        StringReader singleTestString = new StringReader(
-          "Case1.\n  Test1\n  Test2\nCase2.\n  Test3\n Test4\n");
-        BufferedReader reader = new BufferedReader(singleTestString);
-
-        List<String> names = NativeScanner.getTestNames(reader, "TestSuite");
-
-        Iterator<String> it = names.iterator();
-        assertEquals("suite:TestSuite", it.next());
-        assertEquals("case:Case1", it.next());
-        assertEquals("test:Test1", it.next());
-        assertEquals("test:Test2", it.next());
-        assertEquals("case:Case2", it.next());
-        assertEquals("test:Test3", it.next());
-        assertEquals("test:Test4", it.next());
-        assertFalse(it.hasNext());
-    }
-
-    public void testMissingTestCaseNameCase() throws IOException {
-        StringReader singleTestString = new StringReader("  Test1\n");
-        BufferedReader reader = new BufferedReader(singleTestString);
-
-        try {
-            NativeScanner.getTestNames(reader, "TestSuite");
-            fail("Expected RuntimeException");
-        } catch (RuntimeException expected) {}
-    }
-}
diff --git a/common/host-side/scripts/compatibility-tests_v2 b/common/host-side/scripts/compatibility-tests_v2
deleted file mode 100755
index 797909e..0000000
--- a/common/host-side/scripts/compatibility-tests_v2
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-#
-# 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.
-
-checkFile() {
-    if [ ! -f "$1" ]; then
-        echo "Unable to locate $1"
-        exit
-    fi;
-}
-
-HOST_JAR_DIR=${ANDROID_HOST_OUT}/framework
-HOST_JARS="ddmlib-prebuilt tradefed-prebuilt hosttestlib\
-    compatibility-tradefed_v2 compatibility-tradefed-tests_v2\
-    compatibility-java-scanner_v2 compatibility-java-scanner-tests_v2\
-    compatibility-native-scanner_v2 compatibility-native-scanner-tests_v2\
-    compatibility-xml-plan-generator_v2 compatibility-xml-plan-generator-tests_v2\
-    compatibility-device-util-tests_v2 compatibility-device-setup-tests_v2\
-    compatibility-common-util-hostsidelib_v2 compatibility-common-util-tests_v2"
-
-for JAR in ${HOST_JARS}; do
-    checkFile ${HOST_JAR_DIR}/${JAR}.jar
-    JAR_PATH=${JAR_PATH}:${HOST_JAR_DIR}/${JAR}.jar
-done
-
-DEVICE_LIBS_DIR=${ANDROID_PRODUCT_OUT}/obj/JAVA_LIBRARIES
-DEVICE_LIBS="compatibility-common-util-devicesidelib_v2 compatibility-device-util_v2\
-    compatibility-device-setup_v2"
-
-for LIB in ${DEVICE_LIBS}; do
-    checkFile ${DEVICE_LIBS_DIR}/${LIB}_intermediates/javalib.jar
-    JAR_PATH=${JAR_PATH}:${DEVICE_LIBS_DIR}/${LIB}_intermediates/javalib.jar
-done
-
-# TODO(stuartscott): Currently the test classes are explicitly set here, but
-# once our wrappers for tradefed are in place we can make it scan and generate
-# the list of test at runtime.
-TEST_CLASSES="com.android.compatibility.common.devicesetup.DeviceSetupTest\
-    com.android.compatibility.common.scanner.JavaScannerTest\
-    com.android.compatibility.common.scanner.NativeScannerTest\
-    com.android.compatibility.common.tradefed.TradefedTest\
-    com.android.compatibility.common.util.DeviceUtilTest\
-    com.android.compatibility.common.util.CommonUtilTest\
-    com.android.compatibility.common.xmlgenerator.XmlPlanGeneratorTest"
-
-for CLASS in ${TEST_CLASSES}; do
-    java $RDBG_FLAG -cp ${JAR_PATH} com.android.compatibility.common.tradefed.command.CompatibilityConsole run\
-            singleCommand host -n --class ${CLASS} "$@"
-done
diff --git a/common/host-side/tradefed/Android.mk b/common/host-side/tradefed/Android.mk
index 8ff7c8c..9faabed 100644
--- a/common/host-side/tradefed/Android.mk
+++ b/common/host-side/tradefed/Android.mk
@@ -12,40 +12,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-###############################################################################
-# Builds the compatibility tradefed host library
-###############################################################################
-
 LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-#LOCAL_JAVA_RESOURCE_DIRS := res
+LOCAL_JAVA_RESOURCE_DIRS := res
 
-LOCAL_MODULE := compatibility-tradefed_v2
+LOCAL_MODULE := compatibility-tradefed
 
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt hosttestlib compatibility-common-util-hostsidelib_v2
+LOCAL_JAVA_LIBRARIES := tradefed-prebuilt hosttestlib compatibility-host-util
 
 include $(BUILD_HOST_JAVA_LIBRARY)
 
-###############################################################################
-# Build the compatibility tradefed tests
-###############################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, tests/src)
-
-LOCAL_MODULE := compatibility-tradefed-tests_v2
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := tradefed-prebuilt compatibility-tradefed_v2 junit
-
-LOCAL_STATIC_JAVA_LIBRARIES := easymock
-
-include $(BUILD_HOST_JAVA_LIBRARY)
+include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/common/host-side/tradefed/res/config/common-compatibility-config.xml b/common/host-side/tradefed/res/config/common-compatibility-config.xml
new file mode 100644
index 0000000..5bac748
--- /dev/null
+++ b/common/host-side/tradefed/res/config/common-compatibility-config.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Common config for Compatibility suites">
+
+    <device_recovery class="com.android.tradefed.device.WaitDeviceRecovery" />
+    <build_provider class="com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider" />
+    <test class="com.android.compatibility.common.tradefed.testtype.CompatibilityTest" />
+    <logger class="com.android.tradefed.log.FileLogger" />
+    <result_reporter class="com.android.compatibility.common.tradefed.result.ResultReporter" />
+
+</configuration>
diff --git a/common/host-side/tradefed/res/config/common-config.xml b/common/host-side/tradefed/res/config/common-config.xml
new file mode 100644
index 0000000..e05fc0d
--- /dev/null
+++ b/common/host-side/tradefed/res/config/common-config.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Common base configuration for Compatibility tests">
+    <!--
+      This common base configuration contains some commonly used preparers
+      -->
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
+        <option name="cleanup" value="true" />
+    </target_preparer>
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
+        <option name="cleanup-apks" value="true" />
+    </target_preparer>
+    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer" />
+</configuration>
diff --git a/common/host-side/tradefed/res/config/everything.xml b/common/host-side/tradefed/res/config/everything.xml
new file mode 100644
index 0000000..4cef5e4
--- /dev/null
+++ b/common/host-side/tradefed/res/config/everything.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Common config for Compatibility suites to run all modules">
+
+    <include name="common-compatibility-config" />
+    <option name="compatibility-build-provider:plan" value="everything" />
+
+    <option name="compatibility-test:include-filter" value=".*" />
+
+</configuration>
diff --git a/common/host-side/tradefed/res/report/compatibility-result.css b/common/host-side/tradefed/res/report/compatibility-result.css
new file mode 100644
index 0000000..c667e138
--- /dev/null
+++ b/common/host-side/tradefed/res/report/compatibility-result.css
@@ -0,0 +1,164 @@
+/* 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.
+*/
+
+body {
+    font-family:arial,sans-serif;
+    color:#000;
+    font-size:13px;
+    color:#333;
+    padding:10;
+    margin:10;
+}
+
+/* Report logo and device name */
+table.title {
+    padding:5px;
+    border-width: 0px;
+    margin-left:auto;
+    margin-right:auto;
+    vertical-align:middle;
+}
+
+table.summary {
+    background-color: rgb(212, 233, 169);
+    border-collapse:collapse;
+    border: 0px solid #A5C639;
+    margin-left:auto;
+    margin-right:auto;
+}
+
+table.summary th {
+    background-color: #A5C639;
+    font-size: 1.2em;
+    padding: 0.5em;
+}
+
+table.summary td {
+    border-width: 0px 0px 0px 0px;
+    border-color: gray;
+    border-style: inset;
+    font-size: 1em;
+    padding: 0.5em;
+    vertical-align: top;
+}
+
+table.testsummary {
+    background-color: rgb(212, 233, 169);
+    border-collapse:collapse;
+    margin-left:auto;
+    margin-right:auto;
+}
+
+table.testsummary th {
+    background-color: #A5C639;
+    border: 1px outset gray;
+    padding: 0.5em;
+}
+
+table.testsummary td {
+    border: 1px outset #A5C639;
+    padding: 0.5em;
+    text-align: center;
+}
+
+table.testdetails {
+    background-color: rgb(212, 233, 169);
+    border-collapse:collapse;
+    border-width:1;
+    border-color: #A5C639;
+    margin-left:auto;
+    margin-right:auto;
+    margin-bottom: 2em;
+    vertical-align: top;
+    width: 95%;
+}
+
+table.testdetails th {
+    background-color: #A5C639;
+    border-width: 1px;
+    border-color: gray;
+    border-style: outset;
+    height: 2em;
+    padding: 0.2em;
+}
+
+table.testdetails td {
+    border-width: 1px;
+    border-color: #A5C639;
+    border-style: outset;
+    text-align: left;
+    vertical-align: top;
+    padding: 0.2em;
+}
+
+table.testdetails td.module {
+    background-color: white;
+    border: 0px;
+    font-weight: bold;
+}
+
+/* Test cell details */
+td.failed {
+    background-color: #FA5858;
+    font-weight:bold;
+    vertical-align: top;
+    text-align: center;
+}
+
+td.failuredetails {
+    text-align: left;
+}
+
+td.pass {
+    text-align: center;
+    margin-left:auto;
+    margin-right:auto;
+}
+
+td.not-executed {
+    background-color: #A5C639;
+    vertical-align: top;
+    text-align: center;
+}
+
+td.testname {
+    border-width: 1px;
+    border-color: #A5C639;
+    border-style: outset;
+    text-align: left;
+    vertical-align: top;
+    padding:1;
+    overflow:hidden;
+}
+
+td.testcase {
+    border-width: 1px;
+    border-color: #A5C639;
+    border-style: outset;
+    text-align: left;
+    vertical-align: top;
+    padding:1;
+    overflow:hidden;
+    font-weight:bold;
+}
+
+div.details {
+    white-space: pre-wrap;       /* css-3 */
+    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
+    white-space: -pre-wrap;      /* Opera 4-6 */
+    white-space: -o-pre-wrap;    /* Opera 7 */
+    word-wrap: break-word;       /* Internet Explorer 5.5+ */
+    overflow:auto;
+}
diff --git a/common/host-side/tradefed/res/report/compatibility-result.xsd b/common/host-side/tradefed/res/report/compatibility-result.xsd
new file mode 100644
index 0000000..770ae5a
--- /dev/null
+++ b/common/host-side/tradefed/res/report/compatibility-result.xsd
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+ -->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           targetNamespace="http://compatibility.android.com/compatibility_result/1.15"
+           xmlns="http://compatibility.android.com/compatibility_result/1.15"
+           elementFormDefault="qualified">
+
+  <xs:element name="Result">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="Summary" type="summaryType"/>
+        <xs:element name="Module" type="moduleType" minOccurs="1" maxOccurs="unbounded"/>
+      </xs:sequence>
+      <xs:attribute name="start" type="xs:string"/>
+      <xs:attribute name="end" type="xs:string"/>
+      <xs:attribute name="plan" type="xs:string"/>
+      <xs:attribute name="suite-name" type="xs:string"/>
+      <xs:attribute name="suite-version" type="xs:string"/>
+    </xs:complexType>
+  </xs:element>
+
+  <xs:complexType name="summaryType">
+    <xs:attribute name="failed" type="xs:integer"/>
+    <xs:attribute name="not-executed" type="xs:integer"/>
+    <xs:attribute name="pass" type="xs:integer"/>
+  </xs:complexType>
+
+  <xs:complexType name="moduleType">
+    <xs:sequence>
+      <xs:element name="Test" type="testType" minOccurs="1" maxOccurs="unbounded" />
+    </xs:sequence>
+    <xs:attribute name="name" type="xs:string" use="required"/>
+    <xs:attribute name="abi" type="xs:string"/>
+  </xs:complexType>
+
+  <xs:simpleType name="unitType">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="none"/>
+      <xs:enumeration value="ms"/>
+      <xs:enumeration value="fps"/>
+      <xs:enumeration value="ops"/>
+      <xs:enumeration value="kbps"/>
+      <xs:enumeration value="mbps"/>
+      <xs:enumeration value="byte"/>
+      <xs:enumeration value="count"/>
+      <xs:enumeration value="score"/>
+    </xs:restriction>
+  </xs:simpleType>
+
+  <xs:simpleType name="scoreTypeType">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="higher-better"/>
+      <xs:enumeration value="lower-better"/>
+      <xs:enumeration value="neutral"/>
+      <xs:enumeration value="warning"/>
+    </xs:restriction>
+  </xs:simpleType>
+
+  <xs:complexType name="testType">
+    <xs:sequence>
+      <xs:element name="Failure" minOccurs="0" maxOccurs="1">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="StackTrace" type="xs:string" minOccurs="0" maxOccurs="1"/>
+          </xs:sequence>
+          <xs:attribute name="message" type="xs:string"/>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="Summary" minOccurs="0" maxOccurs="1">
+        <xs:complexType>
+          <xs:simpleContent>
+            <xs:extension base="xs:decimal">
+              <xs:attribute name="message" type="xs:string" use="required" />
+              <xs:attribute name="scoreType" type="scoreTypeType" use="required" />
+              <xs:attribute name="unit" type="unitType" use="required" />
+              <xs:attribute name="target" type="xs:decimal" />
+            </xs:extension>
+          </xs:simpleContent>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="Details" minOccurs="0" maxOccurs="1">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="ValueArray" minOccurs="0" maxOccurs="unbounded">
+              <xs:complexType>
+                <xs:sequence>
+                  <xs:element name="Value" type="xs:decimal" minOccurs="0" maxOccurs="unbounded" />
+                </xs:sequence>
+                <xs:attribute name="source" type="xs:string" use="required" />
+                <xs:attribute name="message" type="xs:string" use="required" />
+                <xs:attribute name="scoreType" type="scoreTypeType" use="required" />
+                <xs:attribute name="unit" type="unitType" use="required" />
+              </xs:complexType>
+            </xs:element>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+    <xs:attribute name="name" type="xs:string" use="required"/>
+    <xs:attribute name="result" type="resultType" use="required"/>
+    <xs:attribute name="start" type="xs:string"/>
+    <xs:attribute name="end" type="xs:string"/>
+  </xs:complexType>
+
+  <xs:simpleType name="resultType">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="pass"/>
+      <xs:enumeration value="fail"/>
+      <xs:enumeration value="not-executed"/>
+    </xs:restriction>
+  </xs:simpleType>
+</xs:schema>
\ No newline at end of file
diff --git a/common/host-side/tradefed/res/report/compatibility-result.xsl b/common/host-side/tradefed/res/report/compatibility-result.xsl
new file mode 100644
index 0000000..6334826
--- /dev/null
+++ b/common/host-side/tradefed/res/report/compatibility-result.xsl
@@ -0,0 +1,273 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#160;"> ]>
+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
+
+    <xsl:template match="/">
+
+        <html>
+            <head>
+                <title>Test Report</title>
+                <style type="text/css">
+                    @import "compatibility-result.css";
+                </style>
+            </head>
+            <body>
+                <div>
+                    <table class="title">
+                        <tr>
+                            <td width="40%" align="left"><img src="logo.png"></img></td>
+                            <td width="60%" align="left">
+                                <h1>Test Report</h1>
+                            </td>
+                        </tr>
+                    </table>
+                </div>
+                <img src="newrule-green.png" align="left"></img>
+
+                <br></br>
+
+                <center>
+                    <a href="device-info.xml" >Device Information</a>
+                </center>
+
+                <br></br>
+
+                <div>
+                    <table class="summary">
+                        <tr>
+                            <th colspan="2">Test Summary</th>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Compatibility Suite</td>
+                            <td>
+                                <xsl:value-of select="Result/@suite-name"/>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Compatibility Version</td>
+                            <td>
+                                <xsl:value-of select="Result/@suite-version"/>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Report Version</td>
+                            <td>
+                                <xsl:value-of select="Result/@report-version"/>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Host Info</td>
+                            <td>
+                                <xsl:value-of select="Result/@host-name"/>
+                                (<xsl:value-of select="Result/@os-name"/> - <xsl:value-of select="Result/@os-version"/>)
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Plan</td>
+                            <td>
+                                <xsl:value-of select="Result/@plan"/>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Start time</td>
+                            <td>
+                                <xsl:value-of select="Result/@start"/>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">End time</td>
+                            <td>
+                                <xsl:value-of select="Result/@end"/>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Tests Passed</td>
+                            <td>
+                                <xsl:value-of select="Result/Summary/@pass"/>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Tests Failed</td>
+                            <td>
+                                <xsl:value-of select="Result/Summary/@failed"/>
+                            </td>
+                        </tr>
+                        <tr>
+                            <td class="rowtitle">Tests Not Executed</td>
+                            <td>
+                                <xsl:value-of select="Result/Summary/@not-executed"/>
+                            </td>
+                        </tr>
+                    </table>
+                </div>
+
+                <!-- High level summary of test execution -->
+                <h2 align="center">Test Summary by Module</h2>
+                <div>
+                    <table class="testsummary">
+                        <tr>
+                            <th>Module</th>
+                            <th>Passed</th>
+                            <th>Failed</th>
+                            <th>Not Executed</th>
+                            <th>Total Tests</th>
+                        </tr>
+                        <xsl:for-each select="Result/Module">
+                            <tr>
+                                <td>
+                                    <xsl:variable name="href"><xsl:value-of select="@name"/> - <xsl:value-of select="@abi"/></xsl:variable>
+                                    <a href="#{$href}"><xsl:value-of select="@name"/> - <xsl:value-of select="@abi"/></a>
+                                </td>
+                                <td>
+                                    <xsl:value-of select="count(Test[@result = 'pass'])"/>
+                                </td>
+                                <td>
+                                    <xsl:value-of select="count(Test[@result = 'fail'])"/>
+                                </td>
+                                <td>
+                                    <xsl:value-of select="count(Test[@result = 'not-executed'])"/>
+                                </td>
+                                <td>
+                                    <xsl:value-of select="count(Test)"/>
+                                </td>
+                            </tr>
+                        </xsl:for-each> <!-- end Module -->
+                    </table>
+                </div>
+
+                <xsl:call-template name="filteredResultTestReport">
+                    <xsl:with-param name="header" select="'Failured Tests'" />
+                    <xsl:with-param name="resultFilter" select="'fail'" />
+                </xsl:call-template>
+
+                <xsl:call-template name="filteredResultTestReport">
+                    <xsl:with-param name="header" select="'Not Executed Tests'" />
+                    <xsl:with-param name="resultFilter" select="'not-executed'" />
+                </xsl:call-template>
+
+                <h2 align="center">Detailed Test Report</h2>
+                <xsl:call-template name="detailedTestReport" />
+
+            </body>
+        </html>
+    </xsl:template>
+
+    <xsl:template name="filteredResultTestReport">
+        <xsl:param name="header" />
+        <xsl:param name="resultFilter" />
+        <xsl:variable name="numMatching" select="count(Result/Module/Test[@result=$resultFilter])" />
+        <xsl:if test="$numMatching &gt; 0">
+            <h2 align="center"><xsl:value-of select="$header" /> (<xsl:value-of select="$numMatching"/>)</h2>
+            <xsl:call-template name="detailedTestReport">
+                <xsl:with-param name="resultFilter" select="$resultFilter"/>
+            </xsl:call-template>
+        </xsl:if>
+    </xsl:template>
+
+    <xsl:template name="detailedTestReport">
+        <xsl:param name="resultFilter" />
+        <div>
+            <xsl:for-each select="Result/Module">
+                <xsl:if test="$resultFilter=''
+                        or count(Test[@result=$resultFilter]) &gt; 0">
+
+                    <table class="testdetails">
+                        <tr>
+                            <td class="module" colspan="3">
+                                <xsl:variable name="href"><xsl:value-of select="@name"/> - <xsl:value-of select="@abi"/></xsl:variable>
+                                <a name="{$href}"><xsl:value-of select="@name"/> - <xsl:value-of select="@abi"/></a>
+                            </td>
+                        </tr>
+
+                        <tr>
+                            <th width="30%">Test</th>
+                            <th width="5%">Result</th>
+                            <th>Details</th>
+                        </tr>
+
+                        <!-- test -->
+                        <xsl:for-each select="Test">
+                            <xsl:if test="$resultFilter='' or $resultFilter=@result">
+                                <tr>
+                                    <td class="testname"> -- <xsl:value-of select="@name"/></td>
+
+                                    <!-- test results -->
+                                    <xsl:if test="@result='pass'">
+                                        <td class="pass">
+                                            <div style="text-align: center; margin-left:auto; margin-right:auto;">
+                                                <xsl:value-of select="@result"/>
+                                            </div>
+                                        </td>
+                                        <td class="failuredetails"/>
+                                    </xsl:if>
+
+                                    <xsl:if test="@result='fail'">
+                                        <td class="failed">
+                                            <div style="text-align: center; margin-left:auto; margin-right:auto;">
+                                                <xsl:value-of select="@result"/>
+                                            </div>
+                                        </td>
+                                        <td class="failuredetails">
+                                            <div class="details">
+                                                <xsl:value-of select="Failure/@message"/>
+                                            </div>
+                                        </td>
+                                    </xsl:if>
+
+                                    <xsl:if test="@result='not-executed'">
+                                        <td class="not-executed">
+                                            <div style="text-align: center; margin-left:auto; margin-right:auto;">
+                                                <xsl:value-of select="@result"/>
+                                            </div>
+                                        </td>
+                                        <td class="failuredetails"></td>
+                                    </xsl:if>
+                                </tr> <!-- finished with a row -->
+                            </xsl:if>
+                        </xsl:for-each> <!-- end test -->
+                    </table>
+                </xsl:if>
+            </xsl:for-each> <!-- end test Module -->
+        </div>
+    </xsl:template>
+
+    <!-- Take a delimited string and insert line breaks after a some number of elements. -->
+    <xsl:template name="formatDelimitedString">
+        <xsl:param name="string" />
+        <xsl:param name="numTokensPerRow" select="10" />
+        <xsl:param name="tokenIndex" select="1" />
+        <xsl:if test="$string">
+            <!-- Requires the last element to also have a delimiter after it. -->
+            <xsl:variable name="token" select="substring-before($string, ';')" />
+            <xsl:value-of select="$token" />
+            <xsl:text>&#160;</xsl:text>
+
+            <xsl:if test="$tokenIndex mod $numTokensPerRow = 0">
+                <br />
+            </xsl:if>
+
+            <xsl:call-template name="formatDelimitedString">
+                <xsl:with-param name="string" select="substring-after($string, ';')" />
+                <xsl:with-param name="numTokensPerRow" select="$numTokensPerRow" />
+                <xsl:with-param name="tokenIndex" select="$tokenIndex + 1" />
+            </xsl:call-template>
+        </xsl:if>
+    </xsl:template>
+
+</xsl:stylesheet>
diff --git a/common/host-side/tradefed/res/report/logo.png b/common/host-side/tradefed/res/report/logo.png
new file mode 100644
index 0000000..61970b3
--- /dev/null
+++ b/common/host-side/tradefed/res/report/logo.png
Binary files differ
diff --git a/common/host-side/tradefed/res/report/newrule-green.png b/common/host-side/tradefed/res/report/newrule-green.png
new file mode 100644
index 0000000..10a4194
--- /dev/null
+++ b/common/host-side/tradefed/res/report/newrule-green.png
Binary files differ
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildInfo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildInfo.java
new file mode 100644
index 0000000..12ce976
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildInfo.java
@@ -0,0 +1,116 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.build;
+
+import com.android.tradefed.build.FolderBuildInfo;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+/**
+ * A simple {@link FolderBuildInfo} that uses a pre-existing Compatibility install.
+ */
+public class CompatibilityBuildInfo extends FolderBuildInfo {
+
+    /** The root location of the extracted Compatibility package */
+    private final File mDir;
+    private final String mSuiteName;
+    private final String mSuiteFullName;
+    private final String mSuiteVersion;
+    private final String mSuitePlan;
+
+    /**
+     * Creates a {@link CompatibilityBuildInfo} containing information about the suite and
+     * invocation being run.
+     * @param buildId The id of the build in which this compatibility suite was made.
+     * @param suiteName The common name for the suite, often an abbreviation eg "CTS".
+     * @param suiteFullName The full name for the suite, eg "Compatibility Test Suite".
+     * @param suiteVersion The version string of this suite, eg "5.0.2_r8".
+     * @param suitePlan The suite plan to run in this invocation, found in the jar under "config/".
+     * @param rootDir the parent folder that contains the compatibility installation.
+     */
+    public CompatibilityBuildInfo(String buildId, String suiteName, String suiteFullName,
+            String suiteVersion, String suitePlan, File rootDir) {
+        super(buildId, suiteName, suitePlan);
+        mSuiteName = suiteName;
+        mSuiteFullName = suiteFullName;
+        mSuiteVersion = suiteVersion;
+        mSuitePlan = suitePlan;
+        setRootDir(rootDir);
+        mDir = new File(rootDir, String.format("android-%s", mSuiteName.toLowerCase()));
+    }
+
+    public String getSuiteName() {
+        return mSuiteName;
+    }
+
+    public String getSuiteFullName() {
+        return mSuiteFullName;
+    }
+
+    public String getSuiteVersion() {
+        return mSuiteVersion;
+    }
+
+    public String getSuitePlan() {
+        return mSuitePlan;
+    }
+
+    /**
+     * @return a {@link File} representing the "android-<suite>" folder of the Compatibility
+     * installation
+     * @throws FileNotFoundException if the directory does not exist
+     */
+    public File getDir() throws FileNotFoundException {
+        if (!mDir.exists()) {
+            throw new FileNotFoundException(String.format(
+                    "Compatibility install folder %s does not exist",
+                    mDir.getAbsolutePath()));
+        }
+        return mDir;
+    }
+
+    /**
+     * @return a {@link File} representing the results directory.
+     * @throws FileNotFoundException if the directory structure is not valid.
+     */
+    public File getResultsDir() throws FileNotFoundException {
+        return new File(getDir(), "results");
+    }
+
+    /**
+     * @return a {@link File} representing the directory to store result logs.
+     * @throws FileNotFoundException if the directory structure is not valid.
+     */
+    public File getLogsDir() throws FileNotFoundException {
+        return new File(getDir(), "logs");
+    }
+
+    /**
+     * @return a {@link File} representing the test modules directory.
+     * @throws FileNotFoundException if the directory structure is not valid.
+     */
+    public File getTestsDir() throws FileNotFoundException {
+        File testsDir = new File(getDir(), "testcases");
+        if (!testsDir.exists()) {
+            throw new FileNotFoundException(String.format(
+                    "Compatibility tests folder %s does not exist",
+                    testsDir.getAbsolutePath()));
+        }
+        return testsDir;
+    }
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java
new file mode 100644
index 0000000..fabd415
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProvider.java
@@ -0,0 +1,94 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.build;
+
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.build.IBuildProvider;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.config.Option.Importance;
+
+import java.io.File;
+
+/**
+ * A simple {@link IBuildProvider} that uses a pre-existing Compatibility install.
+ */
+@OptionClass(alias="compatibility-build-provider")
+public class CompatibilityBuildProvider implements IBuildProvider {
+
+    public static final String PLAN_OPTION = "plan";
+
+    private final String mBuildId;
+    private final String mSuiteName;
+    private final String mSuiteFullName;
+    private final String mSuiteVersion;
+
+    @Option(name = PLAN_OPTION,
+            description = "the test suite plan to run, such as \"everything\" or \"cts\"",
+            importance = Importance.ALWAYS)
+    private String mSuitePlan;
+
+    /**
+     * Creates a new {@link CompatibilityBuildProvider} which reads Test Suite-specific information
+     * from the jar's manifest file.
+     */
+    public CompatibilityBuildProvider() {
+        Package pkg = Package.getPackage("com.android.compatibility.tradefed.command");
+        mSuiteFullName = pkg.getSpecificationTitle();
+        mSuiteName = pkg.getSpecificationVendor();
+        mSuiteVersion = pkg.getSpecificationVersion();
+        mBuildId = pkg.getImplementationVersion();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IBuildInfo getBuild() {
+        return getCompatibilityBuild();
+    }
+
+    /**
+     * Returns the {@link CompatibilityBuildInfo} for this test suite.
+     *
+     * Note: this is a convenience method for {@code (CompatibilityBuildInfo) getBuild()}
+     */
+    public CompatibilityBuildInfo getCompatibilityBuild() {
+        String mRootDirPath = System.getProperty(String.format("%s_ROOT", mSuiteName));
+        if (mRootDirPath == null || mRootDirPath.equals("")) {
+            throw new IllegalArgumentException(
+                    String.format("Missing install path property %s_ROOT", mSuiteName));
+        }
+        return new CompatibilityBuildInfo(mBuildId, mSuiteName, mSuiteFullName, mSuiteVersion,
+                mSuitePlan, new File(mRootDirPath));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void buildNotTested(IBuildInfo info) {
+        // ignore
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void cleanUp(IBuildInfo info) {
+        // ignore
+    }
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
index dfd1c71..9941bda 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/command/CompatibilityConsole.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * 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.
@@ -13,19 +13,211 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.android.compatibility.common.tradefed.command;
 
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildProvider;
+import com.android.compatibility.common.tradefed.result.IInvocationResultRepo;
+import com.android.compatibility.common.tradefed.result.InvocationResultRepo;
+import com.android.compatibility.common.tradefed.testtype.ModuleRepo;
+import com.android.compatibility.common.util.IInvocationResult;
+import com.android.compatibility.common.util.TestStatus;
 import com.android.tradefed.command.Console;
-import com.android.tradefed.config.ConfigurationException;
+import com.android.tradefed.util.ArrayUtil;
+import com.android.tradefed.util.FileUtil;
+import com.android.tradefed.util.RegexTrie;
+import com.android.tradefed.util.TableFormatter;
+import com.android.tradefed.util.TimeUtil;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
 
 /**
  * An extension of Tradefed's console which adds features specific to compatibility testing.
  */
-public class CompatibilityConsole extends Console {
+public abstract class CompatibilityConsole extends Console {
 
-    public static void main(String[] args) throws InterruptedException, ConfigurationException {
-        CompatibilityConsole console = new CompatibilityConsole();
-        Console.startConsole(console, args);
+    private CompatibilityBuildInfo mBuild = null;
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void run() {
+        CompatibilityBuildInfo build = getCompatibilityBuild();
+        printLine(String.format("Android %s %s (%s)", build.getSuiteName(), build.getSuiteVersion(),
+                build.getBuildId()));
+        super.run();
     }
-}
+
+    /**
+     * Adds the 'list plans', 'list modules' and 'list results' commands
+     */
+    @Override
+    protected void setCustomCommands(RegexTrie<Runnable> trie, List<String> genericHelp,
+            Map<String, String> commandHelp) {
+        trie.put(new Runnable() {
+            @Override
+            public void run() {
+                CompatibilityBuildInfo build = getCompatibilityBuild();
+                if (build != null) {
+                    // TODO(stuartscott)" listPlans(build);
+                }
+            }
+        }, LIST_PATTERN, "p(?:lans)?");
+        trie.put(new Runnable() {
+            @Override
+            public void run() {
+                CompatibilityBuildInfo build = getCompatibilityBuild();
+                if (build != null) {
+                    listModules(build);
+                }
+            }
+        }, LIST_PATTERN, "m(?:odules)?");
+        trie.put(new Runnable() {
+            @Override
+            public void run() {
+                CompatibilityBuildInfo build = getCompatibilityBuild();
+                if (build != null) {
+                    listResults(build);
+                }
+            }
+        }, LIST_PATTERN, "r(?:esults)?");
+
+        // find existing help for 'LIST_PATTERN' commands, and append these commands help
+        String listHelp = commandHelp.get(LIST_PATTERN);
+        if (listHelp == null) {
+            // no help? Unexpected, but soldier on
+            listHelp = new String();
+        }
+        String combinedHelp = listHelp +
+                "\tp[lans]\tList all plans" + LINE_SEPARATOR +
+                "\tm[odules]\tList all modules" + LINE_SEPARATOR +
+                "\tr[esults]\tList all results" + LINE_SEPARATOR;
+        commandHelp.put(LIST_PATTERN, combinedHelp);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected String getConsolePrompt() {
+        return String.format("%s-tf > ", getCompatibilityBuild().getSuiteName().toLowerCase());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected String getGenericHelpString(List<String> genericHelp) {
+        CompatibilityBuildInfo build = getCompatibilityBuild();
+        StringBuilder helpBuilder = new StringBuilder();
+        helpBuilder.append(build.getSuiteFullName());
+        helpBuilder.append("\n\n");
+        helpBuilder.append(build.getSuiteName());
+        helpBuilder.append(" is the test harness for running the Android Compatibility Suite, ");
+        helpBuilder.append("built on top of Trade Federation.\n\n");
+        helpBuilder.append("Available commands and options\n");
+        helpBuilder.append("Host:\n");
+        helpBuilder.append("  help: show this message\n");
+        helpBuilder.append("  help all: show the complete tradefed help\n");
+        helpBuilder.append("  version: show the version\n");
+        helpBuilder.append("  exit: gracefully exit the compatibiltiy console, waiting until all ");
+        helpBuilder.append("invocations have completed\n");
+        helpBuilder.append("Run:\n");
+        final String runPrompt = "  run <plan> ";
+        helpBuilder.append(runPrompt);
+        helpBuilder.append("--module/-m <module>: run a test module\n");
+        helpBuilder.append(runPrompt);
+        helpBuilder.append("--module/-m <module> --test/-t <test_name>: run a specific test from");
+        helpBuilder.append(" the module. Test name can be <package>, ");
+        helpBuilder.append("<package>.<class>, <package>.<class>#<method> or <native_name>");
+        helpBuilder.append(runPrompt);
+        helpBuilder.append("--retry <session_id>: run all failed tests from a previous session\n");
+        helpBuilder.append(runPrompt);
+        helpBuilder.append("[options] --serial/-s <device_id>: run on the specified device\n");
+        helpBuilder.append(runPrompt);
+        helpBuilder.append("[options] --abi/-a <abi>: the ABI to run the test against\n");
+        helpBuilder.append(runPrompt);
+        helpBuilder.append("[options] --shard <shards>: shards a run into the given number of ");
+        helpBuilder.append("independent chunks, to run on multiple devices in parallel\n");
+        helpBuilder.append(runPrompt);
+        helpBuilder.append("--help/--help-all: get help for ");
+        helpBuilder.append(build.getSuiteFullName());
+        helpBuilder.append("\n");
+        helpBuilder.append("List:\n");
+        helpBuilder.append("  l/list d/devices: list connected devices and their state\n");
+        helpBuilder.append("  l/list m/modules: list test modules\n");
+        helpBuilder.append("  l/list i/invocations: list invocations aka test runs currently in ");
+        helpBuilder.append("progress\n");
+        helpBuilder.append("  l/list c/commands: list commands: aka test run commands currently");
+        helpBuilder.append("in the queue waiting to be allocated devices\n");
+        helpBuilder.append("  l/list r/results: list results currently in the repository\n");
+        helpBuilder.append("Dump:\n");
+        helpBuilder.append("  d/dump l/logs: dump the tradefed logs for all running invocations\n");
+        helpBuilder.append("Options:\n");
+        helpBuilder.append("  --disable-reboot : Do not reboot device after running some amount ");
+        helpBuilder.append(" of tests.\n");
+        return helpBuilder.toString();
+    }
+
+    private void listModules(CompatibilityBuildInfo build) {
+        File[] files = null;
+        try {
+            files = build.getTestsDir().listFiles(new ModuleRepo.ConfigFilter());
+        } catch (FileNotFoundException e) {
+            printLine(e.getMessage());
+            e.printStackTrace();
+        }
+        if (files != null && files.length > 0) {
+            for (File moduleFile : files) {
+                printLine(FileUtil.getBaseName(moduleFile.getName()));
+            }
+        } else {
+            printLine("No modules found");
+        }
+    }
+
+    private void listResults(CompatibilityBuildInfo build) {
+        TableFormatter tableFormatter = new TableFormatter();
+        List<List<String>> table = new ArrayList<>();
+        table.add(Arrays.asList("Session","Pass", "Fail", "Not Executed", "Start Time", "Test Plan",
+                "Device serial(s)"));
+        IInvocationResultRepo testResultRepo = null;
+        List<IInvocationResult> results = null;
+        try {
+            testResultRepo = new InvocationResultRepo(build.getResultsDir());
+            results = testResultRepo.getResults();
+        } catch (FileNotFoundException e) {
+            printLine(e.getMessage());
+            e.printStackTrace();
+        }
+        if (testResultRepo != null && results.size() > 0) {
+            for (int i = 0; i < results.size(); i++) {
+                IInvocationResult result = results.get(i);
+                table.add(Arrays.asList(Integer.toString(i),
+                        Integer.toString(result.countResults(TestStatus.PASS)),
+                        Integer.toString(result.countResults(TestStatus.FAIL)),
+                        Integer.toString(result.countResults(TestStatus.NOT_EXECUTED)),
+                        TimeUtil.formatTimeStamp(result.getStartTime()),
+                        result.getTestPlan(),
+                        ArrayUtil.join(", ", result.getDeviceSerials())));
+            }
+            tableFormatter.displayTable(table, new PrintWriter(System.out, true));
+        } else {
+            printLine(String.format("No results found"));
+        }
+    }
+
+    public CompatibilityBuildInfo getCompatibilityBuild() {
+        if (mBuild == null) {
+            mBuild = new CompatibilityBuildProvider().getCompatibilityBuild();
+        }
+        return mBuild;
+    }
+}
\ No newline at end of file
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IInvocationResultRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IInvocationResultRepo.java
new file mode 100644
index 0000000..c07223b0
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IInvocationResultRepo.java
@@ -0,0 +1,42 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.result;
+
+import com.android.compatibility.common.util.IInvocationResult;
+import com.android.compatibility.common.util.InvocationResult;
+
+import java.util.List;
+
+/**
+ * Repository for Compatibility results.
+ */
+public interface IInvocationResultRepo {
+
+    /**
+     * @return the list of {@link IInvocationResult}s. The index is its session id
+     */
+    List<IInvocationResult> getResults();
+
+    /**
+     * Get the {@link IInvocationResult} for given session id.
+     *
+     * @param sessionId the session id
+     * @return the {@link InvocationResult} or <code>null</null> if the result with that session id
+     * cannot be retrieved
+     */
+    IInvocationResult getResult(int sessionId);
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IModuleListener.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IModuleListener.java
new file mode 100644
index 0000000..213d293
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/IModuleListener.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.result;
+
+import com.android.tradefed.result.ITestInvocationListener;
+
+/**
+ * Listener for Compatibility tests.
+ * <p>
+ * This listener wraps around the normal listener to convert from module name to module id.
+ */
+public interface IModuleListener extends ITestInvocationListener {
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/InvocationResultRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/InvocationResultRepo.java
new file mode 100644
index 0000000..f714ba6
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/InvocationResultRepo.java
@@ -0,0 +1,63 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.result;
+
+import com.android.compatibility.common.util.IInvocationResult;
+import com.android.compatibility.common.util.XmlResultHandler;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An implementation of {@link IInvocationResultRepo}.
+ */
+public class InvocationResultRepo implements IInvocationResultRepo {
+
+    /**
+     * Ordered list of result directories. the index of each file is its session id.
+     */
+    private List<IInvocationResult> mResults;
+
+    /**
+     * Create a {@link InvocationResultRepo} from a directory of results
+     *
+     * @param testResultDir the parent directory of results
+     */
+    public InvocationResultRepo(File testResultDir) {
+        mResults = XmlResultHandler.getResults(testResultDir);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<IInvocationResult> getResults() {
+        return new ArrayList<IInvocationResult>(mResults);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IInvocationResult getResult(int sessionId) {
+        if (sessionId < 0 || sessionId >= mResults.size()) {
+            return null;
+        }
+        return mResults.get(sessionId);
+    }
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ModuleListener.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ModuleListener.java
new file mode 100644
index 0000000..5b2a3fe
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ModuleListener.java
@@ -0,0 +1,158 @@
+package com.android.compatibility.common.tradefed.result;
+
+import com.android.compatibility.common.tradefed.testtype.IModuleDef;
+import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.ITestInvocationListener;
+import com.android.tradefed.result.InputStreamSource;
+import com.android.tradefed.result.LogDataType;
+import com.android.tradefed.result.TestSummary;
+
+import java.util.Map;
+
+/**
+ * Listener for Compatibility test info.
+ * <p>
+ * This listener wraps around the normal listener to convert from module name to module id.
+ */
+public class ModuleListener implements IModuleListener {
+
+    private IModuleDef mModule;
+    private ITestInvocationListener mListener;
+
+    /**
+     * @param module
+     * @param listener
+     */
+    public ModuleListener(IModuleDef module, ITestInvocationListener listener) {
+        mModule = module;
+        mListener = listener;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void invocationStarted(IBuildInfo buildInfo) {
+        CLog.d("ModuleListener.invocationStarted(%s)", buildInfo.toString());
+        mListener.invocationStarted(buildInfo);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testRunStarted(String name, int numTests) {
+        CLog.d("ModuleListener.testRunStarted(%s, %d)", name, numTests);
+        mListener.testRunStarted(mModule.getId(), numTests);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testStarted(TestIdentifier test) {
+        CLog.d("ModuleListener.testStarted(%s)", test.toString());
+        mListener.testStarted(test);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testEnded(TestIdentifier test, Map<String, String> metrics) {
+        CLog.d("ModuleListener.testEnded(%s, %s)", test.toString(), metrics.toString());
+        mListener.testEnded(test, metrics);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testIgnored(TestIdentifier test) {
+        CLog.d("ModuleListener.testIgnored(%s)", test.toString());
+        mListener.testIgnored(test);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testFailed(TestIdentifier test, String trace) {
+        CLog.d("ModuleListener.testFailed(%s, %s)", test.toString(), trace);
+        mListener.testFailed(test, trace);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testAssumptionFailure(TestIdentifier test, String trace) {
+        CLog.d("ModuleListener.testAssumptionFailure(%s, %s)", test.toString(), trace);
+        mListener.testAssumptionFailure(test, trace);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testRunStopped(long elapsedTime) {
+        CLog.d("ModuleListener.testRunStopped(%d)", elapsedTime);
+        mListener.testRunStopped(elapsedTime);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testRunEnded(long elapsedTime, Map<String, String> metrics) {
+        CLog.d("ModuleListener.testRunEnded(%d, %s)", elapsedTime, metrics.toString());
+        mListener.testRunEnded(elapsedTime, metrics);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testRunFailed(String id) {
+        CLog.d("ModuleListener.testRunFailed(%s)", id);
+        mListener.testRunFailed(mModule.getId());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public TestSummary getSummary() {
+        return mListener.getSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void invocationEnded(long elapsedTime) {
+        CLog.d("ModuleListener.invocationEnded(%d)", elapsedTime);
+        mListener.invocationEnded(elapsedTime);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void invocationFailed(Throwable cause) {
+        CLog.d("ModuleListener.invocationFailed(%s)", cause.toString());
+        mListener.invocationFailed(cause);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testLog(String name, LogDataType type, InputStreamSource stream) {
+        CLog.d("ModuleListener.testLog(%s, %s, %s)", name, type.toString(), stream.toString());
+        mListener.testLog(name, type, stream);
+    }
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
new file mode 100644
index 0000000..c3de549
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ResultReporter.java
@@ -0,0 +1,368 @@
+package com.android.compatibility.common.tradefed.result;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.compatibility.common.tradefed.testtype.CompatibilityTest;
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.compatibility.common.util.ICaseResult;
+import com.android.compatibility.common.util.IInvocationResult;
+import com.android.compatibility.common.util.IModuleResult;
+import com.android.compatibility.common.util.ITestResult;
+import com.android.compatibility.common.util.InvocationResult;
+import com.android.compatibility.common.util.MetricsStore;
+import com.android.compatibility.common.util.ReportLog;
+import com.android.compatibility.common.util.TestStatus;
+import com.android.compatibility.common.util.XmlResultHandler;
+import com.android.ddmlib.Log;
+import com.android.ddmlib.Log.LogLevel;
+import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.config.Option.Importance;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.result.ITestInvocationListener;
+import com.android.tradefed.result.InputStreamSource;
+import com.android.tradefed.result.LogDataType;
+import com.android.tradefed.result.LogFileSaver;
+import com.android.tradefed.result.TestSummary;
+import com.android.tradefed.util.FileUtil;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Reporter for Compatibility test results.
+ */
+@OptionClass(alias="result-reporter")
+public class ResultReporter implements ITestInvocationListener {
+
+    private static final String RESULT_KEY = "COMPATIBILITY_TEST_RESULT";
+    private static final String DEVICE_INFO_COLLECTOR = "com.android.compatibility.deviceinfo";
+    private static final String[] RESULT_RESOURCES = {
+        "compatibility-result.css",
+        "compatibility-result.xsd",
+        "compatibility-result.xsl",
+        "logo.png",
+        "newrule-green.png"};
+
+    @Option(name = CompatibilityTest.RETRY_OPTION,
+            shortName = 'r',
+            description = "retry a previous session.",
+            importance = Importance.IF_UNSET)
+    private Integer mRetrySessionId = null;
+
+    private String mDeviceSerial;
+
+    private boolean mInitialized;
+    private IInvocationResult mResult;
+    private File mResultDir = null;
+    private File mLogDir = null;
+    private long mStartTime;
+    private boolean mIsDeviceInfoRun;
+    private IModuleResult mCurrentModuleResult;
+    private ICaseResult mCurrentCaseResult;
+    private ITestResult mCurrentResult;
+    private CompatibilityBuildInfo mBuild;
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void invocationStarted(IBuildInfo buildInfo) {
+        mInitialized = false;
+        mBuild = (CompatibilityBuildInfo) buildInfo;
+        mDeviceSerial = buildInfo.getDeviceSerial();
+        if (mDeviceSerial == null) {
+            mDeviceSerial = "unknown_device";
+        }
+        long time = System.currentTimeMillis();
+        String dirSuffix = getDirSuffix(time);
+        if (mRetrySessionId != null) {
+            Log.d(mDeviceSerial, String.format("Retrying session %d", mRetrySessionId));
+            List<IInvocationResult> results = null;
+            try {
+                results = XmlResultHandler.getResults(
+                        mBuild.getResultsDir());
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+            if (results != null && mRetrySessionId >= 0 && mRetrySessionId < results.size()) {
+                mResult = results.get(mRetrySessionId);
+            } else {
+                throw new IllegalArgumentException(
+                        String.format("Could not find session %d",mRetrySessionId));
+            }
+            mStartTime = mResult.getStartTime();
+            mResultDir = mResult.getResultDir();
+        } else {
+            mStartTime = time;
+            try {
+                mResultDir = new File(mBuild.getResultsDir(), dirSuffix);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+            if (mResultDir != null && mResultDir.mkdirs()) {
+                Log.logAndDisplay(LogLevel.INFO, mDeviceSerial,
+                        String.format("Created result dir %s", mResultDir.getAbsolutePath()));
+            } else {
+                throw new IllegalArgumentException(String.format("Could not create result dir %s",
+                        mResultDir.getAbsolutePath()));
+            }
+            mResult = new InvocationResult(mStartTime, mResultDir);
+        }
+        try {
+            mLogDir = new File(mBuild.getLogsDir(), dirSuffix);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+        if (mLogDir != null && mLogDir.mkdirs()) {
+            Log.logAndDisplay(LogLevel.INFO, mDeviceSerial,
+                    String.format("Created log dir %s", mLogDir.getAbsolutePath()));
+        } else {
+            throw new IllegalArgumentException(String.format("Could not create log dir %s",
+                    mLogDir.getAbsolutePath()));
+        }
+        mInitialized = true;
+    }
+
+    /**
+     * @return a {@link String} to use for directory suffixes created from the given time.
+     */
+    private String getDirSuffix(long time) {
+        return new SimpleDateFormat("yyyy.MM.dd_HH.mm.ss").format(new Date(time));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testRunStarted(String id, int numTests) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testRunStarted(%s, %d)", id, numTests));
+        mIsDeviceInfoRun = AbiUtils.parseTestName(id).equals(DEVICE_INFO_COLLECTOR);
+        if (!mIsDeviceInfoRun) {
+            mCurrentModuleResult = mResult.getOrCreateModule(id);
+            mCurrentModuleResult.setDeviceSerial(mDeviceSerial);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testStarted(TestIdentifier test) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testStarted(%s)", test));
+        if (!mIsDeviceInfoRun) {
+            mCurrentCaseResult = mCurrentModuleResult.getOrCreateResult(test.getClassName());
+            mCurrentResult = mCurrentCaseResult.getOrCreateResult(test.getTestName());
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testEnded(TestIdentifier test, Map<String, String> metrics) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testEnded(%s, %s)", test, metrics));
+        if (!mIsDeviceInfoRun) {
+            // device test can have performance results in test metrics
+            String perfResult = metrics.get(RESULT_KEY);
+            ReportLog report = null;
+            if (perfResult != null) {
+                try {
+                    report = ReportLog.parse(perfResult);
+                } catch (XmlPullParserException | IOException e) {
+                    e.printStackTrace();
+                }
+            } else {
+                // host test should be checked into MetricsStore.
+                report = MetricsStore.removeResult(
+                        mDeviceSerial, mCurrentModuleResult.getAbi(), test.toString());
+            }
+            mCurrentResult.passed(report);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testIgnored(TestIdentifier test) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testIgnored(%s)", test));
+        // ignore
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testFailed(TestIdentifier test, String trace) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testFailed(%s, %s)", test, trace));
+        if (!mIsDeviceInfoRun) {
+            mCurrentResult.failed(trace);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testAssumptionFailure(TestIdentifier test, String trace) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testAssumptionFailure(%s, %s)", test,
+                trace));
+        if (!mIsDeviceInfoRun) {
+            mCurrentResult.failed(trace);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testRunStopped(long elapsedTime) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testRunStopped(%d)", elapsedTime));
+        // ignore
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testRunEnded(long elapsedTime, Map<String, String> metrics) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testRunEnded(%d, %s)", elapsedTime,
+                metrics));
+        if (mIsDeviceInfoRun) {
+            mResult.populateDeviceInfoMetrics(metrics);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testRunFailed(String id) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testRunFailed(%s)", id));
+        // ignore
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public TestSummary getSummary() {
+        // ignore
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void invocationEnded(long elapsedTime) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.invocationEnded(%d)", elapsedTime));
+        if (mInitialized) {
+            Log.logAndDisplay(LogLevel.INFO, mDeviceSerial, String.format(
+                    "Invocation finished. Passed %d, Failed %d, Not Executed %d",
+                    mResult.countResults(TestStatus.PASS),
+                    mResult.countResults(TestStatus.FAIL),
+                    mResult.countResults(TestStatus.NOT_EXECUTED)));
+            try {
+                XmlResultHandler.writeResults(mBuild.getSuiteName(),
+                        mBuild.getSuiteVersion(), mBuild.getSuitePlan(), mResult,
+                        mResultDir, mStartTime, elapsedTime + mStartTime);
+                copyFormattingFiles(mResultDir);
+                zipResults(mResultDir);
+            } catch (IOException | XmlPullParserException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void invocationFailed(Throwable cause) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.invocationFailed(%s)", cause));
+        mInitialized = false;
+        // Clean up
+        mResultDir.delete();
+        mResultDir = null;
+        mLogDir.delete();
+        mLogDir = null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void testLog(String name, LogDataType type, InputStreamSource stream) {
+        Log.d(mDeviceSerial, String.format("ResultReporter.testLog(%s, %s, %s)", name, type,
+                stream));
+        try {
+            LogFileSaver saver = new LogFileSaver(mLogDir);
+            File logFile = saver.saveAndZipLogData(name, type, stream.createInputStream());
+            Log.i(mDeviceSerial, String.format("Saved logs for %s in %s", name,
+                    logFile.getAbsolutePath()));
+        } catch (IOException e) {
+            Log.e(mDeviceSerial, String.format("Failed to write log for %s", name));
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Copy the xml formatting files stored in this jar to the results directory
+     *
+     * @param resultsDir
+     */
+    static void copyFormattingFiles(File resultsDir) {
+        for (String resultFileName : RESULT_RESOURCES) {
+            InputStream configStream = XmlResultHandler.class.getResourceAsStream(
+                    String.format("/report/%s", resultFileName));
+            if (configStream != null) {
+                File resultFile = new File(resultsDir, resultFileName);
+                try {
+                    FileUtil.writeToFile(configStream, resultFile);
+                } catch (IOException e) {
+                    Log.w(ResultReporter.class.getSimpleName(),
+                            String.format("Failed to write %s to file", resultFileName));
+                }
+            } else {
+                Log.w(ResultReporter.class.getSimpleName(),
+                        String.format("Failed to load %s from jar", resultFileName));
+            }
+        }
+    }
+
+    /**
+     * Zip the contents of the given results directory.
+     *
+     * @param resultsDir
+     */
+    @SuppressWarnings("deprecation")
+    private static void zipResults(File resultsDir) {
+        try {
+            // create a file in parent directory, with same name as resultsDir
+            File zipResultFile = new File(resultsDir.getParent(), String.format("%s.zip",
+                    resultsDir.getName()));
+            FileUtil.createZip(resultsDir, zipResultFile);
+        } catch (IOException e) {
+            Log.w(ResultReporter.class.getSimpleName(),
+                    String.format("Failed to create zip for %s", resultsDir.getName()));
+        }
+    }
+
+    /**
+     * @return the mResult
+     */
+    public IInvocationResult getResult() {
+        return mResult;
+    }
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstaller.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstaller.java
new file mode 100644
index 0000000..9c73683
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstaller.java
@@ -0,0 +1,59 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.targetprep;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.targetprep.TargetSetupError;
+import com.android.tradefed.targetprep.TestAppInstallSetup;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+/**
+ * Installs specified APKs from Compatibility repository.
+ */
+@OptionClass(alias="apk-installer")
+public class ApkInstaller extends TestAppInstallSetup {
+
+    private CompatibilityBuildInfo mBuild = null;
+
+    protected CompatibilityBuildInfo getBuild(IBuildInfo buildInfo) {
+        if (mBuild == null) {
+            mBuild = (CompatibilityBuildInfo) buildInfo;
+        }
+        return mBuild;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected File getLocalPathForFilename(IBuildInfo buildInfo, String apkFileName)
+            throws TargetSetupError {
+        File apkFile = null;
+        try {
+            apkFile = new File(getBuild(buildInfo).getTestsDir(), apkFileName);
+            if (!apkFile.isFile()) {
+                throw new FileNotFoundException();
+            }
+        } catch (FileNotFoundException e) {
+            throw new TargetSetupError(String.format("%s not found", apkFileName), e);
+        }
+        return apkFile;
+    }
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/FilePusher.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/FilePusher.java
new file mode 100644
index 0000000..179f8e0
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/FilePusher.java
@@ -0,0 +1,53 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.targetprep;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.targetprep.PushFilePreparer;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+/**
+ * Pushes specified testing artifacts from Compatibility repository.
+ */
+@OptionClass(alias="file-pusher")
+public class FilePusher extends PushFilePreparer {
+
+    private CompatibilityBuildInfo mBuild;
+
+    protected CompatibilityBuildInfo getBuild(IBuildInfo buildInfo) {
+        if (mBuild == null) {
+            mBuild = (CompatibilityBuildInfo) buildInfo;
+        }
+        return mBuild;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public File resolveRelativeFilePath(IBuildInfo buildInfo, String fileName) {
+        try {
+            return new File(getBuild(buildInfo).getTestsDir(), fileName);
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/Abi.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/Abi.java
new file mode 100644
index 0000000..fab990e
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/Abi.java
@@ -0,0 +1,59 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.testtype;
+
+import com.android.tradefed.testtype.IAbi;
+
+/**
+ * A class representing an ABI.
+ *
+ * TODO(stuartscott): should be in TradeFed.
+ */
+public class Abi implements IAbi {
+
+    private final String mName;
+    private final String mBitness;
+
+    public Abi(String name, String bitness) {
+        mName = name;
+        mBitness = bitness;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getName() {
+        return mName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getBitness() {
+        return mBitness;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return mName;
+    }
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
new file mode 100644
index 0000000..273a2c8
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
@@ -0,0 +1,326 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.testtype;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.compatibility.common.tradefed.result.IInvocationResultRepo;
+import com.android.compatibility.common.tradefed.result.InvocationResultRepo;
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.compatibility.common.util.ICaseResult;
+import com.android.compatibility.common.util.IInvocationResult;
+import com.android.compatibility.common.util.IModuleResult;
+import com.android.compatibility.common.util.ITestResult;
+import com.android.compatibility.common.util.TestFilter;
+import com.android.compatibility.common.util.TestStatus;
+import com.android.ddmlib.Log.LogLevel;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.config.Option;
+import com.android.tradefed.config.Option.Importance;
+import com.android.tradefed.config.OptionClass;
+import com.android.tradefed.config.OptionCopier;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.ITestInvocationListener;
+import com.android.tradefed.testtype.IAbi;
+import com.android.tradefed.testtype.IBuildReceiver;
+import com.android.tradefed.testtype.IDeviceTest;
+import com.android.tradefed.testtype.IRemoteTest;
+import com.android.tradefed.testtype.IShardableTest;
+import com.android.tradefed.util.AbiFormatter;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A Test for running Compatibility Suites
+ */
+@OptionClass(alias="compatibility-test")
+public class CompatibilityTest implements IDeviceTest, IShardableTest, IBuildReceiver {
+
+    private static final String INCLUDE_FILTER_OPTION = "include-filter";
+    private static final String EXCLUDE_FILTER_OPTION = "exclude-filter";
+    private static final String MODULE_OPTION = "module";
+    private static final String TEST_OPTION = "test";
+    public static final String RETRY_OPTION = "retry";
+    private static final String ABI_OPTION = "abi";
+    private static final String SHARD_OPTION = "shard";
+    private static final TestStatus[] RETRY_TEST_STATUS = new TestStatus[] {
+        TestStatus.FAIL,
+        TestStatus.NOT_EXECUTED
+    };
+
+    @Option(name = INCLUDE_FILTER_OPTION,
+            description = "the include module filters to apply.",
+            importance = Importance.ALWAYS)
+    private List<String> mIncludeFilters = new ArrayList<>();
+
+    @Option(name = EXCLUDE_FILTER_OPTION,
+            description = "the exclude module filters to apply.",
+            importance = Importance.ALWAYS)
+    private List<String> mExcludeFilters = new ArrayList<>();
+
+    @Option(name = MODULE_OPTION,
+            shortName = 'm',
+            description = "the test module to run.",
+            importance = Importance.IF_UNSET)
+    private String mModuleName = null;
+
+    @Option(name = TEST_OPTION,
+            shortName = 't',
+            description = "the test run.",
+            importance = Importance.IF_UNSET)
+    private String mTestName = null;
+
+    @Option(name = RETRY_OPTION,
+            shortName = 'r',
+            description = "retry a previous session.",
+            importance = Importance.IF_UNSET)
+    private Integer mRetrySessionId = null;
+
+    @Option(name = ABI_OPTION,
+            shortName = 'a',
+            description = "the abi to test.",
+            importance = Importance.IF_UNSET)
+    private String mAbiName = null;
+
+    @Option(name = SHARD_OPTION,
+            description = "split the modules up to run on multiple devices concurrently.")
+    private int mShards = 1;
+
+    private int mShardAssignment;
+    private int mTotalShards;
+    private ITestDevice mDevice;
+    private CompatibilityBuildInfo mBuild;
+    private List<IModuleDef> mModules = new ArrayList<>();
+    private int mLastModuleIndex = 0;
+
+    /**
+     * Create a new {@link CompatibilityTest} that will run the default list of modules.
+     */
+    public CompatibilityTest() {
+        this(0 /*shardAssignment*/, 1 /*totalShards*/);
+    }
+
+    /**
+     * Create a new {@link CompatibilityTest} that will run a sublist of modules.
+     */
+    public CompatibilityTest(int shardAssignment, int totalShards) {
+        if (shardAssignment < 0) {
+            throw new IllegalArgumentException(
+                "shardAssignment cannot be negative. found:" + shardAssignment);
+        }
+        if (totalShards < 1) {
+            throw new IllegalArgumentException(
+                "shardAssignment must be at least 1. found:" + totalShards);
+        }
+        mShardAssignment = shardAssignment;
+        mTotalShards = totalShards;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ITestDevice getDevice() {
+        return mDevice;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setDevice(ITestDevice device) {
+        mDevice = device;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setBuild(IBuildInfo buildInfo) {
+        mBuild = (CompatibilityBuildInfo) buildInfo;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+        try {
+            Set<IAbi> abiSet = getAbis();
+            if (abiSet == null || abiSet.isEmpty()) {
+                if (mAbiName == null) {
+                    throw new IllegalArgumentException("Could not get device's ABIs");
+                } else {
+                    throw new IllegalArgumentException(String.format("Device %s does't support %s",
+                            mDevice.getSerialNumber(), mAbiName));
+                }
+            }
+            CLog.logAndDisplay(LogLevel.INFO, "ABIs: %s", abiSet);
+            setupTestModules(abiSet);
+
+            // Always collect the device info, even for resumed runs, since test will likely be
+            // running on a different device
+            //collectDeviceInfo(getDevice(), mBuildHelper, listener);
+
+            int moduleCount = mModules.size();
+            CLog.logAndDisplay(LogLevel.INFO, "Start test run of %d module%s", moduleCount,
+                    (moduleCount > 1) ? "s" : "");
+
+            for (int i = mLastModuleIndex; i < moduleCount; i++) {
+                IModuleDef module = mModules.get(i);
+                CLog.logAndDisplay(LogLevel.INFO, "Module: %s", module.getId());
+                module.setBuild(mBuild);
+                module.setDevice(mDevice);
+                module.run(listener);
+                // Track of the last complete test package index for resume
+                mLastModuleIndex = i;
+            }
+        } catch (DeviceNotAvailableException e) {
+            // Pass up
+            throw e;
+        } catch (RuntimeException e) {
+            CLog.logAndDisplay(LogLevel.ERROR, "Exception: %s", e.getMessage());
+            CLog.e(e);
+        } catch (Error e) {
+            CLog.logAndDisplay(LogLevel.ERROR, "Error: %s", e.getMessage());
+            CLog.e(e);
+        }
+    }
+
+    /**
+     * Set {@code mModules} to the list of test modules to run.
+     * @param abis
+     */
+    private void setupTestModules(Set<IAbi> abis) {
+        if (!mModules.isEmpty()) {
+            CLog.d("Resume tests using existing module list");
+            return;
+        }
+        if (mRetrySessionId != null) {
+            // We're retrying so clear the filters
+            mIncludeFilters.clear();
+            mExcludeFilters.clear();
+            mModuleName = null;
+            mTestName = null;
+            // Load the invocation result
+            IInvocationResultRepo repo;
+            IInvocationResult result = null;
+            try {
+                repo = new InvocationResultRepo(mBuild.getResultsDir());
+                result = repo.getResult(mRetrySessionId);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+            if (result == null) {
+                throw new IllegalArgumentException(String.format(
+                        "Could not find session with id %d", mRetrySessionId));
+            }
+            // Append each test that failed or was not executed to the filters
+            for (IModuleResult module : result.getModules()) {
+                for (ICaseResult cr : module.getResults()) {
+                    for (TestStatus status : RETRY_TEST_STATUS) {
+                        for (ITestResult r : cr.getResults(status)) {
+                            // Create the filter for the test to be run.
+                            mIncludeFilters.add(new TestFilter(module.getAbi(), module.getName(),
+                                    r.getFullName()).toString());
+                        }
+                    }
+                }
+            }
+        }
+        if (mModuleName != null) {
+            mIncludeFilters.clear();
+            mIncludeFilters.add(new TestFilter(mAbiName, mModuleName, mTestName).toString());
+            if (mTestName != null) {
+                // We're filtering it down to the lowest level, no need to give excludes
+                mExcludeFilters.clear();
+            } else {
+                // If we dont specify a test name, we only want to run this module with any
+                // exclusions defined by the plan as long as they dont exclude the whole module.
+                List<String> excludeFilters = new ArrayList<>();
+                for (String excludeFilter : mExcludeFilters) {
+                    TestFilter filter = TestFilter.createFrom(excludeFilter);
+                    String name = filter.getName();
+                    // Add the filter if it applies to this module, and it has a test name
+                    if ((mModuleName.equals(name) || mModuleName.matches(name) ||
+                            name.matches(mModuleName)) && filter.getTest() != null) {
+                        excludeFilters.add(excludeFilter);
+                    }
+                }
+                mExcludeFilters = excludeFilters;
+            }
+        }
+        // Collect ALL tests
+        IModuleRepo testRepo = new ModuleRepo(mBuild, abis);
+        List<IModuleDef> modules = testRepo.getModules(mIncludeFilters, mExcludeFilters);
+        // Filter by shard
+        int numTestmodules = modules.size();
+        int totalShards = Math.min(mTotalShards, numTestmodules);
+
+        mModules.clear();
+        for (int i = mShardAssignment; i < numTestmodules; i += totalShards) {
+            mModules.add(modules.get(i));
+        }
+    }
+
+    /**
+     * Gets the set of ABIs supported by both Compatibility and the device under test
+     * @return The set of ABIs to run the tests on
+     * @throws DeviceNotAvailableException
+     */
+    Set<IAbi> getAbis() throws DeviceNotAvailableException {
+        Set<IAbi> abis = new HashSet<>();
+        for (String abi : AbiFormatter.getSupportedAbis(mDevice, "")) {
+            // Only test against ABIs supported by Compatibility, and if the --abi option was given,
+            // it must match.
+            if (AbiUtils.isAbiSupportedByCompatibility(abi)
+                    && (mAbiName == null || mAbiName.equals(abi))) {
+                abis.add(new Abi(abi, AbiUtils.getBitness(abi)));
+            }
+        }
+        return abis;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Collection<IRemoteTest> split() {
+        if (mShards <= 1) {
+            return null;
+        }
+
+        List<IRemoteTest> shardQueue = new LinkedList<>();
+        for (int shardAssignment = 0; shardAssignment < mShards; shardAssignment++) {
+            CompatibilityTest test = new CompatibilityTest(shardAssignment, mShards /* total */);
+            OptionCopier.copyOptionsNoThrow(this, test);
+            // Set the shard count because the copy option on the previous line copies
+            // over the mShard value
+            test.mShards = 0;
+            shardQueue.add(test);
+        }
+
+        return shardQueue;
+    }
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
new file mode 100644
index 0000000..6555810
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
@@ -0,0 +1,78 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.testtype;
+
+import com.android.tradefed.targetprep.ITargetPreparer;
+import com.android.tradefed.testtype.IAbi;
+import com.android.tradefed.testtype.IBuildReceiver;
+import com.android.tradefed.testtype.IDeviceTest;
+import com.android.tradefed.testtype.IRemoteTest;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * Container for Compatibility test info.
+ */
+public interface IModuleDef extends Comparable<IModuleDef>, IBuildReceiver, IDeviceTest, IRemoteTest {
+
+    /**
+     * @return The name of this module.
+     */
+    String getName();
+
+    /**
+     * @return a {@link String} to uniquely identify this module.
+     */
+    String getId();
+
+    /**
+     * @return the abi of this test module.
+     */
+    IAbi getAbi();
+
+    /**
+     * @return a list of preparers used for setup or teardown of test cases in this module
+     */
+    List<ITargetPreparer> getPreparers();
+
+    /**
+     * @return a {@link List} of {@link IRemoteTest}s to run the test module.
+     */
+    List<IRemoteTest> getTests();
+
+    /**
+     * Adds a filter to include a specific test
+     *
+     * @param name the name of the test. Can be <package>, <package>.<class>,
+     * <package>.<class>#<method> or <native_name>
+     */
+    void addIncludeFilter(String name);
+
+    /**
+     * Adds a filter to exclude a specific test
+     *
+     * @param name the name of the test. Can be <package>, <package>.<class>,
+     * <package>.<class>#<method> or <native_name>
+     */
+    void addExcludeFilter(String name);
+
+    /**
+     * @return true iff this module's name matches the give regular expression pattern.
+     */
+    boolean nameMatches(Pattern pattern);
+
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java
new file mode 100644
index 0000000..40e944b
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleRepo.java
@@ -0,0 +1,65 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.testtype;
+
+import com.android.compatibility.common.util.AbiUtils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Interface for accessing tests from the Compatibility repository.
+ */
+public interface IModuleRepo {
+
+    /**
+     * Get a {@link IModuleDef} given an id.
+     *
+     * @param id the id of the module (created by {@link AbiUtils#createId(String, String)})
+     */
+    IModuleDef getModule(String id);
+
+    /**
+     * @return a {@link Map} of all modules in repo.
+     */
+    Map<String, IModuleDef> getModules();
+
+    /**
+     * @return a sorted {@link List} of {@link IModuleDef}s given the filters.
+     */
+    List<IModuleDef> getModules(List<String> includeFilters, List<String> excludeFilters);
+
+    /**
+     * @return a {@link Map} of all module in repo keyed by name.
+     */
+    Map<String, List<IModuleDef>> getModulesByName();
+
+    /**
+     * @return a sorted {@link List} of module names.
+     */
+    List<String> getModuleNames();
+
+    /**
+     * @return a {@link Set} of modules names that match the given regular expression.
+     */
+    Set<String> getModulesMatching(String regex);
+
+    /**
+     * @return a sorted {@link List} of module ids.
+     */
+    List<String> getModuleIds();
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
new file mode 100644
index 0000000..7b6ec51
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
@@ -0,0 +1,217 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.testtype;
+
+import com.android.compatibility.common.tradefed.result.IModuleListener;
+import com.android.compatibility.common.tradefed.result.ModuleListener;
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.device.ITestDevice;
+import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.result.ITestInvocationListener;
+import com.android.tradefed.targetprep.BuildError;
+import com.android.tradefed.targetprep.ITargetCleaner;
+import com.android.tradefed.targetprep.ITargetPreparer;
+import com.android.tradefed.targetprep.TargetSetupError;
+import com.android.tradefed.testtype.IAbi;
+import com.android.tradefed.testtype.IAbiReceiver;
+import com.android.tradefed.testtype.IBuildReceiver;
+import com.android.tradefed.testtype.IDeviceTest;
+import com.android.tradefed.testtype.IRemoteTest;
+import com.android.tradefed.testtype.ITestFilterReceiver;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * Container for Compatibility test module info.
+ */
+public class ModuleDef implements IModuleDef {
+
+    private final String mId;
+    private final String mName;
+    private final IAbi mAbi;
+    private List<IRemoteTest> mTests = null;
+    private List<ITargetPreparer> mPreparers = null;
+    private IBuildInfo mBuild;
+    private ITestDevice mDevice;
+    private List<String> mIncludeFilters = new ArrayList<>();
+    private List<String> mExcludeFilters = new ArrayList<>();
+
+    public ModuleDef(String name, IAbi abi, List<IRemoteTest> tests,
+            List<ITargetPreparer> preparers) {
+        mId = AbiUtils.createId(abi.getName(), name);
+        mName = name;
+        mAbi = abi;
+        mTests = tests;
+        mPreparers = preparers;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getId() {
+        return mId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getName() {
+        return mName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IAbi getAbi() {
+        return mAbi;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<IRemoteTest> getTests() {
+        return mTests;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<ITargetPreparer> getPreparers() {
+        return mPreparers;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addIncludeFilter(String filter) {
+        mIncludeFilters.add(filter);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addExcludeFilter(String filter) {
+        mExcludeFilters.add(filter);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int compareTo(IModuleDef moduleDef) {
+        return getName().compareTo(moduleDef.getName());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean nameMatches(Pattern pattern) {
+        return pattern.matcher(mName).matches();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setBuild(IBuildInfo build) {
+        mBuild = build;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ITestDevice getDevice() {
+        return mDevice;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setDevice(ITestDevice device) {
+        mDevice = device;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+        IModuleListener moduleListener = new ModuleListener(this, listener);
+
+        List<ITargetCleaner> cleaners = new ArrayList<>();
+        // Setup
+        for (ITargetPreparer preparer : mPreparers) {
+            CLog.d("Preparer: %s", preparer.getClass().getSimpleName());
+            if (preparer instanceof IAbiReceiver) {
+                ((IAbiReceiver) preparer).setAbi(mAbi);
+            }
+            if (preparer instanceof ITargetCleaner) {
+                cleaners.add((ITargetCleaner) preparer);
+            }
+            try {
+                preparer.setUp(mDevice, mBuild);
+            } catch (BuildError e) {
+                // This should only happen for flashing new build
+                CLog.e("Unexpected BuildError from preparer: %s",
+                    preparer.getClass().getCanonicalName());
+            } catch (TargetSetupError e) {
+                // log preparer class then rethrow & let caller handle
+                CLog.e("TargetSetupError in preparer: %s",
+                    preparer.getClass().getCanonicalName());
+                throw new RuntimeException(e);
+            }
+        }
+        // Run tests
+        for (IRemoteTest test : mTests) {
+            CLog.d("Test: %s", test.getClass().getSimpleName());
+            if (test instanceof IAbiReceiver) {
+                ((IAbiReceiver) test).setAbi(mAbi);
+            }
+            if (test instanceof IBuildReceiver) {
+                ((IBuildReceiver) test).setBuild(mBuild);
+            }
+            if (test instanceof IDeviceTest) {
+                ((IDeviceTest) test).setDevice(mDevice);
+            }
+            if (test instanceof ITestFilterReceiver) {
+                ((ITestFilterReceiver) test).addAllIncludeFilters(mIncludeFilters);
+                ((ITestFilterReceiver) test).addAllExcludeFilters(mExcludeFilters);
+            }
+            test.run(moduleListener);
+        }
+        // Tear down - in reverse order
+        Collections.reverse(cleaners);
+        for (ITargetCleaner cleaner : cleaners) {
+            CLog.d("Cleaner: %s", cleaner.getClass().getSimpleName());
+            cleaner.tearDown(mDevice, mBuild, null);
+        }
+    }
+}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
new file mode 100644
index 0000000..5ebfb51
--- /dev/null
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleRepo.java
@@ -0,0 +1,259 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.testtype;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.compatibility.common.util.TestFilter;
+import com.android.tradefed.config.Configuration;
+import com.android.tradefed.config.ConfigurationException;
+import com.android.tradefed.config.ConfigurationFactory;
+import com.android.tradefed.config.IConfigurationFactory;
+import com.android.tradefed.targetprep.ITargetPreparer;
+import com.android.tradefed.testtype.IAbi;
+import com.android.tradefed.testtype.IRemoteTest;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * Retrieves Compatibility test module definitions from the repository.
+ */
+public class ModuleRepo implements IModuleRepo {
+
+    private static final String CONFIG_EXT = ".config";
+
+    /** mapping of module id to definition */
+    private final Map<String, IModuleDef> mModules;
+    private final Set<IAbi> mAbis;
+
+    /**
+     * Creates a {@link ModuleRepo}, initialized from provided build
+     */
+    public ModuleRepo(CompatibilityBuildInfo build, Set<IAbi> abis) {
+        this(new HashMap<String, IModuleDef>(), abis);
+        try {
+            parse(build.getTestsDir());
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * Creates a {@link ModuleRepo}, initialized with the given modules
+     */
+    public ModuleRepo(Map<String, IModuleDef> modules, Set<IAbi> abis) {
+        mModules = modules;
+        mAbis = abis;
+    }
+
+    /**
+     * Builds mTestMap based on directory contents
+     */
+    private void parse(File dir) {
+        File[] configFiles = dir.listFiles(new ConfigFilter());
+        IConfigurationFactory configFactory = ConfigurationFactory.getInstance();
+        for (File configFile : configFiles) {
+            try {
+                // Invokes parser to process the test module config file
+                // Need to generate a different config for each ABI as we cannot guarantee the
+                // configs are idempotent. This however means we parse the same file multiple times.
+                for (IAbi abi : mAbis) {
+                    Configuration config = (Configuration) configFactory.createConfigurationFromArgs(
+                            new String[]{configFile.getAbsolutePath()});
+                    String name = configFile.getName().replace(CONFIG_EXT, "");
+                    List<IRemoteTest> tests = config.getTests();
+                    List<ITargetPreparer> preparers = config.getTargetPreparers();
+                    IModuleDef def = new ModuleDef(name, abi, tests, preparers);
+                    mModules.put(AbiUtils.createId(abi.getName(), name), def);
+                }
+            } catch (ConfigurationException e) {
+                throw new RuntimeException(String.format("error parsing config file: %s",
+                        configFile.getName()), e);
+            }
+        }
+    }
+
+    /**
+     * A {@link FilenameFilter} to find all the config files in a directory.
+     */
+    public static class ConfigFilter implements FilenameFilter {
+
+        /**
+         * {@inheritDoc}
+         */
+        @Override
+        public boolean accept(File dir, String name) {
+            return name.endsWith(CONFIG_EXT);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IModuleDef getModule(String id) {
+        return mModules.get(id);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Map<String, IModuleDef> getModules() {
+        return mModules;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Map<String, List<IModuleDef>> getModulesByName() {
+        Map<String, List<IModuleDef>> modules = new HashMap<>();
+        for (IModuleDef moduleDef : mModules.values()) {
+            String name = moduleDef.getName();
+            List<IModuleDef> defs = modules.get(name);
+            if (defs == null) {
+                defs = new ArrayList<IModuleDef>();
+                modules.put(name, defs);
+            }
+            defs.add(moduleDef);
+        }
+        return modules;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<String> getModuleIds() {
+        List<String> ids = new ArrayList<>(mModules.keySet());
+        Collections.sort(ids);
+        return ids;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<String> getModuleNames() {
+        Set<String> names = new HashSet<>();
+        for (IModuleDef moduleDef : mModules.values()) {
+            names.add(moduleDef.getName());
+        }
+        List<String> namesList = new ArrayList<>(names);
+        Collections.sort(namesList);
+        return namesList;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Set<String> getModulesMatching(String regex) {
+        Set<String> names = new HashSet<>();
+        Pattern pattern = Pattern.compile(regex);
+        for (IModuleDef moduleDef : mModules.values()) {
+            if (moduleDef.nameMatches(pattern)) {
+                names.add(moduleDef.getName());
+            }
+        }
+        return names;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<IModuleDef> getModules(List<String> includeFilters, List<String> excludeFilters) {
+        Map<String, IModuleDef> moduleDefs = new HashMap<>();
+        Set<String> ids;
+        // Include all the inclusions
+        for (String filterString : includeFilters) {
+            TestFilter filter = TestFilter.createFrom(filterString);
+            String test = filter.getTest();
+            ids = getAllIds(filter);
+            for (String id : ids) {
+                IModuleDef module = getModule(id);
+                if (test != null) {
+                    // We're including a subset of tests
+                    module.addIncludeFilter(test);
+                }
+                moduleDefs.put(id, module);
+            }
+        }
+        // Exclude all the exclusions
+        for (String filterString : includeFilters) {
+            TestFilter filter = TestFilter.createFrom(filterString);
+            String test = filter.getTest();
+            ids = getAllIds(filter);
+            // Iterate through all IDs
+            for (String id : ids) {
+                IModuleDef module = moduleDefs.get(id);
+                if (module != null) {
+                    if (test != null) {
+                        // Excluding a subset of tests, so keep module but give filter
+                        module.addExcludeFilter(test);
+                    } else {
+                        // Excluding all tests in the module so just remove the whole thing
+                        moduleDefs.remove(id);
+                    }
+                }
+            }
+        }
+        if (moduleDefs.isEmpty()) {
+            throw new IllegalStateException("Nothing to do. Use 'list modules' to see available"
+                    + " modules, and 'list results' to see available sessions to retry.");
+        }
+        // Note: run() relies on the fact that the list is reliably sorted for sharding purposes
+        List<IModuleDef> sortedModuleDefs = new ArrayList<>(moduleDefs.values());
+        Collections.sort(sortedModuleDefs);
+        return sortedModuleDefs;
+    }
+
+    /**
+     * Returns all IDs matching the given filter.
+     */
+    private Set<String> getAllIds(TestFilter filter) {
+        String abi = filter.getAbi();
+        String name = filter.getName();
+        Set<String> filteredNames = getModulesMatching(name);
+        if (filteredNames.isEmpty()) {
+            throw new IllegalArgumentException(String.format(
+                    "Not modules matching %s. Use 'list modules' to see available modules.",
+                    filter.getName()));
+        }
+        Set<String> ids = new HashSet<>();
+        for (String module : filteredNames) {
+            if (abi != null) {
+                ids.add(AbiUtils.createId(abi, module));
+            } else {
+                // ABI not specified, test on all ABIs
+                for (IAbi a : mAbis) ids.add(AbiUtils.createId(a.getName(), module));
+            }
+        }
+        return ids;
+    }
+}
diff --git a/tests/tests/acceleration/Android.mk b/common/host-side/tradefed/tests/Android.mk
similarity index 64%
copy from tests/tests/acceleration/Android.mk
copy to common/host-side/tradefed/tests/Android.mk
index d417371..959aff5 100644
--- a/tests/tests/acceleration/Android.mk
+++ b/common/host-side/tradefed/tests/Android.mk
@@ -1,10 +1,10 @@
-# Copyright (C) 2011 The Android Open Source Project
+# 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
+# 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,
@@ -16,18 +16,14 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
+LOCAL_MODULE := compatibility-tradefed-tests
 
-LOCAL_INSTRUMENTATION_FOR := CtsAccelerationTestStubs
+LOCAL_JAR_MANIFEST := MANIFEST.mf
 
-LOCAL_SDK_VERSION := current
+LOCAL_MODULE_TAGS := optional
 
-include $(BUILD_CTS_PACKAGE)
+LOCAL_JAVA_LIBRARIES := tradefed-prebuilt compatibility-tradefed junit compatibility-host-util
+
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/host-side/tradefed/tests/MANIFEST.mf b/common/host-side/tradefed/tests/MANIFEST.mf
new file mode 100644
index 0000000..017dc9f
--- /dev/null
+++ b/common/host-side/tradefed/tests/MANIFEST.mf
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Main-Class: com.android.compatibility.tradefed.command.MockConsole
+Specification-Title: Compatibility Tests
+Specification-Vendor: TESTS
+Specification-Version: 1
+Implementation-Version: 2
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildInfoTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildInfoTest.java
new file mode 100644
index 0000000..91dd539
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildInfoTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.build;
+
+import com.android.tradefed.util.FileUtil;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+public class CompatibilityBuildInfoTest extends TestCase {
+
+    private static final String BUILD_ID = "2";
+    private static final String SUITE_NAME = "TESTS";
+    private static final String SUITE_FULL_NAME = "Compatibility Tests";
+    private static final String SUITE_VERSION = "1";
+    private static final String SUITE_PLAN = "foobar";
+    private static final String ROOT_DIR_NAME = "root";
+    private static final String BASE_DIR_NAME = "android-tests";
+    private static final String TESTCASES = "testcases";
+
+    private File mRoot = null;
+    private File mBase = null;
+    private File mTests = null;
+
+    @Override
+    public void setUp() throws Exception {
+        mRoot = FileUtil.createTempDir(ROOT_DIR_NAME);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        FileUtil.recursiveDelete(mRoot);
+        mRoot = null;
+        mBase = null;
+        mTests = null;
+    }
+
+    private void createDirStructure() {
+        mBase = new File(mRoot, BASE_DIR_NAME);
+        mBase.mkdirs();
+        mTests = new File(mBase, TESTCASES);
+        mTests.mkdirs();
+    }
+
+    public void testValidation() throws Exception {
+        try {
+            CompatibilityBuildInfo build = new CompatibilityBuildInfo(
+                    BUILD_ID, SUITE_NAME, SUITE_FULL_NAME, SUITE_VERSION, SUITE_PLAN, mRoot);
+            build.getDir();
+            fail("Build helper validation succeeded on an invalid installation");
+        } catch (FileNotFoundException e) {
+            // Expected
+        }
+        createDirStructure();
+        try {
+            CompatibilityBuildInfo build = new CompatibilityBuildInfo(
+                    BUILD_ID, SUITE_NAME, SUITE_FULL_NAME, SUITE_VERSION, SUITE_PLAN, mRoot);
+            build.getTestsDir();
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+            fail("Build helper validation failed on a valid installation");
+        }
+    }
+
+    public void testDirs() throws Exception {
+        createDirStructure();
+        CompatibilityBuildInfo info = new CompatibilityBuildInfo(
+                BUILD_ID, SUITE_NAME, SUITE_FULL_NAME, SUITE_VERSION, SUITE_PLAN, mRoot);
+        assertNotNull(mRoot);
+        assertNotNull(info);
+        assertNotNull(info.getRootDir());
+        assertEquals("Incorrect root dir", mRoot.getAbsolutePath(),
+                info.getRootDir().getAbsolutePath());
+        assertEquals("Incorrect base dir", mBase.getAbsolutePath(),
+                info.getDir().getAbsolutePath());
+        assertEquals("Incorrect logs dir", new File(mBase, "logs").getAbsolutePath(),
+                info.getLogsDir().getAbsolutePath());
+        assertEquals("Incorrect tests dir", mTests.getAbsolutePath(),
+                info.getTestsDir().getAbsolutePath());
+        assertEquals("Incorrect results dir", new File(mBase, "results").getAbsolutePath(),
+                info.getResultsDir().getAbsolutePath());
+    }
+
+    public void testAccessors() throws Exception {
+        createDirStructure();
+        CompatibilityBuildInfo info = new CompatibilityBuildInfo(
+                BUILD_ID, SUITE_NAME, SUITE_FULL_NAME, SUITE_VERSION, SUITE_PLAN, mRoot);
+        assertEquals("Incorrect build id", BUILD_ID, info.getBuildId());
+        assertEquals("Incorrect suite name", SUITE_NAME, info.getSuiteName());
+        assertEquals("Incorrect suite full name", SUITE_FULL_NAME, info.getSuiteFullName());
+        assertEquals("Incorrect suite version", SUITE_VERSION, info.getSuiteVersion());
+        assertEquals("Incorrect suite plan", SUITE_PLAN, info.getSuitePlan());
+    }
+}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProviderTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProviderTest.java
new file mode 100644
index 0000000..eb334be
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/build/CompatibilityBuildProviderTest.java
@@ -0,0 +1,89 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.build;
+
+import com.android.compatibility.tradefed.command.MockConsole;
+import com.android.tradefed.config.OptionSetter;
+
+import junit.framework.TestCase;
+
+public class CompatibilityBuildProviderTest extends TestCase {
+
+    private static final String ROOT_PROPERTY = "TESTS_ROOT";
+    private static final String BUILD_ID = "2";
+    private static final String SUITE_NAME = "TESTS";
+    private static final String SUITE_FULL_NAME = "Compatibility Tests";
+    private static final String SUITE_VERSION = "1";
+    private static final String SUITE_PLAN = "foobar";
+
+    // Make sure the mock is in the ClassLoader
+    @SuppressWarnings("unused")
+    private MockConsole mMockConsole;
+
+    @Override
+    public void setUp() throws Exception {
+        mMockConsole = new MockConsole();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        setProperty(null);
+        mMockConsole = null;
+    }
+
+    public void testManifestLoad() throws Exception {
+        setProperty("/tmp/foobar");
+        CompatibilityBuildProvider provider = new CompatibilityBuildProvider();
+        OptionSetter setter = new OptionSetter(provider);
+        setter.setOptionValue(CompatibilityBuildProvider.PLAN_OPTION, SUITE_PLAN);
+        CompatibilityBuildInfo info = provider.getCompatibilityBuild();
+        assertEquals("Incorrect build id", BUILD_ID, info.getBuildId());
+        assertEquals("Incorrect suite name", SUITE_NAME, info.getSuiteName());
+        assertEquals("Incorrect suite full name", SUITE_FULL_NAME, info.getSuiteFullName());
+        assertEquals("Incorrect suite version", SUITE_VERSION, info.getSuiteVersion());
+        assertEquals("Incorrect suite plan", SUITE_PLAN, info.getSuitePlan());
+    }
+
+    public void testProperty() throws Exception {
+        setProperty(null);
+        CompatibilityBuildProvider provider = new CompatibilityBuildProvider();
+        try {
+            // Should fail with root unset
+            provider.getCompatibilityBuild();
+            fail("Expected fail for unset root property");
+        } catch (IllegalArgumentException e) {
+            /* expected */
+        }
+        setProperty("/tmp/foobar");
+        // Shouldn't fail with root set
+        provider.getCompatibilityBuild();
+    }
+
+    /**
+     * Sets the *_ROOT property of the build's installation location.
+     *
+     * @param value the value to set, or null to clear the property.
+     */
+    public static void setProperty(String value) {
+        if (value == null) {
+            System.clearProperty(ROOT_PROPERTY);
+        } else {
+            System.setProperty(ROOT_PROPERTY, value);
+        }
+    }
+
+}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/command/CompatibilityConsoleTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/command/CompatibilityConsoleTest.java
new file mode 100644
index 0000000..73caa6a
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/command/CompatibilityConsoleTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.command;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildProviderTest;
+import com.android.compatibility.tradefed.command.MockConsole;
+
+import junit.framework.TestCase;
+
+public class CompatibilityConsoleTest extends TestCase {
+
+    // Make sure the mock is in the ClassLoader
+    @SuppressWarnings("unused")
+    private MockConsole mMockConsole;
+
+    @Override
+    public void setUp() throws Exception {
+        CompatibilityBuildProviderTest.setProperty("/tmp/foobar");
+        mMockConsole = new MockConsole();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        CompatibilityBuildProviderTest.setProperty(null);
+        mMockConsole = null;
+    }
+
+    public void testHelpExists() throws Exception {
+        CompatibilityConsole console = new CompatibilityConsole() {};
+        assertFalse("No help", console.getGenericHelpString(null).isEmpty());
+    }
+
+    public void testPromptExists() throws Exception {
+        CompatibilityConsole console = new CompatibilityConsole() {};
+        assertFalse("No prompt", console.getConsolePrompt().isEmpty());
+    }
+}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java
new file mode 100644
index 0000000..cfc2ecd
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ResultReporterTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.result;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.compatibility.common.util.ICaseResult;
+import com.android.compatibility.common.util.IInvocationResult;
+import com.android.compatibility.common.util.IModuleResult;
+import com.android.compatibility.common.util.ITestResult;
+import com.android.compatibility.common.util.TestStatus;
+import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.tradefed.util.FileUtil;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.HashMap;
+import java.util.List;
+
+public class ResultReporterTest extends TestCase {
+
+    private static final String BUILD_ID = "2";
+    private static final String SUITE_NAME = "TESTS";
+    private static final String SUITE_FULL_NAME = "Compatibility Tests";
+    private static final String SUITE_VERSION = "1";
+    private static final String SUITE_PLAN = "foobar";
+    private static final String ROOT_DIR_NAME = "root";
+    private static final String BASE_DIR_NAME = "android-tests";
+    private static final String TESTCASES = "testcases";
+    private static final String NAME = "ModuleName";
+    private static final String ABI = "mips64";
+    private static final String ID = AbiUtils.createId(ABI, NAME);
+    private static final String CLASS = "android.test.FoorBar";
+    private static final String METHOD_1 = "testBlah1";
+    private static final String METHOD_2 = "testBlah2";
+    private static final String METHOD_3 = "testBlah3";
+    private static final String TEST_1 = String.format("%s#%s", CLASS, METHOD_1);
+    private static final String TEST_2 = String.format("%s#%s", CLASS, METHOD_2);
+    private static final String TEST_3 = String.format("%s#%s", CLASS, METHOD_3);
+    private static final String STACK_TRACE = "Something small is not alright\n " +
+            "at four.big.insects.Marley.sing(Marley.java:10)";
+    private static final String RESULT_DIR = "result123";
+    private static final String[] FORMATTING_FILES = {
+        "compatibility-result.css",
+        "compatibility-result.xsd",
+        "compatibility-result.xsl",
+        "logo.png",
+        "newrule-green.png"};
+
+    private ResultReporter mReporter;
+    private CompatibilityBuildInfo mBuild;
+
+    private File mRoot = null;
+    private File mBase = null;
+    private File mTests = null;
+
+    @Override
+    public void setUp() throws Exception {
+        mReporter = new ResultReporter();
+        mRoot = FileUtil.createTempDir(ROOT_DIR_NAME);
+        mBase = new File(mRoot, BASE_DIR_NAME);
+        mBase.mkdirs();
+        mTests = new File(mBase, TESTCASES);
+        mTests.mkdirs();
+        mBuild = new CompatibilityBuildInfo(
+                BUILD_ID, SUITE_NAME, SUITE_FULL_NAME, SUITE_VERSION, SUITE_PLAN, mRoot);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        mReporter = null;
+        FileUtil.recursiveDelete(mRoot);
+    }
+
+    public void testSetup() throws Exception {
+        mReporter.invocationStarted(mBuild);
+        // Should have created a directory for the results
+        File[] children = mBuild.getResultsDir().listFiles();
+        assertTrue("Didn't create results dir", children.length == 1 && children[0].isDirectory());
+        // Should have created a directory for the logs
+        children = mBuild.getResultsDir().listFiles();
+        assertTrue("Didn't create logs dir", children.length == 1 && children[0].isDirectory());
+        mReporter.invocationEnded(10);
+        // Should have created a zip file
+        children = mBuild.getResultsDir().listFiles(new FileFilter() {
+            @Override
+            public boolean accept(File pathname) {
+                return pathname.getName().endsWith(".zip");
+            }
+        });
+        assertTrue("Didn't create results zip",
+                children.length == 1 && children[0].isFile() && children[0].length() > 0);
+    }
+
+    public void testResultReporting() throws Exception {
+        mReporter.invocationStarted(mBuild);
+        mReporter.testRunStarted(ID, 2);
+        TestIdentifier test1 = new TestIdentifier(CLASS, METHOD_1);
+        mReporter.testStarted(test1);
+        mReporter.testEnded(test1, new HashMap<String, String>());
+        TestIdentifier test2 = new TestIdentifier(CLASS, METHOD_2);
+        mReporter.testStarted(test2);
+        mReporter.testFailed(test2, STACK_TRACE);
+        TestIdentifier test3 = new TestIdentifier(CLASS, METHOD_3);
+        mReporter.testStarted(test3);
+        mReporter.testFailed(test3, STACK_TRACE);
+        mReporter.testRunEnded(10, new HashMap<String, String>());
+        mReporter.invocationEnded(10);
+        IInvocationResult result = mReporter.getResult();
+        assertEquals("Expected 1 pass", 1, result.countResults(TestStatus.PASS));
+        assertEquals("Expected 2 failures", 2, result.countResults(TestStatus.FAIL));
+        List<IModuleResult> modules = result.getModules();
+        assertEquals("Expected 1 module", 1, modules.size());
+        IModuleResult module = modules.get(0);
+        assertEquals("Incorrect ID", ID, module.getId());
+        List<ICaseResult> caseResults = module.getResults();
+        assertEquals("Expected 1 test case", 1, caseResults.size());
+        ICaseResult caseResult = caseResults.get(0);
+        List<ITestResult> testResults = caseResult.getResults();
+        assertEquals("Expected 3 tests", 3, testResults.size());
+        ITestResult result1 = caseResult.getResult(METHOD_1);
+        assertNotNull(String.format("Expected result for %s", TEST_1), result1);
+        assertEquals(String.format("Expected pass for %s", TEST_1), TestStatus.PASS,
+                result1.getResultStatus());
+        ITestResult result2 = caseResult.getResult(METHOD_2);
+        assertNotNull(String.format("Expected result for %s", TEST_2), result2);
+        assertEquals(String.format("Expected fail for %s", TEST_2), TestStatus.FAIL,
+                result2.getResultStatus());
+        ITestResult result3 = caseResult.getResult(METHOD_3);
+        assertNotNull(String.format("Expected result for %s", TEST_3), result3);
+        assertEquals(String.format("Expected fail for %s", TEST_3), TestStatus.FAIL,
+                result3.getResultStatus());
+    }
+
+    public void testCopyFormattingFiles() throws Exception {
+        File resultDir = new File(mBuild.getResultsDir(), RESULT_DIR);
+        resultDir.mkdirs();
+        ResultReporter.copyFormattingFiles(resultDir);
+        for (String filename : FORMATTING_FILES) {
+            File file = new File(resultDir, filename);
+            assertTrue(String.format("%s (%s) was not created", filename, file.getAbsolutePath()),
+                    file.exists() && file.isFile() && file.length() > 0);
+        }
+    }
+}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTestTest.java
similarity index 66%
copy from common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java
copy to common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTestTest.java
index ab19369..ccab426 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTestTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * 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.
@@ -14,12 +14,18 @@
  * limitations under the License.
  */
 
-package com.android.compatibility.common.tradefed;
+package com.android.compatibility.common.tradefed.testtype;
 
 import junit.framework.TestCase;
 
-public class TradefedTest extends TestCase {
+public class CompatibilityTestTest extends TestCase {
 
-    // TODO(stuartscott): Add tests when there is something to test.
+    @Override
+    public void setUp() throws Exception {
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+    }
 
 }
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java
new file mode 100644
index 0000000..899ac2c
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java
@@ -0,0 +1,189 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.testtype;
+
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.ddmlib.testrunner.TestIdentifier;
+import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.result.ITestInvocationListener;
+import com.android.tradefed.result.InputStreamSource;
+import com.android.tradefed.result.LogDataType;
+import com.android.tradefed.result.TestSummary;
+import com.android.tradefed.targetprep.ITargetPreparer;
+import com.android.tradefed.testtype.IAbi;
+import com.android.tradefed.testtype.IRemoteTest;
+import com.android.tradefed.testtype.ITestFilterReceiver;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+public class ModuleDefTest extends TestCase {
+
+    private static final String NAME = "ModuleName";
+    private static final String ABI = "mips64";
+    private static final String ID = AbiUtils.createId(ABI, NAME);
+    private static final String CLASS = "android.test.FoorBar";
+    private static final String METHOD_1 = "testBlah1";
+    private static final String TEST_1 = String.format("%s#%s", CLASS, METHOD_1);
+
+    public void testAccessors() throws Exception {
+        IAbi abi = new Abi(ABI, "");
+        IModuleDef def = new ModuleDef(NAME, abi, new ArrayList<IRemoteTest>(),
+                new ArrayList<ITargetPreparer>());
+        assertEquals("Incorrect ID", ID, def.getId());
+        assertEquals("Incorrect ABI", ABI, def.getAbi().getName());
+        assertEquals("Incorrect Name", NAME, def.getName());
+        assertNotNull("Expected tests", def.getTests());
+        assertNotNull("Expected preparers", def.getPreparers());
+    }
+
+    public void testNameMatching() throws Exception {
+        IAbi abi = new Abi(ABI, "");
+        ModuleDef def = new ModuleDef(NAME, abi, new ArrayList<IRemoteTest>(),
+                new ArrayList<ITargetPreparer>());
+        assertTrue("Expected equality", def.nameMatches(Pattern.compile(NAME)));
+        assertTrue("Expected regex equality", def.nameMatches(Pattern.compile(".*")));
+        assertFalse("Expected no match to ID", def.nameMatches(Pattern.compile(ID)));
+        assertFalse("Expected no match to empty", def.nameMatches(Pattern.compile("")));
+    }
+
+    public void testAddFilters() throws Exception {
+        IAbi abi = new Abi(ABI, "");
+        List<IRemoteTest> tests = new ArrayList<>();
+        MockRemoteTest mockTest = new MockRemoteTest();
+        tests.add(mockTest);
+        ModuleDef def = new ModuleDef(NAME, abi, tests, new ArrayList<ITargetPreparer>());
+        def.addIncludeFilter(CLASS);
+        def.addExcludeFilter(TEST_1);
+        MockListener mockListener = new MockListener();
+        def.run(mockListener);
+        assertEquals("Expected one include filter", 1, mockTest.mIncludeFilters.size());
+        assertEquals("Expected one exclude filter", 1, mockTest.mExcludeFilters.size());
+        assertEquals("Incorrect include filter", CLASS, mockTest.mIncludeFilters.get(0));
+        assertEquals("Incorrect exclude filter", TEST_1, mockTest.mExcludeFilters.get(0));
+    }
+
+    private class MockRemoteTest implements IRemoteTest, ITestFilterReceiver {
+
+        private final List<String> mIncludeFilters = new ArrayList<>();
+        private final List<String> mExcludeFilters = new ArrayList<>();
+
+        @Override
+        public void addIncludeFilter(String filter) {
+            mIncludeFilters.add(filter);
+        }
+
+        @Override
+        public void addAllIncludeFilters(List<String> filters) {
+            mIncludeFilters.addAll(filters);
+        }
+
+        @Override
+        public void addExcludeFilter(String filter) {
+            mExcludeFilters.add(filter);
+        }
+
+        @Override
+        public void addAllExcludeFilters(List<String> filters) {
+            mExcludeFilters.addAll(filters);
+        }
+
+        @Override
+        public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
+            // Do nothing
+        }
+
+    }
+
+    private class MockListener implements ITestInvocationListener {
+
+        @Override
+        public void invocationStarted(IBuildInfo buildInfo) {
+            // Do nothing
+        }
+
+        @Override
+        public void testRunStarted(String name, int numTests) {
+            // Do nothing
+        }
+
+        @Override
+        public void testStarted(TestIdentifier test) {
+            // Do nothing
+        }
+
+        @Override
+        public void testEnded(TestIdentifier test, Map<String, String> metrics) {
+            // Do nothing
+        }
+
+        @Override
+        public void testIgnored(TestIdentifier test) {
+            // Do nothing
+        }
+
+        @Override
+        public void testFailed(TestIdentifier test, String trace) {
+            // Do nothing
+        }
+
+        @Override
+        public void testAssumptionFailure(TestIdentifier test, String trace) {
+            // Do nothing
+        }
+
+        @Override
+        public void testRunStopped(long elapsedTime) {
+            // Do nothing
+        }
+
+        @Override
+        public void testRunEnded(long elapsedTime, Map<String, String> metrics) {
+            // Do nothing
+        }
+
+        @Override
+        public void testRunFailed(String id) {
+            // Do nothing
+        }
+
+        @Override
+        public TestSummary getSummary() {
+            return null;
+        }
+
+        @Override
+        public void invocationEnded(long elapsedTime) {
+            // Do nothing
+        }
+
+        @Override
+        public void invocationFailed(Throwable cause) {
+            // Do nothing
+        }
+
+        @Override
+        public void testLog(String name, LogDataType type, InputStreamSource stream) {
+            // Do nothing
+        }
+    }
+}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleRepoTest.java
similarity index 67%
copy from common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java
copy to common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleRepoTest.java
index ab19369..bff1072 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleRepoTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * 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.
@@ -14,12 +14,18 @@
  * limitations under the License.
  */
 
-package com.android.compatibility.common.tradefed;
+package com.android.compatibility.common.tradefed.testtype;
 
 import junit.framework.TestCase;
 
-public class TradefedTest extends TestCase {
+public class ModuleRepoTest extends TestCase {
 
-    // TODO(stuartscott): Add tests when there is something to test.
+    @Override
+    public void setUp() throws Exception {
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+    }
 
 }
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/tradefed/command/MockConsole.java
similarity index 62%
copy from common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java
copy to common/host-side/tradefed/tests/src/com/android/compatibility/tradefed/command/MockConsole.java
index ab19369..20fab72 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/tradefed/command/MockConsole.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * 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.
@@ -13,13 +13,12 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package com.android.compatibility.tradefed.command;
 
-package com.android.compatibility.common.tradefed;
-
-import junit.framework.TestCase;
-
-public class TradefedTest extends TestCase {
-
-    // TODO(stuartscott): Add tests when there is something to test.
+/**
+ * This console is not used for any purpose other than creating the package name space from which
+ * the suite-specific values in the MANIFEST.mf can be read; replicating what a test suite.
+ */
+public class MockConsole {
 
 }
diff --git a/tests/tests/acceleration/Android.mk b/common/host-side/util/Android.mk
similarity index 61%
copy from tests/tests/acceleration/Android.mk
copy to common/host-side/util/Android.mk
index d417371..10ed127 100644
--- a/tests/tests/acceleration/Android.mk
+++ b/common/host-side/util/Android.mk
@@ -1,10 +1,10 @@
-# Copyright (C) 2011 The Android Open Source Project
+# 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
+# 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,
@@ -12,22 +12,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-common-util-hostsidelib
 
-LOCAL_INSTRUMENTATION_FOR := CtsAccelerationTestStubs
+LOCAL_MODULE := compatibility-host-util
 
-LOCAL_SDK_VERSION := current
+LOCAL_MODULE_TAGS := optional
 
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/common/util/src/com/android/compatibility/common/util/MetricsReportLog.java b/common/host-side/util/src/com/android/compatibility/common/util/MetricsReportLog.java
similarity index 100%
rename from common/util/src/com/android/compatibility/common/util/MetricsReportLog.java
rename to common/host-side/util/src/com/android/compatibility/common/util/MetricsReportLog.java
diff --git a/common/util/src/com/android/compatibility/common/util/MetricsStore.java b/common/host-side/util/src/com/android/compatibility/common/util/MetricsStore.java
similarity index 98%
rename from common/util/src/com/android/compatibility/common/util/MetricsStore.java
rename to common/host-side/util/src/com/android/compatibility/common/util/MetricsStore.java
index 9eeb94a..efe7182 100644
--- a/common/util/src/com/android/compatibility/common/util/MetricsStore.java
+++ b/common/host-side/util/src/com/android/compatibility/common/util/MetricsStore.java
@@ -28,6 +28,8 @@
     private static final ConcurrentHashMap<String, ReportLog> mMap =
             new ConcurrentHashMap<String, ReportLog>();
 
+    private MetricsStore() {}
+
     /**
      * Stores a result. Existing result with the same key will be replaced.
      * Note that key is generated in the form of device_serial#class#method name.
diff --git a/tests/tests/acceleration/Android.mk b/common/host-side/util/tests/Android.mk
similarity index 61%
copy from tests/tests/acceleration/Android.mk
copy to common/host-side/util/tests/Android.mk
index d417371..332d846 100644
--- a/tests/tests/acceleration/Android.mk
+++ b/common/host-side/util/tests/Android.mk
@@ -1,10 +1,10 @@
-# Copyright (C) 2011 The Android Open Source Project
+# 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
+# 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,
@@ -12,22 +12,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
+LOCAL_JAVA_LIBRARIES := compatibility-host-util junit
 
-LOCAL_INSTRUMENTATION_FOR := CtsAccelerationTestStubs
+LOCAL_MODULE := compatibility-host-util-tests
 
-LOCAL_SDK_VERSION := current
+LOCAL_MODULE_TAGS := optional
 
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/common/util/tests/src/com/android/compatibility/common/util/MetricsStoreTest.java b/common/host-side/util/tests/src/com/android/compatibility/common/util/MetricsStoreTest.java
similarity index 100%
rename from common/util/tests/src/com/android/compatibility/common/util/MetricsStoreTest.java
rename to common/host-side/util/tests/src/com/android/compatibility/common/util/MetricsStoreTest.java
diff --git a/common/host-side/xml-plan-generator/Android.mk b/common/host-side/xml-plan-generator/Android.mk
deleted file mode 100644
index 53718e5..0000000
--- a/common/host-side/xml-plan-generator/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_LIBRARIES := compatibility-common-util-hostsidelib_v2
-
-LOCAL_STATIC_JAVA_LIBRARIES := vogarexpectlib
-
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
-
-LOCAL_MODULE := compatibility-xml-plan-generator_v2
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-###############################################################################
-# Build the tests
-###############################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, tests/src)
-
-LOCAL_JAVA_LIBRARIES := compatibility-tradefed_v2 compatibility-xml-plan-generator_v2 junit
-
-LOCAL_MODULE := compatibility-xml-plan-generator-tests_v2
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/host-side/xml-plan-generator/MANIFEST.mf b/common/host-side/xml-plan-generator/MANIFEST.mf
deleted file mode 100644
index 95aee0d..0000000
--- a/common/host-side/xml-plan-generator/MANIFEST.mf
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.android.compatibility.common.xmlgenerator.XmlPlanGenerator
-Class-Path: compatibility-common-util-hostsidelib_v2.jar
diff --git a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/Test.java b/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/Test.java
deleted file mode 100644
index d3e1d88..0000000
--- a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/Test.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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 com.android.compatibility.common.xmlgenerator;
-
-public class Test {
-
-    private final String mName;
-
-    public Test(String name) {
-        mName = name;
-    }
-
-    public String getName() {
-        return mName;
-    }
-}
diff --git a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestCase.java b/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestCase.java
deleted file mode 100644
index 65b4aa3..0000000
--- a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestCase.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 com.android.compatibility.common.xmlgenerator;
-
-import java.util.ArrayList;
-
-public class TestCase {
-
-    private final String mName;
-    private final ArrayList<Test> mTests = new ArrayList<Test>();
-
-    public TestCase(String name) {
-        mName = name;
-    }
-
-    public void addTest(Test test) {
-        mTests.add(test);
-    }
-
-    public String getName() {
-        return mName;
-    }
-
-    public ArrayList<Test> getTests() {
-        return mTests;
-    }
-}
diff --git a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestListParser.java b/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestListParser.java
deleted file mode 100644
index 6880440..0000000
--- a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestListParser.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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 com.android.compatibility.common.xmlgenerator;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Scanner;
-
-/**
- * Parser of test lists in the form;
- *
- * suite:android.sample
- * case:SampleTest
- * test:testA
- * test:testB
- * suite:android.sample.ui
- * case:SampleUiTest
- * test:testA
- * test:testB
- */
-public class TestListParser {
-
-    private TestListParser() {}
-
-    public static HashMap<String, TestSuite> parse(InputStream input) {
-        final HashMap<String, TestSuite> suites = new HashMap<String, TestSuite>();
-        TestSuite currentSuite = null;
-        TestCase currentCase = null;
-        Scanner in = null;
-        try {
-            in = new Scanner(input);
-            while (in.hasNextLine()) {
-                final String line = in.nextLine();
-                final String[] parts = line.split(":");
-                if (parts.length != 2) {
-                    throw new RuntimeException("Invalid Format: " + line);
-                }
-                final String key = parts[0];
-                final String value = parts[1];
-                if (currentSuite == null) {
-                    if (!"suite".equals(key)) {
-                        throw new RuntimeException("TestSuite Expected");
-                    }
-                    final String[] names = value.split("\\.");
-                    for (int i = 0; i < names.length; i++) {
-                        final String name = names[i];
-                        if (currentSuite != null) {
-                            if (currentSuite.hasTestSuite(name)) {
-                                currentSuite = currentSuite.getTestSuite(name);
-                            } else {
-                                final TestSuite newSuite = new TestSuite(name);
-                                currentSuite.addTestSuite(newSuite);
-                                currentSuite = newSuite;
-                            }
-                        } else if (suites.containsKey(name)) {
-                            currentSuite = suites.get(name);
-                        } else {
-                            currentSuite = new TestSuite(name);
-                            suites.put(name, currentSuite);
-                        }
-                    }
-                } else if (currentCase == null) {
-                    if (!"case".equals(key)) {
-                        throw new RuntimeException("TestCase Expected");
-                    }
-                    currentCase = new TestCase(value);
-                    currentSuite.addTestCase(currentCase);
-                } else {
-                    if (!"test".equals(key)) {
-                        throw new RuntimeException("Test Expected");
-                    }
-                    currentCase.addTest(new Test(value));
-                }
-            }
-        } finally {
-            if (in != null) {
-                in.close();
-            }
-        }
-        return suites;
-    }
-}
diff --git a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestSuite.java b/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestSuite.java
deleted file mode 100644
index db4fd07..0000000
--- a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/TestSuite.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 com.android.compatibility.common.xmlgenerator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-public class TestSuite {
-
-    private final String mName;
-    private final HashMap<String, TestSuite> mTestSuites = new HashMap<String, TestSuite>();
-    private final ArrayList<TestCase> mTestCases = new ArrayList<TestCase>();
-
-    public TestSuite(String name) {
-        mName = name;
-    }
-
-    public boolean hasTestSuite(String name) {
-        return mTestSuites.containsKey(name);
-    }
-
-    public TestSuite getTestSuite(String name) {
-        return mTestSuites.get(name);
-    }
-
-    public void addTestSuite(TestSuite testSuite) {
-        mTestSuites.put(testSuite.getName(), testSuite);
-    }
-
-    public void addTestCase(TestCase testCase) {
-        mTestCases.add(testCase);
-    }
-
-    public String getName() {
-        return mName;
-    }
-
-    public HashMap<String, TestSuite> getTestSuites() {
-        return mTestSuites;
-    }
-
-    public ArrayList<TestCase> getTestCases() {
-        return mTestCases;
-    }
-}
diff --git a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/XmlPlanGenerator.java b/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/XmlPlanGenerator.java
deleted file mode 100644
index efb53d5..0000000
--- a/common/host-side/xml-plan-generator/src/com/android/compatibility/common/xmlgenerator/XmlPlanGenerator.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * 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 com.android.compatibility.common.xmlgenerator;
-
-import com.android.compatibility.common.util.KeyValueArgsParser;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import vogar.ExpectationStore;
-import vogar.ModeId;
-import vogar.Result;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-
-/**
- * Passes the scanner output and outputs an xml description of the tests.
- */
-public class XmlPlanGenerator {
-
-    private final ExpectationStore mExpectations;
-    private final String mAppNameSpace;
-    private final String mAppPackageName;
-    private final String mName;
-    private final String mRunner;
-    private final String mTargetBinaryName;
-    private final String mTargetNameSpace;
-    private final String mJarPath;
-    private final String mTestType;
-    private final String mOutput;
-
-    private XmlPlanGenerator(ExpectationStore expectations, String appNameSpace,
-            String appPackageName, String name, String runner, String targetBinaryName,
-            String targetNameSpace, String jarPath, String testType, String output) {
-        mExpectations = expectations;
-        mAppNameSpace = appNameSpace;
-        mAppPackageName = appPackageName;
-        mName = name;
-        mRunner = runner;
-        mTargetBinaryName = targetBinaryName;
-        mTargetNameSpace = targetNameSpace;
-        mJarPath = jarPath;
-        mTestType = testType;
-        mOutput = output;
-    }
-
-    private void writePackageXml() throws IOException {
-        OutputStream out = System.out;
-        if (mOutput != null) {
-            out = new FileOutputStream(mOutput);
-        }
-        PrintWriter writer = null;
-        try {
-            writer = new PrintWriter(out);
-            writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-            writeTestPackage(writer);
-        } finally {
-            if (writer != null) {
-                writer.close();
-            }
-        }
-    }
-
-    private void writeTestPackage(PrintWriter writer) {
-        writer.append("<TestPackage");
-        if (mAppNameSpace != null) {
-            writer.append(" appNameSpace=\"").append(mAppNameSpace).append("\"");
-        }
-
-        writer.append(" appPackageName=\"").append(mAppPackageName).append("\"");
-        writer.append(" name=\"").append(mName).append("\"");
-
-        if (mRunner != null) {
-            writer.append(" runner=\"").append(mRunner).append("\"");
-        }
-
-        if (mAppNameSpace != null && mTargetNameSpace != null
-                && !mAppNameSpace.equals(mTargetNameSpace)) {
-            writer.append(" targetBinaryName=\"").append(mTargetBinaryName).append("\"");
-            writer.append(" targetNameSpace=\"").append(mTargetNameSpace).append("\"");
-        }
-
-        if (mTestType != null && !mTestType.isEmpty()) {
-            writer.append(" testType=\"").append(mTestType).append("\"");
-        }
-
-        if (mJarPath != null) {
-            writer.append(" jarPath=\"").append(mJarPath).append("\"");
-        }
-
-        writer.println(" version=\"1.0\">");
-
-        final HashMap<String, TestSuite> suites = TestListParser.parse(System.in);
-        if (suites.isEmpty()) {
-            throw new RuntimeException("No TestSuites Found");
-        }
-        writeTestSuites(writer, suites, "");
-        writer.println("</TestPackage>");
-    }
-
-    private void writeTestSuites(PrintWriter writer, HashMap<String, TestSuite> suites, String name) {
-        for (String suiteName : suites.keySet()) {
-            final TestSuite suite = suites.get(suiteName);
-            writer.append("<TestSuite name=\"").append(suiteName).println("\">");
-            final String fullname = name + suiteName + ".";
-            writeTestSuites(writer, suite.getTestSuites(), fullname);
-            writeTestCases(writer, suite.getTestCases(), fullname);
-            writer.println("</TestSuite>");
-        }
-    }
-
-    private void writeTestCases(PrintWriter writer, ArrayList<TestCase> cases, String name) {
-        for (TestCase testCase : cases) {
-            final String caseName = testCase.getName();
-            writer.append("<TestCase name=\"").append(caseName).println("\">");
-            final String fullname = name + caseName;
-            writeTests(writer, testCase.getTests(), fullname);
-            writer.println("</TestCase>");
-        }
-    }
-
-    private void writeTests(PrintWriter writer, ArrayList<Test> tests, String name) {
-        if (tests.isEmpty()) {
-            throw new RuntimeException("No Tests Found");
-        }
-        for (Test test : tests) {
-            final String testName = test.getName();
-            writer.append("<Test name=\"").append(testName).append("\"");
-            final String fullname = name + "#" + testName;
-            if (isKnownFailure(mExpectations, fullname)) {
-                writer.append(" expectation=\"failure\"");
-            }
-            writer.println(" />");
-        }
-    }
-
-    public static boolean isKnownFailure(ExpectationStore store, String fullname) {
-        return store != null && store.get(fullname).getResult() != Result.SUCCESS;
-    }
-
-    public static void main(String[] args) throws Exception {
-        final HashMap<String, String> argsMap = KeyValueArgsParser.parse(args);
-        final String packageName = argsMap.get("-p");
-        final String name = argsMap.get("-n");
-        final String testType = argsMap.get("-t");
-        final String jarPath = argsMap.get("-j");
-        final String instrumentation = argsMap.get("-i");
-        final String manifest = argsMap.get("-m");
-        final String expectations = argsMap.get("-e");
-        final String output = argsMap.get("-o");
-        String appNameSpace = argsMap.get("-a");
-        String targetNameSpace = argsMap.get("-r");
-        if (packageName == null || name == null) {
-            usage(args);
-        }
-        String runner = null;
-        if (manifest != null) {
-            Document m = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(manifest);
-            Element elem = m.getDocumentElement();
-            appNameSpace = elem.getAttribute("package");
-            runner = getElementAttribute(elem, "instrumentation", "android:name");
-            targetNameSpace = getElementAttribute(elem, "instrumentation", "android:targetPackage");
-        }
-
-        final HashSet<File> expectationFiles = new HashSet<File>();
-        if (expectations != null) {
-            expectationFiles.add(new File(expectations));
-        }
-        final ExpectationStore store = ExpectationStore.parse(expectationFiles, ModeId.DEVICE);
-        XmlPlanGenerator generator = new XmlPlanGenerator(store, appNameSpace, packageName, name,
-            runner, instrumentation, targetNameSpace, jarPath, testType, output);
-        generator.writePackageXml();
-    }
-
-    private static String getElementAttribute(Element parent, String elem, String name) {
-        NodeList nodeList = parent.getElementsByTagName(elem);
-        if (nodeList.getLength() > 0) {
-             Element element = (Element) nodeList.item(0);
-             return element.getAttribute(name);
-        }
-        return null;
-    }
-
-    private static void usage(String[] args) {
-        System.err.println("Arguments: " + Arrays.toString(args));
-        System.err.println("Usage: compatibility-xml-plan-generator -p PACKAGE_NAME -n NAME" +
-            "[-t TEST_TYPE] [-j JAR_PATH] [-i INSTRUMENTATION] [-m MANIFEST] [-e EXPECTATIONS]" +
-            "[-o OUTPUT]");
-        System.exit(1);
-    }
-}
diff --git a/common/host-side/xml-plan-generator/tests/src/com/android/compatibility/common/xmlgenerator/XmlPlanGeneratorTest.java b/common/host-side/xml-plan-generator/tests/src/com/android/compatibility/common/xmlgenerator/XmlPlanGeneratorTest.java
deleted file mode 100644
index 082af17..0000000
--- a/common/host-side/xml-plan-generator/tests/src/com/android/compatibility/common/xmlgenerator/XmlPlanGeneratorTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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 com.android.compatibility.common.xmlgenerator;
-
-import junit.framework.TestCase;
-
-import java.io.ByteArrayInputStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Scanner;
-
-public class XmlPlanGeneratorTest extends TestCase {
-
-    private static final String JAR = "out/host/linux-x86/framework/compatibility-xml-plan-generator_v2.jar";
-    private static final String PACKAGE_NAME = "com.android.test";
-    private static final String NAME = "ValidTest";
-    private static final String VALID_RESULT =
-        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-        "<TestPackage appPackageName=\"com.android.test\" name=\"ValidTest\" version=\"1.0\">" +
-        "<TestSuite name=\"com\">" +
-        "<TestSuite name=\"android\">" +
-        "<TestSuite name=\"test\">" +
-        "<TestCase name=\"ValidTest\">" +
-        "<Test name=\"testA\" />" +
-        "</TestCase>" +
-        "</TestSuite>" +
-        "</TestSuite>" +
-        "</TestSuite>" +
-        "</TestPackage>";
-
-    private static final String VALID =
-        "suite:com.android.test\n" +
-        "case:ValidTest\n" +
-        "test:testA\n";
-
-    private static final String INVALID_A = "";
-
-    private static final String INVALID_B =
-        "suite:com.android.test\n" +
-        "case:InvalidTest\n";
-
-    private static final String INVALID_C =
-        "uh oh";
-
-    private static final String INVALID_D =
-        "test:testA\n" +
-        "case:InvalidTest\n" +
-        "suite:com.android.test\n";
-
-    private static final String INVALID_E =
-        "suite:com.android.test\n" +
-        "test:testA\n" +
-        "case:InvalidTest\n";
-
-    public void testValid() throws Exception {
-        assertEquals(VALID_RESULT, runGenerator(VALID));
-    }
-
-    public void testInvalidA() throws Exception {
-        assertNull(runGenerator(INVALID_A));
-    }
-
-    public void testInvalidB() throws Exception {
-        assertNull(runGenerator(INVALID_B));
-    }
-
-    public void testTestListParserInvalidFormat() throws Exception {
-        runTestListParser(INVALID_C);
-    }
-
-    public void testTestListParserSuiteExpected() throws Exception {
-        runTestListParser(INVALID_D);
-    }
-
-    public void testTestListParserCaseExpected() throws Exception {
-        runTestListParser(INVALID_E);
-    }
-
-    private static String runGenerator(String input) throws Exception {
-        ArrayList<String> args = new ArrayList<String>();
-        args.add("java");
-        args.add("-jar");
-        args.add(JAR);
-        args.add("-p");
-        args.add(PACKAGE_NAME);
-        args.add("-n");
-        args.add(NAME);
-
-        final Process p = new ProcessBuilder(args).start();
-        final PrintWriter out = new PrintWriter(p.getOutputStream());
-        out.print(input);
-        out.flush();
-        out.close();
-        final StringBuilder output = new StringBuilder();
-        final Scanner in = new Scanner(p.getInputStream());
-        while (in.hasNextLine()) {
-            output.append(in.nextLine());
-        }
-        int ret = p.waitFor();
-        if (ret == 0) {
-            return output.toString();
-        }
-        return null;
-    }
-
-    private static void runTestListParser(String input) throws Exception {
-        try {
-            final ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes());
-            final HashMap<String, TestSuite> suites = TestListParser.parse(in);
-            fail();
-        } catch (RuntimeException e) {}
-    }
-}
diff --git a/common/util/Android.mk b/common/util/Android.mk
index 84ced65..2d4220f 100644
--- a/common/util/Android.mk
+++ b/common/util/Android.mk
@@ -24,7 +24,7 @@
 
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_MODULE := compatibility-common-util-devicesidelib_v2
+LOCAL_MODULE := compatibility-common-util-devicesidelib
 
 LOCAL_SDK_VERSION := current
 
@@ -40,27 +40,10 @@
 
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_MODULE := compatibility-common-util-hostsidelib_v2
+LOCAL_MODULE := compatibility-common-util-hostsidelib
 
 LOCAL_STATIC_JAVA_LIBRARIES := kxml2-2.3.0
 
 include $(BUILD_HOST_JAVA_LIBRARY)
 
-###############################################################################
-# Build the tests
-###############################################################################
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, tests/src)
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-                        junit \
-                        kxml2-2.3.0 \
-                        compatibility-common-util-hostsidelib_v2
-
-LOCAL_MODULE := compatibility-common-util-tests_v2
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
+include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file
diff --git a/common/util/run_unit_tests.sh b/common/util/run_unit_tests.sh
deleted file mode 100755
index 04a6745..0000000
--- a/common/util/run_unit_tests.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2012 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.
-
-# helper script for running the cts common unit tests
-
-checkFile() {
-    if [ ! -f "$1" ]; then
-        echo "Unable to locate $1"
-        exit
-    fi;
-}
-
-# check if in Android build env
-if [ ! -z ${ANDROID_BUILD_TOP} ]; then
-    HOST=`uname`
-    if [ "$HOST" == "Linux" ]; then
-        OS="linux-x86"
-    elif [ "$HOST" == "Darwin" ]; then
-        OS="darwin-x86"
-    else
-        echo "Unrecognized OS"
-        exit
-    fi;
-fi;
-
-JAR_DIR=${ANDROID_BUILD_TOP}/out/host/$OS/framework
-JARS="tradefed-prebuilt.jar compatibility-common-util-hostsidelib_v2.jar compatibility-common-util-tests_v2.jar"
-
-for JAR in $JARS; do
-    checkFile ${JAR_DIR}/${JAR}
-    JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
-done
-
-java $RDBG_FLAG \
-  -cp ${JAR_PATH} com.android.tradefed.command.Console run singleCommand host -n --class com.android.compatibility.common.util.UnitTests "$@"
-
diff --git a/libs/commonutil/src/com/android/cts/util/AbiUtils.java b/common/util/src/com/android/compatibility/common/util/AbiUtils.java
similarity index 82%
rename from libs/commonutil/src/com/android/cts/util/AbiUtils.java
rename to common/util/src/com/android/compatibility/common/util/AbiUtils.java
index 42336f3..ef42a00 100644
--- a/libs/commonutil/src/com/android/cts/util/AbiUtils.java
+++ b/common/util/src/com/android/compatibility/common/util/AbiUtils.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.util;
+package com.android.compatibility.common.util;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -51,9 +51,9 @@
     private static final Set<String> MIPS_ABIS = new HashSet<String>();
 
     /**
-     * The set of ABI names which CTS supports.
+     * The set of ABI names which Compatibility supports.
      */
-    private static final Set<String> ABIS_SUPPORTED_BY_CTS = new HashSet<String>();
+    private static final Set<String> ABIS_SUPPORTED_BY_COMPATIBILITY = new HashSet<String>();
 
     /**
      * The map of architecture to ABI.
@@ -84,9 +84,9 @@
         ARCH_TO_ABIS.put("mips", MIPS_ABIS);
         ARCH_TO_ABIS.put("mips64", MIPS_ABIS);
 
-        ABIS_SUPPORTED_BY_CTS.addAll(ARM_ABIS);
-        ABIS_SUPPORTED_BY_CTS.addAll(INTEL_ABIS);
-        ABIS_SUPPORTED_BY_CTS.addAll(MIPS_ABIS);
+        ABIS_SUPPORTED_BY_COMPATIBILITY.addAll(ARM_ABIS);
+        ABIS_SUPPORTED_BY_COMPATIBILITY.addAll(INTEL_ABIS);
+        ABIS_SUPPORTED_BY_COMPATIBILITY.addAll(MIPS_ABIS);
     }
 
     /**
@@ -101,25 +101,25 @@
      */
     public static Set<String> getAbisForArch(String arch) {
         if (arch == null || arch.isEmpty() || !ARCH_TO_ABIS.containsKey(arch)) {
-            return getAbisSupportedByCts();
+            return getAbisSupportedByCompatibility();
         }
         return new HashSet<String>(ARCH_TO_ABIS.get(arch));
     }
 
     /**
-     * Returns the set of ABIs supported by CTS.
+     * Returns the set of ABIs supported by Compatibility.
      * @return a new Set containing the supported ABIs.
      */
-    public static Set<String> getAbisSupportedByCts() {
-        return new HashSet<String>(ABIS_SUPPORTED_BY_CTS);
+    public static Set<String> getAbisSupportedByCompatibility() {
+        return new HashSet<String>(ABIS_SUPPORTED_BY_COMPATIBILITY);
     }
 
     /**
      * @param abi The ABI name to test.
-     * @return true if the given ABI is supported by CTS.
+     * @return true if the given ABI is supported by Compatibility.
      */
-    public static boolean isAbiSupportedByCts(String abi) {
-        return ABIS_SUPPORTED_BY_CTS.contains(abi);
+    public static boolean isAbiSupportedByCompatibility(String abi) {
+        return ABIS_SUPPORTED_BY_COMPATIBILITY.contains(abi);
     }
 
     /**
@@ -128,7 +128,7 @@
      * @return a string which can be add to a command sent to ADB.
      */
     public static String createAbiFlag(String abi) {
-        if (abi == null || abi.isEmpty() || !isAbiSupportedByCts(abi)) {
+        if (abi == null || abi.isEmpty() || !isAbiSupportedByCompatibility(abi)) {
             return "";
         }
         return String.format("--abi %s ", abi);
@@ -181,7 +181,7 @@
     }
 
     /**
-     * @param abilistString A comma separated string containing abis.
+     * @param unsupportedAbiDescription A comma separated string containing abis.
      * @return A List of Strings containing valid ABIs.
      */
     public static Set<String> parseAbiList(String unsupportedAbiDescription) {
@@ -190,7 +190,7 @@
         if (descSegments.length == 2) {
             for (String abi : descSegments[1].split(",")) {
                 String trimmedAbi = abi.trim();
-                if (isAbiSupportedByCts(trimmedAbi)) {
+                if (isAbiSupportedByCompatibility(trimmedAbi)) {
                     abiSet.add(trimmedAbi);
                 }
             }
diff --git a/common/util/src/com/android/compatibility/common/util/CaseResult.java b/common/util/src/com/android/compatibility/common/util/CaseResult.java
new file mode 100644
index 0000000..e16ad1f
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/CaseResult.java
@@ -0,0 +1,115 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Data structure for a Compatibility test case result.
+ */
+public class CaseResult implements ICaseResult {
+
+    private String mName;
+
+    private Map<String, ITestResult> mResults = new HashMap<>();
+
+    /**
+     * Creates a {@link CaseResult} for the given name, eg &lt;package-name&gt;.&lt;class-name&gt;
+     */
+    public CaseResult(String name) {
+        mName = name;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getName() {
+        return mName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ITestResult getOrCreateResult(String testName) {
+        ITestResult result = mResults.get(testName);
+        if (result == null) {
+            result = new TestResult(this, testName);
+            mResults.put(testName, result);
+        }
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ITestResult getResult(String testName) {
+        return mResults.get(testName);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<ITestResult> getResults(TestStatus status) {
+        List<ITestResult> results = new ArrayList<>();
+        for (ITestResult result : mResults.values()) {
+            if (result.getResultStatus() == status) {
+                results.add(result);
+            }
+        }
+        return results;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<ITestResult> getResults() {
+        ArrayList<ITestResult> results = new ArrayList<>(mResults.values());
+        Collections.sort(results);
+        return results;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int countResults(TestStatus status) {
+        int total = 0;
+        for (ITestResult result : mResults.values()) {
+            if (result.getResultStatus() == status) {
+                total++;
+            }
+        }
+        return total;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int compareTo(ICaseResult another) {
+        return getName().compareTo(another.getName());
+    }
+
+}
\ No newline at end of file
diff --git a/common/util/src/com/android/compatibility/common/util/DeviceInfoResult.java b/common/util/src/com/android/compatibility/common/util/DeviceInfoResult.java
new file mode 100644
index 0000000..fa1199e
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/DeviceInfoResult.java
@@ -0,0 +1,35 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import java.util.Map;
+
+/**
+ * Holds information collected from the Device Under Test (DUT).
+ *
+ */
+public class DeviceInfoResult {
+
+    /**
+     * Populates this object with the DUT's information.
+     *
+     * @param metrics the metrics collected from the device.
+     */
+    public void populateMetrics(Map<String, String> runMetrics) {
+        // TODO(stuartscott): Auto-generated method stub
+    }
+
+}
diff --git a/common/util/src/com/android/compatibility/common/util/ICaseResult.java b/common/util/src/com/android/compatibility/common/util/ICaseResult.java
new file mode 100644
index 0000000..99e646a
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/ICaseResult.java
@@ -0,0 +1,58 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import java.util.List;
+
+/**
+ * Data structure for a Compatibility test case result.
+ */
+public interface ICaseResult extends Comparable<ICaseResult> {
+
+    String getName();
+
+    /**
+     * Gets a {@link ITestResult} for the given test, creating it if it doesn't exist.
+     *
+     * @param testName the name of the test eg &lt;method-name&gt;
+     * @return the {@link ITestResult} or <code>null</code>
+     */
+    ITestResult getOrCreateResult(String testName);
+
+    /**
+     * Gets the {@link ITestResult} for given test.
+     *
+     * @param testName the name of the test eg &lt;method-name&gt;
+     * @return the {@link ITestResult} or <code>null</code>
+     */
+    ITestResult getResult(String testName);
+
+    /**
+     * Gets all results sorted by name.
+     */
+    List<ITestResult> getResults();
+
+    /**
+     * Gets all results which have the given status.
+     */
+    List<ITestResult> getResults(TestStatus status);
+
+    /**
+     * Counts the number of results which have the given status.
+     */
+    int countResults(TestStatus status);
+
+}
diff --git a/common/util/src/com/android/compatibility/common/util/IInvocationResult.java b/common/util/src/com/android/compatibility/common/util/IInvocationResult.java
new file mode 100644
index 0000000..43d1d47
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/IInvocationResult.java
@@ -0,0 +1,77 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Interface for a the result of a single Compatibility invocation.
+ */
+public interface IInvocationResult {
+
+    /**
+     * @return the starting timestamp.
+     */
+    long getStartTime();
+
+    /**
+     * @param time the starting timestamp
+     */
+    void setStartTime(long time);
+
+    /**
+     * Count the number of results with given status.
+     */
+    int countResults(TestStatus result);
+
+    /**
+     * @param plan the plan associated with this result.
+     */
+    void setTestPlan(String plan);
+
+    /**
+     * @return the test plan associated with this result.
+     */
+    String getTestPlan();
+
+    /**
+     * @return the device serials associated with result.
+     */
+    Set<String> getDeviceSerials();
+
+    /**
+     * @return the {@link IModuleResult} for the given id, creating one if it doesn't exist
+     */
+    IModuleResult getOrCreateModule(String id);
+
+    /**
+     * @return the {@link IModuleResult}s sorted by id.
+     */
+    List<IModuleResult> getModules();
+
+    /**
+     * @return the directory containing this result.
+     */
+    File getResultDir();
+
+    /**
+     * Populate the results with collected device info metrics.
+     */
+    void populateDeviceInfoMetrics(Map<String, String> metrics);
+}
diff --git a/common/util/src/com/android/compatibility/common/util/IModuleResult.java b/common/util/src/com/android/compatibility/common/util/IModuleResult.java
new file mode 100644
index 0000000..ea6df67
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/IModuleResult.java
@@ -0,0 +1,61 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import java.util.List;
+
+/**
+ * Data structure for a Compatibility test module result.
+ */
+public interface IModuleResult extends Comparable<IModuleResult> {
+
+    void setDeviceSerial(String deviceSerial);
+
+    String getDeviceSerial();
+
+    String getId();
+
+    String getName();
+
+    String getAbi();
+
+    /**
+     * Gets a {@link ICaseResult} for the given testcase, creating it if it doesn't exist.
+     *
+     * @param caseName the name of the testcase eg &lt;package-name&gt;&lt;class-name&gt;
+     * @return the {@link ICaseResult} or <code>null</code>
+     */
+    ICaseResult getOrCreateResult(String caseName);
+
+    /**
+     * Gets the {@link ICaseResult} result for given testcase.
+     *
+     * @param caseName the name of the testcase eg &lt;package-name&gt;&lt;class-name&gt;
+     * @return the {@link ITestResult} or <code>null</code>
+     */
+    ICaseResult getResult(String caseName);
+
+    /**
+     * Gets all results sorted by name.
+     */
+    List<ICaseResult> getResults();
+
+    /**
+     * Counts the number of results which have the given status.
+     */
+    int countResults(TestStatus status);
+
+}
diff --git a/common/util/src/com/android/compatibility/common/util/ITestResult.java b/common/util/src/com/android/compatibility/common/util/ITestResult.java
new file mode 100644
index 0000000..6defa44
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/ITestResult.java
@@ -0,0 +1,130 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+/**
+ * Represents a single test result.
+ */
+public interface ITestResult extends Comparable<ITestResult> {
+
+    /**
+     * @return The name of this test result.
+     */
+    String getName();
+
+    /**
+     * @return The full name of this test result, ie
+     * &lt;package-name&gt;.&lt;class-name&gt;#&lt;method-name&gt;
+     */
+    String getFullName();
+
+    /**
+     * @return The {@link TestStatus} of this result.
+     */
+    TestStatus getResultStatus();
+
+    /**
+     * Sets the {@link TestStatus} of the result and updates the end time of the test.
+     *
+     * @param status The {@link TestStatus} of this result.
+     */
+    void setResultStatus(TestStatus status);
+
+    /**
+     * @return The failure message to display
+     */
+    String getMessage();
+
+    /**
+     * @param message The message to display which describes the failure
+     */
+    void setMessage(String message);
+
+    /**
+     * @param time the start time of the test.
+     */
+    void setStartTime(long time);
+
+    /**
+     * @return The time the test started
+     */
+    long getStartTime();
+
+    /**
+     * @param time the end time of the test.
+     */
+    void setEndTime(long time);
+
+    /**
+     * @return The time the test ended
+     */
+    long getEndTime();
+
+    /**
+     * @return The stack trace generated by the failure
+     */
+    String getStackTrace();
+
+    /**
+     * @param stackTrace the stack trace generated by the failure.
+     */
+    void setStackTrace(String stackTrace);
+
+    /**
+     * @return the metrics report.
+     */
+    ReportLog getReportLog();
+
+    /**
+     * @param report the metrics report.
+     */
+    void setReportLog(ReportLog report);
+
+    /**
+     * @return the uri of the bug report generated of the failure.
+     */
+    String getBugReport();
+
+    /**
+     * @param uri the uri of the bug report generated of the failure.
+     */
+    void setBugReport(String uri);
+
+    /**
+     * @return the uri of the log file generated of the failure.
+     */
+    String getLog();
+
+    /**
+     * @param uri the uri of the log file generated of the failure.
+     */
+    void setLog(String uri);
+
+    /**
+     * Report the test as a failure.
+     *
+     * @param trace the stacktrace of the failure.
+     */
+    void failed(String trace);
+
+    /**
+     * Report that the test has completed.
+     *
+     * @param report A report generated by the test, or null.
+     */
+    void passed(ReportLog report);
+
+}
diff --git a/common/util/src/com/android/compatibility/common/util/InvocationResult.java b/common/util/src/com/android/compatibility/common/util/InvocationResult.java
new file mode 100644
index 0000000..6434c95
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/InvocationResult.java
@@ -0,0 +1,149 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Data structure for the detailed Compatibility test results.
+ */
+public class InvocationResult implements IInvocationResult {
+
+    private long mTimestamp;
+    private Map<String, IModuleResult> mModuleResults = new LinkedHashMap<>();
+    private DeviceInfoResult mDeviceInfo = new DeviceInfoResult();
+    private String mTestPlan;
+    private File mResultDir;
+
+    /**
+     * @param resultDir
+     */
+    public InvocationResult(File resultDir) {
+        this(System.currentTimeMillis(), resultDir);
+    }
+
+    /**
+     * @param timestamp
+     * @param resultDir
+     */
+    public InvocationResult(long timestamp, File resultDir) {
+        setStartTime(timestamp);
+        mResultDir = resultDir;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<IModuleResult> getModules() {
+        ArrayList<IModuleResult> modules = new ArrayList<>(mModuleResults.values());
+        Collections.sort(modules);
+        return modules;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int countResults(TestStatus result) {
+        int total = 0;
+        for (IModuleResult m : mModuleResults.values()) {
+            total += m.countResults(result);
+        }
+        return total;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IModuleResult getOrCreateModule(String id) {
+        IModuleResult moduleResult = mModuleResults.get(id);
+        if (moduleResult == null) {
+            moduleResult = new ModuleResult(id);
+            mModuleResults.put(id, moduleResult);
+        }
+        return moduleResult;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void populateDeviceInfoMetrics(Map<String, String> metrics) {
+        mDeviceInfo.populateMetrics(metrics);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setStartTime(long time) {
+        mTimestamp = time;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public long getStartTime() {
+        return mTimestamp;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setTestPlan(String plan) {
+        mTestPlan = plan;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getTestPlan() {
+        return mTestPlan;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Set<String> getDeviceSerials() {
+        Set<String> serials = new HashSet<>();
+        for (IModuleResult module : mModuleResults.values()) {
+            serials.add(module.getDeviceSerial());
+        }
+        return serials;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public File getResultDir() {
+        return mResultDir;
+    }
+
+}
diff --git a/common/util/src/com/android/compatibility/common/util/MeasureRun.java b/common/util/src/com/android/compatibility/common/util/MeasureRun.java
index d58b8d4..2b8905f 100644
--- a/common/util/src/com/android/compatibility/common/util/MeasureRun.java
+++ b/common/util/src/com/android/compatibility/common/util/MeasureRun.java
@@ -25,7 +25,7 @@
      */
     public void prepare(int i) throws Exception {
         // default empty implementation
-    };
+    }
 
     abstract public void run(int i) throws Exception;
 }
diff --git a/common/util/src/com/android/compatibility/common/util/MetricsXmlSerializer.java b/common/util/src/com/android/compatibility/common/util/MetricsXmlSerializer.java
index 0e2b004..0f4b597 100644
--- a/common/util/src/com/android/compatibility/common/util/MetricsXmlSerializer.java
+++ b/common/util/src/com/android/compatibility/common/util/MetricsXmlSerializer.java
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.util.List;
 
+//TODO(stuartscott): Delete file for v2, ReportLog can serialize itself.
 /**
  * Serialize Metric data from {@link ReportLog} into compatibility report friendly XML
  */
@@ -36,26 +37,26 @@
         if (reportLog == null) {
             return;
         }
-        ReportLog.Result summary = reportLog.getSummary();
-        List<ReportLog.Result> detailedMetrics = reportLog.getDetailedMetrics();
+        ReportLog.Metric summary = reportLog.getSummary();
+        List<ReportLog.Metric> detailedMetrics = reportLog.getDetailedMetrics();
         // <Summary message="Average" scoreType="lower_better" unit="ms">195.2</Summary>
         if (summary != null) {
             mXmlSerializer.startTag(null, "Summary");
             mXmlSerializer.attribute(null, "message", summary.getMessage());
-            mXmlSerializer.attribute(null, "scoreType", summary.getType().getXmlString());
-            mXmlSerializer.attribute(null, "unit", summary.getUnit().getXmlString());
+            mXmlSerializer.attribute(null, "scoreType", summary.getType().toReportString());
+            mXmlSerializer.attribute(null, "unit", summary.getUnit().toReportString());
             mXmlSerializer.text(Double.toString(summary.getValues()[0]));
             mXmlSerializer.endTag(null, "Summary");
         }
 
         if (!detailedMetrics.isEmpty()) {
             mXmlSerializer.startTag(null, "Details");
-            for (ReportLog.Result result : detailedMetrics) {
+            for (ReportLog.Metric result : detailedMetrics) {
                 mXmlSerializer.startTag(null, "ValueArray");
-                mXmlSerializer.attribute(null, "source", result.getLocation());
+                mXmlSerializer.attribute(null, "source", result.getSource());
                 mXmlSerializer.attribute(null, "message", result.getMessage());
-                mXmlSerializer.attribute(null, "scoreType", result.getType().getXmlString());
-                mXmlSerializer.attribute(null, "unit", result.getUnit().getXmlString());
+                mXmlSerializer.attribute(null, "scoreType", result.getType().toReportString());
+                mXmlSerializer.attribute(null, "unit", result.getUnit().toReportString());
 
                 for (double value : result.getValues()) {
                     mXmlSerializer.startTag(null, "Value");
@@ -67,4 +68,4 @@
             mXmlSerializer.endTag(null, "Details");
         }
     }
-}
+}
\ No newline at end of file
diff --git a/common/util/src/com/android/compatibility/common/util/ModuleResult.java b/common/util/src/com/android/compatibility/common/util/ModuleResult.java
new file mode 100644
index 0000000..eb4b568
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/ModuleResult.java
@@ -0,0 +1,132 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Data structure for a Compatibility test module result.
+ */
+public class ModuleResult implements IModuleResult {
+
+    private String mDeviceSerial;
+    private String mId;
+
+    private Map<String, ICaseResult> mResults = new HashMap<>();
+
+    /**
+     * Creates a {@link ModuleResult} for the given id, created with
+     * {@link AbiUtils#createId(String, String)}
+     */
+    public ModuleResult(String id) {
+        mId = id;
+    }
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setDeviceSerial(String deviceSerial) {
+        mDeviceSerial = deviceSerial;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getDeviceSerial() {
+        return mDeviceSerial;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getId() {
+        return mId;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getName() {
+        return AbiUtils.parseTestName(mId);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getAbi() {
+        return AbiUtils.parseAbi(mId);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ICaseResult getOrCreateResult(String caseName) {
+        ICaseResult result = mResults.get(caseName);
+        if (result == null) {
+            result = new CaseResult(caseName);
+            mResults.put(caseName, result);
+        }
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ICaseResult getResult(String caseName) {
+        return mResults.get(caseName);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<ICaseResult> getResults() {
+        ArrayList<ICaseResult> results = new ArrayList<>(mResults.values());
+        Collections.sort(results);
+        return results;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int countResults(TestStatus status) {
+        int total = 0;
+        for (ICaseResult result : mResults.values()) {
+            total += result.countResults(status);
+        }
+        return total;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int compareTo(IModuleResult another) {
+        return getId().compareTo(another.getId());
+    }
+
+}
diff --git a/common/util/src/com/android/compatibility/common/util/ReportLog.java b/common/util/src/com/android/compatibility/common/util/ReportLog.java
index 7209ac8..31320c1 100644
--- a/common/util/src/com/android/compatibility/common/util/ReportLog.java
+++ b/common/util/src/com/android/compatibility/common/util/ReportLog.java
@@ -16,66 +16,71 @@
 
 package com.android.compatibility.common.util;
 
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+import org.xmlpull.v1.XmlSerializer;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.StringTokenizer;
-import java.util.regex.Pattern;
 
 /**
  * Utility class to add results to the report.
  */
 public class ReportLog implements Serializable {
 
-    private static final String LOG_SEPARATOR = "+++";
-    private static final String SUMMARY_SEPARATOR = "++++";
-    private static final String LOG_ELEM_SEPARATOR = "|";
-    private static final String EMPTY_CHAR = " ";
-    private Result mSummary;
-    private final List<Result> mDetails = new ArrayList<Result>();
+    private static final String ENCODING = "UTF-8";
+    private static final String TYPE = "org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer";
 
-    static class Result implements Serializable {
-        private String mLocation;
+    // XML constants
+    private static final String DETAIL_TAG = "Detail";
+    private static final String METRIC_TAG = "Metric";
+    private static final String MESSAGE_ATTR = "message";
+    private static final String SCORETYPE_ATTR = "score-type";
+    private static final String SCOREUNIT_ATTR = "score-unit";
+    private static final String SOURCE_ATTR = "source";
+    private static final String SUMMARY_TAG = "Summary";
+    private static final String VALUE_TAG = "Value";
+
+    private Metric mSummary;
+    private final List<Metric> mDetails = new ArrayList<>();
+
+    public static class Metric implements Serializable {
+        private String mSource;
         private String mMessage;
         private double[] mValues;
         private ResultType mType;
         private ResultUnit mUnit;
-        private Double mTarget;
 
-
-        private Result(String location, String message, double[] values,
-                ResultType type, ResultUnit unit) {
-            this(location, message, values, null /*target*/, type, unit);
+        Metric(String source, String message, double value, ResultType type, ResultUnit unit) {
+            this(source, message, new double[] { value }, type, unit);
         }
 
         /**
-         * Creates a result object to be included in the report. Each object has a message
+         * Creates a metric array to be included in the report. Each object has a message
          * describing its values and enums to interpret them. In addition, each result also includes
          * class, method and line number information about the test which added this result which is
          * collected by looking at the stack trace.
          *
          * @param message A string describing the values
          * @param values An array of the values
-         * @param target Nullable. The target value.
          * @param type Represents how to interpret the values (eg. A lower score is better)
          * @param unit Represents the unit in which the values are (eg. Milliseconds)
          */
-        private Result(String location, String message, double[] values,
-                Double target, ResultType type, ResultUnit unit) {
-            mLocation = location;
+        Metric(String source, String message, double[] values, ResultType type, ResultUnit unit) {
+            mSource = source;
             mMessage = message;
             mValues = values;
             mType = type;
             mUnit = unit;
-            mTarget = target;
         }
 
-        public double getTarget() {
-            return mTarget;
-        }
-
-        public String getLocation() {
-            return mLocation;
+        public String getSource() {
+            return mSource;
         }
 
         public String getMessage() {
@@ -94,137 +99,189 @@
             return mUnit;
         }
 
-        /**
-         * Format:
-         * location|message|target|type|unit|value[s], target can be " " if there is no target set.
-         * log for array = classMethodName:line_number|message|unit|type|space separated values
-         */
-        String toEncodedString() {
-            StringBuilder builder = new StringBuilder()
-                    .append(mLocation)
-                    .append(LOG_ELEM_SEPARATOR)
-                    .append(mMessage)
-                    .append(LOG_ELEM_SEPARATOR)
-                    .append(mTarget != null ? mTarget : EMPTY_CHAR)
-                    .append(LOG_ELEM_SEPARATOR)
-                    .append(mType.name())
-                    .append(LOG_ELEM_SEPARATOR)
-                    .append(mUnit.name())
-                    .append(LOG_ELEM_SEPARATOR);
-            for (double value : mValues) {
-                builder.append(value).append(" ");
+        void serialize(XmlSerializer serializer)
+                throws IllegalArgumentException, IllegalStateException, IOException {
+            serializer.startTag(null, METRIC_TAG);
+            serializer.attribute(null, SOURCE_ATTR, getSource());
+            serializer.attribute(null, MESSAGE_ATTR, getMessage());
+            serializer.attribute(null, SCORETYPE_ATTR, getType().toReportString());
+            serializer.attribute(null, SCOREUNIT_ATTR, getUnit().toReportString());
+            for (double d : getValues()) {
+                serializer.startTag(null, VALUE_TAG);
+                serializer.text(Double.toString(d));
+                serializer.endTag(null, VALUE_TAG);
             }
-            return builder.toString();
+            serializer.endTag(null, METRIC_TAG);
         }
 
-        static Result fromEncodedString(String encodedString) {
-            String[] elems = encodedString.split(Pattern.quote(LOG_ELEM_SEPARATOR));
-            if (elems.length < 5) {
-                return null;
+        static Metric parse(XmlPullParser parser)
+                throws XmlPullParserException, IOException {
+            parser.require(XmlPullParser.START_TAG, null, METRIC_TAG);
+            String source = parser.getAttributeValue(null, SOURCE_ATTR);
+            String message = parser.getAttributeValue(null, MESSAGE_ATTR);
+            ResultType type = ResultType.parseReportString(
+                    parser.getAttributeValue(null, SCORETYPE_ATTR));
+            ResultUnit unit = ResultUnit.parseReportString(
+                    parser.getAttributeValue(null, SCOREUNIT_ATTR));
+            List<String> valuesList = new ArrayList<>();
+            while (parser.nextTag() == XmlPullParser.START_TAG) {
+                parser.require(XmlPullParser.START_TAG, null, VALUE_TAG);
+                valuesList.add(parser.nextText());
+                parser.require(XmlPullParser.END_TAG, null, VALUE_TAG);
             }
-
-            String[] valueStrArray = elems[5].split(" ");
-            double[] valueArray = new double[valueStrArray.length];
-            for (int i = 0; i < valueStrArray.length; i++) {
-                valueArray[i] = Double.parseDouble(valueStrArray[i]);
+            int length = valuesList.size();
+            double[] values = new double[length];
+            for (int i = 0; i < length; i++) {
+                values[i] = Double.parseDouble(valuesList.get(i));
             }
-            return new Result(
-                    elems[0], /*location*/
-                    elems[1], /*message*/
-                    valueArray, /*values*/
-                    elems[2].equals(EMPTY_CHAR) ? null : Double.parseDouble(elems[2]), /*target*/
-                    ResultType.valueOf(elems[3]), /*type*/
-                    ResultUnit.valueOf(elems[4])  /*unit*/);
+            parser.require(XmlPullParser.END_TAG, null, METRIC_TAG);
+            return new Metric(source, message, values, type, unit);
         }
     }
 
     /**
-     * Adds an array of values to the report.
+     * @param elem
+     */
+    /* package */ void addMetric(Metric elem) {
+        mDetails.add(elem);
+    }
+
+    /**
+     * Adds an array of metrics to the report.
      */
     public void addValues(String message, double[] values, ResultType type, ResultUnit unit) {
-        mDetails.add(new Result(Stacktrace.getTestCallerClassMethodNameLineNumber(),
+        addMetric(new Metric(Stacktrace.getTestCallerClassMethodNameLineNumber(),
                 message, values, type, unit));
     }
 
     /**
-     * Adds an array of values to the report.
+     * Adds an array of metrics to the report.
      */
-    public void addValues(
-            String message, double[] values, ResultType type, ResultUnit unit, String location) {
-        mDetails.add(new Result(location, message, values, type, unit));
+    public void addValues(String source, String message, double[] values, ResultType type,
+            ResultUnit unit) {
+        addMetric(new Metric(source, message, values, type, unit));
     }
 
     /**
-     * Adds a value to the report.
+     * Adds a metric to the report.
      */
     public void addValue(String message, double value, ResultType type, ResultUnit unit) {
-        mDetails.add(new Result(Stacktrace.getTestCallerClassMethodNameLineNumber(), message,
-                new double[] {value}, type, unit));
+        addMetric(new Metric(Stacktrace.getTestCallerClassMethodNameLineNumber(), message,
+                value, type, unit));
     }
 
     /**
-     * Adds a value to the report.
+     * Adds a metric to the report.
      */
-    public void addValue(String message, double value, ResultType type,
-            ResultUnit unit, String location) {
-        mDetails.add(new Result(location, message, new double[] {value}, type, unit));
+    public void addValue(String source, String message, double value, ResultType type,
+            ResultUnit unit) {
+        addMetric(new Metric(source, message, value, type, unit));
+    }
+
+    /**
+     * @param elem
+     */
+    /* package */ void setSummary(Metric elem) {
+        mSummary = elem;
     }
 
     /**
      * Sets the summary of the report.
      */
     public void setSummary(String message, double value, ResultType type, ResultUnit unit) {
-        mSummary = new Result(Stacktrace.getTestCallerClassMethodNameLineNumber(),
-                message, new double[] {value}, type, unit);
+        setSummary(new Metric(Stacktrace.getTestCallerClassMethodNameLineNumber(),
+                message, value, type, unit));
     }
 
-    public Result getSummary() {
+    public Metric getSummary() {
         return mSummary;
     }
 
-    public List<Result> getDetailedMetrics() {
-        return new ArrayList<Result>(mDetails);
+    public List<Metric> getDetailedMetrics() {
+        return new ArrayList<Metric>(mDetails);
     }
 
     /**
-     * Parse a String encoded {@link com.android.compatibility.common.util.ReportLog}
+     * Serializes a given {@link ReportLog} to a String.
+     * @throws XmlPullParserException
+     * @throws IOException
+     * @throws IllegalStateException
+     * @throws IllegalArgumentException
      */
-    public static ReportLog fromEncodedString(String encodedString) {
-        ReportLog reportLog = new ReportLog();
-        StringTokenizer tok = new StringTokenizer(encodedString, SUMMARY_SEPARATOR);
-        if (tok.hasMoreTokens()) {
-            // Extract the summary
-            reportLog.mSummary = Result.fromEncodedString(tok.nextToken());
+    public static String serialize(ReportLog reportlog) throws XmlPullParserException,
+            IllegalArgumentException, IllegalStateException, IOException {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        XmlSerializer serializer = XmlPullParserFactory.newInstance(TYPE, null).newSerializer();
+        serializer.setOutput(byteArrayOutputStream, ENCODING);
+        serializer.startDocument(ENCODING, true);
+        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
+        serialize(serializer, reportlog);
+        serializer.endDocument();
+        return byteArrayOutputStream.toString(ENCODING);
+    }
+
+    /**
+     * Serializes a given {@link ReportLog} to XML.
+     * @param serializer
+     * @param reportLog
+     * @throws IOException
+     */
+    public static void serialize(XmlSerializer serializer, ReportLog reportLog)
+            throws IOException {
+        if (reportLog == null) {
+            return;
         }
-        if (tok.hasMoreTokens()) {
-            // Extract the detailed results
-            StringTokenizer detailedTok = new StringTokenizer(tok.nextToken(), LOG_SEPARATOR);
-            while (detailedTok.hasMoreTokens()) {
-                reportLog.mDetails.add(Result.fromEncodedString(detailedTok.nextToken()));
+        Metric summary = reportLog.getSummary();
+        List<Metric> detailedMetrics = reportLog.getDetailedMetrics();
+        if (summary != null) {
+            serializer.startTag(null, SUMMARY_TAG);
+            summary.serialize(serializer);
+            serializer.endTag(null, SUMMARY_TAG);
+        }
+
+        if (!detailedMetrics.isEmpty()) {
+            serializer.startTag(null, DETAIL_TAG);
+            for (Metric elem : detailedMetrics) {
+                elem.serialize(serializer);
             }
+            serializer.endTag(null, DETAIL_TAG);
         }
-        return reportLog;
     }
 
     /**
-     * @return a String representation of this report or null if not collected
+     * Parses a {@link ReportLog} from the given string.
+     * @throws XmlPullParserException
+     * @throws IOException
      */
-    protected String toEncodedString() {
-        if ((mSummary == null) && mDetails.isEmpty()) {
-            // just return empty string
-            return null;
-        }
-        StringBuilder builder = new StringBuilder();
-        builder.append(mSummary.toEncodedString());
-        builder.append(SUMMARY_SEPARATOR);
-        for (Result result : mDetails) {
-            builder.append(result.toEncodedString());
-            builder.append(LOG_SEPARATOR);
-        }
-        // delete the last separator
-        if (builder.length() >= LOG_SEPARATOR.length()) {
-            builder.delete(builder.length() - LOG_SEPARATOR.length(), builder.length());
-        }
-        return builder.toString();
+    public static ReportLog parse(String result) throws XmlPullParserException, IOException {
+        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+        XmlPullParser parser = factory.newPullParser();
+        parser.setInput(new ByteArrayInputStream(result.getBytes(ENCODING)), ENCODING);
+        parser.nextTag();
+        return parse(parser);
     }
+
+    /**
+     * Parses a {@link ReportLog} from the given XML parser.
+     * @param parser
+     * @throws IOException
+     * @throws XmlPullParserException
+     */
+    public static ReportLog parse(XmlPullParser parser) throws XmlPullParserException, IOException {
+        parser.require(XmlPullParser.START_TAG, null, SUMMARY_TAG);
+        parser.nextTag();
+        ReportLog report = new ReportLog();
+        report.setSummary(Metric.parse(parser));
+        parser.nextTag();
+        parser.require(XmlPullParser.END_TAG, null, SUMMARY_TAG);
+        parser.nextTag();
+        if (parser.getName().equals(DETAIL_TAG)) {
+            while (parser.nextTag() == XmlPullParser.START_TAG) {
+                report.addMetric(Metric.parse(parser));
+            }
+            parser.require(XmlPullParser.END_TAG, null, DETAIL_TAG);
+        }
+        return report;
+    }
+
 }
diff --git a/common/util/src/com/android/compatibility/common/util/ResultType.java b/common/util/src/com/android/compatibility/common/util/ResultType.java
index 779c6d0..9d0a5fa 100644
--- a/common/util/src/com/android/compatibility/common/util/ResultType.java
+++ b/common/util/src/com/android/compatibility/common/util/ResultType.java
@@ -30,9 +30,16 @@
     WARNING;
 
     /**
-     * Return string used in the XML report
+     * @return a string to be used in the report.
      */
-    public String getXmlString() {
+    public String toReportString() {
         return name().toLowerCase();
     }
+
+    /**
+     * Returns a {@link ResultType} given a string from the report.
+     */
+    public static ResultType parseReportString(String value) {
+        return ResultType.valueOf(value.toUpperCase());
+    }
 }
diff --git a/common/util/src/com/android/compatibility/common/util/ResultUnit.java b/common/util/src/com/android/compatibility/common/util/ResultUnit.java
index f38ddae..5b082f9 100644
--- a/common/util/src/com/android/compatibility/common/util/ResultUnit.java
+++ b/common/util/src/com/android/compatibility/common/util/ResultUnit.java
@@ -40,10 +40,16 @@
     SCORE;
 
     /**
-     * Return string used in the XML report
+     * @return a string to be used in the report.
      */
-    public String getXmlString() {
+    public String toReportString() {
         return name().toLowerCase();
     }
-}
 
+    /**
+     * Returns a {@link ResultUnit} given a string from the report.
+     */
+    public static ResultUnit parseReportString(String value) {
+        return ResultUnit.valueOf(value.toUpperCase());
+    }
+}
diff --git a/common/util/src/com/android/compatibility/common/util/Stat.java b/common/util/src/com/android/compatibility/common/util/Stat.java
index 8bf9bf7..ee58070 100644
--- a/common/util/src/com/android/compatibility/common/util/Stat.java
+++ b/common/util/src/com/android/compatibility/common/util/Stat.java
@@ -22,6 +22,10 @@
  * Utilities for doing statistics
  */
 public class Stat {
+    /**
+     * Private constructor for static class.
+     */
+    private Stat() {}
 
     /**
      * Collection of statistical propertirs like average, max, min, and stddev
@@ -159,7 +163,6 @@
      * timeInSec with 0 value will be changed to small value to prevent divide by zero.
      * @param change total change of quality for the given duration timeInMSec.
      * @param timeInMSec
-     * @return
      */
     public static double calcRatePerSec(double change, double timeInMSec) {
         if (timeInMSec == 0) {
@@ -185,4 +188,14 @@
         return result;
     }
 
+    /**
+     * Get the value of the 95th percentile using nearest rank algorithm.
+     */
+    public static double get95PercentileValue(double[] values) {
+        Arrays.sort(values);
+        // zero-based array index
+        int index = (int) Math.round(values.length * 0.95 + .5) - 1;
+        return values[index];
+    }
+
 }
diff --git a/common/util/src/com/android/compatibility/common/util/TestFilter.java b/common/util/src/com/android/compatibility/common/util/TestFilter.java
new file mode 100644
index 0000000..78b68cf
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/TestFilter.java
@@ -0,0 +1,128 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+/**
+ * Represents a filter for including and excluding tests.
+ */
+public class TestFilter {
+
+    private final String mAbi;
+    private final String mName;
+    private final String mTest;
+
+    /**
+     * Builds a new {@link TestFilter} from the given string. Filters can be in one of four forms,
+     * the instance will be initialized as;
+     * -"name"              -> abi = null, name = "name", test = null
+     * -"name" "test"       -> abi = null, name = "name", test = "test"
+     * -"abi" "name"        -> abi = "abi", name = "name", test = null
+     * -"abi" "name" test"  -> abi = "abi", name = "name", test = "test"
+     *
+     * @param filter the filter to parse
+     * @return the {@link TestFilter}
+     */
+    public static TestFilter createFrom(String filter) {
+        String[] parts = filter.split(" ");
+        String abi = null, name = null, test = null;
+        // Either:
+        // <name>
+        // <name> <test>
+        // <abi> <name>
+        // <abi> <name> <test>
+        if (parts.length == 1) {
+            name = parts[0];
+        } else if (parts.length == 2) {
+            if (AbiUtils.isAbiSupportedByCompatibility(parts[0])) {
+                abi = parts[0];
+                name = parts[1];
+            } else {
+                name = parts[0];
+                test = parts[1];
+            }
+        } else if (parts.length == 3){
+            abi = parts[0];
+            name = parts[1];
+            test = parts[2];
+        } else {
+            throw new IllegalArgumentException(String.format("Could not parse filter: %s", filter));
+        }
+        return new TestFilter(abi, name, test);
+    }
+
+    /**
+     * Creates a new {@link TestFilter} from the given parts.
+     *
+     * @param abi The ABI must be supported {@link AbiUtils#isAbiSupportedByCompatibility(String)}
+     * @param name The module's name
+     * @param test The test's identifier eg <package>.<class>#<method>
+     */
+    public TestFilter(String abi, String name, String test) {
+        mAbi = abi;
+        mName = name;
+        mTest = test;
+    }
+
+    /**
+     * Returns a String representation of this filter. This function is the inverse of
+     * {@link TestFilter#createFrom(String)}.
+     *
+     * For a valid filter f;
+     * <pre>
+     * {@code
+     * new TestFilter(f).toString().equals(f)
+     * }
+     * </pre>
+     */
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        if (mAbi != null) {
+            sb.append(mAbi);
+            sb.append(" ");
+        }
+        if (mName != null) {
+            sb.append(mName);
+        }
+        if (mTest != null) {
+            sb.append(" ");
+            sb.append(mTest);
+        }
+        return sb.toString();
+    }
+
+    /**
+     * @return the abi of this filter, or null if not specified.
+     */
+    public String getAbi() {
+        return mAbi;
+    }
+
+    /**
+     * @return the module name of this filter, or null if not specified.
+     */
+    public String getName() {
+        return mName;
+    }
+
+    /**
+     * @return the test identifier of this filter, or null if not specified.
+     */
+    public String getTest() {
+        return mTest;
+    }
+
+}
diff --git a/common/util/src/com/android/compatibility/common/util/TestResult.java b/common/util/src/com/android/compatibility/common/util/TestResult.java
new file mode 100644
index 0000000..b0b5b6f
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/TestResult.java
@@ -0,0 +1,238 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+/**
+ * Represents a single test result.
+ */
+public class TestResult implements ITestResult {
+
+    private final ICaseResult mParent;
+    private final String mTestName;
+    private long mStartTime;
+    private long mEndTime;
+    private TestStatus mResult;
+    private String mMessage;
+    private String mStackTrace;
+    private ReportLog mReport;
+    private String mBugReport;
+    private String mLog;
+
+    /**
+     * Create a {@link TestResult} for the given test name.
+     */
+    public TestResult(ICaseResult parent, String name) {
+        mParent = parent;
+        mTestName = name;
+        mResult = TestStatus.NOT_EXECUTED;
+        mStartTime = System.currentTimeMillis();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getName() {
+        return mTestName;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getFullName() {
+        return String.format("%s#%s", mParent.getName(), getName());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public TestStatus getResultStatus() {
+        return mResult;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setResultStatus(TestStatus status) {
+        mResult = status;
+        mEndTime = System.currentTimeMillis();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getMessage() {
+        return mMessage;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setMessage(String message) {
+        mMessage = message;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setStartTime(long time) {
+        mStartTime = time;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public long getStartTime() {
+        return mStartTime;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setEndTime(long time) {
+        mEndTime = time;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public long getEndTime() {
+        return mEndTime;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getStackTrace() {
+        return mStackTrace;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setStackTrace(String stackTrace) {
+        mStackTrace = sanitizeStackTrace(stackTrace);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public ReportLog getReportLog() {
+        return mReport;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setReportLog(ReportLog report) {
+        mReport = report;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getBugReport() {
+        return mBugReport;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setBugReport(String uri) {
+        mBugReport = uri;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getLog() {
+        return mLog;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setLog(String uri) {
+        mLog = uri;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void failed(String trace) {
+        setResultStatus(TestStatus.FAIL);
+        int index = trace.indexOf('\n');
+        if (index < 0) {
+            // Trace is a single line, just set the message to be the same as the stacktrace.
+            setMessage(trace);
+        } else {
+            setMessage(trace.substring(0, index));
+        }
+        setStackTrace(trace);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void passed(ReportLog report) {
+        if (!getResultStatus().equals(TestStatus.FAIL)) {
+            setResultStatus(TestStatus.PASS);
+            if (report != null) {
+                setReportLog(report);
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int compareTo(ITestResult another) {
+        return getName().compareTo(another.getName());
+    }
+
+    /**
+     * Strip out any invalid XML characters that might cause the report to be unviewable.
+     * http://www.w3.org/TR/REC-xml/#dt-character
+     */
+    static String sanitizeStackTrace(String trace) {
+        if (trace != null) {
+            return trace.replaceAll("[^\\u0009\\u000A\\u000D\\u0020-\\uD7FF\\uE000-\\uFFFD]", "");
+        } else {
+            return null;
+        }
+    }
+
+}
diff --git a/common/util/src/com/android/compatibility/common/util/TestStatus.java b/common/util/src/com/android/compatibility/common/util/TestStatus.java
new file mode 100644
index 0000000..ef14547
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/TestStatus.java
@@ -0,0 +1,56 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+/**
+ * An enum of possible test statuses.
+ */
+public enum TestStatus {
+    PASS("pass"),
+    FAIL("fail"),
+    NOT_EXECUTED("not-executed");
+
+    private String mValue;
+
+    private TestStatus(String storedValue) {
+        mValue = storedValue;
+    }
+
+    /**
+     * Get the String representation of this test status that should be stored in
+     * xml
+     */
+    public String getValue() {
+       return mValue;
+    }
+
+    /**
+     * Find the {@link TestStatus} corresponding to given string value
+     * <p/>
+     * Performs a case insensitive search
+     *
+     * @param value
+     * @return the {@link TestStatus} or <code>null</code> if it could not be found
+     */
+    static TestStatus getStatus(String  value) {
+        for (TestStatus status : TestStatus.values()) {
+            if (value.compareToIgnoreCase(status.getValue()) == 0) {
+                return status;
+            }
+        }
+        return null;
+    }
+}
diff --git a/common/util/src/com/android/compatibility/common/util/XmlResultHandler.java b/common/util/src/com/android/compatibility/common/util/XmlResultHandler.java
new file mode 100644
index 0000000..d0da369
--- /dev/null
+++ b/common/util/src/com/android/compatibility/common/util/XmlResultHandler.java
@@ -0,0 +1,253 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+import org.xmlpull.v1.XmlPullParserFactory;
+import org.xmlpull.v1.XmlSerializer;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Handles conversion of results to/from XML.
+ */
+public class XmlResultHandler {
+
+    private static final String ENCODING = "UTF-8";
+    private static final String TYPE = "org.kxml2.io.KXmlParser,org.kxml2.io.KXmlSerializer";
+    private static final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    private static final String NS = null;
+    private static final String RESULT_FILE_VERSION = "5.0";
+    /* package */ static final String TEST_RESULT_FILE_NAME = "test-result.xml";
+
+    // XML constants
+    private static final String ABI_ATTR = "abi";
+    private static final String CASE_TAG = "TestCase";
+    private static final String DEVICE_ATTR = "device";
+    private static final String END_TIME_ATTR = "end";
+    private static final String FAILED_ATTR = "failed";
+    private static final String FAILURE_TAG = "Failure";
+    private static final String HOST_NAME_ATTR = "host-name";
+    private static final String JAVA_VENDOR_ATTR = "java-vendor";
+    private static final String JAVA_VERSION_ATTR = "java-version";
+    private static final String MESSAGE_ATTR = "message";
+    private static final String MODULE_TAG = "Module";
+    private static final String NAME_ATTR = "name";
+    private static final String NOT_EXECUTED_ATTR = "not-executed";
+    private static final String OS_ARCH_ATTR = "os-arch";
+    private static final String OS_NAME_ATTR = "os-name";
+    private static final String OS_VERSION_ATTR = "os-version";
+    private static final String PASS_ATTR = "pass";
+    private static final String REPORT_VERSION_ATTR = "report-version";
+    private static final String RESULT_ATTR = "result";
+    private static final String RESULT_TAG = "Result";
+    private static final String STACK_TAG = "StackTrace";
+    private static final String START_TIME_ATTR = "start";
+    private static final String SUITE_NAME_ATTR = "suite-name";
+    private static final String SUITE_PLAN_ATTR = "suite-plan";
+    private static final String SUITE_VERSION_ATTR = "suite-version";
+    private static final String SUMMARY_TAG = "Summary";
+    private static final String TEST_TAG = "Test";
+
+    /**
+     * @param resultsDir
+     */
+    public static List<IInvocationResult> getResults(File resultsDir) {
+        ArrayList<IInvocationResult> results = new ArrayList<>();
+        for (File resultDir : resultsDir.listFiles()) {
+            if (!resultDir.isDirectory()) {
+                continue;
+            }
+            try {
+                IInvocationResult invocation = new InvocationResult(resultDir);
+                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+                XmlPullParser parser = factory.newPullParser();
+                parser.setInput(new FileReader(new File(resultDir, TEST_RESULT_FILE_NAME)));
+                parser.nextTag();
+                parser.require(XmlPullParser.START_TAG, NS, RESULT_TAG);
+                invocation.setStartTime(parseTimeStamp(
+                        parser.getAttributeValue(NS, START_TIME_ATTR)));
+                invocation.setTestPlan(parser.getAttributeValue(NS, SUITE_PLAN_ATTR));
+                parser.nextTag();
+                parser.require(XmlPullParser.START_TAG, NS, SUMMARY_TAG);
+                parser.nextTag();
+                parser.require(XmlPullParser.END_TAG, NS, SUMMARY_TAG);
+                while (parser.nextTag() == XmlPullParser.START_TAG) {
+                    parser.require(XmlPullParser.START_TAG, NS, MODULE_TAG);
+                    String name = parser.getAttributeValue(NS, NAME_ATTR);
+                    String abi = parser.getAttributeValue(NS, ABI_ATTR);
+                    String id = AbiUtils.createId(abi, name);
+                    IModuleResult module = invocation.getOrCreateModule(id);
+                    module.setDeviceSerial(parser.getAttributeValue(NS, DEVICE_ATTR));
+                    while (parser.nextTag() == XmlPullParser.START_TAG) {
+                        parser.require(XmlPullParser.START_TAG, NS, CASE_TAG);
+                        String caseName = parser.getAttributeValue(NS, NAME_ATTR);
+                        ICaseResult testCase = module.getOrCreateResult(caseName);
+                        while (parser.nextTag() == XmlPullParser.START_TAG) {
+                            parser.require(XmlPullParser.START_TAG, NS, TEST_TAG);
+                            String testName = parser.getAttributeValue(NS, NAME_ATTR);
+                            ITestResult test = testCase.getOrCreateResult(testName);
+                            String result = parser.getAttributeValue(NS, RESULT_ATTR);
+                            test.setResultStatus(TestStatus.getStatus(result));
+                            test.setStartTime(parseTimeStamp(
+                                    parser.getAttributeValue(NS, START_TIME_ATTR)));
+                            test.setEndTime(parseTimeStamp(
+                                    parser.getAttributeValue(NS, END_TIME_ATTR)));
+                            if (parser.nextTag() == XmlPullParser.START_TAG) {
+                                if (parser.getName().equals(FAILURE_TAG)) {
+                                    test.setMessage(parser.getAttributeValue(NS, MESSAGE_ATTR));
+                                    if (parser.nextTag() == XmlPullParser.START_TAG) {
+                                        parser.require(XmlPullParser.START_TAG, NS, STACK_TAG);
+                                        test.setStackTrace(parser.nextText());
+                                        parser.require(XmlPullParser.END_TAG, NS, STACK_TAG);
+                                        parser.nextTag();
+                                    }
+                                    parser.require(XmlPullParser.END_TAG, NS, FAILURE_TAG);
+                                    parser.nextTag();
+                                } else {
+                                    test.setReportLog(ReportLog.parse(parser));
+                                    parser.nextTag();
+                                }
+                            }
+                            parser.require(XmlPullParser.END_TAG, NS, TEST_TAG);
+                        }
+                        parser.require(XmlPullParser.END_TAG, NS, CASE_TAG);
+                    }
+                    parser.require(XmlPullParser.END_TAG, NS, MODULE_TAG);
+                }
+                parser.require(XmlPullParser.END_TAG, NS, RESULT_TAG);
+                results.add(invocation);
+            } catch (XmlPullParserException e) {
+                e.printStackTrace();
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return results;
+    }
+
+    /**
+     * @param result
+     * @param resultDir
+     * @param startTime
+     * @throws IOException
+     * @throws XmlPullParserException
+     */
+    public static void writeResults(String suiteName, String suiteVersion, String suitePlan,
+            IInvocationResult result, File resultDir, long startTime, long endTime)
+                    throws IOException, XmlPullParserException {
+        int passed = result.countResults(TestStatus.PASS);
+        int failed = result.countResults(TestStatus.FAIL);
+        int notExecuted = result.countResults(TestStatus.NOT_EXECUTED);
+        File resultFile = new File(resultDir, TEST_RESULT_FILE_NAME);
+        OutputStream stream = new FileOutputStream(resultFile);
+        XmlSerializer serializer = XmlPullParserFactory.newInstance(TYPE, null).newSerializer();
+        serializer.setOutput(stream, ENCODING);
+        serializer.startDocument(ENCODING, false);
+        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
+        serializer.processingInstruction(
+                "xml-stylesheet type=\"text/xsl\" href=\"compatibility-result.xsl\"");
+        serializer.startTag(NS, RESULT_TAG);
+        serializer.attribute(NS, START_TIME_ATTR, formatTimeStamp(startTime));
+        serializer.attribute(NS, END_TIME_ATTR, formatTimeStamp(endTime));
+        serializer.attribute(NS, SUITE_NAME_ATTR, suiteName);
+        serializer.attribute(NS, SUITE_VERSION_ATTR, suiteVersion);
+        serializer.attribute(NS, SUITE_PLAN_ATTR, suitePlan);
+        serializer.attribute(NS, REPORT_VERSION_ATTR, RESULT_FILE_VERSION);
+
+        String hostName = "";
+        try {
+            hostName = InetAddress.getLocalHost().getHostName();
+        } catch (UnknownHostException ignored) {}
+        serializer.attribute(NS, HOST_NAME_ATTR, hostName);
+        serializer.attribute(NS, OS_NAME_ATTR, System.getProperty("os.name"));
+        serializer.attribute(NS, OS_VERSION_ATTR, System.getProperty("os.version"));
+        serializer.attribute(NS, OS_ARCH_ATTR, System.getProperty("os.arch"));
+        serializer.attribute(NS, JAVA_VENDOR_ATTR, System.getProperty("java.vendor"));
+        serializer.attribute(NS, JAVA_VERSION_ATTR, System.getProperty("java.version"));
+
+        // Summary
+        serializer.startTag(NS, SUMMARY_TAG);
+        serializer.attribute(NS, PASS_ATTR, Integer.toString(passed));
+        serializer.attribute(NS, FAILED_ATTR, Integer.toString(failed));
+        serializer.attribute(NS, NOT_EXECUTED_ATTR, Integer.toString(notExecuted));
+        serializer.endTag(NS, SUMMARY_TAG);
+
+        // Results
+        for (IModuleResult module : result.getModules()) {
+            serializer.startTag(NS, MODULE_TAG);
+            serializer.attribute(NS, NAME_ATTR, module.getName());
+            serializer.attribute(NS, ABI_ATTR, module.getAbi());
+            serializer.attribute(NS, DEVICE_ATTR, module.getDeviceSerial());
+            for (ICaseResult cr : module.getResults()) {
+                serializer.startTag(NS, CASE_TAG);
+                serializer.attribute(NS, NAME_ATTR, cr.getName());
+                for (ITestResult r : cr.getResults()) {
+                    serializer.startTag(NS, TEST_TAG);
+                    serializer.attribute(NS, RESULT_ATTR, r.getResultStatus().getValue());
+                    serializer.attribute(NS, NAME_ATTR, r.getName());
+                    serializer.attribute(NS, START_TIME_ATTR, formatTimeStamp(r.getStartTime()));
+                    serializer.attribute(NS, END_TIME_ATTR, formatTimeStamp(r.getEndTime()));
+                    String message = r.getMessage();
+                    if (message != null) {
+                        serializer.startTag(NS, FAILURE_TAG);
+                        serializer.attribute(NS, MESSAGE_ATTR, message);
+                        String stackTrace = r.getStackTrace();
+                        if (stackTrace != null) {
+                            serializer.startTag(NS, STACK_TAG);
+                            serializer.text(stackTrace);
+                            serializer.endTag(NS, STACK_TAG);
+                        }
+                        serializer.endTag(NS, FAILURE_TAG);
+                    }
+                    ReportLog.serialize(serializer, r.getReportLog());
+                    serializer.endTag(NS, TEST_TAG);
+                }
+                serializer.endTag(NS, CASE_TAG);
+            }
+            serializer.endTag(NS, MODULE_TAG);
+        }
+        serializer.endDocument();
+    }
+
+    private static String formatTimeStamp(long epochTime) {
+        return TIME_FORMAT.format(new Date(epochTime));
+    }
+
+    private static long parseTimeStamp(String time) {
+        try {
+            return TIME_FORMAT.parse(time).getTime();
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return 0L;
+    }
+}
diff --git a/tests/tests/acceleration/Android.mk b/common/util/tests/Android.mk
similarity index 64%
copy from tests/tests/acceleration/Android.mk
copy to common/util/tests/Android.mk
index d417371..0e0af50 100644
--- a/tests/tests/acceleration/Android.mk
+++ b/common/util/tests/Android.mk
@@ -1,10 +1,10 @@
-# Copyright (C) 2011 The Android Open Source Project
+# 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
+# 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,
@@ -16,18 +16,12 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
+LOCAL_JAVA_LIBRARIES := junit kxml2-2.3.0 tradefed-prebuilt compatibility-common-util-hostsidelib
 
-LOCAL_INSTRUMENTATION_FOR := CtsAccelerationTestStubs
+LOCAL_MODULE := compatibility-common-util-tests
 
-LOCAL_SDK_VERSION := current
+LOCAL_MODULE_TAGS := optional
 
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/common/util/tests/src/com/android/compatibility/common/util/AbiUtilsTest.java b/common/util/tests/src/com/android/compatibility/common/util/AbiUtilsTest.java
new file mode 100644
index 0000000..567da54
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/AbiUtilsTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for {@link AbiUtils}
+ */
+public class AbiUtilsTest extends TestCase {
+
+    private static final String MODULE_NAME = "ModuleName";
+    private static final String ABI_NAME = "mips64";
+    private static final String ABI_FLAG = "--abi mips64 ";
+    private static final String ABI_ID = "mips64 ModuleName";
+
+    public void testCreateAbiFlag() {
+        String flag = AbiUtils.createAbiFlag(ABI_NAME);
+        assertEquals("Incorrect flag created", ABI_FLAG, flag);
+    }
+
+    public void testCreateId() {
+        String id = AbiUtils.createId(ABI_NAME, MODULE_NAME);
+        assertEquals("Incorrect id created", ABI_ID, id);
+    }
+
+    public void testParseId() {
+        String[] parts = AbiUtils.parseId(ABI_ID);
+        assertEquals("Wrong size array", 2, parts.length);
+        assertEquals("Wrong abi name", ABI_NAME, parts[0]);
+        assertEquals("Wrong module name", MODULE_NAME, parts[1]);
+    }
+
+    public void testParseName() {
+        String name = AbiUtils.parseTestName(ABI_ID);
+        assertEquals("Incorrect module name", MODULE_NAME, name);
+    }
+
+    public void testParseAbi() {
+        String abi = AbiUtils.parseAbi(ABI_ID);
+        assertEquals("Incorrect abi name", ABI_NAME, abi);
+    }
+
+}
diff --git a/common/util/tests/src/com/android/compatibility/common/util/CaseResultTest.java b/common/util/tests/src/com/android/compatibility/common/util/CaseResultTest.java
new file mode 100644
index 0000000..ae29597
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/CaseResultTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for {@link CaseResult}
+ */
+public class CaseResultTest extends TestCase {
+
+    private static final String CLASS = "android.test.FoorBar";
+    private static final String METHOD_1 = "testBlah1";
+    private static final String METHOD_2 = "testBlah2";
+    private static final String METHOD_3 = "testBlah3";
+    private static final String MESSAGE = "Something small is not alright";
+    private static final String STACK_TRACE = "Something small is not alright\n " +
+            "at four.big.insects.Marley.sing(Marley.java:10)";
+    private CaseResult mResult;
+
+    @Override
+    public void setUp() throws Exception {
+        mResult = new CaseResult(CLASS);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        mResult = null;
+    }
+
+    public void testAccessors() throws Exception {
+        assertEquals("Incorrect case name", CLASS, mResult.getName());
+    }
+
+    public void testResultCreation() throws Exception {
+        ITestResult testResult = mResult.getOrCreateResult(METHOD_1);
+        // Should create one
+        assertEquals("Expected one result", 1, mResult.getResults().size());
+        assertTrue("Expected test result", mResult.getResults().contains(testResult));
+        // Should not create another one
+        ITestResult testResult2 = mResult.getOrCreateResult(METHOD_1);
+        assertEquals("Expected the same result", testResult, testResult2);
+        assertEquals("Expected one result", 1, mResult.getResults().size());
+    }
+
+    public void testResultReporting() throws Exception {
+        ITestResult testResult = mResult.getOrCreateResult(METHOD_1);
+        testResult.failed(STACK_TRACE);
+        assertEquals("Expected status to be set", TestStatus.FAIL, testResult.getResultStatus());
+        assertEquals("Expected message to be set", MESSAGE, testResult.getMessage());
+        assertEquals("Expected stack to be set", STACK_TRACE, testResult.getStackTrace());
+        testResult = mResult.getOrCreateResult(METHOD_2);
+        testResult.passed(null);
+        assertEquals("Expected status to be set", TestStatus.PASS, testResult.getResultStatus());
+        assertEquals("Expected two results", 2, mResult.getResults().size());
+    }
+
+    public void testCountResults() throws Exception {
+        mResult.getOrCreateResult(METHOD_1).failed(STACK_TRACE);
+        mResult.getOrCreateResult(METHOD_2).failed(STACK_TRACE);
+        mResult.getOrCreateResult(METHOD_3).passed(null);
+        assertEquals("Expected two failures", 2, mResult.countResults(TestStatus.FAIL));
+        assertEquals("Expected one pass", 1, mResult.countResults(TestStatus.PASS));
+    }
+}
\ No newline at end of file
diff --git a/common/util/tests/src/com/android/compatibility/common/util/MetricsXmlSerializerTest.java b/common/util/tests/src/com/android/compatibility/common/util/MetricsXmlSerializerTest.java
index 05e69d8..c6f3ec1 100644
--- a/common/util/tests/src/com/android/compatibility/common/util/MetricsXmlSerializerTest.java
+++ b/common/util/tests/src/com/android/compatibility/common/util/MetricsXmlSerializerTest.java
@@ -24,6 +24,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
+//TODO(stuartscott): Delete file for v2, ReportLog can serialize itself.
 /**
  * Unit tests for {@link MetricsXmlSerializer}
  */
@@ -32,8 +33,7 @@
     static class LocalReportLog extends ReportLog {}
     private static final double[] VALUES = new double[] {1, 11, 21, 1211, 111221};
     private static final String HEADER = "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>";
-    private static final String EXPECTED_XML =
-            HEADER
+    private static final String EXPECTED_XML = HEADER
             + "<Summary message=\"Sample\" scoreType=\"higher_better\" unit=\"byte\">1.0</Summary>"
             + "<Details>"
                     + "<ValueArray source=\"com.android.compatibility.common.util."
@@ -89,4 +89,4 @@
 
         assertEquals(EXPECTED_XML, mByteArrayOutputStream.toString("utf-8"));
     }
-}
+}
\ No newline at end of file
diff --git a/common/util/tests/src/com/android/compatibility/common/util/ModuleResultTest.java b/common/util/tests/src/com/android/compatibility/common/util/ModuleResultTest.java
new file mode 100644
index 0000000..28b98fe
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/ModuleResultTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for {@link ModuleResult}
+ */
+public class ModuleResultTest extends TestCase {
+
+    private static final String NAME = "ModuleName";
+    private static final String ABI = "mips64";
+    private static final String ID = AbiUtils.createId(ABI, NAME);
+    private static final String DEVICE = "device123";
+    private static final String CLASS = "android.test.FoorBar";
+    private static final String METHOD_1 = "testBlah1";
+    private static final String METHOD_2 = "testBlah2";
+    private static final String METHOD_3 = "testBlah3";
+    private static final String STACK_TRACE = "Something small is not alright\n " +
+            "at four.big.insects.Marley.sing(Marley.java:10)";
+    private ModuleResult mResult;
+
+    @Override
+    public void setUp() throws Exception {
+        mResult = new ModuleResult(ID);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        mResult = null;
+    }
+
+    public void testAccessors() throws Exception {
+        mResult.setDeviceSerial(DEVICE);
+        assertEquals("Incorrect device serial", DEVICE, mResult.getDeviceSerial());
+        assertEquals("Incorrect module ID", ID, mResult.getId());
+        assertEquals("Incorrect module ABI", ABI, mResult.getAbi());
+        assertEquals("Incorrect module name", NAME, mResult.getName());
+    }
+
+    public void testResultCreation() throws Exception {
+        ICaseResult caseResult = mResult.getOrCreateResult(CLASS);
+        // Should create one
+        assertEquals("Expected one result", 1, mResult.getResults().size());
+        assertTrue("Expected test result", mResult.getResults().contains(caseResult));
+        // Should not create another one
+        ICaseResult caseResult2 = mResult.getOrCreateResult(CLASS);
+        assertEquals("Expected the same result", caseResult, caseResult2);
+        assertEquals("Expected one result", 1, mResult.getResults().size());
+    }
+
+    public void testCountResults() throws Exception {
+        ICaseResult testCase = mResult.getOrCreateResult(CLASS);
+        testCase.getOrCreateResult(METHOD_1).failed(STACK_TRACE);
+        testCase.getOrCreateResult(METHOD_2).failed(STACK_TRACE);
+        testCase.getOrCreateResult(METHOD_3).passed(null);
+        assertEquals("Expected two failures", 2, mResult.countResults(TestStatus.FAIL));
+        assertEquals("Expected one pass", 1, mResult.countResults(TestStatus.PASS));
+    }
+}
\ No newline at end of file
diff --git a/common/util/tests/src/com/android/compatibility/common/util/ReportLogTest.java b/common/util/tests/src/com/android/compatibility/common/util/ReportLogTest.java
index a5f3306..b41525b 100644
--- a/common/util/tests/src/com/android/compatibility/common/util/ReportLogTest.java
+++ b/common/util/tests/src/com/android/compatibility/common/util/ReportLogTest.java
@@ -18,51 +18,50 @@
 
 import junit.framework.TestCase;
 
-import java.util.Arrays;
-
 /**
  * Unit tests for {@link ReportLog}
  */
 public class ReportLogTest extends TestCase {
 
-    private static final double[] VALUES = new double[] {1, 11, 21, 1211, 111221};
+    private static final double[] VALUES = new double[] {.1, 124, 4736, 835.683, 98, 395};
+    private static final String HEADER = "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>";
+    private static final String EXPECTED_XML =
+            HEADER + "\r\n" +
+            "<Summary>\r\n" +
+            "  <Metric source=\"com.android.compatibility.common.util.ReportLogTest#testSerialize:62\" message=\"Sample\" score-type=\"higher_better\" score-unit=\"byte\">\r\n" +
+            "    <Value>1.0</Value>\r\n" +
+            "  </Metric>\r\n" +
+            "</Summary>\r\n" +
+            "<Detail>\r\n" +
+            "  <Metric source=\"com.android.compatibility.common.util.ReportLogTest#testSerialize:63\" message=\"Details\" score-type=\"neutral\" score-unit=\"fps\">\r\n" +
+            "    <Value>0.1</Value>\r\n" +
+            "    <Value>124.0</Value>\r\n" +
+            "    <Value>4736.0</Value>\r\n" +
+            "    <Value>835.683</Value>\r\n" +
+            "    <Value>98.0</Value>\r\n" +
+            "    <Value>395.0</Value>\r\n" +
+            "  </Metric>\r\n" +
+            "</Detail>";
 
-    private static final String EXPECTED_ENCODED_REPORT_LOG =
-            "com.android.compatibility.common.util.ReportLogTest#testEncodeDecode:44|" +
-            "Sample Summary| |HIGHER_BETTER|BYTE|1.0 ++++" +
-            "com.android.compatibility.common.util.ReportLogTest#testEncodeDecode:45|" +
-            "Details| |NEUTRAL|FPS|1.0 11.0 21.0 1211.0 111221.0 ";
-    private ReportLog reportLog;
+    private ReportLog mReportLog;
 
     @Override
     protected void setUp() throws Exception {
-        this.reportLog = new ReportLog();
+        mReportLog = new ReportLog();
     }
 
-    public void testEncodeDecode() {
-
-        reportLog.setSummary("Sample Summary", 1.0, ResultType.HIGHER_BETTER, ResultUnit.BYTE);
-        reportLog.addValues("Details", VALUES, ResultType.NEUTRAL, ResultUnit.FPS);
-
-        String encodedReportLog = reportLog.toEncodedString();
-        assertEquals(EXPECTED_ENCODED_REPORT_LOG, encodedReportLog);
-
-        ReportLog decodedReportLog = ReportLog.fromEncodedString(encodedReportLog);
-        ReportLog.Result summary = reportLog.getSummary();
-        assertEquals("Sample Summary", summary.getMessage());
-        assertFalse(summary.getLocation().isEmpty());
-        assertEquals(ResultType.HIGHER_BETTER, summary.getType());
-        assertEquals(ResultUnit.BYTE, summary.getUnit());
-        assertTrue(Arrays.equals(new double[] {1.0}, summary.getValues()));
-
-        assertEquals(1, decodedReportLog.getDetailedMetrics().size());
-        ReportLog.Result detail = decodedReportLog.getDetailedMetrics().get(0);
-        assertEquals("Details", detail.getMessage());
-        assertFalse(detail.getLocation().isEmpty());
-        assertEquals(ResultType.NEUTRAL, detail.getType());
-        assertEquals(ResultUnit.FPS, detail.getUnit());
-        assertTrue(Arrays.equals(VALUES, detail.getValues()));
-
-        assertEquals(encodedReportLog, decodedReportLog.toEncodedString());
+    public void testSerialize_null() throws Exception {
+        assertEquals(HEADER, ReportLog.serialize(null));
     }
+
+    public void testSerialize_noData() throws Exception {
+        assertEquals(HEADER, ReportLog.serialize(mReportLog));
+    }
+
+    public void testSerialize() throws Exception {
+        mReportLog.setSummary("Sample", 1.0, ResultType.HIGHER_BETTER, ResultUnit.BYTE);
+        mReportLog.addValues("Details", VALUES, ResultType.NEUTRAL, ResultUnit.FPS);
+        assertEquals(EXPECTED_XML, ReportLog.serialize(mReportLog));
+    }
+
 }
diff --git a/common/util/tests/src/com/android/compatibility/common/util/StatTest.java b/common/util/tests/src/com/android/compatibility/common/util/StatTest.java
new file mode 100644
index 0000000..6e53d48
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/StatTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import com.android.compatibility.common.util.Stat;
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the {@link Stat} class.
+ */
+public class StatTest extends TestCase {
+
+    /**
+     * Test {@link Stat#get95PercentileValue(double[])}.
+     */
+    public void testGet95PercentileValue() {
+        double[] values = new double[100];
+        for (int i = 0; i < 100; i++) {
+            values[i] = i;
+        }
+        assertEquals(95, (int) Stat.get95PercentileValue(values));
+
+        values = new double[1000];
+        for (int i = 0; i < 1000; i++) {
+            values[i] = i;
+        }
+        assertEquals(950, (int) Stat.get95PercentileValue(values));
+
+        values = new double[100];
+        for (int i = 0; i < 100; i++) {
+            values[i] = i * i;
+        }
+        assertEquals(95 * 95, (int) Stat.get95PercentileValue(values));
+    }
+
+    /**
+     * Test {@link Stat#getAverage(double[])}.
+     */
+    public void testGetAverage() {
+        double[] values = new double[]{0, 1, 2, 3, 4};
+        double average = Stat.getAverage(values);
+        assertEquals(2.0, average, 0.00001);
+
+        values = new double[]{1, 2, 3, 4, 5};
+        average = Stat.getAverage(values);
+        assertEquals(3.0, average, 0.00001);
+
+        values = new double[]{0, 1, 4, 9, 16};
+        average = Stat.getAverage(values);
+        assertEquals(6.0, average, 0.00001);
+    }
+
+    /**
+     * Test standard deviation.
+     */
+    public void testGetStandardDeviation() {
+        double[] values = new double[]{0, 1, 2, 3, 4};
+        double stddev = Stat.getStat(values).mStddev;
+        assertEquals(Math.sqrt(2.5), stddev, 0.00001);
+
+        values = new double[]{1, 2, 3, 4, 5};
+        stddev = Stat.getStat(values).mStddev;
+        assertEquals(Math.sqrt(2.5), stddev, 0.00001);
+
+        values = new double[]{0, 2, 4, 6, 8};
+        stddev = Stat.getStat(values).mStddev;
+        assertEquals(Math.sqrt(10.0), stddev, 0.00001);
+    }
+
+
+}
diff --git a/common/util/tests/src/com/android/compatibility/common/util/TestFilterTest.java b/common/util/tests/src/com/android/compatibility/common/util/TestFilterTest.java
new file mode 100644
index 0000000..bc1091b
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/TestFilterTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for {@link TestFilter}
+ */
+public class TestFilterTest extends TestCase {
+
+    private static final String NAME = "ModuleName";
+    private static final String ABI = "mips64";
+    private static final String TEST = "com.android.foobar.Blah#testAllTheThings";
+    private static final String NAME_FILTER = String.format("%s", NAME);
+    private static final String ABI_NAME_FILTER = String.format("%s %s", ABI, NAME);
+    private static final String NAME_TEST_FILTER = String.format("%s %s", NAME, TEST);
+    private static final String FULL_FILTER = String.format("%s %s %s", ABI, NAME, TEST);
+
+    public void testParseNameFilter() {
+        TestFilter filter = TestFilter.createFrom(NAME_FILTER);
+        assertNull("Incorrect abi", filter.getAbi());
+        assertEquals("Incorrect name", NAME, filter.getName());
+        assertNull("Incorrect test", filter.getTest());
+    }
+
+    public void testParseAbiNameFilter() {
+        TestFilter filter = TestFilter.createFrom(ABI_NAME_FILTER);
+        assertEquals("Incorrect abi", ABI, filter.getAbi());
+        assertEquals("Incorrect name", NAME, filter.getName());
+        assertNull("Incorrect test", filter.getTest());
+    }
+
+    public void testParseNameTestFilter() {
+        TestFilter filter = TestFilter.createFrom(NAME_TEST_FILTER);
+        assertNull("Incorrect abi", filter.getAbi());
+        assertEquals("Incorrect name", NAME, filter.getName());
+        assertEquals("Incorrect test", TEST, filter.getTest());
+    }
+
+    public void testParseFullFilter() {
+        TestFilter filter = TestFilter.createFrom(FULL_FILTER);
+        assertEquals("Incorrect abi", ABI, filter.getAbi());
+        assertEquals("Incorrect name", NAME, filter.getName());
+        assertEquals("Incorrect test", TEST, filter.getTest());
+    }
+
+    public void testCreateNameFilter() {
+        TestFilter filter = new TestFilter(null, NAME, null);
+        assertEquals("Incorrect filter", NAME_FILTER, filter.toString());
+    }
+
+    public void testCreateAbiNameFilter() {
+        TestFilter filter = new TestFilter(ABI, NAME, null);
+        assertEquals("Incorrect filter", ABI_NAME_FILTER, filter.toString());
+    }
+
+    public void testCreateNameTestFilter() {
+        TestFilter filter = new TestFilter(null, NAME, TEST);
+        assertEquals("Incorrect filter", NAME_TEST_FILTER, filter.toString());
+    }
+
+    public void testCreateFullFilter() {
+        TestFilter filter = new TestFilter(ABI, NAME, TEST);
+        assertEquals("Incorrect filter", FULL_FILTER, filter.toString());
+    }
+
+}
diff --git a/common/util/tests/src/com/android/compatibility/common/util/TestResultTest.java b/common/util/tests/src/com/android/compatibility/common/util/TestResultTest.java
new file mode 100644
index 0000000..5e4431e
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/TestResultTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for {@link TestResult}
+ */
+public class TestResultTest extends TestCase {
+
+    private static final String CLASS = "android.test.FoorBar";
+    private static final String METHOD_1 = "testBlah1";
+    private static final String TEST_1 = String.format("%s#%s", CLASS, METHOD_1);
+    private CaseResult mCase;
+    private TestResult mResult;
+
+    @Override
+    public void setUp() throws Exception {
+        mCase = new CaseResult(CLASS);
+        mResult = new TestResult(mCase, METHOD_1);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        mResult = null;
+    }
+
+    public void testAccessors() throws Exception {
+        assertEquals("Incorrect test name", METHOD_1, mResult.getName());
+        assertEquals("Incorrect full name", TEST_1, mResult.getFullName());
+    }
+
+}
\ No newline at end of file
diff --git a/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java b/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
deleted file mode 100644
index 348c680..0000000
--- a/common/util/tests/src/com/android/compatibility/common/util/UnitTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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 com.android.compatibility.common.util;
-
-import junit.framework.TestSuite;
-
-/**
- * A {@link TestSuite} for the common.util package.
- */
-public class UnitTests extends TestSuite {
-
-    public UnitTests() {
-        super();
-
-        addTestSuite(MetricsStoreTest.class);
-        addTestSuite(MetricsXmlSerializerTest.class);
-        addTestSuite(ReportLogTest.class);
-    }
-}
diff --git a/common/util/tests/src/com/android/compatibility/common/util/XmlResultHandlerTest.java b/common/util/tests/src/com/android/compatibility/common/util/XmlResultHandlerTest.java
new file mode 100644
index 0000000..e8e38c2
--- /dev/null
+++ b/common/util/tests/src/com/android/compatibility/common/util/XmlResultHandlerTest.java
@@ -0,0 +1,325 @@
+/*
+ * 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 com.android.compatibility.common.util;
+
+import com.android.tradefed.util.FileUtil;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Unit tests for {@link XmlResultHandler}
+ */
+public class XmlResultHandlerTest extends TestCase {
+
+    private static final String SUITE_NAME = "CTS";
+    private static final String SUITE_VERSION = "5.0";
+    private static final String SUITE_PLAN = "cts";
+    private static final String REPORT_VERSION = "5.0";
+    private static final String OS_NAME = System.getProperty("os.name");
+    private static final String OS_VERSION = System.getProperty("os.version");
+    private static final String OS_ARCH = System.getProperty("os.arch");
+    private static final String JAVA_VENDOR = System.getProperty("java.vendor");
+    private static final String JAVA_VERSION = System.getProperty("java.version");
+    private static final String NAME_A = "ModuleA";
+    private static final String NAME_B = "ModuleB";
+    private static final String ABI = "mips64";
+    private static final String ID_A = AbiUtils.createId(ABI, NAME_A);
+    private static final String ID_B = AbiUtils.createId(ABI, NAME_B);
+    private static final String DEVICE_A = "device123";
+    private static final String DEVICE_B = "device456";
+    private static final String CLASS_A = "android.test.Foor";
+    private static final String CLASS_B = "android.test.Bar";
+    private static final String METHOD_1 = "testBlah1";
+    private static final String METHOD_2 = "testBlah2";
+    private static final String METHOD_3 = "testBlah3";
+    private static final String METHOD_4 = "testBlah4";
+    private static final String SUMMARY_SOURCE = String.format("%s#%s:20", CLASS_B, METHOD_4);
+    private static final String DETAILS_SOURCE = String.format("%s#%s:18", CLASS_B, METHOD_4);
+    private static final String SUMMARY_MESSAGE = "Headline";
+    private static final double SUMMARY_VALUE = 9001;
+    private static final String DETAILS_MESSAGE = "Deats";
+    private static final double DETAILS_VALUE_1 = 14;
+    private static final double DETAILS_VALUE_2 = 18;
+    private static final double DETAILS_VALUE_3 = 17;
+    private static final String MESSAGE = "Something small is not alright";
+    private static final String STACK_TRACE = "Something small is not alright\n " +
+            "at four.big.insects.Marley.sing(Marley.java:10)";
+    private static final String START = "2015-05-14 00:00:01";
+    private static final long START_MS = 1431586801000L;
+    private static final String END = "2015-05-14 23:59:59";
+    private static final long END_MS = 1431673199000L;
+    private static final String JOIN = "%s%s";
+    private static final String XML_BASE =
+            "<?xml version='1.0' encoding='UTF-8' standalone='no' ?>" +
+            "<?xml-stylesheet type=\"text/xsl\" href=\"compatibility-result.xsl\"?>\n" +
+            "<Result start=\"%s\" end=\"%s\" suite-name=\"%s\" suite-version=\"%s\" " +
+            "suite-plan=\"%s\" report-version=\"%s\" host-name=\"%s\" os-name=\"%s\" " +
+            "os-version=\"%s\" os-arch=\"%s\" java-vendor=\"%s\" java-version=\"%s\">\n" +
+            "%s%s" +
+            "</Result>";
+    private static final String XML_SUMMARY =
+            "  <Summary pass=\"%d\" failed=\"%d\" not-executed=\"%d\" />\n";
+    private static final String XML_MODULE =
+            "  <Module name=\"%s\" abi=\"%s\" device=\"%s\">\n" +
+            "%s" +
+            "  </Module>\n";
+    private static final String XML_CASE =
+            "    <TestCase name=\"%s\">\n" +
+            "%s" +
+            "    </TestCase>\n";
+    private static final String XML_TEST_PASS =
+            "      <Test result=\"pass\" name=\"%s\" start=\"%s\" end=\"%s\" />\n";
+    private static final String XML_TEST_NOT_EXECUTED =
+            "      <Test result=\"not-executed\" name=\"%s\" start=\"%s\" end=\"%s\" />\n";
+    private static final String XML_TEST_FAIL =
+            "      <Test result=\"fail\" name=\"%s\" start=\"%s\" end=\"%s\" >\n" +
+            "        <Failure message=\"%s\">\n" +
+            "          <StackTrace>%s</StackTrace>\n" +
+            "        </Failure>\n" +
+            "      </Test>\n";
+    private static final String XML_TEST_RESULT =
+            "      <Test result=\"pass\" name=\"%s\" start=\"%s\" end=\"%s\">\n" +
+            "        <Summary>\n" +
+            "          <Metric source=\"%s\" message=\"%s\" score-type=\"%s\" score-unit=\"%s\">\n" +
+            "             <Value>%s</Value>\n" +
+            "          </Metric>\n" +
+            "        </Summary>\n" +
+            "        <Detail>\n" +
+            "          <Metric source=\"%s\" message=\"%s\" score-type=\"%s\" score-unit=\"%s\">\n" +
+            "            <Value>%s</Value>\n" +
+            "            <Value>%s</Value>\n" +
+            "            <Value>%s</Value>\n" +
+            "          </Metric>\n" +
+            "        </Detail>\n" +
+            "      </Test>\n";
+    private File resultsDir = null;
+    private File resultDir = null;
+
+    @Override
+    public void setUp() throws Exception {
+        resultsDir = FileUtil.createTempDir("results");
+        resultDir = FileUtil.createTempDir("12345", resultsDir);
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        if (resultsDir != null) {
+            FileUtil.recursiveDelete(resultsDir);
+        }
+    }
+
+    public void testSerialization() throws Exception {
+        IInvocationResult result = new InvocationResult(resultDir);
+        result.setStartTime(START_MS);
+        result.setTestPlan(SUITE_PLAN);
+        IModuleResult moduleA = result.getOrCreateModule(ID_A);
+        moduleA.setDeviceSerial(DEVICE_A);
+        ICaseResult moduleACase = moduleA.getOrCreateResult(CLASS_A);
+        ITestResult moduleATest1 = moduleACase.getOrCreateResult(METHOD_1);
+        moduleATest1.setStartTime(START_MS);
+        moduleATest1.setResultStatus(TestStatus.PASS);
+        moduleATest1.setEndTime(END_MS);
+        ITestResult moduleATest2 = moduleACase.getOrCreateResult(METHOD_2);
+        moduleATest2.setStartTime(START_MS);
+        moduleATest2.setResultStatus(TestStatus.NOT_EXECUTED);
+        moduleATest2.setEndTime(END_MS);
+
+        IModuleResult moduleB = result.getOrCreateModule(ID_B);
+        moduleB.setDeviceSerial(DEVICE_B);
+        ICaseResult moduleBCase = moduleB.getOrCreateResult(CLASS_B);
+        ITestResult moduleBTest3 = moduleBCase.getOrCreateResult(METHOD_3);
+        moduleBTest3.setStartTime(START_MS);
+        moduleBTest3.setResultStatus(TestStatus.FAIL);
+        moduleBTest3.setMessage(MESSAGE);
+        moduleBTest3.setStackTrace(STACK_TRACE);
+        moduleBTest3.setEndTime(END_MS);
+        ITestResult moduleBTest4 = moduleBCase.getOrCreateResult(METHOD_4);
+        moduleBTest4.setStartTime(START_MS);
+        moduleBTest4.setResultStatus(TestStatus.PASS);
+        ReportLog report = new ReportLog();
+        ReportLog.Metric summary = new ReportLog.Metric(SUMMARY_SOURCE, SUMMARY_MESSAGE,
+                SUMMARY_VALUE, ResultType.HIGHER_BETTER, ResultUnit.SCORE);
+        report.setSummary(summary);
+        ReportLog.Metric details = new ReportLog.Metric(DETAILS_SOURCE, DETAILS_MESSAGE,
+                new double[] {DETAILS_VALUE_1, DETAILS_VALUE_2, DETAILS_VALUE_3},
+                ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.addMetric(details);
+        moduleBTest4.setReportLog(report);
+        moduleBTest4.setEndTime(END_MS);
+
+        // Serialize to file
+        XmlResultHandler.writeResults(SUITE_NAME, SUITE_VERSION, SUITE_PLAN, result, resultDir,
+                START_MS, END_MS);
+
+        // Parse the results and assert correctness
+        checkResult(XmlResultHandler.getResults(resultsDir), resultDir);
+    }
+
+    public void testParsing() throws Exception {
+        File resultsDir = null;
+        FileWriter writer = null;
+        try {
+            resultsDir = FileUtil.createTempDir("results");
+            File resultDir = FileUtil.createTempDir("12345", resultsDir);
+            // Create the result file
+            File resultFile = new File(resultDir, XmlResultHandler.TEST_RESULT_FILE_NAME);
+            writer = new FileWriter(resultFile);
+            String summary = String.format(XML_SUMMARY, 2, 1, 1);
+            String moduleATest1 = String.format(XML_TEST_PASS, METHOD_1, START, END);
+            String moduleATest2 = String.format(XML_TEST_NOT_EXECUTED, METHOD_2, START, END);
+            String moduleATests = String.format(JOIN, moduleATest1, moduleATest2);
+            String moduleACases = String.format(XML_CASE, CLASS_A, moduleATests);
+            String moduleA = String.format(XML_MODULE, NAME_A, ABI, DEVICE_A, moduleACases);
+            String moduleBTest3 = String.format(XML_TEST_FAIL, METHOD_3, START, END, MESSAGE, STACK_TRACE);
+            String moduleBTest4 = String.format(XML_TEST_RESULT, METHOD_4, START, END,
+                    SUMMARY_SOURCE, SUMMARY_MESSAGE, ResultType.HIGHER_BETTER.toReportString(),
+                    ResultUnit.SCORE.toReportString(), Double.toString(SUMMARY_VALUE),
+                    DETAILS_SOURCE, DETAILS_MESSAGE, ResultType.LOWER_BETTER.toReportString(),
+                    ResultUnit.MS.toReportString(), Double.toString(DETAILS_VALUE_1),
+                    Double.toString(DETAILS_VALUE_2), Double.toString(DETAILS_VALUE_3));
+            String moduleBTests = String.format(JOIN, moduleBTest3, moduleBTest4);
+            String moduleBCases = String.format(XML_CASE, CLASS_B, moduleBTests);
+            String moduleB = String.format(XML_MODULE, NAME_B, ABI, DEVICE_B, moduleBCases);
+            String modules = String.format(JOIN, moduleA, moduleB);
+            String hostName = "";
+            try {
+                hostName = InetAddress.getLocalHost().getHostName();
+            } catch (UnknownHostException ignored) {}
+            String output = String.format(XML_BASE, START, END, SUITE_NAME, SUITE_VERSION,
+                    SUITE_PLAN, REPORT_VERSION, hostName, OS_NAME,  OS_VERSION, OS_ARCH,
+                    JAVA_VENDOR, JAVA_VERSION, summary, modules);
+            writer.write(output);
+            writer.flush();
+
+            // Parse the results and assert correctness
+            checkResult(XmlResultHandler.getResults(resultsDir), resultDir);
+        } finally {
+            if (writer != null) {
+                writer.close();
+            }
+        }
+    }
+        
+    private void checkResult(List<IInvocationResult> results, File resultDir) throws Exception {
+        assertEquals("Expected 1 result", 1, results.size());
+        IInvocationResult result = results.get(0);
+        assertEquals("Expected 2 passes", 2, result.countResults(TestStatus.PASS));
+        assertEquals("Expected 1 failure", 1, result.countResults(TestStatus.FAIL));
+        assertEquals("Expected 1 not executed", 1, result.countResults(TestStatus.NOT_EXECUTED));
+        Set<String> serials = result.getDeviceSerials();
+        assertEquals("Expected 2 devices", 2, serials.size());
+        assertTrue("Incorrect devices", serials.contains(DEVICE_A) && serials.contains(DEVICE_B));
+        assertEquals("Incorrect result dir", resultDir.getAbsolutePath(),
+                result.getResultDir().getAbsolutePath());
+        assertEquals("Incorrect start time", START_MS, result.getStartTime());
+        assertEquals("Incorrect test plan", SUITE_PLAN, result.getTestPlan());
+
+        List<IModuleResult> modules = result.getModules();
+        assertEquals("Expected 2 modules", 2, modules.size());
+
+        IModuleResult moduleA = modules.get(0);
+        assertEquals("Expected 1 pass", 1, moduleA.countResults(TestStatus.PASS));
+        assertEquals("Expected 0 failures", 0, moduleA.countResults(TestStatus.FAIL));
+        assertEquals("Expected 1 not executed", 1, moduleA.countResults(TestStatus.NOT_EXECUTED));
+        assertEquals("Incorrect ABI", ABI, moduleA.getAbi());
+        assertEquals("Incorrect name", NAME_A, moduleA.getName());
+        assertEquals("Incorrect ID", ID_A, moduleA.getId());
+        assertEquals("Incorrect device", DEVICE_A, moduleA.getDeviceSerial());
+        List<ICaseResult> moduleACases = moduleA.getResults();
+        assertEquals("Expected 1 test case", 1, moduleACases.size());
+        ICaseResult moduleACase = moduleACases.get(0);
+        assertEquals("Incorrect name", CLASS_A, moduleACase.getName());
+        List<ITestResult> moduleAResults = moduleACase.getResults();
+        assertEquals("Expected 2 results", 2, moduleAResults.size());
+        ITestResult moduleATest1 = moduleAResults.get(0);
+        assertEquals("Incorrect name", METHOD_1, moduleATest1.getName());
+        assertEquals("Incorrect start time", START_MS, moduleATest1.getStartTime());
+        assertEquals("Incorrect end time", END_MS, moduleATest1.getEndTime());
+        assertEquals("Incorrect result", TestStatus.PASS, moduleATest1.getResultStatus());
+        assertNull("Unexpected log", moduleATest1.getLog());
+        assertNull("Unexpected message", moduleATest1.getMessage());
+        assertNull("Unexpected stack trace", moduleATest1.getStackTrace());
+        assertNull("Unexpected report", moduleATest1.getReportLog());
+        ITestResult moduleATest2 = moduleAResults.get(1);
+        assertEquals("Incorrect name", METHOD_2, moduleATest2.getName());
+        assertEquals("Incorrect start time", START_MS, moduleATest2.getStartTime());
+        assertEquals("Incorrect end time", END_MS, moduleATest2.getEndTime());
+        assertEquals("Incorrect result", TestStatus.NOT_EXECUTED, moduleATest2.getResultStatus());
+        assertNull("Unexpected log", moduleATest2.getLog());
+        assertNull("Unexpected message", moduleATest2.getMessage());
+        assertNull("Unexpected stack trace", moduleATest2.getStackTrace());
+        assertNull("Unexpected report", moduleATest2.getReportLog());
+
+        IModuleResult moduleB = modules.get(1);
+        assertEquals("Expected 1 pass", 1, moduleB.countResults(TestStatus.PASS));
+        assertEquals("Expected 1 failure", 1, moduleB.countResults(TestStatus.FAIL));
+        assertEquals("Expected 0 not executed", 0, moduleB.countResults(TestStatus.NOT_EXECUTED));
+        assertEquals("Incorrect ABI", ABI, moduleB.getAbi());
+        assertEquals("Incorrect name", NAME_B, moduleB.getName());
+        assertEquals("Incorrect ID", ID_B, moduleB.getId());
+        assertEquals("Incorrect device", DEVICE_B, moduleB.getDeviceSerial());
+        List<ICaseResult> moduleBCases = moduleB.getResults();
+        assertEquals("Expected 1 test case", 1, moduleBCases.size());
+        ICaseResult moduleBCase = moduleBCases.get(0);
+        assertEquals("Incorrect name", CLASS_B, moduleBCase.getName());
+        List<ITestResult> moduleBResults = moduleBCase.getResults();
+        assertEquals("Expected 2 results", 2, moduleBResults.size());
+        ITestResult moduleBTest3 = moduleBResults.get(0);
+        assertEquals("Incorrect name", METHOD_3, moduleBTest3.getName());
+        assertEquals("Incorrect start time", START_MS, moduleBTest3.getStartTime());
+        assertEquals("Incorrect end time", END_MS, moduleBTest3.getEndTime());
+        assertEquals("Incorrect result", TestStatus.FAIL, moduleBTest3.getResultStatus());
+        assertNull("Unexpected log", moduleBTest3.getLog());
+        assertEquals("Incorrect message", MESSAGE, moduleBTest3.getMessage());
+        assertEquals("Incorrect stack trace", STACK_TRACE, moduleBTest3.getStackTrace());
+        assertNull("Unexpected report", moduleBTest3.getReportLog());
+        ITestResult moduleBTest4 = moduleBResults.get(1);
+        assertEquals("Incorrect name", METHOD_4, moduleBTest4.getName());
+        assertEquals("Incorrect start time", START_MS, moduleBTest4.getStartTime());
+        assertEquals("Incorrect end time", END_MS, moduleBTest4.getEndTime());
+        assertEquals("Incorrect result", TestStatus.PASS, moduleBTest4.getResultStatus());
+        assertNull("Unexpected log", moduleBTest4.getLog());
+        assertNull("Unexpected message", moduleBTest4.getMessage());
+        assertNull("Unexpected stack trace", moduleBTest4.getStackTrace());
+        ReportLog report = moduleBTest4.getReportLog();
+        assertNotNull("Expected report", report);
+        ReportLog.Metric summary = report.getSummary();
+        assertNotNull("Expected report summary", summary);
+        assertEquals("Incorrect source", SUMMARY_SOURCE, summary.getSource());
+        assertEquals("Incorrect message", SUMMARY_MESSAGE, summary.getMessage());
+        assertEquals("Incorrect type", ResultType.HIGHER_BETTER, summary.getType());
+        assertEquals("Incorrect unit", ResultUnit.SCORE, summary.getUnit());
+        assertTrue("Incorrect values", Arrays.equals(new double[] { SUMMARY_VALUE },
+                summary.getValues()));
+        List<ReportLog.Metric> details = report.getDetailedMetrics();
+        assertEquals("Expected 1 report detail", 1, details.size());
+        ReportLog.Metric detail = details.get(0);
+        assertEquals("Incorrect source", DETAILS_SOURCE, detail.getSource());
+        assertEquals("Incorrect message", DETAILS_MESSAGE, detail.getMessage());
+        assertEquals("Incorrect type", ResultType.LOWER_BETTER, detail.getType());
+        assertEquals("Incorrect unit", ResultUnit.MS, detail.getUnit());
+        assertTrue("Incorrect values", Arrays.equals(new double[] { DETAILS_VALUE_1,
+                DETAILS_VALUE_2, DETAILS_VALUE_3 }, detail.getValues()));
+    }
+}
diff --git a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
index bf9e81c..d7caabe 100644
--- a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
+++ b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
@@ -16,8 +16,8 @@
 
 package com.android.cts.appsecurity;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.DeviceNotAvailableException;
diff --git a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/ExternalStorageHostTest.java b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/ExternalStorageHostTest.java
index d74ec52..f53f656 100644
--- a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/ExternalStorageHostTest.java
+++ b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/ExternalStorageHostTest.java
@@ -16,8 +16,8 @@
 
 package com.android.cts.appsecurity;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.DeviceNotAvailableException;
diff --git a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/SplitTests.java b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/SplitTests.java
index ef3af8d..e73280c 100644
--- a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/SplitTests.java
+++ b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/SplitTests.java
@@ -16,8 +16,8 @@
 
 package com.android.cts.appsecurity;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk b/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
index 314f996..b3532fb 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util_v2
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk b/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
index b31e74b..9db6718 100644
--- a/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
 
-LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 ctstestrunner compatibility-device-util_v2 \
+LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 ctstestrunner compatibility-device-util \
 	ub-uiautomator
 
 LOCAL_SDK_VERSION := current
diff --git a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
index 47db44e..8cfc58d 100644
--- a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
+++ b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_PACKAGE_NAME := CtsWifiConfigCreator
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util_v2
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
index e47ec9e..7525c11 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
@@ -17,7 +17,6 @@
 package com.android.cts.devicepolicy;
 
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.Log.LogLevel;
 import com.android.ddmlib.testrunner.InstrumentationResultParser;
 import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
diff --git a/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java b/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
index b31a32d..c8c9863 100755
--- a/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
+++ b/hostsidetests/monkey/src/com/android/cts/monkey/AbstractMonkeyTest.java
@@ -1,7 +1,7 @@
 package com.android.cts.monkey;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
diff --git a/hostsidetests/sample/Android.mk b/hostsidetests/sample/Android.mk
index e8cbdda..644621d 100644
--- a/hostsidetests/sample/Android.mk
+++ b/hostsidetests/sample/Android.mk
@@ -18,15 +18,15 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_TAGS := tests
 
-# Must match the package name in CtsTestCaseList.mk
+# tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
 LOCAL_MODULE := CtsSampleHostTestCases
 
-LOCAL_JAVA_LIBRARIES := cts-tradefed tradefed-prebuilt
+LOCAL_JAVA_LIBRARIES := compatibility-host-util compatibility-tradefed tradefed-prebuilt
 
-LOCAL_CTS_TEST_PACKAGE := android.host.sample
-
-include $(BUILD_CTS_HOST_JAVA_LIBRARY)
+include $(BUILD_HOST_JAVA_LIBRARY)
 
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/sample/AndroidTest.xml b/hostsidetests/sample/AndroidTest.xml
new file mode 100644
index 0000000..50b44ec
--- /dev/null
+++ b/hostsidetests/sample/AndroidTest.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Base config for CTS package preparer">
+    <include name="common-config" />
+    <option name="apk-installer:test-file-name" value="CtsSampleDeviceApp.apk" />
+    <test class="android.sample.cts.SampleHostTest" />
+    <test class="android.sample.cts.SampleHostResultTest" />
+</configuration>
diff --git a/hostsidetests/sample/app/Android.mk b/hostsidetests/sample/app/Android.mk
index 4af45b9..773f24f 100644
--- a/hostsidetests/sample/app/Android.mk
+++ b/hostsidetests/sample/app/Android.mk
@@ -16,16 +16,22 @@
 
 include $(CLEAR_VARS)
 
-# Don't include this package in any target.
-LOCAL_MODULE_TAGS := optional
-
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
+# tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
 LOCAL_PACKAGE_NAME := CtsSampleDeviceApp
 
 LOCAL_SDK_VERSION := current
 
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_PACKAGE)
diff --git a/hostsidetests/sample/app/AndroidManifest.xml b/hostsidetests/sample/app/AndroidManifest.xml
index c087435..dfacf25 100755
--- a/hostsidetests/sample/app/AndroidManifest.xml
+++ b/hostsidetests/sample/app/AndroidManifest.xml
@@ -18,7 +18,6 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="android.sample.app">
 
-    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <application>
         <activity android:name=".SampleDeviceActivity" >
             <intent-filter>
diff --git a/hostsidetests/sample/src/android/sample/cts/SampleHostResultTest.java b/hostsidetests/sample/src/android/sample/cts/SampleHostResultTest.java
index bed4c05..2d1666d 100644
--- a/hostsidetests/sample/src/android/sample/cts/SampleHostResultTest.java
+++ b/hostsidetests/sample/src/android/sample/cts/SampleHostResultTest.java
@@ -16,15 +16,13 @@
 
 package android.sample.cts;
 
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.util.HostReportLog;
-import com.android.cts.util.MeasureRun;
-import com.android.cts.util.MeasureTime;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.Stat;
-import com.android.ddmlib.IDevice;
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.compatibility.common.util.MeasureRun;
+import com.android.compatibility.common.util.MeasureTime;
+import com.android.compatibility.common.util.MetricsReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.testtype.DeviceTestCase;
@@ -37,7 +35,6 @@
 import com.android.tradefed.util.RunUtil;
 
 import java.io.File;
-import java.lang.Exception;
 
 /**
  * Test to measure the transfer time of a file from the host to the device.
@@ -52,16 +49,21 @@
     private static final int REPEAT = 5;
 
     /**
-     * The name of the plan to transfer.
-     *
-     * In this case we will transfer the CTS.xml file.
+     * The device-side location to write the file to.
      */
-    private static final String PLAN_NAME = "CTS";
+    private static final String FILE_PATH = "/data/local/tmp/%s";
+
+    /**
+     * The name of the file to transfer.
+     *
+     * In this case we will transfer this test's module config.
+     */
+    private static final String FILE_NAME = "CtsSampleHostTestCases.config";
 
     /**
      * A reference to the build.
      */
-    private CtsBuildHelper mBuild;
+    private CompatibilityBuildInfo mBuild;
 
     /**
      * A reference to the device under test.
@@ -81,7 +83,7 @@
     @Override
     public void setBuild(IBuildInfo buildInfo) {
         // Get the build, this is used to access the APK.
-        mBuild = CtsBuildHelper.createBuildHelper(buildInfo);
+        mBuild = (CompatibilityBuildInfo) buildInfo;
     }
 
     @Override
@@ -100,13 +102,10 @@
      */
     public void testTransferTime() throws Exception {
         final ITestDevice device = mDevice;
-        // Get the external storage location and ensure its not null.
-        final String externalStorePath = mDevice.getMountPoint(IDevice.MNT_EXTERNAL_STORAGE);
-        assertNotNull("External storage location no found", externalStorePath);
         // Create the device side path where the file will be transfered.
-        final String devicePath = String.format("%s/%s", externalStorePath, "tmp_testPushPull.txt");
-        // Get the file from the build.
-        final File testFile = mBuild.getTestPlanFile(PLAN_NAME);
+        final String devicePath = String.format(FILE_PATH, "tmp_testPushPull.txt");
+        // Get this test's module config file from the build.
+        final File testFile = new File(mBuild.getTestsDir(), FILE_NAME);
         double[] result = MeasureTime.measure(REPEAT, new MeasureRun() {
             @Override
             public void prepare(int i) throws Exception {
@@ -133,15 +132,15 @@
         // Compute the stats.
         Stat.StatResult stat = Stat.getStat(result);
         // Get the report for this test and add the results to record.
-        HostReportLog report = new HostReportLog(mDevice.getSerialNumber(), mAbi.getName(),
-                ReportLog.getClassMethodNames());
-        report.printArray("Times", result, ResultType.LOWER_BETTER, ResultUnit.MS);
-        report.printValue("Min", stat.mMin, ResultType.LOWER_BETTER, ResultUnit.MS);
-        report.printValue("Max", stat.mMax, ResultType.LOWER_BETTER, ResultUnit.MS);
+        MetricsReportLog report = new MetricsReportLog(mDevice.getSerialNumber(), mAbi.getName(),
+                String.format("%s#testTransferTime", getClass().getCanonicalName()));
+        report.addValues("Times", result, ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.addValue("Min", stat.mMin, ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.addValue("Max", stat.mMax, ResultType.LOWER_BETTER, ResultUnit.MS);
         // Every report must have a summary,
-        report.printSummary("Average", stat.mAverage, ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.setSummary("Average", stat.mAverage, ResultType.LOWER_BETTER, ResultUnit.MS);
         // Send the report to Tradefed.
-        report.deliverReportToHost();
+        report.submit();
     }
 
     /**
diff --git a/hostsidetests/sample/src/android/sample/cts/SampleHostTest.java b/hostsidetests/sample/src/android/sample/cts/SampleHostTest.java
index ab7e0b0..f276712 100644
--- a/hostsidetests/sample/src/android/sample/cts/SampleHostTest.java
+++ b/hostsidetests/sample/src/android/sample/cts/SampleHostTest.java
@@ -16,27 +16,19 @@
 
 package android.sample.cts;
 
-import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
-import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.testtype.DeviceTestCase;
-import com.android.tradefed.testtype.IAbi;
-import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IBuildReceiver;
 
-import java.io.File;
-import java.lang.String;
 import java.util.Scanner;
 
 /**
  * Test to check the APK logs to Logcat.
  *
  * When this test builds, it also builds {@link android.sample.app.SampleDeviceActivity} into an APK
- * which it then installs at runtime and starts. The activity simply prints a message to Logcat and
- * then gets uninstalled.
+ * which it then installed at runtime and started. The activity simply prints a message to Logcat
+ * and then gets uninstalled.
  */
-public class SampleHostTest extends DeviceTestCase implements IAbiReceiver, IBuildReceiver {
+public class SampleHostTest extends DeviceTestCase {
 
     /**
      * The package name of the APK.
@@ -44,11 +36,6 @@
     private static final String PACKAGE = "android.sample.app";
 
     /**
-     * The file name of the APK.
-     */
-    private static final String APK = "CtsSampleDeviceApp.apk";
-
-    /**
      * The class name of the main activity in the APK.
      */
     private static final String CLASS = "SampleDeviceActivity";
@@ -65,65 +52,18 @@
     private static final String TEST_STRING = "SampleTestString";
 
     /**
-     * The ABI to use.
-     */
-    private IAbi mAbi;
-
-    /**
-     * A reference to the build.
-     */
-    private CtsBuildHelper mBuild;
-
-    /**
-     * A reference to the device under test.
-     */
-    private ITestDevice mDevice;
-
-    @Override
-    public void setAbi(IAbi abi) {
-        mAbi = abi;
-    }
-
-    @Override
-    public void setBuild(IBuildInfo buildInfo) {
-        // Get the build, this is used to access the APK.
-        mBuild = CtsBuildHelper.createBuildHelper(buildInfo);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        // Get the device, this gives a handle to run commands and install APKs.
-        mDevice = getDevice();
-        // Remove any previously installed versions of this APK.
-        mDevice.uninstallPackage(PACKAGE);
-        // Get the APK from the build.
-        File app = mBuild.getTestApp(APK);
-        // Get the ABI flag.
-        String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
-        // Install the APK on the device.
-        mDevice.installPackage(app, false, options);
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        // Remove the package once complete.
-        mDevice.uninstallPackage(PACKAGE);
-        super.tearDown();
-    }
-
-    /**
      * Tests the string was successfully logged to Logcat from the activity.
      *
      * @throws Exception
      */
     public void testLogcat() throws Exception {
+        ITestDevice device = getDevice();
         // Clear logcat.
-        mDevice.executeAdbCommand("logcat", "-c");
+        device.executeAdbCommand("logcat", "-c");
         // Start the APK and wait for it to complete.
-        mDevice.executeShellCommand(START_COMMAND);
+        device.executeShellCommand(START_COMMAND);
         // Dump logcat.
-        String logs = mDevice.executeAdbCommand("logcat", "-v", "brief", "-d", CLASS + ":I", "*:S");
+        String logs = device.executeAdbCommand("logcat", "-v", "brief", "-d", CLASS + ":I", "*:S");
         // Search for string.
         String testString = "";
         Scanner in = new Scanner(logs);
diff --git a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
index 8326b1f..7c4d63a 100644
--- a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
+++ b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
@@ -16,8 +16,8 @@
 
 package android.theme.cts;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.cts.util.TimeoutReq;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.Log.LogLevel;
diff --git a/hostsidetests/usb/src/com/android/cts/usb/TestUsbTest.java b/hostsidetests/usb/src/com/android/cts/usb/TestUsbTest.java
index 3af52c0..7c85707 100644
--- a/hostsidetests/usb/src/com/android/cts/usb/TestUsbTest.java
+++ b/hostsidetests/usb/src/com/android/cts/usb/TestUsbTest.java
@@ -15,8 +15,8 @@
  */
 package com.android.cts.usb;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
 import com.android.ddmlib.testrunner.TestRunResult;
 import com.android.tradefed.build.IBuildInfo;
diff --git a/libs/commonutil/Android.mk b/libs/commonutil/Android.mk
deleted file mode 100644
index 9c131b0..0000000
--- a/libs/commonutil/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# 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.
-#
-
-include $(call all-subdir-makefiles)
-
-# ======================================================
-# Build a static host library for the AbiUtils
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := src/com/android/cts/util/AbiUtils.java
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE := ctsabiutilslib
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/libs/commonutil/src/com/android/cts/util/MeasureRun.java b/libs/commonutil/src/com/android/cts/util/MeasureRun.java
deleted file mode 100644
index 43b5acf..0000000
--- a/libs/commonutil/src/com/android/cts/util/MeasureRun.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2012 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.util;
-
-/**
- * interface for measuring time for each run.
- */
-public abstract class MeasureRun {
-    /**
-     *  called before each run. not included to time measurement.
-     */
-    public void prepare(int i) throws Exception {
-        // default empty implementation
-    };
-
-    abstract public void run(int i) throws Exception;
-}
diff --git a/libs/commonutil/src/com/android/cts/util/MeasureTime.java b/libs/commonutil/src/com/android/cts/util/MeasureTime.java
deleted file mode 100644
index fd22ef2..0000000
--- a/libs/commonutil/src/com/android/cts/util/MeasureTime.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.util;
-
-
-public class MeasureTime {
-    /**
-     * measure time taken for each run for given count
-     * @param count
-     * @param run
-     * @return array of time taken in each run in msec.
-     * @throws Exception
-     */
-    public static double[] measure(int count, MeasureRun run) throws Exception {
-        double[] result = new double[count];
-
-        for (int i = 0; i < count; i++) {
-            run.prepare(i);
-            long start = System.currentTimeMillis();
-            run.run(i);
-            long end =  System.currentTimeMillis();
-            result[i] = end - start;
-        }
-        return result;
-    }
-}
diff --git a/libs/commonutil/src/com/android/cts/util/ReportLog.java b/libs/commonutil/src/com/android/cts/util/ReportLog.java
index dd4b414..05dec0f 100644
--- a/libs/commonutil/src/com/android/cts/util/ReportLog.java
+++ b/libs/commonutil/src/com/android/cts/util/ReportLog.java
@@ -16,29 +16,28 @@
 
 package com.android.cts.util;
 
-import java.util.LinkedList;
-import java.util.List;
+import com.android.compatibility.common.util.Stat;
 
-import junit.framework.Assert;
+import org.xmlpull.v1.XmlPullParserException;
 
+import java.io.IOException;
 
 /**
  * Utility class to print performance measurement result back to host.
  * For now, throws know exception with message.
  *
- * Format:
- * Message = summary log SUMMARY_SEPARATOR [LOG_SEPARATOR log]*
- * summary = message|target|unit|type|value, target can be " " if there is no target set.
- * log for array = classMethodName:line_number|message|unit|type|space seSummaryparated values
+ * This class is deprecated, use {@link com.android.compatibility.common.util.ReportLog}
+ * instead.
  */
+@Deprecated
 public class ReportLog {
-    private static final String LOG_SEPARATOR = "+++";
-    private static final String SUMMARY_SEPARATOR = "++++";
-    private static final String LOG_ELEM_SEPARATOR = "|";
 
-    private List<String> mMessages = new LinkedList<String> ();
-    private String mSummary = null;
     protected static int mDepth = 3;
+    protected com.android.compatibility.common.util.ReportLog mReportLog;
+
+    public ReportLog(com.android.compatibility.common.util.ReportLog reportLog) {
+        mReportLog = reportLog;
+    }
 
     /**
      * print array of values to output log
@@ -80,23 +79,11 @@
 
     private void doPrintArray(String testId, String message,
             double[] values, ResultType type, ResultUnit unit) {
-        StringBuilder builder = new StringBuilder();
-        // note mDepth + 1 as this function will be called by printVaue or printArray
-        // and we need caller of printValue / printArray
-        builder.append(testId);
-        builder.append(LOG_ELEM_SEPARATOR);
-        builder.append(message);
-        builder.append(LOG_ELEM_SEPARATOR);
-        builder.append(type.getXmlString());
-        builder.append(LOG_ELEM_SEPARATOR);
-        builder.append(unit.getXmlString());
-        builder.append(LOG_ELEM_SEPARATOR);
-        for (double v : values) {
-            builder.append(v);
-            builder.append(" ");
-        }
-        mMessages.add(builder.toString());
-        printLog(builder.toString());
+        mReportLog.addValues(testId, message, values,
+                com.android.compatibility.common.util.ResultType.parseReportString(
+                        type.getXmlString()),
+                com.android.compatibility.common.util.ResultUnit.parseReportString(
+                        unit.getXmlString()));
     }
 
     /**
@@ -113,18 +100,12 @@
      */
     public void printSummaryWithTarget(String message, double target, double value,
             ResultType type, ResultUnit unit) {
-        mSummary = message + LOG_ELEM_SEPARATOR + target + LOG_ELEM_SEPARATOR + type.getXmlString()
-                + LOG_ELEM_SEPARATOR + unit.getXmlString() + LOG_ELEM_SEPARATOR + value;
-        boolean resultOk = true;
-        if (type == ResultType.HIGHER_BETTER) {
-            resultOk = value >= target;
-        } else if (type == ResultType.LOWER_BETTER) {
-            resultOk = value <= target;
-        }
-        if (!resultOk) {
-            Assert.fail("Measured result " + value + " does not meet perf target " + target +
-                    " with type " + type.getXmlString());
-        }
+        // Ignore target
+        mReportLog.setSummary(message, value,
+                com.android.compatibility.common.util.ResultType.parseReportString(
+                        type.getXmlString()),
+                com.android.compatibility.common.util.ResultUnit.parseReportString(
+                        unit.getXmlString()));
     }
 
     /**
@@ -136,32 +117,24 @@
      * @param unit unit of the data
      */
     public void printSummary(String message, double value, ResultType type, ResultUnit unit) {
-        mSummary = message + LOG_ELEM_SEPARATOR + " " + LOG_ELEM_SEPARATOR + type.getXmlString() +
-                LOG_ELEM_SEPARATOR + unit.getXmlString() + LOG_ELEM_SEPARATOR + value;
+        mReportLog.setSummary(message, value,
+                com.android.compatibility.common.util.ResultType.parseReportString(
+                        type.getXmlString()),
+                com.android.compatibility.common.util.ResultUnit.parseReportString(
+                        unit.getXmlString()));
     }
 
     /**
      * @return a string representation of this report.
      */
     protected String generateReport() {
-        if ((mSummary == null) && mMessages.isEmpty()) {
-            // just return empty string
-            return "";
+        try {
+            return com.android.compatibility.common.util.ReportLog.serialize(mReportLog);
+        } catch (IllegalArgumentException | IllegalStateException | XmlPullParserException
+                | IOException e) {
+            e.printStackTrace();
         }
-        StringBuilder builder = new StringBuilder();
-        builder.append(mSummary);
-        builder.append(SUMMARY_SEPARATOR);
-        for (String entry : mMessages) {
-            builder.append(entry);
-            builder.append(LOG_SEPARATOR);
-        }
-        // delete the last separator
-        if (builder.length() >= LOG_SEPARATOR.length()) {
-            builder.delete(builder.length() - LOG_SEPARATOR.length(), builder.length());
-        }
-        mSummary = null;
-        mMessages.clear();
-        return builder.toString();
+        return null;
     }
 
     /**
@@ -172,27 +145,14 @@
      * @return
      */
     public static double calcRatePerSec(double change, double timeInMSec) {
-        if (timeInMSec == 0) {
-            return change * 1000.0 / 0.001; // do not allow zero
-        } else {
-            return change * 1000.0 / timeInMSec;
-        }
+        return Stat.calcRatePerSec(change, timeInMSec);
     }
 
     /**
      * array version of calcRatePerSecArray
      */
     public static double[] calcRatePerSecArray(double change, double[] timeInMSec) {
-        double[] result = new double[timeInMSec.length];
-        change *= 1000.0;
-        for (int i = 0; i < timeInMSec.length; i++) {
-            if (timeInMSec[i] == 0) {
-                result[i] = change / 0.001;
-            } else {
-                result[i] = change / timeInMSec[i];
-            }
-        }
-        return result;
+        return Stat.calcRatePerSecArray(change, timeInMSec);
     }
 
     /**
@@ -219,10 +179,4 @@
         return names;
     }
 
-    /**
-     * to be overridden by child to print message to be passed
-     */
-    protected void printLog(String msg) {
-
-    }
 }
diff --git a/libs/commonutil/src/com/android/cts/util/ResultType.java b/libs/commonutil/src/com/android/cts/util/ResultType.java
index a5a388c..dbe8602 100644
--- a/libs/commonutil/src/com/android/cts/util/ResultType.java
+++ b/libs/commonutil/src/com/android/cts/util/ResultType.java
@@ -18,7 +18,11 @@
 
 /**
  * Enum for distinguishing performance results.
+ *
+ * This class is deprecated, use {@link com.android.compatibility.common.util.ResultType}
+ * instead.
  */
+@Deprecated
 public enum ResultType {
     /** lower score shows better performance */
     LOWER_BETTER,
diff --git a/libs/commonutil/src/com/android/cts/util/ResultUnit.java b/libs/commonutil/src/com/android/cts/util/ResultUnit.java
index a216a7e..2148821 100644
--- a/libs/commonutil/src/com/android/cts/util/ResultUnit.java
+++ b/libs/commonutil/src/com/android/cts/util/ResultUnit.java
@@ -19,7 +19,10 @@
 /**
  * Enum for representing the unit of performance results.
  *
+ * This class is deprecated, use {@link com.android.compatibility.common.util.ResultUnit}
+ * instead.
  */
+@Deprecated
 public enum ResultUnit {
     /** for value with no unit */
     NONE,
diff --git a/libs/commonutil/src/com/android/cts/util/Stat.java b/libs/commonutil/src/com/android/cts/util/Stat.java
deleted file mode 100644
index ceafa4e..0000000
--- a/libs/commonutil/src/com/android/cts/util/Stat.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2012 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.util;
-
-import java.util.Arrays;
-
-/**
- * Utilities for doing statistics
- *
- */
-public class Stat {
-
-    /**
-     * Collection of statistical propertirs like average, max, min, and stddev
-     */
-    public static class StatResult {
-        public double mAverage;
-        public double mMin;
-        public double mMax;
-        public double mStddev;
-        public int mDataCount;
-        public StatResult(double average, double min, double max, double stddev, int dataCount) {
-            mAverage = average;
-            mMin = min;
-            mMax = max;
-            mStddev = stddev;
-            mDataCount = dataCount;
-        }
-    }
-
-    /**
-     * Calculate statistics properties likes average, min, max, and stddev for the given array
-     */
-    public static StatResult getStat(double[] data) {
-        double average = data[0];
-        double min = data[0];
-        double max = data[0];
-        double eX2 = data[0] * data[0]; // will become E[X^2]
-        for (int i = 1; i < data.length; i++) {
-            average += data[i];
-            eX2 += data[i] * data[i];
-            if (data[i] > max) {
-                max = data[i];
-            }
-            if (data[i] < min) {
-                min = data[i];
-            }
-        }
-        average /= data.length;
-        eX2 /= data.length;
-        // stddev = sqrt(E[X^2] - (E[X])^2)
-        double stddev = Math.sqrt(eX2 - average * average);
-        return new StatResult(average, min, max, stddev, data.length);
-    }
-
-    /**
-     * Calculate statistics properties likes average, min, max, and stddev for the given array
-     * while rejecting outlier +/- median * rejectionThreshold.
-     * rejectionThreshold should be bigger than 0.0 and be lowerthan 1.0
-     */
-    public static StatResult getStatWithOutlierRejection(double[] data, double rejectionThreshold) {
-        double[] dataCopied = Arrays.copyOf(data, data.length);
-        Arrays.sort(dataCopied);
-        int medianIndex = dataCopied.length / 2;
-        double median;
-        if (dataCopied.length % 2 == 1) {
-            median = dataCopied[medianIndex];
-        } else {
-            median = (dataCopied[medianIndex - 1] + dataCopied[medianIndex]) / 2.0;
-        }
-        double thresholdMin = median * (1.0 - rejectionThreshold);
-        double thresholdMax = median * (1.0 + rejectionThreshold);
-
-        double average = 0.0;
-        double min = median;
-        double max = median;
-        double eX2 = 0.0; // will become E[X^2]
-        int validDataCounter = 0;
-        for (int i = 0; i < data.length; i++) {
-            if ((data[i] > thresholdMin) && (data[i] < thresholdMax)) {
-                validDataCounter++;
-                average += data[i];
-                eX2 += data[i] * data[i];
-                if (data[i] > max) {
-                    max = data[i];
-                }
-                if (data[i] < min) {
-                    min = data[i];
-                }
-            }
-            //TODO report rejected data
-        }
-        double stddev;
-        if (validDataCounter > 0) {
-            average /= validDataCounter;
-            eX2 /= validDataCounter;
-            // stddev = sqrt(E[X^2] - (E[X])^2)
-            stddev = Math.sqrt(eX2 - average * average);
-        } else { // both median is showing too much diff
-            average = median;
-            stddev = 0; // don't care
-        }
-
-        return new StatResult(average, min, max, stddev, validDataCounter);
-    }
-
-    /**
-     * return the average value of the passed array
-     */
-    public static double getAverage(double[] data) {
-        double sum = data[0];
-        for (int i = 1; i < data.length; i++) {
-            sum += data[i];
-        }
-        return sum / data.length;
-    }
-
-    /**
-     * return the minimum value of the passed array
-     */
-    public static double getMin(double[] data) {
-        double min = data[0];
-        for (int i = 1; i < data.length; i++) {
-            if (data[i] < min) {
-                min = data[i];
-            }
-        }
-        return min;
-    }
-
-    /**
-     * return the maximum value of the passed array
-     */
-    public static double getMax(double[] data) {
-        double max = data[0];
-        for (int i = 1; i < data.length; i++) {
-            if (data[i] > max) {
-                max = data[i];
-            }
-        }
-        return max;
-    }
-}
diff --git a/libs/commonutil/src/com/android/cts/util/StatisticsUtils.java b/libs/commonutil/src/com/android/cts/util/StatisticsUtils.java
deleted file mode 100644
index d6589af..0000000
--- a/libs/commonutil/src/com/android/cts/util/StatisticsUtils.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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 com.android.cts.util;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Set of static helper methods for CTS tests.
- */
-public class StatisticsUtils {
-
-
-    /**
-     * Private constructor for static class.
-     */
-    private StatisticsUtils() {}
-
-    /**
-     * Get the value of the 95th percentile using nearest rank algorithm.
-     *
-     * @throws IllegalArgumentException if the collection is null or empty
-     */
-    public static <TValue extends Comparable<? super TValue>> TValue get95PercentileValue(
-            Collection<TValue> collection) {
-        validateCollection(collection);
-
-        List<TValue> arrayCopy = new ArrayList<TValue>(collection);
-        Collections.sort(arrayCopy);
-
-        // zero-based array index
-        int arrayIndex = (int) Math.round(arrayCopy.size() * 0.95 + .5) - 1;
-
-        return arrayCopy.get(arrayIndex);
-    }
-
-    /**
-     * Calculate the mean of a collection.
-     *
-     * @throws IllegalArgumentException if the collection is null or empty
-     */
-    public static <TValue extends Number> double getMean(Collection<TValue> collection) {
-        validateCollection(collection);
-
-        double sum = 0.0;
-        for(TValue value : collection) {
-            sum += value.doubleValue();
-        }
-        return sum / collection.size();
-    }
-
-    /**
-     * Calculate the bias-corrected sample variance of a collection.
-     *
-     * @throws IllegalArgumentException if the collection is null or empty
-     */
-    public static <TValue extends Number> double getVariance(Collection<TValue> collection) {
-        validateCollection(collection);
-
-        double mean = getMean(collection);
-        ArrayList<Double> squaredDiffs = new ArrayList<Double>();
-        for(TValue value : collection) {
-            double difference = mean - value.doubleValue();
-            squaredDiffs.add(Math.pow(difference, 2));
-        }
-
-        double sum = 0.0;
-        for (Double value : squaredDiffs) {
-            sum += value;
-        }
-        return sum / (squaredDiffs.size() - 1);
-    }
-
-    /**
-     * Calculate the bias-corrected standard deviation of a collection.
-     *
-     * @throws IllegalArgumentException if the collection is null or empty
-     */
-    public static <TValue extends Number> double getStandardDeviation(
-            Collection<TValue> collection) {
-        return Math.sqrt(getVariance(collection));
-    }
-
-    /**
-     * Validate that a collection is not null or empty.
-     *
-     * @throws IllegalStateException if collection is null or empty.
-     */
-    private static <T> void validateCollection(Collection<T> collection) {
-        if(collection == null || collection.size() == 0) {
-            throw new IllegalStateException("Collection cannot be null or empty");
-        }
-    }
-
-}
diff --git a/libs/commonutil/src/com/android/cts/util/StatisticsUtilsTest.java b/libs/commonutil/src/com/android/cts/util/StatisticsUtilsTest.java
deleted file mode 100644
index d78ba99..0000000
--- a/libs/commonutil/src/com/android/cts/util/StatisticsUtilsTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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 com.android.cts.util;
-
-import junit.framework.TestCase;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Unit tests for the {@link StatisticsUtils} class.
- */
-public class StatisticsUtilsTest extends TestCase {
-
-    /**
-     * Test {@link StatisticsUtils#get95PercentileValue(Collection)}.
-     */
-    public void testGet95PercentileValue() {
-        Collection<Integer> values = new HashSet<Integer>();
-        for (int i = 0; i < 100; i++) {
-            values.add(i);
-        }
-        assertEquals(95, (int) StatisticsUtils.get95PercentileValue(values));
-
-        values = new HashSet<Integer>();
-        for (int i = 0; i < 1000; i++) {
-            values.add(i);
-        }
-        assertEquals(950, (int) StatisticsUtils.get95PercentileValue(values));
-
-        values = new HashSet<Integer>();
-        for (int i = 0; i < 100; i++) {
-            values.add(i * i);
-        }
-        assertEquals(95 * 95, (int) StatisticsUtils.get95PercentileValue(values));
-    }
-
-    /**
-     * Test {@link StatisticsUtils#getMean(Collection)}.
-     */
-    public void testGetMean() {
-        List<Integer> values = Arrays.asList(0, 1, 2, 3, 4);
-        double mean = StatisticsUtils.getMean(values);
-        assertEquals(2.0, mean, 0.00001);
-
-        values = Arrays.asList(1, 2, 3, 4, 5);
-        mean = StatisticsUtils.getMean(values);
-        assertEquals(3.0, mean, 0.00001);
-
-        values = Arrays.asList(0, 1, 4, 9, 16);
-        mean = StatisticsUtils.getMean(values);
-        assertEquals(6.0, mean, 0.00001);
-    }
-
-    /**
-     * Test {@link StatisticsUtils#getVariance(Collection)}.
-     */
-    public void testGetVariance() {
-        List<Integer> values = Arrays.asList(0, 1, 2, 3, 4);
-        double variance = StatisticsUtils.getVariance(values);
-        assertEquals(2.5, variance, 0.00001);
-
-        values = Arrays.asList(1, 2, 3, 4, 5);
-        variance = StatisticsUtils.getVariance(values);
-        assertEquals(2.5, variance, 0.00001);
-
-        values = Arrays.asList(0, 2, 4, 6, 8);
-        variance = StatisticsUtils.getVariance(values);
-        assertEquals(10.0, variance, 0.00001);
-    }
-
-    /**
-     * Test {@link StatisticsUtils#getStandardDeviation(Collection)}.
-     */
-    public void testGetStandardDeviation() {
-        List<Integer> values = Arrays.asList(0, 1, 2, 3, 4);
-        double stddev = StatisticsUtils.getStandardDeviation(values);
-        assertEquals(Math.sqrt(2.5), stddev, 0.00001);
-
-        values = Arrays.asList(1, 2, 3, 4, 5);
-        stddev = StatisticsUtils.getStandardDeviation(values);
-        assertEquals(Math.sqrt(2.5), stddev, 0.00001);
-
-        values = Arrays.asList(0, 2, 4, 6, 8);
-        stddev = StatisticsUtils.getStandardDeviation(values);
-        assertEquals(Math.sqrt(10.0), stddev, 0.00001);
-    }
-
-
-}
diff --git a/libs/deviceutil/Android.mk b/libs/deviceutil/Android.mk
index 8c81ee4..bb039ca 100644
--- a/libs/deviceutil/Android.mk
+++ b/libs/deviceutil/Android.mk
@@ -22,6 +22,8 @@
 
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
 
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util
+
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_MODULE := ctsdeviceutil
diff --git a/libs/deviceutil/src/android/cts/util/CtsActivityInstrumentationTestCase2.java b/libs/deviceutil/src/android/cts/util/CtsActivityInstrumentationTestCase2.java
deleted file mode 100644
index e039407..0000000
--- a/libs/deviceutil/src/android/cts/util/CtsActivityInstrumentationTestCase2.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2012 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.cts.util;
-
-import com.android.cts.util.ReportLog;
-
-import android.app.Activity;
-import android.test.ActivityInstrumentationTestCase2;
-
-
-public class CtsActivityInstrumentationTestCase2<T extends Activity> extends
-        ActivityInstrumentationTestCase2<T> {
-
-    private DeviceReportLog mReportLog = new DeviceReportLog();
-
-    public CtsActivityInstrumentationTestCase2(Class<T> activityClass) {
-        super(activityClass);
-    }
-
-    public ReportLog getReportLog() {
-        return mReportLog;
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        mReportLog.deliverReportToHost(getInstrumentation());
-        super.tearDown();
-    }
-
-}
diff --git a/libs/deviceutil/src/android/cts/util/CtsAndroidTestCase.java b/libs/deviceutil/src/android/cts/util/CtsAndroidTestCase.java
index b1164bc..7cf0f7e 100644
--- a/libs/deviceutil/src/android/cts/util/CtsAndroidTestCase.java
+++ b/libs/deviceutil/src/android/cts/util/CtsAndroidTestCase.java
@@ -18,13 +18,14 @@
 package android.cts.util;
 
 import android.content.Context;
+import android.test.ActivityInstrumentationTestCase2;
 
 /**
  *  This class emulates AndroidTestCase, but internally it is ActivityInstrumentationTestCase2
  *  to access Instrumentation.
  *  DummyActivity is not supposed to be accessed.
  */
-public class CtsAndroidTestCase extends CtsActivityInstrumentationTestCase2<DummyActivity> {
+public class CtsAndroidTestCase extends ActivityInstrumentationTestCase2<DummyActivity> {
     public CtsAndroidTestCase() {
         super(DummyActivity.class);
     }
diff --git a/libs/deviceutil/src/android/cts/util/DeviceReportLog.java b/libs/deviceutil/src/android/cts/util/DeviceReportLog.java
index 63b07b7..efc31f0 100644
--- a/libs/deviceutil/src/android/cts/util/DeviceReportLog.java
+++ b/libs/deviceutil/src/android/cts/util/DeviceReportLog.java
@@ -22,6 +22,11 @@
 
 import com.android.cts.util.ReportLog;
 
+/**
+ * This class is deprecated, use {@link com.android.compatibility.common.util.DeviceReportLog}
+ * instead.
+ */
+@Deprecated
 public class DeviceReportLog extends ReportLog {
     private static final String TAG = "DeviceCtsReport";
     private static final String CTS_RESULT_KEY = "CTS_TEST_RESULT";
@@ -33,14 +38,10 @@
     }
 
     public DeviceReportLog(int depth) {
+        super(new com.android.compatibility.common.util.DeviceReportLog());
         mDepth = BASE_DEPTH + depth;
     }
 
-    @Override
-    protected void printLog(String msg) {
-        Log.i(TAG, msg);
-    }
-
     public void deliverReportToHost(Instrumentation instrumentation) {
         Log.i(TAG, "deliverReportToHost");
         String report = generateReport();
@@ -50,4 +51,4 @@
             instrumentation.sendStatus(INST_STATUS_IN_PROGRESS, output);
         }
     }
-}
+}
\ No newline at end of file
diff --git a/run_unit_tests.sh b/run_unit_tests.sh
new file mode 100755
index 0000000..2937133
--- /dev/null
+++ b/run_unit_tests.sh
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+# 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.
+
+# Helper script for running unit tests for compatibility libraries
+
+checkFile() {
+    if [ ! -f "$1" ]; then
+        echo "Unable to locate $1"
+        exit
+    fi;
+}
+
+# check if in Android build env
+if [ ! -z ${ANDROID_BUILD_TOP} ]; then
+    HOST=`uname`
+    if [ "$HOST" == "Linux" ]; then
+        OS="linux-x86"
+    elif [ "$HOST" == "Darwin" ]; then
+        OS="darwin-x86"
+    else
+        echo "Unrecognized OS"
+        exit
+    fi;
+fi;
+
+JAR_DIR=${ANDROID_HOST_OUT}/framework
+JARS="
+    compatibility-common-util-hostsidelib\
+    compatibility-common-util-tests\
+    compatibility-host-util\
+    compatibility-host-util-tests\
+    compatibility-tradefed-tests\
+    compatibility-tradefed\
+    cts-tradefed-tests_v2\
+    cts-tradefed_v2\
+    ddmlib-prebuilt\
+    hosttestlib\
+    tradefed-prebuilt"
+
+for JAR in $JARS; do
+    checkFile ${JAR_DIR}/${JAR}.jar
+    JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
+done
+
+APK=${ANDROID_PRODUCT_OUT}/data/app/CompatibilityTestApp/CompatibilityTestApp.apk
+checkFile ${APK}
+
+TF_CONSOLE=com.android.tradefed.command.Console
+COMMON_PACKAGE=com.android.compatibility.common
+RUNNER=android.support.test.runner.AndroidJUnitRunner
+adb install -r ${APK}
+java $RDBG_FLAG -cp ${JAR_PATH} ${TF_CONSOLE} run singleCommand instrument --package ${COMMON_PACKAGE} --runner ${RUNNER}
+adb uninstall ${COMMON_PACKAGE}
+
+TEST_CLASSES="
+    com.android.compatibility.common.tradefed.build.CompatibilityBuildInfoTest\
+    com.android.compatibility.common.tradefed.build.CompatibilityBuildProviderTest\
+    com.android.compatibility.common.tradefed.command.CompatibilityConsoleTest\
+    com.android.compatibility.common.tradefed.result.ResultReporterTest\
+    com.android.compatibility.common.tradefed.testtype.CompatibilityTestTest\
+    com.android.compatibility.common.tradefed.testtype.ModuleDefTest\
+    com.android.compatibility.common.tradefed.testtype.ModuleRepoTest\
+    com.android.compatibility.common.util.AbiUtilsTest\
+    com.android.compatibility.common.util.CaseResultTest\
+    com.android.compatibility.common.util.MetricsStoreTest\
+    com.android.compatibility.common.util.MetricsXmlSerializerTest\
+    com.android.compatibility.common.util.ModuleResultTest\
+    com.android.compatibility.common.util.ReportLogTest\
+    com.android.compatibility.common.util.TestFilterTest\
+    com.android.compatibility.common.util.TestResultTest\
+    com.android.compatibility.common.util.XmlResultHandlerTest\
+    com.android.compatibility.tradefed.CtsTradefedTest"
+
+for CLASS in ${TEST_CLASSES}; do
+    java $RDBG_FLAG -cp ${JAR_PATH} ${TF_CONSOLE} run singleCommand host -n --class ${CLASS} "$@"
+done
diff --git a/suite/cts/deviceTests/browserbench/Android.mk b/suite/cts/deviceTests/browserbench/Android.mk
index 3696bcd..6f247de 100644
--- a/suite/cts/deviceTests/browserbench/Android.mk
+++ b/suite/cts/deviceTests/browserbench/Android.mk
@@ -18,7 +18,7 @@
 # don't include this package in any target
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner ctstestserver
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner ctstestserver
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/suite/cts/deviceTests/browserbench/src/com/android/cts/browser/BrowserBenchTest.java b/suite/cts/deviceTests/browserbench/src/com/android/cts/browser/BrowserBenchTest.java
index d74ddb2..98a4ec8 100644
--- a/suite/cts/deviceTests/browserbench/src/com/android/cts/browser/BrowserBenchTest.java
+++ b/suite/cts/deviceTests/browserbench/src/com/android/cts/browser/BrowserBenchTest.java
@@ -18,18 +18,23 @@
 
 import android.content.Intent;
 import android.content.pm.PackageManager;
+import android.cts.util.CtsAndroidTestCase;
 import android.cts.util.WatchDog;
 import android.net.Uri;
 import android.provider.Browser;
 import android.util.Log;
 import android.webkit.cts.CtsTestServer;
 
-import android.cts.util.CtsAndroidTestCase;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import com.android.cts.util.Stat;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 import com.android.cts.util.TimeoutReq;
 
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.RequestLine;
+
 import java.net.URLDecoder;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -37,10 +42,6 @@
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.RequestLine;
 /**
  * Browser benchmarking.
  * It launches an activity with URL and wait for POST from the client.
@@ -72,10 +73,12 @@
     /** stores results for each runs. last entry will be the final score. */
     private LinkedHashMap<String, double[]> mResultsMap;
     private PackageManager mPackageManager;
+    private DeviceReportLog mReport;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+        mReport = new DeviceReportLog();
         mPackageManager = getInstrumentation().getContext().getPackageManager();
         mWebServer = new CtsTestServer(getContext()) {
             @Override
@@ -102,7 +105,7 @@
                     scores[mRunIndex] = score;
                     if (isFinal == 1) {
                         String userAgent = request.getFirstHeader(HTTP_USER_AGENT).getValue();
-                        getReportLog().printValue(HTTP_USER_AGENT + "=" + userAgent, 0,
+                        mReport.addValue(HTTP_USER_AGENT + "=" + userAgent, 0,
                                 ResultType.NEUTRAL, ResultUnit.NONE);
                         mLatch.countDown();
                     }
@@ -122,6 +125,7 @@
         mWebServer.shutdown();
         mWebServer = null;
         mResultsMap = null;
+        mReport.submit(getInstrumentation());
         super.tearDown();
     }
 
@@ -159,17 +163,16 @@
         }
         // it is somewhat awkward to handle the last one specially with Map
         int numberEntries = mResultsMap.size();
-        int numberToProcess = 1;
+        int numberToProcess = 1; 
         for (Map.Entry<String, double[]> entry : mResultsMap.entrySet()) {
             String message = entry.getKey();
             double[] scores = entry.getValue();
             if (numberToProcess == numberEntries) { // final score
                 // store the whole results first
-                getReportLog().printArray(message, scores, mTypeFinal, mUnitFinal);
-                getReportLog().printSummary(message, Stat.getAverage(scores), mTypeFinal,
-                        mUnitFinal);
+                mReport.addValues(message, scores, mTypeFinal, mUnitFinal);
+                mReport.setSummary(message, Stat.getAverage(scores), mTypeFinal, mUnitFinal);
             } else { // interim results
-                getReportLog().printArray(message, scores, mTypeNonFinal, mUnitNonFinal);
+                mReport.addValues(message, scores, mTypeNonFinal, mUnitNonFinal);
             }
             numberToProcess++;
         }
diff --git a/suite/cts/deviceTests/dram/Android.mk b/suite/cts/deviceTests/dram/Android.mk
index 879d151..fa959e1 100644
--- a/suite/cts/deviceTests/dram/Android.mk
+++ b/suite/cts/deviceTests/dram/Android.mk
@@ -21,7 +21,7 @@
 # Include both the 32 and 64 bit versions
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner
 
 LOCAL_JNI_SHARED_LIBRARIES := libctsdram_jni
 
diff --git a/suite/cts/deviceTests/dram/src/com/android/cts/dram/BandwidthTest.java b/suite/cts/deviceTests/dram/src/com/android/cts/dram/BandwidthTest.java
index eeb7f9b..61aabaf 100644
--- a/suite/cts/deviceTests/dram/src/com/android/cts/dram/BandwidthTest.java
+++ b/suite/cts/deviceTests/dram/src/com/android/cts/dram/BandwidthTest.java
@@ -17,15 +17,15 @@
 package com.android.cts.dram;
 
 import android.content.Context;
+import android.cts.util.CtsAndroidTestCase;
 import android.graphics.Point;
 import android.util.Log;
 import android.view.WindowManager;
 
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import android.cts.util.CtsAndroidTestCase;
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.Stat;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 
 /**
  * check how many screens the memcpy function can copy in a sec.
@@ -165,11 +165,12 @@
         for (int i = 0; i < MEMCPY_REPETITION; i++) {
             result[i] = MemoryNative.runMemcpy(bufferSize, repeatInEachCall);
         }
-        getReportLog().printArray("memcpy time", result, ResultType.LOWER_BETTER,
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValues("memcpy time", result, ResultType.LOWER_BETTER,
                 ResultUnit.MS);
-        double[] mbps = ReportLog.calcRatePerSecArray(
+        double[] mbps = Stat.calcRatePerSecArray(
                 (double)bufferSize * repeatInEachCall / 1024.0 / 1024.0, result);
-        getReportLog().printArray("memcpy throughput", mbps, ResultType.HIGHER_BETTER,
+        report.addValues("memcpy throughput", mbps, ResultType.HIGHER_BETTER,
                 ResultUnit.MBPS);
         Stat.StatResult stat = Stat.getStatWithOutlierRejection(mbps, OUTLIER_THRESHOLD);
         if (stat.mDataCount != result.length) {
@@ -182,10 +183,11 @@
         double pixels = size.x * size.y;
         // now this represents how many times the whole screen can be copied in a sec.
         double screensPerSecAverage = stat.mAverage / pixels * 1024.0 * 1024.0 / 4.0;
-        getReportLog().printValue("memcpy in fps", screensPerSecAverage,
+        report.addValue("memcpy in fps", screensPerSecAverage,
                 ResultType.HIGHER_BETTER, ResultUnit.FPS);
-        getReportLog().printSummary("memcpy throughput", stat.mAverage, ResultType.HIGHER_BETTER,
+        report.setSummary("memcpy throughput", stat.mAverage, ResultType.HIGHER_BETTER,
                 ResultUnit.MBPS);
+        report.submit(getInstrumentation());
     }
 
     private void doRunMemset(int bufferSize) {
@@ -198,12 +200,11 @@
         for (int i = 0; i < MEMSET_REPETITION; i++) {
             result[i] = MemoryNative.runMemset(bufferSize, repeatInEachCall, MEMSET_CHAR);
         }
-        getReportLog().printArray("memset time", result, ResultType.LOWER_BETTER,
-                ResultUnit.MS);
-        double[] mbps = ReportLog.calcRatePerSecArray(
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValues("memset time", result, ResultType.LOWER_BETTER, ResultUnit.MS);
+        double[] mbps = Stat.calcRatePerSecArray(
                 (double)bufferSize * repeatInEachCall / 1024.0 / 1024.0, result);
-        getReportLog().printArray("memset throughput", mbps, ResultType.HIGHER_BETTER,
-                ResultUnit.MBPS);
+        report.addValues("memset throughput", mbps, ResultType.HIGHER_BETTER, ResultUnit.MBPS);
         Stat.StatResult stat = Stat.getStatWithOutlierRejection(mbps, OUTLIER_THRESHOLD);
         if (stat.mDataCount != result.length) {
             Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
@@ -215,9 +216,10 @@
         double pixels = size.x * size.y;
         // now this represents how many times the whole screen can be copied in a sec.
         double screensPerSecAverage = stat.mAverage / pixels * 1024.0 * 1024.0 / 4.0;
-        getReportLog().printValue("memset in fps", screensPerSecAverage,
+        report.addValue("memset in fps", screensPerSecAverage,
                 ResultType.HIGHER_BETTER, ResultUnit.FPS);
-        getReportLog().printSummary("memset throughput", stat.mAverage, ResultType.HIGHER_BETTER,
+        report.setSummary("memset throughput", stat.mAverage, ResultType.HIGHER_BETTER,
                 ResultUnit.MBPS);
+        report.submit(getInstrumentation());
     }
 }
diff --git a/suite/cts/deviceTests/filesystemperf/Android.mk b/suite/cts/deviceTests/filesystemperf/Android.mk
index 843d21a..b98971b 100644
--- a/suite/cts/deviceTests/filesystemperf/Android.mk
+++ b/suite/cts/deviceTests/filesystemperf/Android.mk
@@ -18,7 +18,7 @@
 # don't include this package in any target
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/AlmostFullTest.java b/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/AlmostFullTest.java
index ab81f16..604dbcd 100644
--- a/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/AlmostFullTest.java
+++ b/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/AlmostFullTest.java
@@ -21,6 +21,7 @@
 import android.cts.util.CtsAndroidTestCase;
 import android.cts.util.SystemUtil;
 
+import com.android.compatibility.common.util.DeviceReportLog;
 import com.android.cts.util.TimeoutReq;
 
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -106,8 +107,10 @@
         }
         final int BUFFER_SIZE = 10 * 1024 * 1024;
         final int NUMBER_REPETITION = 10;
-        FileUtil.doSequentialUpdateTest(getContext(), DIR_SEQ_UPDATE, getReportLog(), FILE_SIZE,
+        DeviceReportLog report = new DeviceReportLog();
+        FileUtil.doSequentialUpdateTest(getContext(), DIR_SEQ_UPDATE, report, FILE_SIZE,
                 BUFFER_SIZE, NUMBER_REPETITION);
+        report.submit(getInstrumentation());
     }
 
     // TODO: file size too small and caching will give wrong better result.
@@ -121,8 +124,9 @@
             Log.w(TAG, "too little space: " + freeDisk);
             return;
         }
-        FileUtil.doRandomReadTest(getContext(), DIR_RANDOM_RD, getReportLog(), fileSize,
-                BUFFER_SIZE);
+        DeviceReportLog report = new DeviceReportLog();
+        FileUtil.doRandomReadTest(getContext(), DIR_RANDOM_RD, report, fileSize, BUFFER_SIZE);
+        report.submit(getInstrumentation());
     }
 
     @TimeoutReq(minutes = 60)
@@ -134,7 +138,8 @@
             Log.w(TAG, "too little space: " + freeDisk);
             return;
         }
-        FileUtil.doRandomWriteTest(getContext(), DIR_RANDOM_WR, getReportLog(), fileSize,
-                BUFFER_SIZE);
+        DeviceReportLog report = new DeviceReportLog();
+        FileUtil.doRandomWriteTest(getContext(), DIR_RANDOM_WR, report, fileSize, BUFFER_SIZE);
+        report.submit(getInstrumentation());
     }
 }
diff --git a/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/FileUtil.java b/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/FileUtil.java
index 6231774..3ab34e7 100755
--- a/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/FileUtil.java
+++ b/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/FileUtil.java
@@ -16,6 +16,17 @@
 
 package com.android.cts.filesystemperf;
 
+import android.content.Context;
+import android.cts.util.SystemUtil;
+import android.util.Log;
+
+import com.android.compatibility.common.util.MeasureRun;
+import com.android.compatibility.common.util.MeasureTime;
+import com.android.compatibility.common.util.ReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -25,17 +36,6 @@
 import java.io.RandomAccessFile;
 import java.util.Random;
 
-import com.android.cts.util.MeasureRun;
-import com.android.cts.util.MeasureTime;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.Stat;
-import android.cts.util.SystemUtil;
-
-import android.content.Context;
-import android.util.Log;
-
 public class FileUtil {
     private static final String TAG = "FileUtil";
     private static final Random mRandom = new Random(0);
@@ -301,15 +301,15 @@
             }
         });
         randomFile.close();
-        double[] mbps = ReportLog.calcRatePerSecArray((double)fileSize / runsInOneGo / 1024 / 1024,
+        double[] mbps = Stat.calcRatePerSecArray((double)fileSize / runsInOneGo / 1024 / 1024,
                 times);
-        report.printArray("read throughput",
+        report.addValues("read throughput",
                 mbps, ResultType.HIGHER_BETTER, ResultUnit.MBPS);
         // This is just the amount of IO returned from kernel. So this is performance neutral.
-        report.printArray("read amount", rdAmount, ResultType.NEUTRAL, ResultUnit.BYTE);
+        report.addValues("read amount", rdAmount, ResultType.NEUTRAL, ResultUnit.BYTE);
         Stat.StatResult stat = Stat.getStat(mbps);
 
-        report.printSummary("read throughput", stat.mAverage, ResultType.HIGHER_BETTER,
+        report.setSummary("read throughput", stat.mAverage, ResultType.HIGHER_BETTER,
                 ResultUnit.MBPS);
     }
 
@@ -354,15 +354,15 @@
             }
         });
         randomFile.close();
-        double[] mbps = ReportLog.calcRatePerSecArray((double)fileSize / runsInOneGo / 1024 / 1024,
+        double[] mbps = Stat.calcRatePerSecArray((double)fileSize / runsInOneGo / 1024 / 1024,
                 times);
-        report.printArray("write throughput",
+        report.addValues("write throughput",
                 mbps, ResultType.HIGHER_BETTER, ResultUnit.MBPS);
-        report.printArray("write amount", wrAmount, ResultType.NEUTRAL,
+        report.addValues("write amount", wrAmount, ResultType.NEUTRAL,
                 ResultUnit.BYTE);
         Stat.StatResult stat = Stat.getStat(mbps);
 
-        report.printSummary("write throughput", stat.mAverage, ResultType.HIGHER_BETTER,
+        report.setSummary("write throughput", stat.mAverage, ResultType.HIGHER_BETTER,
                 ResultUnit.MBPS);
     }
 
@@ -395,14 +395,17 @@
                 }
             });
             randomFile.close();
-            double[] mbps = ReportLog.calcRatePerSecArray((double)bufferSize / 1024 / 1024,
+            double[] mbps = Stat.calcRatePerSecArray((double)bufferSize / 1024 / 1024,
                     times);
-            report.printArray(i + "-th round throughput",
+            report.addValues(i + "-th round throughput",
                     mbps, ResultType.HIGHER_BETTER, ResultUnit.MBPS);
-            ReportLog.copyArray(mbps, mbpsAll, i * numberRepeatInOneRun);
+            int offset = i * numberRepeatInOneRun;
+            for (int j = 0; j < mbps.length; j++) {
+                mbpsAll[offset + j] = mbps[j];
+            }
         }
         Stat.StatResult stat = Stat.getStat(mbpsAll);
-        report.printSummary("update throughput", stat.mAverage, ResultType.HIGHER_BETTER,
+        report.setSummary("update throughput", stat.mAverage, ResultType.HIGHER_BETTER,
                 ResultUnit.MBPS);
     }
 }
diff --git a/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/RandomRWTest.java b/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/RandomRWTest.java
index 6ad927b..08c1c77 100644
--- a/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/RandomRWTest.java
+++ b/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/RandomRWTest.java
@@ -17,6 +17,8 @@
 package com.android.cts.filesystemperf;
 
 import android.cts.util.CtsAndroidTestCase;
+
+import com.android.compatibility.common.util.DeviceReportLog;
 import com.android.cts.util.TimeoutReq;
 
 public class RandomRWTest extends CtsAndroidTestCase {
@@ -37,8 +39,10 @@
         if (fileSize == 0) { // not enough space, give up
             return;
         }
-        FileUtil.doRandomReadTest(getContext(), DIR_RANDOM_RD, getReportLog(), fileSize,
+        DeviceReportLog report = new DeviceReportLog();
+        FileUtil.doRandomReadTest(getContext(), DIR_RANDOM_RD, report, fileSize,
                 READ_BUFFER_SIZE);
+        report.submit(getInstrumentation());
     }
 
     // It is taking too long in some device, and thus cannot run multiple times
@@ -46,7 +50,9 @@
     public void testRandomUpdate() throws Exception {
         final int WRITE_BUFFER_SIZE = 4 * 1024;
         final long fileSize = 256 * 1024 * 1024;
-        FileUtil.doRandomWriteTest(getContext(), DIR_RANDOM_WR, getReportLog(), fileSize,
+        DeviceReportLog report = new DeviceReportLog();
+        FileUtil.doRandomWriteTest(getContext(), DIR_RANDOM_WR, report, fileSize,
                 WRITE_BUFFER_SIZE);
+        report.submit(getInstrumentation());
     }
 }
diff --git a/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/SequentialRWTest.java b/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/SequentialRWTest.java
index d369ce8..6cf41f5 100644
--- a/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/SequentialRWTest.java
+++ b/suite/cts/deviceTests/filesystemperf/src/com/android/cts/filesystemperf/SequentialRWTest.java
@@ -17,12 +17,13 @@
 package com.android.cts.filesystemperf;
 
 import android.cts.util.CtsAndroidTestCase;
-import com.android.cts.util.MeasureRun;
-import com.android.cts.util.MeasureTime;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.Stat;
+
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.MeasureRun;
+import com.android.compatibility.common.util.MeasureTime;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 import com.android.cts.util.TimeoutReq;
 
 import java.io.File;
@@ -50,8 +51,8 @@
             return;
         }
         final int numberOfFiles =(int)(fileSize / BUFFER_SIZE);
-        getReportLog().printValue("files", numberOfFiles, ResultType.NEUTRAL,
-                ResultUnit.COUNT);
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValue("files", numberOfFiles, ResultType.NEUTRAL, ResultUnit.COUNT);
         final byte[] data = FileUtil.generateRandomData(BUFFER_SIZE);
         final File[] files = FileUtil.createNewFiles(getContext(), DIR_SEQ_WR,
                 numberOfFiles);
@@ -64,14 +65,15 @@
                 FileUtil.writeFile(files[i], data, false);
             }
         });
-        double[] mbps = ReportLog.calcRatePerSecArray((double)BUFFER_SIZE / 1024 / 1024, times);
-        getReportLog().printArray("write throughput",
+        double[] mbps = Stat.calcRatePerSecArray((double)BUFFER_SIZE / 1024 / 1024, times);
+        report.addValues("write throughput",
                 mbps, ResultType.HIGHER_BETTER, ResultUnit.MBPS);
-        getReportLog().printArray("write amount", wrAmount, ResultType.NEUTRAL,
+        report.addValues("write amount", wrAmount, ResultType.NEUTRAL,
                 ResultUnit.BYTE);
         Stat.StatResult stat = Stat.getStat(mbps);
-        getReportLog().printSummary("write throughput", stat.mAverage, ResultType.HIGHER_BETTER,
+        report.setSummary("write throughput", stat.mAverage, ResultType.HIGHER_BETTER,
                 ResultUnit.MBPS);
+        report.submit(getInstrumentation());
     }
 
     @TimeoutReq(minutes = 60)
@@ -81,8 +83,10 @@
             return;
         }
         final int NUMBER_REPETITION = 6;
-        FileUtil.doSequentialUpdateTest(getContext(), DIR_SEQ_UPDATE, getReportLog(), fileSize,
+        DeviceReportLog report = new DeviceReportLog();
+        FileUtil.doSequentialUpdateTest(getContext(), DIR_SEQ_UPDATE, report, fileSize,
                 BUFFER_SIZE, NUMBER_REPETITION);
+        report.submit(getInstrumentation());
     }
 
     @TimeoutReq(minutes = 30)
@@ -95,8 +99,9 @@
         final File file = FileUtil.createNewFilledFile(getContext(),
                 DIR_SEQ_RD, fileSize);
         long finish = System.currentTimeMillis();
-        getReportLog().printValue("write throughput for test file of length " + fileSize,
-                ReportLog.calcRatePerSec((double)fileSize / 1024 / 1024, finish - start),
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValue("write throughput for test file of length " + fileSize,
+                Stat.calcRatePerSec((double)fileSize / 1024 / 1024, finish - start),
                 ResultType.HIGHER_BETTER, ResultUnit.MBPS);
 
         final int NUMBER_READ = 10;
@@ -115,11 +120,12 @@
                 in.close();
             }
         });
-        double[] mbps = ReportLog.calcRatePerSecArray((double)fileSize / 1024 / 1024, times);
-        getReportLog().printArray("read throughput",
+        double[] mbps = Stat.calcRatePerSecArray((double)fileSize / 1024 / 1024, times);
+        report.addValues("read throughput",
                 mbps, ResultType.HIGHER_BETTER, ResultUnit.MBPS);
         Stat.StatResult stat = Stat.getStat(mbps);
-        getReportLog().printSummary("read throughput", stat.mAverage, ResultType.HIGHER_BETTER,
+        report.setSummary("read throughput", stat.mAverage, ResultType.HIGHER_BETTER,
                 ResultUnit.MBPS);
+        report.submit(getInstrumentation());
     }
 }
diff --git a/suite/cts/deviceTests/jank2/Android.mk b/suite/cts/deviceTests/jank2/Android.mk
index 346297e..c719693 100644
--- a/suite/cts/deviceTests/jank2/Android.mk
+++ b/suite/cts/deviceTests/jank2/Android.mk
@@ -24,6 +24,8 @@
 
 LOCAL_PACKAGE_NAME := CtsJankTestCases
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner ub-uiautomator ub-janktesthelper
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner ub-uiautomator ub-janktesthelper
+
+LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/suite/cts/deviceTests/jank2/AndroidTest.xml b/suite/cts/deviceTests/jank2/OldAndroidTest.xml
similarity index 100%
rename from suite/cts/deviceTests/jank2/AndroidTest.xml
rename to suite/cts/deviceTests/jank2/OldAndroidTest.xml
diff --git a/suite/cts/deviceTests/jank2/src/android/cts/jank/CtsJankTestBase.java b/suite/cts/deviceTests/jank2/src/android/cts/jank/CtsJankTestBase.java
index cb5c122..c936a8b 100644
--- a/suite/cts/deviceTests/jank2/src/android/cts/jank/CtsJankTestBase.java
+++ b/suite/cts/deviceTests/jank2/src/android/cts/jank/CtsJankTestBase.java
@@ -16,14 +16,14 @@
 
 package android.cts.jank;
 
-import android.cts.util.DeviceReportLog;
 import android.os.Bundle;
 import android.support.test.jank.JankTestBase;
 import android.support.test.jank.WindowContentFrameStatsMonitor;
 import android.support.test.uiautomator.UiDevice;
 
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
 
 public abstract class CtsJankTestBase extends JankTestBase {
 
@@ -33,16 +33,16 @@
     @Override
     public void afterTest(Bundle metrics) {
         String source = String.format("%s#%s", getClass().getCanonicalName(), getName());
-        mLog.printValue(source, WindowContentFrameStatsMonitor.KEY_AVG_FPS,
+        mLog.addValue(source, WindowContentFrameStatsMonitor.KEY_AVG_FPS,
                 metrics.getDouble(WindowContentFrameStatsMonitor.KEY_AVG_FPS),
                 ResultType.HIGHER_BETTER, ResultUnit.FPS);
-        mLog.printValue(source, WindowContentFrameStatsMonitor.KEY_AVG_LONGEST_FRAME,
+        mLog.addValue(source, WindowContentFrameStatsMonitor.KEY_AVG_LONGEST_FRAME,
                 metrics.getDouble(WindowContentFrameStatsMonitor.KEY_AVG_LONGEST_FRAME),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        mLog.printValue(source, WindowContentFrameStatsMonitor.KEY_MAX_NUM_JANKY,
+        mLog.addValue(source, WindowContentFrameStatsMonitor.KEY_MAX_NUM_JANKY,
                 metrics.getInt(WindowContentFrameStatsMonitor.KEY_MAX_NUM_JANKY),
                 ResultType.LOWER_BETTER, ResultUnit.COUNT);
-        mLog.printSummary(WindowContentFrameStatsMonitor.KEY_AVG_NUM_JANKY,
+        mLog.setSummary(WindowContentFrameStatsMonitor.KEY_AVG_NUM_JANKY,
                 metrics.getDouble(WindowContentFrameStatsMonitor.KEY_AVG_NUM_JANKY),
                 ResultType.LOWER_BETTER, ResultUnit.COUNT);
     }
@@ -58,7 +58,7 @@
 
     @Override
     protected void tearDown() throws Exception {
-        mLog.deliverReportToHost(getInstrumentation());
+        mLog.submit(getInstrumentation());
         // restore device orientation
         mDevice.unfreezeRotation();
         super.tearDown();
diff --git a/suite/cts/deviceTests/opengl/Android.mk b/suite/cts/deviceTests/opengl/Android.mk
index 0708efb..3aada1b 100644
--- a/suite/cts/deviceTests/opengl/Android.mk
+++ b/suite/cts/deviceTests/opengl/Android.mk
@@ -21,7 +21,7 @@
 # Include both the 32 and 64 bit versions
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner
 
 LOCAL_JNI_SHARED_LIBRARIES := libctsopengl_jni
 
diff --git a/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/primitive/GLPrimitiveBenchmark.java b/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/primitive/GLPrimitiveBenchmark.java
index c177129..171776b 100644
--- a/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/primitive/GLPrimitiveBenchmark.java
+++ b/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/primitive/GLPrimitiveBenchmark.java
@@ -13,18 +13,19 @@
  */
 package com.android.cts.opengl.primitive;
 
-import com.android.cts.opengl.GLActivityIntentKeys;
-import android.cts.util.CtsActivityInstrumentationTestCase2;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-
 import android.content.Intent;
+import android.test.ActivityInstrumentationTestCase2;
+
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.cts.opengl.GLActivityIntentKeys;
 import com.android.cts.util.TimeoutReq;
 
 /**
  * Runs the Primitive OpenGL ES 2.0 Benchmarks.
  */
-public class GLPrimitiveBenchmark extends CtsActivityInstrumentationTestCase2<GLPrimitiveActivity> {
+public class GLPrimitiveBenchmark extends ActivityInstrumentationTestCase2<GLPrimitiveActivity> {
 
     private static final int NUM_FRAMES = 100;
     private static final int NUM_ITERATIONS = 8;
@@ -131,11 +132,9 @@
 
             // TODO: maybe standard deviation / RMSE will be useful?
 
-            getReportLog().printArray(
-                    "Fps Values", fpsValues, ResultType.HIGHER_BETTER, ResultUnit.FPS);
-            getReportLog().printSummary(
-                    "Average Frames Per Second", score, ResultType.HIGHER_BETTER,
-                    ResultUnit.SCORE);
+            DeviceReportLog report = new DeviceReportLog();
+            report.setSummary("Average FPS", score, ResultType.HIGHER_BETTER, ResultUnit.SCORE);
+            report.submit(getInstrumentation());
         }
     }
 }
diff --git a/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/reference/GLReferenceBenchmark.java b/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/reference/GLReferenceBenchmark.java
index fdea916..2d2238a 100644
--- a/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/reference/GLReferenceBenchmark.java
+++ b/suite/cts/deviceTests/opengl/src/com/android/cts/opengl/reference/GLReferenceBenchmark.java
@@ -13,11 +13,13 @@
  */
 package com.android.cts.opengl.reference;
 
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
 import com.android.cts.opengl.GLActivityIntentKeys;
 
-import android.cts.util.CtsActivityInstrumentationTestCase2;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
+import android.test.ActivityInstrumentationTestCase2;
+
 import com.android.cts.util.TimeoutReq;
 
 import android.content.Intent;
@@ -25,7 +27,7 @@
 /**
  * Runs the Reference OpenGL ES 2.0 Benchmark.
  */
-public class GLReferenceBenchmark extends CtsActivityInstrumentationTestCase2<GLReferenceActivity> {
+public class GLReferenceBenchmark extends ActivityInstrumentationTestCase2<GLReferenceActivity> {
 
     private static final int NUM_FRAMES_PER_SCENE = 500;
     private static final int NUM_SCENES = 2;
@@ -65,22 +67,17 @@
             double updateAverage = updateSum / NUM_FRAMES;
             double renderAverage = renderSum / NUM_FRAMES;
 
-            getReportLog().printArray(
-                    "Set Up Times", setUpTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
-            getReportLog().printArray(
-                    "Update Times", updateTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
-            getReportLog().printValue(
-                    "Update Time Average", updateAverage, ResultType.LOWER_BETTER,
+            DeviceReportLog report = new DeviceReportLog();
+            report.addValues("Set Up Times", setUpTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
+            report.addValue("Update Time Average", updateAverage, ResultType.LOWER_BETTER,
                     ResultUnit.MS);
-            getReportLog().printArray(
-                    "Render Times", renderTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
-            getReportLog().printValue(
-                    "Render Time Average", renderAverage, ResultType.LOWER_BETTER,
+            report.addValue("Render Time Average", renderAverage, ResultType.LOWER_BETTER,
                     ResultUnit.MS);
-            totalTime = setUpTimes[0] + setUpTimes[1] + setUpTimes[2] +
-                    setUpTimes[3] + updateAverage + renderAverage;
-            getReportLog().printSummary(
-                    "Total Time", totalTime, ResultType.LOWER_BETTER, ResultUnit.MS);
+            totalTime = setUpTimes[0] + setUpTimes[1] + setUpTimes[2] + setUpTimes[3] +
+                    updateAverage + renderAverage;
+            report.setSummary("Total Time Average", totalTime, ResultType.LOWER_BETTER,
+                    ResultUnit.MS);
+            report.submit(getInstrumentation());
         }
     }
 }
diff --git a/suite/cts/deviceTests/simplecpu/Android.mk b/suite/cts/deviceTests/simplecpu/Android.mk
index 17e7506..0a0be45 100644
--- a/suite/cts/deviceTests/simplecpu/Android.mk
+++ b/suite/cts/deviceTests/simplecpu/Android.mk
@@ -21,7 +21,7 @@
 # Include both the 32 and 64 bit versions
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner
 
 LOCAL_JNI_SHARED_LIBRARIES := libctscpu_jni
 
diff --git a/suite/cts/deviceTests/simplecpu/src/com/android/cts/simplecpu/SimpleCpuTest.java b/suite/cts/deviceTests/simplecpu/src/com/android/cts/simplecpu/SimpleCpuTest.java
index ce0feac..520ae79 100644
--- a/suite/cts/deviceTests/simplecpu/src/com/android/cts/simplecpu/SimpleCpuTest.java
+++ b/suite/cts/deviceTests/simplecpu/src/com/android/cts/simplecpu/SimpleCpuTest.java
@@ -16,12 +16,13 @@
 
 package com.android.cts.simplecpu;
 
+import android.cts.util.CtsAndroidTestCase;
 import android.util.Log;
 
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import android.cts.util.CtsAndroidTestCase;
-import com.android.cts.util.Stat;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 import com.android.cts.util.TimeoutReq;
 
 /**
@@ -99,14 +100,14 @@
         for (int i = 0; i < numberRepeat; i++) {
             result[i] = CpuNative.runSort(arrayLength, numberRepeatInEachCall);
         }
-        getReportLog().printArray("sorting time", result, ResultType.LOWER_BETTER,
-                ResultUnit.MS);
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValues("sorting time", result, ResultType.LOWER_BETTER, ResultUnit.MS);
         Stat.StatResult stat = Stat.getStatWithOutlierRejection(result, OUTLIER_THRESHOLD);
         if (stat.mDataCount != result.length) {
             Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
         }
-        getReportLog().printSummary("sorting time", stat.mAverage, ResultType.LOWER_BETTER,
-                ResultUnit.MS);
+        report.setSummary("sorting time", stat.mAverage, ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.submit(getInstrumentation());
     }
 
     /**
@@ -121,14 +122,16 @@
         for (int i = 0; i < numberRepeat; i++) {
             result[i] = CpuNative.runMatrixMultiplication(n, numberRepeatInEachCall);
         }
-        getReportLog().printArray("matrix mutiplication time", result, ResultType.LOWER_BETTER,
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValues("matrix mutiplication time", result, ResultType.LOWER_BETTER,
                 ResultUnit.MS);
         Stat.StatResult stat = Stat.getStatWithOutlierRejection(result, OUTLIER_THRESHOLD);
         if (stat.mDataCount != result.length) {
             Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
         }
-        getReportLog().printSummary("matrix mutiplication time", stat.mAverage,
+        report.setSummary("matrix mutiplication time", stat.mAverage,
                 ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.submit(getInstrumentation());
     }
 
 }
diff --git a/suite/cts/deviceTests/tvproviderperf/Android.mk b/suite/cts/deviceTests/tvproviderperf/Android.mk
index e268955..8e865fb 100644
--- a/suite/cts/deviceTests/tvproviderperf/Android.mk
+++ b/suite/cts/deviceTests/tvproviderperf/Android.mk
@@ -18,7 +18,7 @@
 # don't include this package in any target
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/suite/cts/deviceTests/tvproviderperf/src/com/android/cts/tvproviderperf/TvProviderPerfTest.java b/suite/cts/deviceTests/tvproviderperf/src/com/android/cts/tvproviderperf/TvProviderPerfTest.java
index f9daa3c..cb56755 100644
--- a/suite/cts/deviceTests/tvproviderperf/src/com/android/cts/tvproviderperf/TvProviderPerfTest.java
+++ b/suite/cts/deviceTests/tvproviderperf/src/com/android/cts/tvproviderperf/TvProviderPerfTest.java
@@ -24,21 +24,21 @@
 import android.content.ContentValues;
 import android.content.OperationApplicationException;
 import android.content.pm.PackageManager;
-import android.database.Cursor;
 import android.cts.util.CtsAndroidTestCase;
+import android.database.Cursor;
 import android.media.tv.TvContract;
 import android.media.tv.TvContract.Channels;
 import android.media.tv.TvContract.Programs;
 import android.net.Uri;
 import android.os.RemoteException;
 
-import com.android.cts.util.MeasureRun;
-import com.android.cts.util.MeasureTime;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import com.android.cts.util.ReportLog;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.MeasureRun;
+import com.android.compatibility.common.util.MeasureTime;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 import com.android.cts.util.TimeoutReq;
-import com.android.cts.util.Stat;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -106,7 +106,8 @@
                 }
             }
         });
-        getReportLog().printArray("Elapsed time for insert: ",
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValues("Elapsed time for insert: ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[0] = Stat.getAverage(applyBatchTimes);
 
@@ -134,7 +135,7 @@
                 }
             });
         }
-        getReportLog().printArray("Elapsed time for update: ",
+        report.addValues("Elapsed time for update: ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[1] = Stat.getAverage(applyBatchTimes);
 
@@ -150,7 +151,7 @@
                 }
             }
         });
-        getReportLog().printArray("Elapsed time for query (channels): ",
+        report.addValues("Elapsed time for query (channels): ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[2] = Stat.getAverage(applyBatchTimes);
 
@@ -170,7 +171,7 @@
                 }
             });
         }
-        getReportLog().printArray("Elapsed time for query (a channel): ",
+        report.addValues("Elapsed time for query (a channel): ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[3] = Stat.getAverage(applyBatchTimes);
 
@@ -181,13 +182,14 @@
                 mContentResolver.delete(TvContract.buildChannelsUriForInput(mInputId), null, null);
             }
         });
-        getReportLog().printArray("Elapsed time for delete: ",
+        report.addValues("Elapsed time for delete: ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[4] = Stat.getAverage(applyBatchTimes);
 
-        getReportLog().printArray("Average elapsed time for insert, update, query (channels), "
+        report.addValues("Average elapsed time for insert, update, query (channels), "
                 + "query (a channel), delete: ",
                 averages, ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.submit(getInstrumentation());
     }
 
     @TimeoutReq(minutes = 12)
@@ -243,7 +245,8 @@
                 }
             }
         });
-        getReportLog().printArray("Elapsed time for insert: ",
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValues("Elapsed time for insert: ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[0] = Stat.getAverage(applyBatchTimes);
 
@@ -278,7 +281,7 @@
                 }
             }
         });
-        getReportLog().printArray("Elapsed time for update: ",
+        report.addValues("Elapsed time for update: ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[1] = Stat.getAverage(applyBatchTimes);
 
@@ -294,7 +297,7 @@
                 }
             }
         });
-        getReportLog().printArray("Elapsed time for query (programs): ",
+        report.addValues("Elapsed time for query (programs): ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[2] = Stat.getAverage(applyBatchTimes);
 
@@ -314,7 +317,7 @@
                 }
             }
         });
-        getReportLog().printArray("Elapsed time for query (programs with selection): ",
+        report.addValues("Elapsed time for query (programs with selection): ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[3] = Stat.getAverage(applyBatchTimes);
 
@@ -334,7 +337,7 @@
                 }
             });
         }
-        getReportLog().printArray("Elapsed time for query (a program): ",
+        report.addValues("Elapsed time for query (a program): ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[4] = Stat.getAverage(applyBatchTimes);
 
@@ -351,7 +354,7 @@
                         null, null);
             }
         });
-        getReportLog().printArray("Elapsed time for delete programs: ",
+        report.addValues("Elapsed time for delete programs: ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[5] = Stat.getAverage(applyBatchTimes);
 
@@ -363,13 +366,14 @@
                 mContentResolver.delete(channelUri, null, null);
             }
         });
-        getReportLog().printArray("Elapsed time for delete channels: ",
+        report.addValues("Elapsed time for delete channels: ",
                 applyBatchTimes, ResultType.LOWER_BETTER, ResultUnit.MS);
         averages[6] = Stat.getAverage(applyBatchTimes);
 
-        getReportLog().printArray("Average elapsed time for insert, update, query (programs), "
+        report.addValues("Average elapsed time for insert, update, query (programs), "
                 + "query (programs with selection), query (a channel), delete (channels), "
                 + "delete (programs): ",
                 averages, ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.submit(getInstrumentation());
     }
 }
diff --git a/suite/cts/deviceTests/ui/Android.mk b/suite/cts/deviceTests/ui/Android.mk
index ee52172..5b5c8f9 100644
--- a/suite/cts/deviceTests/ui/Android.mk
+++ b/suite/cts/deviceTests/ui/Android.mk
@@ -20,7 +20,7 @@
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/suite/cts/deviceTests/ui/src/com/android/cts/ui/ScrollingTest.java b/suite/cts/deviceTests/ui/src/com/android/cts/ui/ScrollingTest.java
index b5b40e4..7f8d025 100644
--- a/suite/cts/deviceTests/ui/src/com/android/cts/ui/ScrollingTest.java
+++ b/suite/cts/deviceTests/ui/src/com/android/cts/ui/ScrollingTest.java
@@ -15,17 +15,19 @@
  */
 package com.android.cts.ui;
 
-import com.android.cts.util.MeasureRun;
-import com.android.cts.util.MeasureTime;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import android.cts.util.CtsActivityInstrumentationTestCase2;
-import com.android.cts.util.Stat;
+import android.test.ActivityInstrumentationTestCase2;
+
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.MeasureRun;
+import com.android.compatibility.common.util.MeasureTime;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 import com.android.cts.util.TimeoutReq;
 
 import java.io.IOException;
 
-public class ScrollingTest extends CtsActivityInstrumentationTestCase2<ScrollingActivity> {
+public class ScrollingTest extends ActivityInstrumentationTestCase2<ScrollingActivity> {
     private ScrollingActivity mActivity;
 
     public ScrollingTest() {
@@ -39,6 +41,7 @@
         getInstrumentation().waitForIdleSync();
         try {
             runTestOnUiThread(new Runnable() {
+                @Override
                 public void run() {
                 }
             });
@@ -66,10 +69,10 @@
                 assertTrue(activity.scrollToTop());
             }
         });
-        getReportLog().printArray("scrolling time", results, ResultType.LOWER_BETTER,
-                ResultUnit.MS);
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValues("scrolling time", results, ResultType.LOWER_BETTER,ResultUnit.MS);
         Stat.StatResult stat = Stat.getStat(results);
-        getReportLog().printSummary("scrolling time", stat.mAverage, ResultType.LOWER_BETTER,
-                ResultUnit.MS);
+        report.setSummary("scrolling time", stat.mAverage, ResultType.LOWER_BETTER,ResultUnit.MS);
+        report.submit(getInstrumentation());
     }
 }
diff --git a/suite/cts/deviceTests/videoperf/Android.mk b/suite/cts/deviceTests/videoperf/Android.mk
index a393683..56d4c2b 100644
--- a/suite/cts/deviceTests/videoperf/Android.mk
+++ b/suite/cts/deviceTests/videoperf/Android.mk
@@ -23,7 +23,7 @@
 # include both the 32 and 64 bit versions
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsmediautil ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsmediautil ctsdeviceutil compatibility-device-util ctstestrunner
 
 LOCAL_JNI_SHARED_LIBRARIES := libctsmediacodec_jni
 
diff --git a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
index d5a73ff..45e7f7c 100644
--- a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
+++ b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
@@ -20,8 +20,6 @@
 import android.cts.util.DeviceReportLog;
 import android.graphics.ImageFormat;
 import android.graphics.Point;
-import android.media.cts.CodecImage;
-import android.media.cts.CodecUtils;
 import android.media.Image;
 import android.media.Image.Plane;
 import android.media.MediaCodec;
@@ -30,25 +28,24 @@
 import android.media.MediaCodecInfo.CodecCapabilities;
 import android.media.MediaCodecList;
 import android.media.MediaFormat;
+import android.media.cts.CodecImage;
+import android.media.cts.CodecUtils;
 import android.util.Log;
 import android.util.Pair;
 import android.util.Range;
-import android.util.Size;
 
 import android.cts.util.CtsAndroidTestCase;
 import com.android.cts.util.ResultType;
 import com.android.cts.util.ResultUnit;
-import com.android.cts.util.Stat;
+import com.android.compatibility.common.util.Stat;
 import com.android.cts.util.TimeoutReq;
 
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.lang.System;
-import java.util.Arrays;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.Random;
-import java.util.Vector;
 
 /**
  * This tries to test video encoder / decoder performance by running encoding / decoding
diff --git a/suite/cts/hostTests/jank/src/com/android/cts/jank/CtsHostJankTest.java b/suite/cts/hostTests/jank/src/com/android/cts/jank/CtsHostJankTest.java
index e196bfb..178fa4d 100644
--- a/suite/cts/hostTests/jank/src/com/android/cts/jank/CtsHostJankTest.java
+++ b/suite/cts/hostTests/jank/src/com/android/cts/jank/CtsHostJankTest.java
@@ -13,10 +13,10 @@
  */
 package com.android.cts.jank;
 
+import com.android.compatibility.common.util.MetricsReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.util.HostReportLog;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
 import com.android.ddmlib.IShellOutputReceiver;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.Log.LogLevel;
@@ -131,17 +131,17 @@
         double avgMaxAccFrames = results.get("average of max accumulated frames");
 
         // Create and deliver the report.
-        HostReportLog report = new HostReportLog(mDevice.getSerialNumber(), mAbi.getName(),
+        MetricsReportLog report = new MetricsReportLog(mDevice.getSerialNumber(), mAbi.getName(),
                 mHostTestClass + "#" + testName);
-        report.printValue(
+        report.addValue(
                 "Average Frame Rate", avgFrameRate, ResultType.HIGHER_BETTER, ResultUnit.COUNT);
-        report.printValue("Average of Maximum Accumulated Frames", avgMaxAccFrames,
+        report.addValue("Average of Maximum Accumulated Frames", avgMaxAccFrames,
                 ResultType.LOWER_BETTER, ResultUnit.COUNT);
-        report.printValue(
+        report.addValue(
                 "Maximum Number of Janks", maxNumJanks, ResultType.LOWER_BETTER, ResultUnit.COUNT);
-        report.printSummary(
+        report.setSummary(
                 "Average Number of Janks", avgNumJanks, ResultType.LOWER_BETTER, ResultUnit.SCORE);
-        report.deliverReportToHost();
+        report.submit();
     }
 
 }
diff --git a/suite/cts/hostTests/jank/src/com/android/cts/jank/opengl/CtsHostJankOpenGl.java b/suite/cts/hostTests/jank/src/com/android/cts/jank/opengl/CtsHostJankOpenGl.java
index 2942ecf..8acf169 100644
--- a/suite/cts/hostTests/jank/src/com/android/cts/jank/opengl/CtsHostJankOpenGl.java
+++ b/suite/cts/hostTests/jank/src/com/android/cts/jank/opengl/CtsHostJankOpenGl.java
@@ -13,8 +13,8 @@
  */
 package com.android.cts.jank.opengl;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.jank.CtsHostJankTest;
-import com.android.cts.util.AbiUtils;
 import java.io.File;
 
 public class CtsHostJankOpenGl extends CtsHostJankTest {
diff --git a/suite/cts/hostTests/uihost/control/Android.mk b/suite/cts/hostTests/uihost/control/Android.mk
index 4de9ae8..de5a6b5 100644
--- a/suite/cts/hostTests/uihost/control/Android.mk
+++ b/suite/cts/hostTests/uihost/control/Android.mk
@@ -20,7 +20,7 @@
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/suite/cts/hostTests/uihost/control/src/com/android/cts/taskswitching/control/TaskswitchingDeviceTest.java b/suite/cts/hostTests/uihost/control/src/com/android/cts/taskswitching/control/TaskswitchingDeviceTest.java
index bdb3132..4bda0bb 100644
--- a/suite/cts/hostTests/uihost/control/src/com/android/cts/taskswitching/control/TaskswitchingDeviceTest.java
+++ b/suite/cts/hostTests/uihost/control/src/com/android/cts/taskswitching/control/TaskswitchingDeviceTest.java
@@ -25,13 +25,14 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 
-import com.android.cts.util.MeasureRun;
-import com.android.cts.util.MeasureTime;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
 import android.cts.util.CtsAndroidTestCase;
-import com.android.cts.util.Stat;
 
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.MeasureRun;
+import com.android.compatibility.common.util.MeasureTime;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 
 /**
  * Device test which actually launches two apps sequentially and
@@ -83,11 +84,12 @@
                 }
             }
         });
-        getReportLog().printArray("taskswitching time", results, ResultType.LOWER_BETTER,
-                ResultUnit.MS);
+        DeviceReportLog report = new DeviceReportLog();
+        report.addValues("taskswitching time", results, ResultType.LOWER_BETTER, ResultUnit.MS);
         Stat.StatResult stat = Stat.getStat(results);
-        getReportLog().printSummary("taskswitching time", stat.mAverage,
+        report.setSummary("taskswitching time", stat.mAverage,
                 ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.submit(getInstrumentation());
     }
 
     private void startActivity(String packageName, String activityName) {
diff --git a/suite/cts/hostTests/uihost/src/com/android/cts/uihost/InstallTimeTest.java b/suite/cts/hostTests/uihost/src/com/android/cts/uihost/InstallTimeTest.java
index 75a2e92..4869e73 100644
--- a/suite/cts/hostTests/uihost/src/com/android/cts/uihost/InstallTimeTest.java
+++ b/suite/cts/hostTests/uihost/src/com/android/cts/uihost/InstallTimeTest.java
@@ -16,15 +16,14 @@
 
 package com.android.cts.uihost;
 
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.compatibility.common.util.MeasureRun;
+import com.android.compatibility.common.util.MeasureTime;
+import com.android.compatibility.common.util.MetricsReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.util.HostReportLog;
-import com.android.cts.util.AbiUtils;
-import com.android.cts.util.MeasureRun;
-import com.android.cts.util.MeasureTime;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.Stat;
 import com.android.ddmlib.Log;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.ITestDevice;
@@ -35,7 +34,6 @@
 
 import java.io.File;
 
-
 /**
  * Test to measure installation time of a APK.
  */
@@ -73,8 +71,8 @@
     }
 
     public void testInstallTime() throws Exception {
-        HostReportLog report = new HostReportLog(mDevice.getSerialNumber(), mAbi.getName(),
-                ReportLog.getClassMethodNames());
+        MetricsReportLog report = new MetricsReportLog(mDevice.getSerialNumber(), mAbi.getName(),
+                String.format("%s#%s", getClass().getName(), "testInstallTime"));
         final int NUMBER_REPEAT = 10;
         final CtsBuildHelper build = mBuild;
         final ITestDevice device = mDevice;
@@ -90,15 +88,13 @@
                 device.installPackage(app, false, options);
             }
         });
-        report.printArray("install time", result, ResultType.LOWER_BETTER,
-                ResultUnit.MS);
+        report.addValues("install time", result, ResultType.LOWER_BETTER, ResultUnit.MS);
         Stat.StatResult stat = Stat.getStatWithOutlierRejection(result, OUTLIER_THRESHOLD);
         if (stat.mDataCount != result.length) {
             Log.w(TAG, "rejecting " + (result.length - stat.mDataCount) + " outliers");
         }
-        report.printSummary("install time", stat.mAverage, ResultType.LOWER_BETTER,
-                ResultUnit.MS);
-        report.deliverReportToHost();
+        report.setSummary("install time", stat.mAverage, ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.submit();
     }
 
 }
diff --git a/suite/cts/hostTests/uihost/src/com/android/cts/uihost/TaskSwitchingTest.java b/suite/cts/hostTests/uihost/src/com/android/cts/uihost/TaskSwitchingTest.java
index 2d33436..cea5715 100644
--- a/suite/cts/hostTests/uihost/src/com/android/cts/uihost/TaskSwitchingTest.java
+++ b/suite/cts/hostTests/uihost/src/com/android/cts/uihost/TaskSwitchingTest.java
@@ -16,11 +16,10 @@
 
 package com.android.cts.uihost;
 
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.compatibility.common.util.MetricsStore;
+import com.android.compatibility.common.util.ReportLog;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.tradefed.util.CtsHostStore;
-import com.android.cts.tradefed.util.HostReportLog;
-import com.android.cts.util.AbiUtils;
-import com.android.cts.util.ReportLog;
 import com.android.cts.util.TimeoutReq;
 import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
 import com.android.ddmlib.testrunner.TestIdentifier;
@@ -33,9 +32,11 @@
 import com.android.tradefed.testtype.IAbiReceiver;
 import com.android.tradefed.testtype.IBuildReceiver;
 
-import java.io.File;
-import java.util.Map;
+import org.xmlpull.v1.XmlPullParserException;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
 
 /**
  * Measure time to taskswitching between two Apps: A & B
@@ -45,9 +46,10 @@
 public class TaskSwitchingTest extends DeviceTestCase implements IAbiReceiver, IBuildReceiver {
     private static final String TAG = "TaskSwitchingTest";
     private final static String RUNNER = "android.support.test.runner.AndroidJUnitRunner";
+    private static final String RESULT_KEY = "COMPATIBILITY_TEST_RESULT";
     private CtsBuildHelper mBuild;
     private ITestDevice mDevice;
-    private String mCtsReport = null;
+    private ReportLog mReport = null;
     private IAbi mAbi;
 
     static final String[] PACKAGES = {
@@ -94,9 +96,6 @@
 
     @TimeoutReq(minutes = 30)
     public void testTaskswitching() throws Exception {
-        // TODO is this used?
-        HostReportLog report = new HostReportLog(mDevice.getSerialNumber(), mAbi.getName(),
-                ReportLog.getClassMethodNames());
         RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(PACKAGES[0], RUNNER,
                 mDevice.getIDevice());
         LocalListener listener = new LocalListener();
@@ -105,9 +104,9 @@
         if (result.isRunFailure()) {
             fail(result.getRunFailureMessage());
         }
-        assertNotNull("no performance data", mCtsReport);
-        CtsHostStore.storeCtsResult(mDevice.getSerialNumber(), mAbi.getName(),
-                ReportLog.getClassMethodNames(), mCtsReport);
+        assertNotNull("no performance data", mReport);
+        MetricsStore.storeResult(mDevice.getSerialNumber(), mAbi.getName(),
+                String.format("%s#%s", getClass().getName(), "testTaskswitching"), mReport);
 
     }
 
@@ -115,8 +114,12 @@
         @Override
         public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
             // necessary as testMetrics passed from CollectingTestListerner is empty
-            if (testMetrics.containsKey("CTS_TEST_RESULT")) {
-                mCtsReport = testMetrics.get("CTS_TEST_RESULT");
+            if (testMetrics.containsKey(RESULT_KEY)) {
+                try {
+                    mReport = ReportLog.parse(testMetrics.get(RESULT_KEY));
+                } catch (XmlPullParserException | IOException e) {
+                    e.printStackTrace();
+                }
             }
             super.testEnded(test, testMetrics);
         }
diff --git a/tests/acceleration/Android.mk b/tests/acceleration/Android.mk
index f36b64b..87aa7c5 100644
--- a/tests/acceleration/Android.mk
+++ b/tests/acceleration/Android.mk
@@ -24,10 +24,15 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := CtsAccelerationTestStubs
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
+LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
 
 LOCAL_SDK_VERSION := current
 
-include $(BUILD_CTS_SUPPORT_PACKAGE)
+include $(BUILD_CTS_PACKAGE)
diff --git a/tests/acceleration/AndroidManifest.xml b/tests/acceleration/AndroidManifest.xml
index f92b736..1a21554 100644
--- a/tests/acceleration/AndroidManifest.xml
+++ b/tests/acceleration/AndroidManifest.xml
@@ -15,15 +15,25 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.android.cts.acceleration.stub">
+        package="android.acceleration.cts">
+
+    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
 
     <application android:hardwareAccelerated="true">
-        <activity android:name="android.acceleration.cts.HardwareAcceleratedActivity" />
-        <activity android:name="android.acceleration.cts.SoftwareAcceleratedActivity"
+        <uses-library android:name="android.test.runner" />
+        <activity android:name="android.acceleration.HardwareAcceleratedActivity" />
+        <activity android:name="android.acceleration.SoftwareAcceleratedActivity"
                 android:hardwareAccelerated="false" />
-        <activity android:name="android.acceleration.cts.WindowFlagHardwareAcceleratedActivity"
+        <activity android:name="android.acceleration.WindowFlagHardwareAcceleratedActivity"
                 android:hardwareAccelerated="false" />
     </application>
 
+    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+            android:targetPackage="android.acceleration.cts"
+            android:label="Tests for the Hardware Acceleration APIs." >
+        <meta-data android:name="listener"
+                android:value="com.android.cts.runner.CtsTestRunListener" />
+    </instrumentation>
+
 </manifest>
 
diff --git a/tests/acceleration/AndroidTest.xml b/tests/acceleration/AndroidTest.xml
new file mode 100644
index 0000000..5d745c1
--- /dev/null
+++ b/tests/acceleration/AndroidTest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Base config for CTS package preparer">
+    <include name="common-config" />
+    <option name="apk-installer:test-file-name" value="CtsAccelerationTestCases.apk" />
+    <test class="com.android.tradefed.testtype.InstrumentationTest" >
+        <option name="package" value="android.acceleration.cts" />
+        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+    </test>
+</configuration>
diff --git a/tests/acceleration/res/layout/acceleration.xml b/tests/acceleration/res/layout/acceleration.xml
index 8dc027a..5127507 100644
--- a/tests/acceleration/res/layout/acceleration.xml
+++ b/tests/acceleration/res/layout/acceleration.xml
@@ -18,25 +18,25 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         >
-    <android.acceleration.cts.AcceleratedView android:id="@+id/hardware_accelerated_view"
+    <android.acceleration.AcceleratedView android:id="@+id/hardware_accelerated_view"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1"
             android:layerType="hardware"
             />
-    <android.acceleration.cts.AcceleratedView android:id="@+id/software_accelerated_view"
+    <android.acceleration.AcceleratedView android:id="@+id/software_accelerated_view"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1"
             android:layerType="software"
             />
     <!-- Acceleration will be set via manual setLayerType calls from the activity. -->
-    <android.acceleration.cts.AcceleratedView android:id="@+id/manual_hardware_accelerated_view"
+    <android.acceleration.AcceleratedView android:id="@+id/manual_hardware_accelerated_view"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1"
             />
-    <android.acceleration.cts.AcceleratedView android:id="@+id/manual_software_accelerated_view"
+    <android.acceleration.AcceleratedView android:id="@+id/manual_software_accelerated_view"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1"
diff --git a/tests/acceleration/src/android/acceleration/cts/AcceleratedView.java b/tests/acceleration/src/android/acceleration/AcceleratedView.java
similarity index 98%
rename from tests/acceleration/src/android/acceleration/cts/AcceleratedView.java
rename to tests/acceleration/src/android/acceleration/AcceleratedView.java
index 7d749a1..7134a76 100644
--- a/tests/acceleration/src/android/acceleration/cts/AcceleratedView.java
+++ b/tests/acceleration/src/android/acceleration/AcceleratedView.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.acceleration.cts;
+package android.acceleration;
 
 import android.content.Context;
 import android.graphics.Canvas;
diff --git a/tests/acceleration/src/android/acceleration/cts/BaseAcceleratedActivity.java b/tests/acceleration/src/android/acceleration/BaseAcceleratedActivity.java
similarity index 93%
rename from tests/acceleration/src/android/acceleration/cts/BaseAcceleratedActivity.java
rename to tests/acceleration/src/android/acceleration/BaseAcceleratedActivity.java
index 8ef6a8e..262b43e 100644
--- a/tests/acceleration/src/android/acceleration/cts/BaseAcceleratedActivity.java
+++ b/tests/acceleration/src/android/acceleration/BaseAcceleratedActivity.java
@@ -14,15 +14,15 @@
  * limitations under the License.
  */
 
-package android.acceleration.cts;
+package android.acceleration;
 
-import com.android.cts.acceleration.stub.R;
+import android.acceleration.cts.R;
 
 import android.app.Activity;
 import android.os.Bundle;
 import android.view.View;
 
-abstract class BaseAcceleratedActivity extends Activity {
+public abstract class BaseAcceleratedActivity extends Activity {
 
     private AcceleratedView mHardwareAcceleratedView;
     private AcceleratedView mSoftwareAcceleratedView;
diff --git a/tests/acceleration/src/android/acceleration/cts/HardwareAcceleratedActivity.java b/tests/acceleration/src/android/acceleration/HardwareAcceleratedActivity.java
similarity index 95%
rename from tests/acceleration/src/android/acceleration/cts/HardwareAcceleratedActivity.java
rename to tests/acceleration/src/android/acceleration/HardwareAcceleratedActivity.java
index bb26202..9122565 100644
--- a/tests/acceleration/src/android/acceleration/cts/HardwareAcceleratedActivity.java
+++ b/tests/acceleration/src/android/acceleration/HardwareAcceleratedActivity.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.acceleration.cts;
+package android.acceleration;
 
 public class HardwareAcceleratedActivity extends BaseAcceleratedActivity {
 }
diff --git a/tests/acceleration/src/android/acceleration/cts/SoftwareAcceleratedActivity.java b/tests/acceleration/src/android/acceleration/SoftwareAcceleratedActivity.java
similarity index 95%
rename from tests/acceleration/src/android/acceleration/cts/SoftwareAcceleratedActivity.java
rename to tests/acceleration/src/android/acceleration/SoftwareAcceleratedActivity.java
index 0a6a3df..7555862 100644
--- a/tests/acceleration/src/android/acceleration/cts/SoftwareAcceleratedActivity.java
+++ b/tests/acceleration/src/android/acceleration/SoftwareAcceleratedActivity.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.acceleration.cts;
+package android.acceleration;
 
 public class SoftwareAcceleratedActivity extends BaseAcceleratedActivity {
 }
diff --git a/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAcceleratedActivity.java b/tests/acceleration/src/android/acceleration/WindowFlagHardwareAcceleratedActivity.java
similarity index 96%
rename from tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAcceleratedActivity.java
rename to tests/acceleration/src/android/acceleration/WindowFlagHardwareAcceleratedActivity.java
index 9def8b7..d448334 100644
--- a/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAcceleratedActivity.java
+++ b/tests/acceleration/src/android/acceleration/WindowFlagHardwareAcceleratedActivity.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.acceleration.cts;
+package android.acceleration;
 
 import android.os.Bundle;
 import android.view.WindowManager;
diff --git a/tests/tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java b/tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java
similarity index 96%
rename from tests/tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java
rename to tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java
index d2f1d9f..c6e94ec 100644
--- a/tests/tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java
+++ b/tests/acceleration/src/android/acceleration/cts/BaseAccelerationTest.java
@@ -16,6 +16,8 @@
 
 package android.acceleration.cts;
 
+import android.acceleration.AcceleratedView;
+import android.acceleration.BaseAcceleratedActivity;
 import android.app.ActivityManager;
 import android.content.Context;
 import android.content.pm.ConfigurationInfo;
diff --git a/tests/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java b/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
similarity index 97%
rename from tests/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
rename to tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
index eddd34f..94089cc 100644
--- a/tests/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
+++ b/tests/acceleration/src/android/acceleration/cts/HardwareAccelerationTest.java
@@ -16,6 +16,8 @@
 
 package android.acceleration.cts;
 
+import android.acceleration.HardwareAcceleratedActivity;
+
 /**
  * Test that uses an Activity with hardware acceleration enabled.
  */
diff --git a/tests/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java b/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
similarity index 96%
rename from tests/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
rename to tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
index 146fa6a..4e12c1e 100644
--- a/tests/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
+++ b/tests/acceleration/src/android/acceleration/cts/SoftwareAccelerationTest.java
@@ -16,6 +16,8 @@
 
 package android.acceleration.cts;
 
+import android.acceleration.SoftwareAcceleratedActivity;
+
 /**
  * Test that uses an Activity with hardware acceleration explicitly disabled
  * and makes sure that all views are rendered using software acceleration.
diff --git a/tests/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java b/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
similarity index 96%
rename from tests/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
rename to tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
index bfbbe63..2070666 100644
--- a/tests/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
+++ b/tests/acceleration/src/android/acceleration/cts/WindowFlagHardwareAccelerationTest.java
@@ -16,6 +16,8 @@
 
 package android.acceleration.cts;
 
+import android.acceleration.WindowFlagHardwareAcceleratedActivity;
+
 /**
  * Test that uses an Activity with hardware acceleration enabled.
  */
diff --git a/tests/sample/Android.mk b/tests/sample/Android.mk
index 5e8f571..1255032 100755
--- a/tests/sample/Android.mk
+++ b/tests/sample/Android.mk
@@ -16,19 +16,24 @@
 
 include $(CLEAR_VARS)
 
-# Don't include this package in any target.
-LOCAL_MODULE_TAGS := optional
-
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
 # When built, explicitly put it in the data partition.
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
+
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util android-support-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-# Must match the package name in CtsTestCaseList.mk
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
 LOCAL_PACKAGE_NAME := CtsSampleDeviceTestCases
 
 LOCAL_SDK_VERSION := current
 
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_PACKAGE)
diff --git a/tests/sample/AndroidManifest.xml b/tests/sample/AndroidManifest.xml
index f07ebbe..194c904 100755
--- a/tests/sample/AndroidManifest.xml
+++ b/tests/sample/AndroidManifest.xml
@@ -18,7 +18,6 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="android.sample.cts">
 
-    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <application>
         <uses-library android:name="android.test.runner" />
         <activity android:name="android.sample.SampleDeviceActivity" >
@@ -34,9 +33,6 @@
         android:name="android.support.test.runner.AndroidJUnitRunner"
         android:label="CTS sample tests"
         android:targetPackage="android.sample.cts" >
-        <meta-data
-            android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
     </instrumentation>
 </manifest>
 
diff --git a/tests/sample/AndroidTest.xml b/tests/sample/AndroidTest.xml
new file mode 100644
index 0000000..f2ec348
--- /dev/null
+++ b/tests/sample/AndroidTest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Base config for CTS package preparer">
+    <include name="common-config" />
+    <option name="apk-installer:test-file-name" value="CtsSampleDeviceTestCases.apk" />
+    <test class="com.android.tradefed.testtype.InstrumentationTest" >
+        <option name="package" value="android.sample.cts" />
+        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+    </test>
+</configuration>
diff --git a/tests/sample/src/android/sample/cts/SampleDeviceResultTest.java b/tests/sample/src/android/sample/cts/SampleDeviceResultTest.java
index 6bf883f..7bd434e 100644
--- a/tests/sample/src/android/sample/cts/SampleDeviceResultTest.java
+++ b/tests/sample/src/android/sample/cts/SampleDeviceResultTest.java
@@ -15,21 +15,25 @@
  */
 package android.sample.cts;
 
-import com.android.cts.util.MeasureRun;
-import com.android.cts.util.MeasureTime;
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import com.android.cts.util.Stat;
+import android.sample.SampleDeviceActivity;
+import android.test.ActivityInstrumentationTestCase2;
 
-import android.cts.util.CtsAndroidTestCase;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.MeasureRun;
+import com.android.compatibility.common.util.MeasureTime;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
+
+import java.util.Arrays;
+import java.util.Random;
 
 /**
  * A simple compatibility test which includes results in the report.
  *
  * This test measures the time taken to run a workload and adds in the report.
  */
-public class SampleDeviceResultTest extends CtsAndroidTestCase {
+public class SampleDeviceResultTest extends ActivityInstrumentationTestCase2<SampleDeviceActivity> {
 
     /**
      * The number of times to repeat the test.
@@ -37,86 +41,74 @@
     private static final int REPEAT = 5;
 
     /**
-     * The input number for the factorial.
+     * A {@link Random} to generate random integers to test the sort.
      */
-    private static final int IN = 15;
+    private static final Random random = new Random(12345);
 
     /**
-     * The expected output number for the factorial.
+     * Constructor which passes the class of the activity to be instrumented.
      */
-    private static final long OUT = 1307674368000L;
-
-    /**
-     * Measures the time taken to compute the factorial of 15 with a recursive method.
-     *
-     * @throws Exception
-     */
-    public void testFactorialRecursive() throws Exception {
-        runTest(new MeasureRun() {
-            @Override
-            public void run(int i) throws Exception {
-                // Compute the factorial and assert it is correct.
-                assertEquals("Incorrect result", OUT, factorialRecursive(IN));
-            }
-        });
+    public SampleDeviceResultTest() {
+        super(SampleDeviceActivity.class);
     }
 
     /**
-     * Measures the time taken to compute the factorial of 15 with a iterative method.
-     *
-     * @throws Exception
+     * Creates an array filled with random numbers of the given size.
      */
-    public void testFactorialIterative() throws Exception {
-        runTest(new MeasureRun() {
-            @Override
-            public void run(int i) throws Exception {
-                // Compute the factorial and assert it is correct.
-                assertEquals("Incorrect result", OUT, factorialIterative(IN));
-            }
-        });
-    }
-
-    /**
-     * Computes the factorial of a number with a recursive method.
-     *
-     * @param num The number to compute the factorial of.
-     */
-    private static long factorialRecursive(int num) {
-        if (num <= 0) {
-            return 1;
+    private static int[] createArray(int size) {
+        int[] array = new int[size];
+        for (int i = 0; i < size; i++) {
+            array[i] = random.nextInt();
         }
-        return num * factorialRecursive(num - 1);
+        return array;
     }
 
     /**
-     * Computes the factorial of a number with a iterative method.
-     *
-     * @param num The number to compute the factorial of.
+     * Tests an array is sorted.
      */
-    private static long factorialIterative(int num) {
-        long result = 1;
-        for (int i = 2; i <= num; i++) {
-            result *= i;
+    private static boolean isSorted(int[] array) {
+        int len = array.length;
+        for (int i = 0, j = 1; j < len; i++, j++) {
+            if (array[i] > array[j]) {
+                return false;
+            }
         }
-        return result;
+        return true;
     }
 
     /**
-     * Runs the workload and records the result to the report log.
-     *
-     * @param workload
+     * Measures the time taken to sort an array.
      */
-    private void runTest(MeasureRun workload) throws Exception {
+    public void testSort() throws Exception {
         // MeasureTime runs the workload N times and records the time taken by each run.
-        double[] result = MeasureTime.measure(REPEAT, workload);
+        double[] result = MeasureTime.measure(REPEAT, new MeasureRun() {
+            /**
+             * The size of the array to sort.
+             */
+            private static final int ARRAY_SIZE = 100000;
+            private int[] array;
+            @Override
+            public void prepare(int i) throws Exception {
+                array = createArray(ARRAY_SIZE);
+            }
+            @Override
+            public void run(int i) throws Exception {
+                Arrays.sort(array);
+                assertTrue("Array not sorted", isSorted(array));
+            }
+        });
         // Compute the stats.
         Stat.StatResult stat = Stat.getStat(result);
-        // Get the report for this test and add the results to record.
-        ReportLog log = getReportLog();
-        log.printArray("Times", result, ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue("Min", stat.mMin, ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue("Max", stat.mMax, ResultType.LOWER_BETTER, ResultUnit.MS);
+        // Create a new report to hold the metrics.
+        DeviceReportLog reportLog = new DeviceReportLog();
+        // Add the results to the report.
+        reportLog.addValues("Times", result, ResultType.LOWER_BETTER, ResultUnit.MS);
+        reportLog.addValue("Min", stat.mMin, ResultType.LOWER_BETTER, ResultUnit.MS);
+        reportLog.addValue("Max", stat.mMax, ResultType.LOWER_BETTER, ResultUnit.MS);
         // Every report must have a summary,
-        log.printSummary("Average", stat.mAverage, ResultType.LOWER_BETTER, ResultUnit.MS);
+        reportLog.setSummary("Average", stat.mAverage, ResultType.LOWER_BETTER, ResultUnit.MS);
+        // Submit the report to the given instrumentation.
+        reportLog.submit(getInstrumentation());
     }
+
 }
diff --git a/tests/tests/acceleration/AndroidManifest.xml b/tests/tests/acceleration/AndroidManifest.xml
deleted file mode 100644
index 0dd2722..0000000
--- a/tests/tests/acceleration/AndroidManifest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-        package="com.android.cts.acceleration">
-
-  <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
-  <application>
-      <uses-library android:name="android.test.runner" />
-  </application>
-
-  <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                   android:targetPackage="com.android.cts.acceleration.stub"
-                   android:label="Tests for the Hardware Acceleration APIs." >
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
-    </instrumentation>
-
-</manifest>
diff --git a/tests/tests/accessibility/Android.mk b/tests/tests/accessibility/Android.mk
index 263c47b..c231ab0 100644
--- a/tests/tests/accessibility/Android.mk
+++ b/tests/tests/accessibility/Android.mk
@@ -26,6 +26,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
 
+LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
+
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/accessibility/AndroidTest.xml b/tests/tests/accessibility/OldAndroidTest.xml
similarity index 100%
rename from tests/tests/accessibility/AndroidTest.xml
rename to tests/tests/accessibility/OldAndroidTest.xml
diff --git a/tests/tests/app/Android.mk b/tests/tests/app/Android.mk
index 301f931..8bdccea 100644
--- a/tests/tests/app/Android.mk
+++ b/tests/tests/app/Android.mk
@@ -31,6 +31,8 @@
 
 LOCAL_INSTRUMENTATION_FOR := CtsAppTestStubs
 
+LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
+
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/app/AndroidTest.xml b/tests/tests/app/OldAndroidTest.xml
similarity index 100%
rename from tests/tests/app/AndroidTest.xml
rename to tests/tests/app/OldAndroidTest.xml
diff --git a/tests/tests/display/Android.mk b/tests/tests/display/Android.mk
index f17f580..dc815c3 100644
--- a/tests/tests/display/Android.mk
+++ b/tests/tests/display/Android.mk
@@ -16,17 +16,26 @@
 
 include $(CLEAR_VARS)
 
-# don't include this package in any target
-LOCAL_MODULE_TAGS := optional
-# and when built explicitly put it in the data partition
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
 LOCAL_PACKAGE_NAME := CtsDisplayTestCases
 
+LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
+
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/display/AndroidManifest.xml b/tests/tests/display/AndroidManifest.xml
index bf84219..22cc824 100644
--- a/tests/tests/display/AndroidManifest.xml
+++ b/tests/tests/display/AndroidManifest.xml
@@ -16,9 +16,8 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.cts.display">
+    package="android.display.cts">
 
-    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <!-- For special presentation windows when testing mode switches. -->
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
 
@@ -26,12 +25,11 @@
         <uses-library android:name="android.test.runner" />
     </application>
 
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="com.android.cts.display"
-                     android:label="CTS tests of android.view.display">
-        <meta-data
-            android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
+    <!--  self-instrumenting test package. -->
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:targetPackage="android.display.cts"
+        android:label="CTS tests of android.display">
     </instrumentation>
 
 </manifest>
diff --git a/tests/tests/display/AndroidTest.xml b/tests/tests/display/AndroidTest.xml
index dd42984..0296e8e 100644
--- a/tests/tests/display/AndroidTest.xml
+++ b/tests/tests/display/AndroidTest.xml
@@ -18,4 +18,9 @@
     <!-- Use a non-standard pattern, must match values in tests/tests/display/.../DisplayTest.java -->
     <option name="run-command:run-command" value="settings put global overlay_display_devices '181x161/214|181x161/214'" />
     <option name="run-command:teardown-command" value="settings put global overlay_display_devices &quot;&quot;" />
+    <option name="apk-installer:test-file-name" value="CtsDisplayTestCases.apk" />
+    <test class="com.android.tradefed.testtype.InstrumentationTest" >
+        <option name="package" value="android.display.cts" />
+        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+    </test>
 </configuration>
diff --git a/tests/tests/display/OldAndroidTest.xml b/tests/tests/display/OldAndroidTest.xml
new file mode 100644
index 0000000..dd42984
--- /dev/null
+++ b/tests/tests/display/OldAndroidTest.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Base config for CTS package preparer">
+    <include name="common-config" />
+    <!-- Use a non-standard pattern, must match values in tests/tests/display/.../DisplayTest.java -->
+    <option name="run-command:run-command" value="settings put global overlay_display_devices '181x161/214|181x161/214'" />
+    <option name="run-command:teardown-command" value="settings put global overlay_display_devices &quot;&quot;" />
+</configuration>
diff --git a/tests/tests/gesture/Android.mk b/tests/tests/gesture/Android.mk
index 4a97931..0c4e023 100755
--- a/tests/tests/gesture/Android.mk
+++ b/tests/tests/gesture/Android.mk
@@ -16,15 +16,22 @@
 
 include $(CLEAR_VARS)
 
-# don't include this package in any target
-LOCAL_MODULE_TAGS := optional
-# and when built explicitly put it in the data partition
+# Don't include this package in any target
+LOCAL_MODULE_TAGS := tests
+# When built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_DEX_PREOPT := false
+
+LOCAL_PROGUARD_ENABLED := disabled
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+
+# Tag this module as a cts_v2 test artifact
+LOCAL_COMPATIBILITY_SUITE := cts_v2
+
 LOCAL_PACKAGE_NAME := CtsGestureTestCases
 
 LOCAL_SDK_VERSION := current
diff --git a/tests/tests/gesture/AndroidManifest.xml b/tests/tests/gesture/AndroidManifest.xml
index b288cd2..fb3ee51 100755
--- a/tests/tests/gesture/AndroidManifest.xml
+++ b/tests/tests/gesture/AndroidManifest.xml
@@ -16,19 +16,17 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.cts.gesture">
+    package="android.gesture.cts">
 
-    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <application>
         <uses-library android:name="android.test.runner" />
     </application>
 
     <!--  self-instrumenting test package. -->
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="com.android.cts.gesture"
-                     android:label="CTS tests of android.gesture">
-        <meta-data android:name="listener"
-            android:value="com.android.cts.runner.CtsTestRunListener" />
+    <instrumentation
+        android:name="android.support.test.runner.AndroidJUnitRunner"
+        android:targetPackage="android.gesture.cts"
+        android:label="CTS tests of android.gesture">
     </instrumentation>
 
 </manifest>
diff --git a/tests/tests/gesture/AndroidTest.xml b/tests/tests/gesture/AndroidTest.xml
new file mode 100644
index 0000000..e0be497
--- /dev/null
+++ b/tests/tests/gesture/AndroidTest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Base config for CTS package preparer">
+    <include name="common-config" />
+    <option name="apk-installer:test-file-name" value="CtsGestureTestCases.apk" />
+    <test class="com.android.tradefed.testtype.InstrumentationTest" >
+        <option name="package" value="android.gesture.cts" />
+        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+    </test>
+</configuration>
diff --git a/tests/tests/hardware/Android.mk b/tests/tests/hardware/Android.mk
index 9523d87..895da2c 100644
--- a/tests/tests/hardware/Android.mk
+++ b/tests/tests/hardware/Android.mk
@@ -22,7 +22,7 @@
 
 LOCAL_MODULE_TAGS := tests
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util
 
 LOCAL_SDK_VERSION := current
 
@@ -36,8 +36,6 @@
     src/android/hardware/cts/SensorTest.java \
     src/android/hardware/cts/SensorManagerStaticTest.java \
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil
-
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
 
@@ -47,12 +45,14 @@
 
 LOCAL_MODULE_TAGS := tests
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner mockito-target android-ex-camera2
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil compatibility-device-util ctstestrunner mockito-target android-ex-camera2
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsHardwareTestCases
 
+LOCAL_CTS_MODULE_CONFIG := $(LOCAL_PATH)/Old$(CTS_MODULE_TEST_CONFIG)
+
 LOCAL_SDK_VERSION := current
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
diff --git a/tests/tests/hardware/AndroidManifest.xml b/tests/tests/hardware/AndroidManifest.xml
index 031b19e..34a1475 100644
--- a/tests/tests/hardware/AndroidManifest.xml
+++ b/tests/tests/hardware/AndroidManifest.xml
@@ -72,6 +72,9 @@
             android:process=":camera2ActivityProcess">
         </activity>
 
+        <activity android:name="android.hardware.input.cts.InputCtsActivity"
+            android:label="InputCtsActivity" />
+
         <activity android:name="android.hardware.cts.FingerprintTestActivity"
             android:label="FingerprintTestActivity">
         </activity>
diff --git a/tests/tests/hardware/AndroidTest.xml b/tests/tests/hardware/OldAndroidTest.xml
similarity index 100%
rename from tests/tests/hardware/AndroidTest.xml
rename to tests/tests/hardware/OldAndroidTest.xml
diff --git a/tests/tests/hardware/res/raw/gamepad_press_a.json b/tests/tests/hardware/res/raw/gamepad_press_a.json
new file mode 100644
index 0000000..ff3ca4f
--- /dev/null
+++ b/tests/tests/hardware/res/raw/gamepad_press_a.json
@@ -0,0 +1,39 @@
+{
+    "id": 1,
+    "command": "register",
+    "name": "Odie (Test)",
+    "vid": 0x18d1,
+    "pid": 0x2c40,
+    "descriptor": [0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x01, 0x05, 0x09, 0x0a, 0x01, 0x00,
+        0x0a, 0x02, 0x00, 0x0a, 0x04, 0x00, 0x0a, 0x05, 0x00, 0x0a, 0x07, 0x00, 0x0a, 0x08, 0x00,
+        0x0a, 0x0e, 0x00, 0x0a, 0x0f, 0x00, 0x0a, 0x0d, 0x00, 0x05, 0x0c, 0x0a, 0x24, 0x02, 0x0a,
+        0x23, 0x02, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x0b, 0x81, 0x02, 0x75, 0x01, 0x95,
+        0x01, 0x81, 0x03, 0x05, 0x01, 0x75, 0x04, 0x95, 0x01, 0x25, 0x07, 0x46, 0x3b, 0x01, 0x66,
+        0x14, 0x00, 0x09, 0x39, 0x81, 0x42, 0x66, 0x00, 0x00, 0x09, 0x01, 0xa1, 0x00, 0x09, 0x30,
+        0x09, 0x31, 0x09, 0x32, 0x09, 0x35, 0x05, 0x02, 0x09, 0xc5, 0x09, 0xc4, 0x15, 0x00, 0x26,
+        0xff, 0x00, 0x35, 0x00, 0x46, 0xff, 0x00, 0x75, 0x08, 0x95, 0x06, 0x81, 0x02, 0xc0, 0x85,
+        0x02, 0x05, 0x08, 0x0a, 0x01, 0x00, 0x0a, 0x02, 0x00, 0x0a, 0x03, 0x00, 0x0a, 0x04, 0x00,
+        0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x04, 0x91, 0x02, 0x75, 0x04, 0x95, 0x01, 0x91,
+        0x03, 0xc0, 0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x05, 0x01, 0x09, 0x06, 0xa1,
+        0x02, 0x05, 0x06, 0x09, 0x20, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81,
+        0x02, 0x06, 0xbc, 0xff, 0x0a, 0xad, 0xbd, 0x75, 0x08, 0x95, 0x06, 0x81, 0x02, 0xc0, 0xc0],
+    "report": [0x01, 0x00, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
+}
+
+{
+    "id": 1,
+    "command": "report",
+    "report": [0x01, 0x01, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
+}
+
+{
+    "id": 1,
+    "command": "delay",
+    "duration": 10
+}
+
+{
+    "id": 1,
+    "command": "report",
+    "report": [0x01, 0x00, 0x80, 0x90, 0x80, 0x7f, 0x73, 0x00, 0x00]
+}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
index 908e6a5..ace8af5 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
@@ -16,7 +16,7 @@
 
 package android.hardware.camera2.cts;
 
-import static com.android.ex.camera2.blocking.BlockingSessionCallback.*;
+import static com.android.ex.camera2.blocking.BlockingSessionCallback.SESSION_CLOSED;
 
 import android.graphics.ImageFormat;
 import android.hardware.camera2.CameraAccessException;
@@ -32,20 +32,20 @@
 import android.hardware.camera2.cts.helpers.StaticMetadata.CheckLevel;
 import android.hardware.camera2.cts.testcases.Camera2SurfaceViewTestCase;
 import android.hardware.camera2.params.InputConfiguration;
-import android.util.Log;
-import android.util.Pair;
-import android.util.Size;
-import android.view.Surface;
-import android.cts.util.DeviceReportLog;
 import android.media.Image;
 import android.media.ImageReader;
 import android.media.ImageWriter;
 import android.os.ConditionVariable;
 import android.os.SystemClock;
+import android.util.Log;
+import android.util.Pair;
+import android.util.Size;
+import android.view.Surface;
 
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
-import com.android.cts.util.Stat;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+import com.android.compatibility.common.util.Stat;
 import com.android.ex.camera2.blocking.BlockingSessionCallback;
 import com.android.ex.camera2.exceptions.TimeoutRuntimeException;
 
@@ -96,7 +96,7 @@
     @Override
     protected void tearDown() throws Exception {
         // Deliver the report to host will automatically clear the report log.
-        mReportLog.deliverReportToHost(getInstrumentation());
+        mReportLog.submit(getInstrumentation());
         super.tearDown();
     }
 
@@ -171,22 +171,22 @@
 
                 avgCameraLaunchTimes[counter] = Stat.getAverage(cameraLaunchTimes);
                 // Finish the data collection, report the KPIs.
-                mReportLog.printArray("Camera " + id
+                mReportLog.addValues("Camera " + id
                         + ": Camera open time", cameraOpenTimes,
                         ResultType.LOWER_BETTER, ResultUnit.MS);
-                mReportLog.printArray("Camera " + id
+                mReportLog.addValues("Camera " + id
                         + ": Camera configure stream time", configureStreamTimes,
                         ResultType.LOWER_BETTER, ResultUnit.MS);
-                mReportLog.printArray("Camera " + id
+                mReportLog.addValues("Camera " + id
                         + ": Camera start preview time", startPreviewTimes,
                         ResultType.LOWER_BETTER, ResultUnit.MS);
-                mReportLog.printArray("Camera " + id
+                mReportLog.addValues("Camera " + id
                         + ": Camera stop preview", stopPreviewTimes,
                         ResultType.LOWER_BETTER, ResultUnit.MS);
-                mReportLog.printArray("Camera " + id
+                mReportLog.addValues("Camera " + id
                         + ": Camera close time", cameraCloseTimes,
                         ResultType.LOWER_BETTER, ResultUnit.MS);
-                mReportLog.printArray("Camera " + id
+                mReportLog.addValues("Camera " + id
                         + ": Camera launch time", cameraLaunchTimes,
                         ResultType.LOWER_BETTER, ResultUnit.MS);
             }
@@ -195,7 +195,7 @@
             }
             counter++;
         }
-        mReportLog.printSummary("Camera launch average time for all cameras ",
+        mReportLog.setSummary("Camera launch average time for all cameras ",
                 Stat.getAverage(avgCameraLaunchTimes), ResultType.LOWER_BETTER, ResultUnit.MS);
     }
 
@@ -280,19 +280,19 @@
                     // simulate real scenario (preview runs a bit)
                     waitForNumResults(previewResultListener, NUM_RESULTS_WAIT);
 
-                    blockingStopPreview();
+                    stopPreview();
 
                 }
-                mReportLog.printArray("Camera " + id
+                mReportLog.addValues("Camera " + id
                         + ": Camera capture latency", captureTimes,
                         ResultType.LOWER_BETTER, ResultUnit.MS);
                 // If any of the partial results do not contain AE and AF state, then no report
                 if (isPartialTimingValid) {
-                    mReportLog.printArray("Camera " + id
+                    mReportLog.addValues("Camera " + id
                             + ": Camera partial result latency", getPartialTimes,
                             ResultType.LOWER_BETTER, ResultUnit.MS);
                 }
-                mReportLog.printArray("Camera " + id
+                mReportLog.addValues("Camera " + id
                         + ": Camera capture result latency", getResultTimes,
                         ResultType.LOWER_BETTER, ResultUnit.MS);
 
@@ -306,7 +306,7 @@
         }
 
         // Result will not be reported in CTS report if no summary is printed.
-        mReportLog.printSummary("Camera capture result average latency for all cameras ",
+        mReportLog.setSummary("Camera capture result average latency for all cameras ",
                 Stat.getAverage(avgResultTimes), ResultType.LOWER_BETTER, ResultUnit.MS);
     }
 
@@ -460,13 +460,13 @@
             reprocessType = " opaque reprocessing ";
         }
 
-        mReportLog.printArray("Camera " + mCamera.getId()
+        mReportLog.addValues("Camera " + mCamera.getId()
                 + ":" + reprocessType + " max capture timestamp gaps", maxCaptureGapsMs,
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        mReportLog.printArray("Camera " + mCamera.getId()
+        mReportLog.addValues("Camera " + mCamera.getId()
                 + ":" + reprocessType + "capture average frame duration", averageFrameDurationMs,
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        mReportLog.printSummary("Camera reprocessing average max capture timestamp gaps for Camera "
+        mReportLog.setSummary("Camera reprocessing average max capture timestamp gaps for Camera "
                 + mCamera.getId(), Stat.getAverage(maxCaptureGapsMs), ResultType.LOWER_BETTER,
                 ResultUnit.MS);
 
@@ -544,17 +544,17 @@
 
         // Report the performance data
         if (asyncMode) {
-            mReportLog.printArray("Camera " + mCamera.getId()
+            mReportLog.addValues("Camera " + mCamera.getId()
                     + ":" + reprocessType + "capture latency", getImageLatenciesMs,
                     ResultType.LOWER_BETTER, ResultUnit.MS);
-            mReportLog.printSummary("Camera reprocessing average latency for Camera " +
+            mReportLog.setSummary("Camera reprocessing average latency for Camera " +
                     mCamera.getId(), Stat.getAverage(getImageLatenciesMs), ResultType.LOWER_BETTER,
                     ResultUnit.MS);
         } else {
-            mReportLog.printArray("Camera " + mCamera.getId()
+            mReportLog.addValues("Camera " + mCamera.getId()
                     + ":" + reprocessType + "shot to shot latency", getImageLatenciesMs,
                     ResultType.LOWER_BETTER, ResultUnit.MS);
-            mReportLog.printSummary("Camera reprocessing shot to shot average latency for Camera " +
+            mReportLog.setSummary("Camera reprocessing shot to shot average latency for Camera " +
                     mCamera.getId(), Stat.getAverage(getImageLatenciesMs), ResultType.LOWER_BETTER,
                     ResultUnit.MS);
         }
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataCollectionTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataCollectionTest.java
index 283f09b..4f4c5fe 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataCollectionTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataCollectionTest.java
@@ -17,13 +17,13 @@
 package android.hardware.camera2.cts;
 
 import android.content.pm.PackageManager;
-import android.cts.util.DeviceReportLog;
-import android.hardware.camera2.cts.testcases.Camera2SurfaceViewTestCase;
 import android.hardware.camera2.cts.helpers.CameraMetadataGetter;
+import android.hardware.camera2.cts.testcases.Camera2SurfaceViewTestCase;
 import android.util.Log;
 
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
@@ -48,7 +48,7 @@
     @Override
     protected void tearDown() throws Exception {
         // Deliver the report to host will automatically clear the report log.
-        mReportLog.deliverReportToHost(getInstrumentation());
+        mReportLog.submit(getInstrumentation());
         super.tearDown();
     }
 
@@ -80,7 +80,7 @@
                 Log.e(TAG, "Unable to close camera info getter " + e.getMessage());
             }
 
-            mReportLog.printSummary("Camera data collection for static info and capture request"
+            mReportLog.setSummary("Camera data collection for static info and capture request"
                     + " templates",
                     0.0, ResultType.NEUTRAL, ResultUnit.NONE);
         }
@@ -88,11 +88,11 @@
     }
 
     private void dumpDoubleAsCtsResult(String name, double value) {
-        mReportLog.printValue(name, value, ResultType.NEUTRAL, ResultUnit.NONE);
+        mReportLog.addValue(name, value, ResultType.NEUTRAL, ResultUnit.NONE);
     }
 
     public void dumpDoubleArrayAsCtsResult(String name, double[] values) {
-        mReportLog.printArray(name, values, ResultType.NEUTRAL, ResultUnit.NONE);
+        mReportLog.addValues(name, values, ResultType.NEUTRAL, ResultUnit.NONE);
     }
 
     private double getJsonValueAsDouble(String name, Object obj) throws Exception {
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
index 6633903..8e542b3 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerification.java
@@ -19,15 +19,13 @@
 import junit.framework.Assert;
 
 import android.hardware.Sensor;
-import android.hardware.cts.helpers.SensorCtsHelper;
 import android.hardware.cts.helpers.SensorStats;
 import android.hardware.cts.helpers.TestSensorEnvironment;
 import android.hardware.cts.helpers.TestSensorEvent;
 import android.util.SparseIntArray;
 
-import com.android.cts.util.StatisticsUtils;
+import com.android.compatibility.common.util.Stat;
 
-import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -87,8 +85,8 @@
             return;
         }
 
-        List<Double> jitters = getJitterValues();
-        double jitter95PercentileNs = SensorCtsHelper.get95PercentileValue(jitters);
+        double[] jitters = getJitterValues();
+        double jitter95PercentileNs = Stat.get95PercentileValue(jitters);
         long firstTimestamp = mTimestamps.get(0);
         long lastTimestamp = mTimestamps.get(timestampsCount - 1);
         long measuredPeriodNs = (lastTimestamp - firstTimestamp) / (timestampsCount - 1);
@@ -128,15 +126,16 @@
     /**
      * Get the list of all jitter values. Exposed for unit testing.
      */
-    List<Double> getJitterValues() {
-        List<Long> deltas = new ArrayList<Long>(mTimestamps.size() - 1);
-        for (int i = 1; i < mTimestamps.size(); i++) {
-            deltas.add(mTimestamps.get(i) - mTimestamps.get(i - 1));
+    double[] getJitterValues() {
+        int length = mTimestamps.size() - 1;
+        double[] deltas = new double[length];
+        for (int i = 0; i < length; i++) {
+            deltas[i] = mTimestamps.get(i + 1) - mTimestamps.get(i);
         }
-        double deltaMean = StatisticsUtils.getMean(deltas);
-        List<Double> jitters = new ArrayList<Double>(deltas.size());
-        for (long delta : deltas) {
-            jitters.add(Math.abs(delta - deltaMean));
+        double deltaMean = Stat.getAverage(deltas);
+        double[] jitters = new double[length];
+        for (int i = 0; i < length; i++) {
+            jitters[i] = Math.abs(deltas[i] - deltaMean);
         }
         return jitters;
     }
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
index 50e288c..5cf747f 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/JitterVerificationTest.java
@@ -24,7 +24,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
 
 /**
  * Tests for {@link EventOrderingVerification}.
@@ -73,31 +72,30 @@
     public void testCalculateJitter() {
         long[] timestamps = new long[]{0, 1, 2, 3, 4};
         JitterVerification verification = getVerification(1, timestamps);
-        List<Double> jitterValues = verification.getJitterValues();
-        assertEquals(4, jitterValues.size());
-        assertEquals(0.0, jitterValues.get(0));
-        assertEquals(0.0, jitterValues.get(1));
-        assertEquals(0.0, jitterValues.get(2));
-        assertEquals(0.0, jitterValues.get(3));
+        double[] jitterValues = verification.getJitterValues();
+        assertEquals(4, jitterValues.length);
+        assertEquals(0.0, jitterValues[0]);
+        assertEquals(0.0, jitterValues[1]);
+        assertEquals(0.0, jitterValues[2]);
+        assertEquals(0.0, jitterValues[3]);
 
         timestamps = new long[]{0, 0, 2, 4, 4};
         verification = getVerification(1, timestamps);
         jitterValues = verification.getJitterValues();
-        assertEquals(4, jitterValues.size());
-        assertEquals(1.0, jitterValues.get(0));
-        assertEquals(1.0, jitterValues.get(1));
-        assertEquals(1.0, jitterValues.get(2));
-        assertEquals(1.0, jitterValues.get(3));
+        assertEquals(4, jitterValues.length);
+        assertEquals(1.0, jitterValues[0]);
+        assertEquals(1.0, jitterValues[1]);
+        assertEquals(1.0, jitterValues[2]);
+        assertEquals(1.0, jitterValues[3]);
 
         timestamps = new long[]{0, 1, 4, 9, 16};
         verification = getVerification(1, timestamps);
         jitterValues = verification.getJitterValues();
-        assertEquals(4, jitterValues.size());
-        assertEquals(4, jitterValues.size());
-        assertEquals(3.0, jitterValues.get(0));
-        assertEquals(1.0, jitterValues.get(1));
-        assertEquals(1.0, jitterValues.get(2));
-        assertEquals(3.0, jitterValues.get(3));
+        assertEquals(4, jitterValues.length);
+        assertEquals(3.0, jitterValues[0]);
+        assertEquals(1.0, jitterValues[1]);
+        assertEquals(1.0, jitterValues[2]);
+        assertEquals(3.0, jitterValues[3]);
     }
 
     private static JitterVerification getVerification(int threshold, long ... timestamps) {
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java b/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java
similarity index 67%
rename from common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java
rename to tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java
index ab19369..accdcaf 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/TradefedTest.java
+++ b/tests/tests/hardware/src/android/hardware/input/cts/InputCallback.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright 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.
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-package com.android.compatibility.common.tradefed;
+package android.hardware.input.cts;
 
-import junit.framework.TestCase;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
 
-public class TradefedTest extends TestCase {
-
-    // TODO(stuartscott): Add tests when there is something to test.
-
+public interface InputCallback {
+    public void onKeyEvent(KeyEvent ev);
+    public void onMotionEvent(MotionEvent ev);
 }
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java b/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java
new file mode 100644
index 0000000..b16cadb
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/input/cts/InputCtsActivity.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 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.hardware.input.cts;
+
+import android.app.Activity;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InputCtsActivity extends Activity {
+    private InputCallback mInputCallback;
+
+    @Override
+    public boolean dispatchGenericMotionEvent(MotionEvent ev) {
+        if (mInputCallback != null) {
+            mInputCallback.onMotionEvent(ev);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean dispatchTouchEvent(MotionEvent ev) {
+        if (mInputCallback != null) {
+            mInputCallback.onMotionEvent(ev);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean dispatchTrackballEvent(MotionEvent ev) {
+        if (mInputCallback != null) {
+            mInputCallback.onMotionEvent(ev);
+        }
+        return true;
+    }
+
+    @Override
+    public boolean dispatchKeyEvent(KeyEvent ev) {
+        if (mInputCallback != null) {
+            mInputCallback.onKeyEvent(ev);
+        }
+        return true;
+    }
+
+    public void setInputCallback(InputCallback callback) {
+        mInputCallback = callback;
+    }
+}
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java
new file mode 100644
index 0000000..92fba12
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/GamepadTestCase.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 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.hardware.input.cts.tests;
+
+import android.util.Log;
+import android.view.KeyEvent;
+
+import java.io.Writer;
+import java.util.List;
+
+import com.android.cts.hardware.R;
+
+public class GamepadTestCase extends InputTestCase {
+    private static final String TAG = "GamepadTests";
+
+    public void testButtonA() throws Exception {
+        sendHidCommands(R.raw.gamepad_press_a);
+        assertReceivedKeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_A);
+        assertReceivedKeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BUTTON_A);
+        assertNoMoreEvents();
+    }
+}
diff --git a/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java b/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
new file mode 100644
index 0000000..fba5f51
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/input/cts/tests/InputTestCase.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright 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.hardware.input.cts.tests;
+
+import android.app.UiAutomation;
+import android.hardware.input.cts.InputCtsActivity;
+import android.hardware.input.cts.InputCallback;
+import android.system.ErrnoException;
+import android.system.Os;
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.List;
+import java.util.UUID;
+
+public class InputTestCase extends ActivityInstrumentationTestCase2<InputCtsActivity> {
+    private static final String TAG = "InputTestCase";
+    private static final String HID_EXECUTABLE = "hid";
+    private static final int SHELL_UID = 2000;
+    private static final String[] KEY_ACTIONS = {"DOWN", "UP", "MULTIPLE"};
+
+    private File mFifo;
+    private Writer mWriter;
+
+    private BlockingQueue<KeyEvent> mKeys;
+    private BlockingQueue<MotionEvent> mMotions;
+    private InputListener mInputListener;
+
+    public InputTestCase() {
+        super(InputCtsActivity.class);
+        mKeys = new LinkedBlockingQueue<KeyEvent>();
+        mMotions = new LinkedBlockingQueue<MotionEvent>();
+        mInputListener = new InputListener();
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mFifo = setupFifo();
+        clearKeys();
+        clearMotions();
+        getActivity().setInputCallback(mInputListener);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mFifo != null) {
+            mFifo.delete();
+            mFifo = null;
+        }
+        closeQuietly(mWriter);
+        mWriter = null;
+        super.tearDown();
+    }
+
+    /**
+     * Sends the HID commands designated by the given resource id.
+     * The commands must be in the format expected by the `hid` shell command.
+     *
+     * @param id The resource id from which to load the HID commands. This must be a "raw"
+     * resource.
+     */
+    public void sendHidCommands(int id) {
+        try {
+            Writer w = getWriter();
+            w.write(getEvents(id));
+            w.flush();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * Asserts that the application received a {@link android.view.KeyEvent} with the given action
+     * and keycode.
+     *
+     * If other KeyEvents are received by the application prior to the expected KeyEvent, or no
+     * KeyEvents are received within a reasonable amount of time, then this will throw an
+     * AssertionFailedError.
+     *
+     * @param action The action to expect on the next KeyEvent
+     * (e.g. {@link android.view.KeyEvent#ACTION_DOWN}).
+     * @param keyCode The expected key code of the next KeyEvent.
+     */
+    public void assertReceivedKeyEvent(int action, int keyCode) {
+        KeyEvent k = waitForKey();
+        if (k == null) {
+            fail("Timed out waiting for " + KeyEvent.keyCodeToString(keyCode)
+                    + " with action " + KEY_ACTIONS[action]);
+            return;
+        }
+        assertEquals(action, k.getAction());
+        assertEquals(keyCode, k.getKeyCode());
+    }
+
+    /**
+     * Asserts that no more events have been received by the application.
+     *
+     * If any more events have been received by the application, this throws an
+     * AssertionFailedError.
+     */
+    public void assertNoMoreEvents() {
+        KeyEvent key;
+        MotionEvent motion;
+        if ((key = mKeys.poll()) != null) {
+            fail("Extraneous key events generated: " + key);
+        }
+        if ((motion = mMotions.poll()) != null) {
+            fail("Extraneous motion events generated: " + motion);
+        }
+    }
+
+    private KeyEvent waitForKey() {
+        try {
+            return mKeys.poll(1, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            return null;
+        }
+    }
+
+    private void clearKeys() {
+        mKeys.clear();
+    }
+
+    private void clearMotions() {
+        mMotions.clear();
+    }
+
+    private File setupFifo() throws ErrnoException {
+        File dir = getActivity().getCacheDir();
+        String filename = dir.getAbsolutePath() + File.separator +  UUID.randomUUID().toString();
+        Os.mkfifo(filename, 0666);
+        File f = new File(filename);
+        return f;
+    }
+
+    private Writer getWriter() throws IOException {
+        if (mWriter == null) {
+            UiAutomation ui = getInstrumentation().getUiAutomation();
+            ui.executeShellCommand("hid " + mFifo.getAbsolutePath());
+            mWriter = new FileWriter(mFifo);
+        }
+        return mWriter;
+    }
+
+    private String getEvents(int id) throws IOException {
+        InputStream is =
+            getInstrumentation().getTargetContext().getResources().openRawResource(id);
+        return readFully(is);
+    }
+
+
+    private static void closeQuietly(AutoCloseable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (RuntimeException rethrown) {
+                throw rethrown;
+            } catch (Exception ignored) { }
+        }
+    }
+
+    private static String readFully(InputStream is) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        int read = 0;
+        byte[] buffer = new byte[1024];
+        while ((read = is.read(buffer)) >= 0) {
+            baos.write(buffer, 0, read);
+        }
+        return baos.toString();
+    }
+
+    private class InputListener implements InputCallback {
+        public void onKeyEvent(KeyEvent ev) {
+            boolean done = false;
+            do {
+                try {
+                    mKeys.put(new KeyEvent(ev));
+                    done = true;
+                } catch (InterruptedException ignore) { }
+            } while (!done);
+        }
+
+        public void onMotionEvent(MotionEvent ev) {
+            boolean done = false;
+            do {
+                try {
+                    mMotions.put(MotionEvent.obtain(ev));
+                    done = true;
+                } catch (InterruptedException ignore) { }
+            } while (!done);
+        }
+    }
+}
diff --git a/tests/tests/media/Android.mk b/tests/tests/media/Android.mk
index 13daca6..2019da3 100644
--- a/tests/tests/media/Android.mk
+++ b/tests/tests/media/Android.mk
@@ -38,8 +38,7 @@
 # include both the 32 and 64 bit versions
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    ctsmediautil ctsdeviceutil ctstestserver ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsmediautil ctsdeviceutil compatibility-device-util ctstestserver ctstestrunner
 
 LOCAL_JNI_SHARED_LIBRARIES := libctsmediacodec_jni libaudio_jni
 
diff --git a/tests/tests/media/src/android/media/cts/AudioRecordTest.java b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
index b1ee3f5..5b7b031 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecordTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
@@ -16,9 +16,6 @@
 
 package android.media.cts;
 
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-
 import android.content.pm.PackageManager;
 import android.cts.util.CtsAndroidTestCase;
 import android.media.AudioFormat;
@@ -31,11 +28,13 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
-import android.util.Log;
 
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
 
 public class AudioRecordTest extends CtsAndroidTestCase {
     private final static String TAG = "AudioRecordTest";
@@ -944,38 +943,39 @@
         }
 
         // report this
-        ReportLog log = getReportLog();
-        log.printValue(reportName + ": startRecording lag", firstSampleTime - startTime,
+        DeviceReportLog log = new DeviceReportLog();
+        log.addValue(reportName + ": startRecording lag", firstSampleTime - startTime,
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": stop execution time", stopTime - stopRequestTime,
+        log.addValue(reportName + ": stop execution time", stopTime - stopRequestTime,
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Total record time expected", TEST_TIME_MS,
+        log.addValue(reportName + ": Total record time expected", TEST_TIME_MS,
                 ResultType.NEUTRAL, ResultUnit.MS);
-        log.printValue(reportName + ": Total record time actual", endTime - firstSampleTime,
+        log.addValue(reportName + ": Total record time actual", endTime - firstSampleTime,
                 ResultType.NEUTRAL, ResultUnit.MS);
-        log.printValue(reportName + ": Total markers expected", markerPeriods,
+        log.addValue(reportName + ": Total markers expected", markerPeriods,
                 ResultType.NEUTRAL, ResultUnit.COUNT);
-        log.printValue(reportName + ": Total markers actual", markerList.size(),
+        log.addValue(reportName + ": Total markers actual", markerList.size(),
                 ResultType.NEUTRAL, ResultUnit.COUNT);
-        log.printValue(reportName + ": Total periods expected", updatePeriods,
+        log.addValue(reportName + ": Total periods expected", updatePeriods,
                 ResultType.NEUTRAL, ResultUnit.COUNT);
-        log.printValue(reportName + ": Total periods actual", periodicList.size(),
+        log.addValue(reportName + ": Total periods actual", periodicList.size(),
                 ResultType.NEUTRAL, ResultUnit.COUNT);
-        log.printValue(reportName + ": Average Marker diff", markerStat.getAvg(),
+        log.addValue(reportName + ": Average Marker diff", markerStat.getAvg(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Maximum Marker abs diff", markerStat.getMaxAbs(),
+        log.addValue(reportName + ": Maximum Marker abs diff", markerStat.getMaxAbs(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Average Marker abs diff", markerStat.getAvgAbs(),
+        log.addValue(reportName + ": Average Marker abs diff", markerStat.getAvgAbs(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Average Periodic diff", periodicStat.getAvg(),
+        log.addValue(reportName + ": Average Periodic diff", periodicStat.getAvg(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Maximum Periodic abs diff", periodicStat.getMaxAbs(),
+        log.addValue(reportName + ": Maximum Periodic abs diff", periodicStat.getMaxAbs(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Average Periodic abs diff", periodicStat.getAvgAbs(),
+        log.addValue(reportName + ": Average Periodic abs diff", periodicStat.getAvgAbs(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printSummary(reportName + ": Unified abs diff",
+        log.setSummary(reportName + ": Unified abs diff",
                 (periodicStat.getAvgAbs() + markerStat.getAvgAbs()) / 2,
                 ResultType.LOWER_BETTER, ResultUnit.MS);
+        log.submit(getInstrumentation());
     }
 
     private class MockOnRecordPositionUpdateListener
diff --git a/tests/tests/media/src/android/media/cts/AudioTrackTest.java b/tests/tests/media/src/android/media/cts/AudioTrackTest.java
index 4c03183..49ebd2b 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrackTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrackTest.java
@@ -26,14 +26,13 @@
 import android.media.PlaybackParams;
 import android.util.Log;
 
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
 
-import java.nio.ByteOrder;
 import java.nio.ByteBuffer;
-import java.nio.ShortBuffer;
 import java.nio.FloatBuffer;
+import java.nio.ShortBuffer;
 
 public class AudioTrackTest extends CtsAndroidTestCase {
     private String TAG = "AudioTrackTest";
@@ -2013,15 +2012,16 @@
         track.release();
         // Log the average jitter
         if (cumulativeJitterCount > 0) {
-            ReportLog log = getReportLog();
+            DeviceReportLog log = new DeviceReportLog();
             final float averageJitterInFrames = cumulativeJitter / cumulativeJitterCount;
             final float averageJitterInMs = averageJitterInFrames * 1000 / TEST_SR;
             final float maxJitterInMs = maxJitter * 1000 / TEST_SR;
             // ReportLog needs at least one Value and Summary.
-            log.printValue("Maximum Jitter", maxJitterInMs,
+            log.addValue("Maximum Jitter", maxJitterInMs,
                     ResultType.LOWER_BETTER, ResultUnit.MS);
-            log.printSummary("Average Jitter", averageJitterInMs,
+            log.setSummary("Average Jitter", averageJitterInMs,
                     ResultType.LOWER_BETTER, ResultUnit.MS);
+            log.submit(getInstrumentation());
         }
     }
 
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 e059e36..37affd0 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrack_ListenerTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrack_ListenerTest.java
@@ -16,21 +16,20 @@
 
 package android.media.cts;
 
-import java.util.ArrayList;
-
 import android.cts.util.CtsAndroidTestCase;
 import android.media.AudioFormat;
 import android.media.AudioManager;
 import android.media.AudioTrack;
 import android.media.AudioTrack.OnPlaybackPositionUpdateListener;
-import android.media.cts.AudioHelper;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
-import android.util.Log;
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
+
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
+
+import java.util.ArrayList;
 
 public class AudioTrack_ListenerTest extends CtsAndroidTestCase {
     private final static String TAG = "AudioTrack_ListenerTest";
@@ -206,22 +205,23 @@
         }
 
         // report this
-        ReportLog log = getReportLog();
-        log.printValue(reportName + ": Average Marker diff", markerStat.getAvg(),
+        DeviceReportLog log = new DeviceReportLog();
+        log.addValue(reportName + ": Average Marker diff", markerStat.getAvg(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Maximum Marker abs diff", markerStat.getMaxAbs(),
+        log.addValue(reportName + ": Maximum Marker abs diff", markerStat.getMaxAbs(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Average Marker abs diff", markerStat.getAvgAbs(),
+        log.addValue(reportName + ": Average Marker abs diff", markerStat.getAvgAbs(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Average Periodic diff", periodicStat.getAvg(),
+        log.addValue(reportName + ": Average Periodic diff", periodicStat.getAvg(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Maximum Periodic abs diff", periodicStat.getMaxAbs(),
+        log.addValue(reportName + ": Maximum Periodic abs diff", periodicStat.getMaxAbs(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printValue(reportName + ": Average Periodic abs diff", periodicStat.getAvgAbs(),
+        log.addValue(reportName + ": Average Periodic abs diff", periodicStat.getAvgAbs(),
                 ResultType.LOWER_BETTER, ResultUnit.MS);
-        log.printSummary(reportName + ": Unified abs diff",
+        log.setSummary(reportName + ": Unified abs diff",
                 (periodicStat.getAvgAbs() + markerStat.getAvgAbs()) / 2,
                 ResultType.LOWER_BETTER, ResultUnit.MS);
+        log.submit(getInstrumentation());
     }
 
     private class MockOnPlaybackPositionUpdateListener
diff --git a/tests/tests/media/src/android/media/cts/CodecState.java b/tests/tests/media/src/android/media/cts/CodecState.java
index 8f62227..8494a74 100644
--- a/tests/tests/media/src/android/media/cts/CodecState.java
+++ b/tests/tests/media/src/android/media/cts/CodecState.java
@@ -328,12 +328,10 @@
         if (mAudioTrack != null) {
             ByteBuffer buffer = mCodecOutputBuffers[index];
             buffer.clear();
-            buffer.position(0 /* offset */);
+            ByteBuffer audioBuffer = ByteBuffer.allocate(buffer.remaining());
+            audioBuffer.put(buffer);
 
-            byte[] audioCopy = new byte[info.size];
-            buffer.get(audioCopy, 0, info.size);
-
-            mAudioTrack.write(audioCopy, info.size);
+            mAudioTrack.write(audioBuffer, info.size, info.presentationTimeUs*1000);
 
             mCodec.releaseOutputBuffer(index, false /* render */);
 
diff --git a/tests/tests/media/src/android/media/cts/NonBlockingAudioTrack.java b/tests/tests/media/src/android/media/cts/NonBlockingAudioTrack.java
index 20c1dff..3847252 100644
--- a/tests/tests/media/src/android/media/cts/NonBlockingAudioTrack.java
+++ b/tests/tests/media/src/android/media/cts/NonBlockingAudioTrack.java
@@ -21,6 +21,7 @@
 import android.media.AudioAttributes;
 import android.util.Log;
 
+import java.nio.ByteBuffer;
 import java.util.LinkedList;
 
 /**
@@ -32,20 +33,16 @@
 public class NonBlockingAudioTrack {
     private static final String TAG = NonBlockingAudioTrack.class.getSimpleName();
 
-    class QueueElem {
-        byte[] data;
-        int offset;
+    class QueueElement {
+        ByteBuffer data;
         int size;
+        long pts;
     }
 
     private AudioTrack mAudioTrack;
-    private boolean mWriteMorePending = false;
     private int mSampleRate;
-    private int mFrameSize;
-    private int mBufferSizeInFrames;
-    private int mNumFramesSubmitted = 0;
     private int mNumBytesQueued = 0;
-    private LinkedList<QueueElem> mQueue = new LinkedList<QueueElem>();
+    private LinkedList<QueueElement> mQueue = new LinkedList<QueueElement>();
 
     public NonBlockingAudioTrack(int sampleRate, int channelCount, boolean hwAvSync,
                     int audioSessionId) {
@@ -97,8 +94,6 @@
         }
 
         mSampleRate = sampleRate;
-        mFrameSize = 2 * channelCount;
-        mBufferSizeInFrames = bufferSize / mFrameSize;
     }
 
     public long getAudioTimeUs() {
@@ -116,18 +111,13 @@
     }
 
     public void stop() {
-        cancelWriteMore();
-
         mAudioTrack.stop();
 
-        mNumFramesSubmitted = 0;
         mQueue.clear();
         mNumBytesQueued = 0;
     }
 
     public void pause() {
-        cancelWriteMore();
-
         mAudioTrack.pause();
     }
 
@@ -136,95 +126,48 @@
             return;
         }
         mAudioTrack.flush();
-        mNumFramesSubmitted = 0;
         mQueue.clear();
         mNumBytesQueued = 0;
     }
 
     public void release() {
-        cancelWriteMore();
-
+        mQueue.clear();
+        mNumBytesQueued = 0;
         mAudioTrack.release();
         mAudioTrack = null;
     }
 
     public void process() {
-        mWriteMorePending = false;
-        writeMore();
+        while (!mQueue.isEmpty()) {
+            QueueElement element = mQueue.peekFirst();
+            int written = mAudioTrack.write(element.data, element.size,
+                                            AudioTrack.WRITE_NON_BLOCKING, element.pts);
+            if (written < 0) {
+                throw new RuntimeException("Audiotrack.write() failed.");
+            }
+
+            mNumBytesQueued -= written;
+            element.size -= written;
+            if (element.size != 0) {
+                break;
+            }
+            mQueue.removeFirst();
+        }
     }
 
     public int getPlayState() {
         return mAudioTrack.getPlayState();
     }
 
-    private void writeMore() {
-        if (mQueue.isEmpty()) {
-            return;
-        }
-
-        int numFramesPlayed = mAudioTrack.getPlaybackHeadPosition();
-        int numFramesPending = mNumFramesSubmitted - numFramesPlayed;
-        int numFramesAvailableToWrite = mBufferSizeInFrames - numFramesPending;
-        int numBytesAvailableToWrite = numFramesAvailableToWrite * mFrameSize;
-
-        while (numBytesAvailableToWrite > 0) {
-            QueueElem elem = mQueue.peekFirst();
-
-            int numBytes = elem.size;
-            if (numBytes > numBytesAvailableToWrite) {
-                numBytes = numBytesAvailableToWrite;
-            }
-
-            int written = mAudioTrack.write(elem.data, elem.offset, numBytes);
-            assert(written == numBytes);
-
-            mNumFramesSubmitted += written / mFrameSize;
-
-            elem.size -= numBytes;
-            numBytesAvailableToWrite -= numBytes;
-            mNumBytesQueued -= numBytes;
-
-            if (elem.size == 0) {
-                mQueue.removeFirst();
-
-                if (mQueue.isEmpty()) {
-                    break;
-                }
-            } else {
-                elem.offset += numBytes;
-            }
-        }
-
-        if (!mQueue.isEmpty()) {
-            scheduleWriteMore();
-        }
-    }
-
-    private void scheduleWriteMore() {
-        if (mWriteMorePending) {
-            return;
-        }
-
-        int numFramesPlayed = mAudioTrack.getPlaybackHeadPosition();
-        int numFramesPending = mNumFramesSubmitted - numFramesPlayed;
-        int pendingDurationMs = 1000 * numFramesPending / mSampleRate;
-
-        mWriteMorePending = true;
-    }
-
-    private void cancelWriteMore() {
-        mWriteMorePending = false;
-    }
-
-    public void write(byte[] data, int size) {
-        QueueElem elem = new QueueElem();
-        elem.data = data;
-        elem.offset = 0;
-        elem.size = size;
+    public void write(ByteBuffer data, int size, long pts) {
+        QueueElement element = new QueueElement();
+        element.data = data;
+        element.size = size;
+        element.pts  = pts;
 
         // accumulate size written to queue
         mNumBytesQueued += size;
-        mQueue.add(elem);
+        mQueue.add(element);
     }
 }
 
diff --git a/tests/tests/security/Android.mk b/tests/tests/security/Android.mk
index ec36d6d..043553b 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -21,7 +21,7 @@
 # Include both the 32 and 64 bit versions
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestserver ctstestrunner ctsdeviceutil guava
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestserver ctstestrunner ctsdeviceutil compatibility-device-util guava
 
 LOCAL_JAVA_LIBRARIES := android.test.runner org.apache.http.legacy
 
diff --git a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
index 350309b..ec7e4bd 100644
--- a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
@@ -35,6 +35,7 @@
 #include <inttypes.h>
 #include <linux/sysctl.h>
 #include <arpa/inet.h>
+#include <linux/ipc.h>
 
 /*
  * Returns true iff this device is vulnerable to CVE-2013-2094.
@@ -251,6 +252,25 @@
     return true;
 }
 
+#define SHMEMSIZE 0x1 /* request one page */
+static jboolean android_security_cts_NativeCodeTest_doSysVipcTest(JNIEnv*, jobject)
+{
+    key_t key = 0x1a25;
+
+#if defined(__i386__) || (_MIPS_SIM == _MIPS_SIM_ABI32)
+    /* system call does not exist for x86 or mips 32 */
+    return true;
+#else
+    /*
+     * Not supported in bionic. Must directly invoke syscall
+     * Only acceptable errno is ENOSYS: shmget syscall
+     * function not implemented
+     */
+    return ((syscall(SYS_shmget, key, SHMEMSIZE, IPC_CREAT | 0666) == -1)
+                && (errno == ENOSYS));
+#endif
+}
+
 static JNINativeMethod gMethods[] = {
     {  "doPerfEventTest", "()Z",
             (void *) android_security_cts_NativeCodeTest_doPerfEventTest },
@@ -266,6 +286,8 @@
             (void *) android_security_cts_NativeCodeTest_doNvmapIocFromIdTest },
     {  "doPingPongRootTest", "()Z",
             (void *) android_security_cts_NativeCodeTest_doPingPongRootTest },
+    {  "doSysVipcTest", "()Z",
+            (void *) android_security_cts_NativeCodeTest_doSysVipcTest },
 };
 
 int register_android_security_cts_NativeCodeTest(JNIEnv* env)
diff --git a/tests/tests/security/src/android/security/cts/HwRngTest.java b/tests/tests/security/src/android/security/cts/HwRngTest.java
index f9ce6be..7654b6f 100644
--- a/tests/tests/security/src/android/security/cts/HwRngTest.java
+++ b/tests/tests/security/src/android/security/cts/HwRngTest.java
@@ -17,11 +17,10 @@
 package android.security.cts;
 
 import android.cts.util.CtsAndroidTestCase;
-import com.android.cts.util.ReportLog;
-import com.android.cts.util.ResultType;
-import com.android.cts.util.ResultUnit;
 
-import junit.framework.TestCase;
+import com.android.compatibility.common.util.DeviceReportLog;
+import com.android.compatibility.common.util.ResultType;
+import com.android.compatibility.common.util.ResultUnit;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
@@ -51,18 +50,19 @@
      * Reports whether the {@code /dev/hw_random} device is found. This test always passes.
      */
     public void testDeviceFilePresent() {
-        ReportLog report = getReportLog();
+        DeviceReportLog report = new DeviceReportLog();
         // Need to report at least one value, otherwise summary won't be logged.
-        report.printValue(
+        report.addValue(
                 DEV_HW_RANDOM + " found",
                 DEV_HW_RANDOM.exists() ? 1 : 0,
                 ResultType.WARNING,
                 ResultUnit.NONE);
-        report.printSummary(
+        report.setSummary(
                 "Hardware RNG exposed",
                 DEV_HW_RANDOM.exists() ? 1 : 0,
                 ResultType.WARNING,
                 ResultUnit.NONE);
+        report.submit(getInstrumentation());
     }
 
     /**
diff --git a/tests/tests/security/src/android/security/cts/NativeCodeTest.java b/tests/tests/security/src/android/security/cts/NativeCodeTest.java
index ab41b4f..5ec6ddc 100644
--- a/tests/tests/security/src/android/security/cts/NativeCodeTest.java
+++ b/tests/tests/security/src/android/security/cts/NativeCodeTest.java
@@ -64,6 +64,15 @@
                    + "https://github.com/torvalds/linux/commit/a134f083e79f",
                    doPingPongRootTest());
     }
+
+    public void testSysVipc() throws Exception {
+        assertTrue("Android does not support Sys V IPC, it must "
+                   + "be removed from the kernel. In the kernel config: "
+                   + "Change \"CONFIG_SYSVIPC=y\" to \"# CONFIG_SYSVIPC is not set\" "
+                   + "and rebuild.",
+                   doSysVipcTest());
+    }
+
     /**
      * Returns true iff this device is vulnerable to CVE-2013-2094.
      * A patch for CVE-2013-2094 can be found at
@@ -140,4 +149,25 @@
      */
     private static native boolean doPingPongRootTest();
 
+    /**
+     * Test that SysV IPC has been removed from the kernel.
+     *
+     * Returns true if SysV IPC has been removed.
+     *
+     * System V IPCs are not compliant with Android's application lifecycle because allocated
+     * resources are not freed by the low memory killer. This lead to global kernel resource leakage.
+     *
+     * For example, there is no way to automatically release a SysV semaphore
+     * allocated in the kernel when:
+     * - a buggy or malicious process exits
+     * - a non-buggy and non-malicious process crashes or is explicitly killed.
+     *
+     * Killing processes automatically to make room for new ones is an
+     * important part of Android's application lifecycle implementation. This means
+     * that, even assuming only non-buggy and non-malicious code, it is very likely
+     * that over time, the kernel global tables used to implement SysV IPCs will fill
+     * up.
+     */
+    private static native boolean doSysVipcTest();
+
 }
diff --git a/tools/cts-device-info/Android.mk b/tools/cts-device-info/Android.mk
index 5f2b223..9bedcf2 100644
--- a/tools/cts-device-info/Android.mk
+++ b/tools/cts-device-info/Android.mk
@@ -25,4 +25,3 @@
 LOCAL_PACKAGE_NAME := CtsDeviceInfo
 
 include $(BUILD_CTS_DEVICE_INFO_PACKAGE)
-
diff --git a/tools/cts-device-info/src/com/android/cts/deviceinfo/SampleDeviceInfo.java b/tools/cts-device-info/src/com/android/cts/deviceinfo/SampleDeviceInfo.java
index 886193c..2bd5959 100644
--- a/tools/cts-device-info/src/com/android/cts/deviceinfo/SampleDeviceInfo.java
+++ b/tools/cts-device-info/src/com/android/cts/deviceinfo/SampleDeviceInfo.java
@@ -60,4 +60,3 @@
         endGroup(); // foo
     }
 }
-
diff --git a/tests/tests/acceleration/Android.mk b/tools/cts-tradefed/Android.mk
similarity index 60%
copy from tests/tests/acceleration/Android.mk
copy to tools/cts-tradefed/Android.mk
index d417371..1cf7599 100644
--- a/tests/tests/acceleration/Android.mk
+++ b/tools/cts-tradefed/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 The Android Open Source Project
+# 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.
@@ -12,22 +12,23 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
+LOCAL_JAVA_RESOURCE_DIRS := res
 
-LOCAL_INSTRUMENTATION_FOR := CtsAccelerationTestStubs
+LOCAL_JAR_MANIFEST := MANIFEST.mf
 
-LOCAL_SDK_VERSION := current
+LOCAL_MODULE := cts-tradefed_v2
+LOCAL_MODULE_TAGS := optional
+LOCAL_JAVA_LIBRARIES := tradefed-prebuilt hosttestlib compatibility-tradefed
 
-include $(BUILD_CTS_PACKAGE)
+LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
+include $(BUILD_HOST_JAVA_LIBRARY)
+
+# Build all sub-directories
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tools/cts-tradefed/MANIFEST.mf b/tools/cts-tradefed/MANIFEST.mf
new file mode 100644
index 0000000..5bac62a
--- /dev/null
+++ b/tools/cts-tradefed/MANIFEST.mf
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Main-Class: com.android.compatibility.tradefed.command.CtsConsole
+Specification-Title: Compatibility Test Suite
+Specification-Vendor: CTS_V2
+Specification-Version: 5.0_r1.91
+Implementation-Version: %BUILD_NUMBER%
diff --git a/tools/cts-tradefed/README b/tools/cts-tradefed/README
new file mode 100644
index 0000000..880b8e6
--- /dev/null
+++ b/tools/cts-tradefed/README
@@ -0,0 +1,83 @@
+CTS Trade Federation
+---------------------
+
+CTS Trade Federation, cts-tradefed for short, is the next
+generation test harness for CTS.
+
+cts-tradefed is built on top of the Android Trade Federation test harness.
+
+It works in a similar manner to the prior CTS harness, but supports some
+advanced features such as:
+
+  - modular, flexible extensible design. cts-tradefed can be extended to
+support running CTS in a continuous test environment.
+  - supports sharding a CTS test run across multiple devices in parallel
+  - automatically continue a CTS test run on another device if connection
+is lost
+
+Configuring cts-tradefed
+------------------------
+
+1. Ensure 'adb' is in your current PATH. adb can be found in the
+Android SDK available from http://developer.android.com
+
+Example:
+  PATH=$PATH:/home/myuser/android-sdk-linux_x86/platform-tools
+
+2. Follow the 'Setting up your device' steps documented in the
+CTS User Manual. The CTS User Manual can be downloaded at
+http://source.android.com/compatibility/downloads.html
+
+3. Connect the device to the host machine.
+
+4. Ensure device is visible via 'adb devices'
+
+Using cts-tradefed
+-------------------
+
+To run a test plan on a single device:
+
+1. Make sure you have at least one device connected
+2. Launch the cts-tradefed console by running the 'cts-tradefed'. If you've
+downloaded and extracted the CTS zip, the script can be found at
+  android-cts/tools/cts-tradefed
+Or else if you are working from the Android source tree and have run make cts,
+the script can be found at
+  out/host/linux-x86/cts/android-cts/tools/cts-tradefed
+3. Type:
+'run cts --plan CTS' to run the default CTS plan
+
+Some other useful commands are
+
+To run a test module:
+'run cts --module <module_name>'
+
+To run a specific test:
+'run cts --test <test_name>'
+
+To shard a plan test run on multiple devices
+'run cts --plan CTS --shards <number of shards>
+note: all connected devices must be running the same build
+
+For more options:
+'run cts --help'
+
+CTS Tradefed Development
+------------------------
+See http://source.android.com for instructions on obtaining the Android
+platform source code and setting up a build environment.
+
+The source for the CTS extensions for tradefed can be found at
+<android source root>/cts/tools/tradefed-host
+
+The source for the tradefed framework can be found on the 'tradefed' branch.
+
+Perform these steps to build and run cts-tradefed from the development
+environment:
+cd <path to android source root>
+make cts
+cts-tradefed
+
+More documentation and details on using and extending trade federation will
+be forthcoming in the near future.
+
diff --git a/common/host-side/scripts/compatibility-tradefed_v2 b/tools/cts-tradefed/etc/Android.mk
old mode 100755
new mode 100644
similarity index 64%
rename from common/host-side/scripts/compatibility-tradefed_v2
rename to tools/cts-tradefed/etc/Android.mk
index f64e273..877f67c
--- a/common/host-side/scripts/compatibility-tradefed_v2
+++ b/tools/cts-tradefed/etc/Android.mk
@@ -1,16 +1,22 @@
-#!/bin/bash
-#
-# Copyright (C) 2014 The Android Open Source Project
+# 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
+#      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.
-echo "TODO(stuartscott): Add the wrapper to launch the executable. This will be done in the next CL"
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_PREBUILT_EXECUTABLES := cts-tradefed_v2
+include $(BUILD_HOST_PREBUILT)
+
diff --git a/tools/cts-tradefed/etc/cts-tradefed_v2 b/tools/cts-tradefed/etc/cts-tradefed_v2
new file mode 100755
index 0000000..cccd4b9
--- /dev/null
+++ b/tools/cts-tradefed/etc/cts-tradefed_v2
@@ -0,0 +1,109 @@
+#!/bin/bash
+
+# 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.
+
+# launcher script for cts-tradefed harness
+# can be used from an Android build environment, or a standalone cts zip
+
+checkFile() {
+    if [ ! -f "$1" ]; then
+        echo "Unable to locate $1"
+        exit
+    fi;
+}
+
+checkPath() {
+    if ! type -P $1 &> /dev/null; then
+        echo "Unable to find $1 in path."
+        exit
+    fi;
+}
+
+checkPath adb
+checkPath java
+
+# check java version
+JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '[ "]1\.[67][\. "$$]')
+if [ "${JAVA_VERSION}" == "" ]; then
+    echo "Wrong java version. 1.6 or 1.7 is required."
+    exit
+fi
+
+# check debug flag and set up remote debugging
+if [ -n "${TF_DEBUG}" ]; then
+  if [ -z "${TF_DEBUG_PORT}" ]; then
+    TF_DEBUG_PORT=10088
+  fi
+  RDBG_FLAG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${TF_DEBUG_PORT}
+fi
+
+# get OS
+HOST=`uname`
+if [ "$HOST" == "Linux" ]; then
+    OS="linux-x86"
+elif [ "$HOST" == "Darwin" ]; then
+    OS="darwin-x86"
+else
+    echo "Unrecognized OS"
+    exit
+fi
+
+# check if in Android build env
+if [ ! -z "${ANDROID_BUILD_TOP}" ]; then
+    if [ ! -z "${ANDROID_HOST_OUT}" ]; then
+      CTS_V2_ROOT=${ANDROID_HOST_OUT}/cts_v2
+    else
+      CTS_V2_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/cts_v2
+    fi
+    if [ ! -d ${CTS_V2_ROOT} ]; then
+        echo "Could not find $CTS_V2_ROOT in Android build environment. Try 'make cts_v2'"
+        exit
+    fi;
+fi;
+
+if [ -z ${CTS_V2_ROOT} ]; then
+    # assume we're in an extracted cts install
+    CTS_V2_ROOT="$(dirname $0)/../.."
+fi;
+
+JAR_DIR=${CTS_V2_ROOT}/android-cts_v2/tools
+JARS="tradefed-prebuilt
+  hosttestlib
+  compatibility-host-util
+  compatibility-tradefed
+  cts-tradefed_v2"
+
+for JAR in $JARS; do
+    checkFile ${JAR_DIR}/${JAR}.jar
+    JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}.jar
+done
+
+# load any shared libraries for host-side executables
+LIB_DIR=${CTS_V2_ROOT}/android-cts_v2/lib
+if [ "$HOST" == "Linux" ]; then
+    LD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${LD_LIBRARY_PATH}
+    export LD_LIBRARY_PATH
+elif [ "$HOST" == "Darwin" ]; then
+    DYLD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${DYLD_LIBRARY_PATH}
+    export DYLD_LIBRARY_PATH
+fi
+
+# include any host-side test jars
+HOST_TEST_JAR_PATH="$(ls -1 ${CTS_V2_ROOT}/android-cts_v2/testcases/*.jar)"
+
+CLASS_PATH=${JAR_PATH}:${HOST_TEST_JAR_PATH}
+
+java $RDBG_FLAG -cp ${CLASS_PATH} -DCTS_V2_ROOT=${CTS_V2_ROOT} com.android.compatibility.tradefed.command.CtsConsole "$@"
+
diff --git a/tools/cts-tradefed/res/config/cts.xml b/tools/cts-tradefed/res/config/cts.xml
new file mode 100644
index 0000000..2660d73
--- /dev/null
+++ b/tools/cts-tradefed/res/config/cts.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<configuration description="Runs CTS from a pre-existing CTS installation">
+
+    <include name="everything" />
+
+    <option name="enable-root" value="false" />
+    <option name="compatibility-build-provider:plan" value="cts" />
+
+    <option name="compatibility-test:include-filter" value="arm64-v8a CtsSampleDeviceTestCases" />
+    <option name="compatibility-test:exclude-filter" value="CtsSampleHostTestCases" />
+
+</configuration>
diff --git a/tools/cts-tradefed/src/com/android/compatibility/tradefed/command/CtsConsole.java b/tools/cts-tradefed/src/com/android/compatibility/tradefed/command/CtsConsole.java
new file mode 100644
index 0000000..fcd9f94
--- /dev/null
+++ b/tools/cts-tradefed/src/com/android/compatibility/tradefed/command/CtsConsole.java
@@ -0,0 +1,34 @@
+/*
+ * 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 com.android.compatibility.tradefed.command;
+
+import com.android.compatibility.common.tradefed.command.CompatibilityConsole;
+import com.android.tradefed.command.Console;
+import com.android.tradefed.config.ConfigurationException;
+
+/**
+ * An extension of {@link CompatibilityConsole} for running CTS tests.
+ *
+ * This file mainly exists to provide package name space from which the suite-specific values in the
+ * MANIFEST.mf can be read.
+ */
+public class CtsConsole extends CompatibilityConsole {
+
+    public static void main(String[] args) throws InterruptedException, ConfigurationException {
+        Console console = new CtsConsole();
+        Console.startConsole(console, args);
+    }
+}
diff --git a/tests/tests/acceleration/Android.mk b/tools/cts-tradefed/tests/Android.mk
similarity index 66%
rename from tests/tests/acceleration/Android.mk
rename to tools/cts-tradefed/tests/Android.mk
index d417371..454c9d6 100644
--- a/tests/tests/acceleration/Android.mk
+++ b/tools/cts-tradefed/tests/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2011 The Android Open Source Project
+# 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.
@@ -12,22 +12,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH:= $(call my-dir)
+LOCAL_PATH := $(call my-dir)
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-
+# Only compile source java files in this lib.
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := CtsAccelerationTestCases
+LOCAL_MODULE := cts-tradefed-tests_v2
+LOCAL_MODULE_TAGS := optional
+LOCAL_JAVA_LIBRARIES := tradefed-prebuilt cts-tradefed_v2 compatibility-tradefed
 
-LOCAL_INSTRUMENTATION_FOR := CtsAccelerationTestStubs
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java b/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java
new file mode 100644
index 0000000..13e1c77
--- /dev/null
+++ b/tools/cts-tradefed/tests/src/com/android/compatibility/tradefed/CtsTradefedTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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 com.android.compatibility.tradefed;
+
+import com.android.compatibility.common.tradefed.build.CompatibilityBuildInfo;
+import com.android.compatibility.tradefed.command.CtsConsole;
+import com.android.tradefed.util.FileUtil;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+
+/**
+ * Tests for cts-tradefed.
+ */
+public class CtsTradefedTest extends TestCase {
+
+    private static final String PROPERTY_NAME = "CTS_V2_ROOT";
+    private static final String SUITE_FULL_NAME = "Compatibility Test Suite";
+    private static final String SUITE_NAME = "CTS_V2";
+
+    public void testManifest() throws Exception {
+        // Test the values in the manifest can be loaded
+        File root = FileUtil.createTempDir("root");
+        System.setProperty(PROPERTY_NAME, root.getAbsolutePath());
+        File base = new File(root, "android-cts_v2");
+        base.mkdirs();
+        File tests = new File(base, "testcases");
+        tests.mkdirs();
+        CtsConsole c = new CtsConsole();
+        CompatibilityBuildInfo build = c.getCompatibilityBuild();
+        assertEquals("Incorrect suite full name", SUITE_FULL_NAME, build.getSuiteFullName());
+        assertEquals("Incorrect suite name", SUITE_NAME, build.getSuiteName());
+        FileUtil.recursiveDelete(root);
+        System.clearProperty(PROPERTY_NAME);
+    }
+}
diff --git a/tools/cts-xml-generator/src/Android.mk b/tools/cts-xml-generator/src/Android.mk
index a6d85b6..94c561b 100644
--- a/tools/cts-xml-generator/src/Android.mk
+++ b/tools/cts-xml-generator/src/Android.mk
@@ -18,15 +18,13 @@
 # ============================================================
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := \
-    $(call all-subdir-java-files) \
-    ../../../libs/commonutil/src/com/android/cts/util/AbiUtils.java
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
 
 LOCAL_JAR_MANIFEST := MANIFEST.mf
 
 LOCAL_MODULE := cts-xml-generator
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_STATIC_JAVA_LIBRARIES := vogarexpectlib
+LOCAL_STATIC_JAVA_LIBRARIES := vogarexpectlib compatibility-host-util
 
 include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/XmlGenerator.java b/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/XmlGenerator.java
index 328b855..96c83a9 100644
--- a/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/XmlGenerator.java
+++ b/tools/cts-xml-generator/src/com/android/cts/xmlgenerator/XmlGenerator.java
@@ -16,12 +16,12 @@
 
 package com.android.cts.xmlgenerator;
 
-import com.android.cts.util.AbiUtils;
-
 import vogar.Expectation;
 import vogar.ExpectationStore;
 import vogar.Result;
 
+import com.android.compatibility.common.util.AbiUtils;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -259,7 +259,7 @@
         String[] unsupportedAbis = description.split(":")[1].split(",");
         for (String a : unsupportedAbis) {
             String abi = a.trim();
-            if (!AbiUtils.isAbiSupportedByCts(abi)) {
+            if (!AbiUtils.isAbiSupportedByCompatibility(abi)) {
                 throw new RuntimeException(
                         String.format("Unrecognised ABI %s in %s", abi, description));
             }
diff --git a/tools/tradefed-host/Android.mk b/tools/tradefed-host/Android.mk
index 1f73e95..c33a927 100644
--- a/tools/tradefed-host/Android.mk
+++ b/tools/tradefed-host/Android.mk
@@ -25,7 +25,7 @@
 LOCAL_MODULE := cts-tradefed
 LOCAL_MODULE_TAGS := optional
 LOCAL_JAVA_LIBRARIES := tradefed-prebuilt hosttestlib
-LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceinfolib
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceinfolib compatibility-host-util
 
 LOCAL_JAR_MANIFEST := MANIFEST.mf
 
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java b/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
index 2d6d8f2..4986e39 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/command/CtsConsole.java
@@ -15,6 +15,7 @@
  */
 package com.android.cts.tradefed.command;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
 import com.android.cts.tradefed.build.CtsBuildProvider;
 import com.android.cts.tradefed.result.ITestResultRepo;
@@ -23,7 +24,6 @@
 import com.android.cts.tradefed.result.TestResultRepo;
 import com.android.cts.tradefed.testtype.ITestPackageRepo;
 import com.android.cts.tradefed.testtype.TestPackageRepo;
-import com.android.cts.util.AbiUtils;
 import com.android.tradefed.command.Console;
 import com.android.tradefed.config.ArgsOptionParser;
 import com.android.tradefed.config.ConfigurationException;
@@ -119,7 +119,7 @@
                 CtsBuildHelper ctsBuild = getCtsBuild();
                 if (ctsBuild != null) {
                     // FIXME may want to only add certain ABIs
-                    addDerivedPlan(ctsBuild, AbiUtils.getAbisSupportedByCts(), flatArgs);
+                    addDerivedPlan(ctsBuild, AbiUtils.getAbisSupportedByCompatibility(), flatArgs);
                 }
             }
         };
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java b/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
index 7883fce..a8583d5 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/device/DeviceInfoCollector.java
@@ -15,8 +15,8 @@
  */
 package com.android.cts.tradefed.device;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.ICtsBuildInfo;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.DeviceNotAvailableException;
@@ -53,7 +53,7 @@
     public static final Set<String> EXTENDED_IDS = new HashSet<String>();
 
     static {
-        for (String abi : AbiUtils.getAbisSupportedByCts()) {
+        for (String abi : AbiUtils.getAbisSupportedByCompatibility()) {
             IDS.add(AbiUtils.createId(abi, APP_PACKAGE_NAME));
             EXTENDED_IDS.add(AbiUtils.createId(abi, EXTENDED_APP_PACKAGE_NAME));
         }
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java
index b7f064f..71eb8f5 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsTestLogReporter.java
@@ -16,8 +16,8 @@
 
 package com.android.cts.tradefed.result;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.device.DeviceInfoCollector;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.Log.LogLevel;
 import com.android.ddmlib.testrunner.TestIdentifier;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
index f4f133a..f491171 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
@@ -25,7 +25,6 @@
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
 import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.result.ILogSaver;
 import com.android.tradefed.result.ILogSaverListener;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java
index 3881c0e..0926635 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/PlanCreator.java
@@ -22,7 +22,6 @@
 import com.android.cts.tradefed.testtype.ITestPlan;
 import com.android.cts.tradefed.testtype.TestPackageRepo;
 import com.android.cts.tradefed.testtype.TestPlan;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.Log.LogLevel;
 import com.android.ddmlib.testrunner.TestIdentifier;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java
index 12a2b29..e25ea5a 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/Test.java
@@ -15,7 +15,8 @@
  */
 package com.android.cts.tradefed.result;
 
-import com.android.ddmlib.Log;
+import com.android.compatibility.common.util.MetricsXmlSerializer;
+import com.android.compatibility.common.util.ReportLog;
 import com.android.cts.tradefed.result.TestLog.TestLogType;
 
 import org.kxml2.io.KXmlSerializer;
@@ -38,27 +39,13 @@
     private static final String RESULT_ATTR = "result";
     private static final String SCENE_TAG = "FailedScene";
     private static final String STACK_TAG = "StackTrace";
-    private static final String SUMMARY_TAG = "Summary";
-    private static final String DETAILS_TAG = "Details";
-    private static final String VALUEARRAY_TAG = "ValueArray";
-    private static final String VALUE_TAG = "Value";
-    private static final String TARGET_ATTR = "target";
-    private static final String SCORETYPE_ATTR = "scoreType";
-    private static final String UNIT_ATTR = "unit";
-    private static final String SOURCE_ATTR = "source";
-    // separators for the message
-    private static final String LOG_SEPARATOR = "\\+\\+\\+";
-    private static final String LOG_ELEM_SEPARATOR = "\\|";
-
     private String mName;
     private CtsTestStatus mResult;
     private String mStartTime;
     private String mEndTime;
     private String mMessage;
     private String mStackTrace;
-    // summary and details passed from cts
-    private String mSummary;
-    private String mDetails;
+    private ReportLog mReport;
 
     /**
      * Log info for this test like a logcat dump or bugreport.
@@ -73,7 +60,7 @@
     }
 
     /**
-     * Create a {@link Test} from a {@link TestResult}.
+     * Create a {@link Test}.
      *
      * @param name
      */
@@ -135,20 +122,12 @@
         mMessage = getFailureMessageFromStackTrace(mStackTrace);
     }
 
-    public String getSummary() {
-        return mSummary;
+    public ReportLog getReportLog() {
+        return mReport;
     }
 
-    public void setSummary(String summary) {
-        mSummary = summary;
-    }
-
-    public String getDetails() {
-        return mDetails;
-    }
-
-    public void setDetails(String details) {
-        mDetails = details;
+    public void setReportLog(ReportLog report) {
+        mReport = report;
     }
 
     public void updateEndTime() {
@@ -185,113 +164,12 @@
             }
             serializer.endTag(CtsXmlResultReporter.ns, SCENE_TAG);
         }
-        if (mSummary != null) {
-            // <Summary message = "screen copies per sec" scoretype="higherBetter" unit="fps">
-            // 23938.82978723404</Summary>
-            PerfResultSummary summary = parseSummary(mSummary);
-            if (summary != null) {
-                serializer.startTag(CtsXmlResultReporter.ns, SUMMARY_TAG);
-                serializer.attribute(CtsXmlResultReporter.ns, MESSAGE_ATTR, summary.mMessage);
-                if (summary.mTarget.length() != 0 && !summary.mTarget.equals(" ")) {
-                    serializer.attribute(CtsXmlResultReporter.ns, TARGET_ATTR, summary.mTarget);
-                }
-                serializer.attribute(CtsXmlResultReporter.ns, SCORETYPE_ATTR, summary.mType);
-                serializer.attribute(CtsXmlResultReporter.ns, UNIT_ATTR, summary.mUnit);
-                serializer.text(summary.mValue);
-                serializer.endTag(CtsXmlResultReporter.ns, SUMMARY_TAG);
-                // add details only if summary is present
-                // <Details>
-                //   <ValueArray source=”com.android.cts.dram.BandwidthTest#doRunMemcpy:98”
-                //                    message=”measure1” unit="ms" scoretype="higherBetter">
-                //     <Value>0.0</Value>
-                //     <Value>0.1</Value>
-                //   </ValueArray>
-                // </Details>
-                if (mDetails != null) {
-                    PerfResultDetail[] ds = parseDetails(mDetails);
-                    serializer.startTag(CtsXmlResultReporter.ns, DETAILS_TAG);
-                        for (PerfResultDetail d : ds) {
-                            if (d == null) {
-                                continue;
-                            }
-                            serializer.startTag(CtsXmlResultReporter.ns, VALUEARRAY_TAG);
-                            serializer.attribute(CtsXmlResultReporter.ns, SOURCE_ATTR, d.mSource);
-                            serializer.attribute(CtsXmlResultReporter.ns, MESSAGE_ATTR,
-                                    d.mMessage);
-                            serializer.attribute(CtsXmlResultReporter.ns, SCORETYPE_ATTR, d.mType);
-                            serializer.attribute(CtsXmlResultReporter.ns, UNIT_ATTR, d.mUnit);
-                            for (String v : d.mValues) {
-                                if (v == null) {
-                                    continue;
-                                }
-                                serializer.startTag(CtsXmlResultReporter.ns, VALUE_TAG);
-                                serializer.text(v);
-                                serializer.endTag(CtsXmlResultReporter.ns, VALUE_TAG);
-                            }
-                            serializer.endTag(CtsXmlResultReporter.ns, VALUEARRAY_TAG);
-                        }
-                    serializer.endTag(CtsXmlResultReporter.ns, DETAILS_TAG);
-                }
-            }
-        }
+        MetricsXmlSerializer metricsXmlSerializer = new MetricsXmlSerializer(serializer);
+        metricsXmlSerializer.serialize(mReport);
         serializer.endTag(CtsXmlResultReporter.ns, TAG);
     }
 
     /**
-     *  class containing performance result.
-     */
-    public static class PerfResultCommon {
-        public String mMessage;
-        public String mType;
-        public String mUnit;
-    }
-
-    private class PerfResultSummary extends PerfResultCommon {
-        public String mTarget;
-        public String mValue;
-    }
-
-    private class PerfResultDetail extends PerfResultCommon {
-        public String mSource;
-        public String[] mValues;
-    }
-
-    private PerfResultSummary parseSummary(String summary) {
-        String[] elems = summary.split(LOG_ELEM_SEPARATOR);
-        PerfResultSummary r = new PerfResultSummary();
-        if (elems.length < 5) {
-            Log.w(TAG, "wrong message " + summary);
-            return null;
-        }
-        r.mMessage = elems[0];
-        r.mTarget = elems[1];
-        r.mType = elems[2];
-        r.mUnit = elems[3];
-        r.mValue = elems[4];
-        return r;
-    }
-
-    private PerfResultDetail[] parseDetails(String details) {
-        String[] arrays = details.split(LOG_SEPARATOR);
-        PerfResultDetail[] rs = new PerfResultDetail[arrays.length];
-        for (int i = 0; i < arrays.length; i++) {
-            String[] elems = arrays[i].split(LOG_ELEM_SEPARATOR);
-            if (elems.length < 5) {
-                Log.w(TAG, "wrong message " + arrays[i]);
-                continue;
-            }
-            PerfResultDetail r = new PerfResultDetail();
-            r.mSource = elems[0];
-            r.mMessage = elems[1];
-            r.mType = elems[2];
-            r.mUnit = elems[3];
-            r.mValues = elems[4].split(" ");
-            rs[i] = r;
-        }
-        return rs;
-    }
-
-    /**
      * Strip out any invalid XML characters that might cause the report to be unviewable.
      * http://www.w3.org/TR/REC-xml/#dt-character
      */
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java
index f5a3d02..2229671 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestPackageResult.java
@@ -15,9 +15,10 @@
  */
 package com.android.cts.tradefed.result;
 
+import com.android.compatibility.common.util.AbiUtils;
+import com.android.compatibility.common.util.MetricsStore;
+import com.android.compatibility.common.util.ReportLog;
 import com.android.cts.tradefed.testtype.CtsTest;
-import com.android.cts.tradefed.util.CtsHostStore;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.log.LogUtil.CLog;
 
@@ -33,8 +34,6 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 /**
  * Data structure for a CTS test package result.
@@ -45,7 +44,7 @@
 
     static final String TAG = "TestPackage";
 
-    public static final String CTS_RESULT_KEY = "CTS_TEST_RESULT";
+    public static final String RESULT_KEY = "COMPATIBILITY_TEST_RESULT";
 
     private static final String DIGEST_ATTR = "digest";
     private static final String APP_PACKAGE_NAME_ATTR = "appPackageName";
@@ -54,8 +53,6 @@
     private static final String ns = CtsXmlResultReporter.ns;
     private static final String SIGNATURE_TEST_PKG = "android.tests.sigtest";
 
-    private static final Pattern mCtsLogPattern = Pattern.compile("(.*)\\+\\+\\+\\+(.*)");
-
     private String mDeviceSerial;
     private String mAppPackageName;
     private String mName;
@@ -249,23 +246,22 @@
         // Collect performance results
         for (TestIdentifier test : mTestMetrics.keySet()) {
             // device test can have performance results in test metrics
-            String perfResult = mTestMetrics.get(test).get(CTS_RESULT_KEY);
-            // host test should be checked in CtsHostStore.
-            if (perfResult == null) {
-                perfResult = CtsHostStore.removeCtsResult(mDeviceSerial, mAbi, test.toString());
-            }
+            String perfResult = mTestMetrics.get(test).get(RESULT_KEY);
+            ReportLog report = null;
             if (perfResult != null) {
-                // CTS result is passed in Summary++++Details format.
-                // Extract Summary and Details, and pass them.
-                Matcher m = mCtsLogPattern.matcher(perfResult);
-                if (m.find()) {
-                    Test result = findTest(test);
-                    result.setResultStatus(CtsTestStatus.PASS);
-                    result.setSummary(m.group(1));
-                    result.setDetails(m.group(2));
-                } else {
-                    CLog.e("CTS Result unrecognizable:" + perfResult);
+                try {
+                    report = ReportLog.parse(perfResult);
+                } catch (XmlPullParserException | IOException e) {
+                    e.printStackTrace();
                 }
+            } else {
+                // host test should be checked into MetricsStore.
+                report = MetricsStore.removeResult(mDeviceSerial, getAbi(), test.toString());
+            }
+            Test result = findTest(test);
+            if (report != null && !result.getResult().equals(CtsTestStatus.FAIL)) {
+                result.setResultStatus(CtsTestStatus.PASS);
+                result.setReportLog(report);
             }
         }
     }
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java
index 68cd1c0..0707ffa 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/TestResults.java
@@ -15,8 +15,8 @@
  */
 package com.android.cts.tradefed.result;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildProvider;
-import com.android.cts.util.AbiUtils;
 import com.android.tradefed.log.LogUtil.CLog;
 
 import org.kxml2.io.KXmlSerializer;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
index 66d1135..1fa4e7b 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsInstrumentationApkTest.java
@@ -15,8 +15,8 @@
  */
 package com.android.cts.tradefed.testtype;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.DeviceNotAvailableException;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
index 01f148ae..9f47ce5 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
@@ -16,11 +16,11 @@
 
 package com.android.cts.tradefed.testtype;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
 import com.android.cts.tradefed.device.DeviceInfoCollector;
 import com.android.cts.tradefed.result.CtsTestStatus;
 import com.android.cts.tradefed.result.PlanCreator;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.Log.LogLevel;
 import com.android.ddmlib.testrunner.TestIdentifier;
@@ -1078,7 +1078,7 @@
      * Exposed for unit testing
      */
     ITestPlan createPlan(String planName) {
-        return new TestPlan(planName, AbiUtils.getAbisSupportedByCts());
+        return new TestPlan(planName, AbiUtils.getAbisSupportedByCompatibility());
     }
 
     /**
@@ -1092,7 +1092,7 @@
         String bitness = (mForceAbi == null) ? "" : mForceAbi;
         Set<String> abis = new HashSet<>();
         for (String abi : AbiFormatter.getSupportedAbis(mDevice, bitness)) {
-            if (AbiUtils.isAbiSupportedByCts(abi)) {
+            if (AbiUtils.isAbiSupportedByCompatibility(abi)) {
                 abis.add(abi);
             }
         }
@@ -1107,7 +1107,7 @@
      */
     ITestPlan createPlan(PlanCreator planCreator)
             throws ConfigurationException {
-        return planCreator.createDerivedPlan(mCtsBuild, AbiUtils.getAbisSupportedByCts());
+        return planCreator.createDerivedPlan(mCtsBuild, AbiUtils.getAbisSupportedByCompatibility());
     }
 
     /**
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
index 12adb9f..3f8b820 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/DeqpTestRunner.java
@@ -1,7 +1,7 @@
 package com.android.cts.tradefed.testtype;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.AdbCommandRejectedException;
 import com.android.ddmlib.IShellOutputReceiver;
 import com.android.ddmlib.MultiLineReceiver;
@@ -172,7 +172,7 @@
     }
 
     private static final class CapabilityQueryFailureException extends Exception {
-    };
+    }
 
     /**
      * Test configuration of dEPQ test instance execution.
@@ -252,13 +252,13 @@
         private boolean mGotTestResult;
         private String mCurrentTestLog;
 
-        private class PendingResult
-        {
+        private class PendingResult {
             boolean allInstancesPassed;
             Map<BatchRunConfiguration, String> testLogs;
             Map<BatchRunConfiguration, String> errorMessages;
             Set<BatchRunConfiguration> remainingConfigs;
-        };
+        }
+
         private final Map<TestIdentifier, PendingResult> mPendingResults = new HashMap<>();
 
         public void setSink(ITestInvocationListener sink) {
@@ -737,7 +737,7 @@
      */
     public static interface ISleepProvider {
         public void sleep(int milliseconds);
-    };
+    }
 
     private static class SleepProvider implements ISleepProvider {
         public void sleep(int milliseconds) {
@@ -746,7 +746,7 @@
             } catch (InterruptedException ex) {
             }
         }
-    };
+    }
 
     /**
      * Interface for failure recovery.
@@ -1004,7 +1004,7 @@
         private void rebootDevice() throws DeviceNotAvailableException {
             mDevice.reboot();
         }
-    };
+    }
 
     /**
      * Parse map of instance arguments to map of BatchRunConfigurations
@@ -1326,12 +1326,13 @@
         public AdbComLinkOpenError(String description, Throwable inner) {
             super(description, inner);
         }
-    };
+    }
+
     private static final class AdbComLinkKilledError extends Exception {
         public AdbComLinkKilledError(String description, Throwable inner) {
             super(description, inner);
         }
-    };
+    }
 
     /**
      * Executes a given command in adb shell
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java
index 234f437..893758f 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/ITestPackageRepo.java
@@ -16,7 +16,7 @@
 
 package com.android.cts.tradefed.testtype;
 
-import com.android.cts.util.AbiUtils;
+import com.android.compatibility.common.util.AbiUtils;
 
 import java.util.List;
 import java.util.Map;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
index f276f1d..10e5373 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageDef.java
@@ -16,7 +16,7 @@
 
 package com.android.cts.tradefed.testtype;
 
-import com.android.cts.util.AbiUtils;
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.ddmlib.Log.LogLevel;
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.log.LogUtil.CLog;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java
index 7e16170..9857105 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageRepo.java
@@ -15,7 +15,7 @@
  */
 package com.android.cts.tradefed.testtype;
 
-import com.android.cts.util.AbiUtils;
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.tradefed.config.ConfigurationException;
 import com.android.tradefed.config.ConfigurationFactory;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java
index 649dd9e..acd977e 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPackageXmlParser.java
@@ -15,7 +15,7 @@
  */
 package com.android.cts.tradefed.testtype;
 
-import com.android.cts.util.AbiUtils;
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.ddmlib.Log;
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.util.xml.AbstractXmlParser;
@@ -87,7 +87,7 @@
                 final String runTimeArgs = attributes.getValue("runtimeArgs");
                 final String testType = getTestType(attributes);
 
-                for (String abiName : AbiUtils.getAbisSupportedByCts()) {
+                for (String abiName : AbiUtils.getAbisSupportedByCompatibility()) {
                     Abi abi = new Abi(abiName, AbiUtils.getBitness(abiName));
                     TestPackageDef packageDef = new TestPackageDef();
                     packageDef.setAppPackageName(appPackageName);
@@ -154,7 +154,7 @@
                         Set<String> abis = new HashSet<String>();
                         if (abiList == null) {
                             // If no specification, add all supported abis
-                            abis.addAll(AbiUtils.getAbisSupportedByCts());
+                            abis.addAll(AbiUtils.getAbisSupportedByCompatibility());
                         } else {
                             for (String abi : abiList.split(",")) {
                                 // Else only add the abi which are supported
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java
index 2419784..6b02db9 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/TestPlan.java
@@ -16,7 +16,7 @@
 
 package com.android.cts.tradefed.testtype;
 
-import com.android.cts.util.AbiUtils;
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.util.ArrayUtil;
 import com.android.tradefed.util.xml.AbstractXmlParser;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java
index e3ff825..4f40c89 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/WrappedGTest.java
@@ -16,8 +16,8 @@
 
 package com.android.cts.tradefed.testtype;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.build.CtsBuildHelper;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.testrunner.ITestRunListener;
 import com.android.tradefed.build.IBuildInfo;
 import com.android.tradefed.device.DeviceNotAvailableException;
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/util/CtsHostStore.java b/tools/tradefed-host/src/com/android/cts/tradefed/util/CtsHostStore.java
deleted file mode 100644
index 288b48c..0000000
--- a/tools/tradefed-host/src/com/android/cts/tradefed/util/CtsHostStore.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 com.android.cts.tradefed.util;
-
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Utility class for storing Cts Results.
- * This is necessary for host tests where test metrics cannot be passed.
- */
-public class CtsHostStore {
-
-    // needs concurrent version as there can be multiple client accessing this.
-    // But there is no additional protection for the same key as that should not happen.
-    private static final ConcurrentHashMap<String, String> mMap =
-            new ConcurrentHashMap<String, String>();
-
-    /**
-     * Stores CTS result. Existing result with the same key will be replaced.
-     * Note that key is generated in the form of device_serial#class#method name.
-     * So there should be no concurrent test for the same (serial, class, method).
-     * @param deviceSerial
-     * @param abi
-     * @param classMethodName
-     * @param result CTS result string
-     */
-    public static void storeCtsResult(String deviceSerial, String abi, String classMethodName, String result) {
-        mMap.put(generateTestKey(deviceSerial, abi, classMethodName), result);
-    }
-
-    /**
-     * retrieves a CTS result for the given condition and remove it from the internal
-     * storage. If there is no result for the given condition, it will return null.
-     */
-    public static String removeCtsResult(String deviceSerial, String abi, String classMethodName) {
-        return mMap.remove(generateTestKey(deviceSerial, abi, classMethodName));
-    }
-
-    /**
-     * @return test key in the form of device_serial#abi#class_name#method_name
-     */
-    private static String generateTestKey(String deviceSerial, String abi, String classMethodName) {
-        return String.format("%s#%s#%s", deviceSerial, abi, classMethodName);
-
-    }
-}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/util/HostReportLog.java b/tools/tradefed-host/src/com/android/cts/tradefed/util/HostReportLog.java
index 645dbb9..f72b097 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/util/HostReportLog.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/util/HostReportLog.java
@@ -16,17 +16,17 @@
 
 package com.android.cts.tradefed.util;
 
+import com.android.compatibility.common.util.MetricsReportLog;
 import com.android.cts.util.ReportLog;
 
 /**
  * ReportLog for host tests
  * Note that setTestInfo should be set before throwing report
+ *
+ * This class is deprecated, use {@link MetricsReportLog} instead.
  */
+@Deprecated
 public class HostReportLog extends ReportLog {
-    private final String mDeviceSerial;
-    private final String mAbiName;
-    private final String mClassMethodName;
-
     /**
      * @param deviceSerial serial number of the device
      * @param abiName the name of the ABI on which the test was run
@@ -34,12 +34,10 @@
      *        Note that ReportLog.getClassMethodNames() provide this.
      */
     public HostReportLog(String deviceSerial, String abiName, String classMethodName) {
-        mDeviceSerial = deviceSerial;
-        mAbiName = abiName;
-        mClassMethodName = classMethodName;
+        super(new MetricsReportLog(deviceSerial, abiName, classMethodName));
     }
 
     public void deliverReportToHost() {
-        CtsHostStore.storeCtsResult(mDeviceSerial, mAbiName, mClassMethodName, generateReport());
+        ((MetricsReportLog) mReportLog).submit();
     }
-}
+}
\ No newline at end of file
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java
index 7ba1741..80cd00f 100644
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java
+++ b/tools/tradefed-host/tests/src/com/android/cts/tradefed/result/CtsXmlResultReporterTest.java
@@ -17,11 +17,10 @@
 
 import static com.android.cts.tradefed.result.CtsXmlResultReporter.CTS_RESULT_FILE_VERSION;
 
-import com.android.cts.tradefed.build.ICtsBuildInfo;
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.UnitTests;
-import com.android.cts.util.AbiUtils;
+import com.android.cts.tradefed.build.ICtsBuildInfo;
 import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.log.LogUtil.CLog;
 import com.android.tradefed.result.LogDataType;
 import com.android.tradefed.result.LogFile;
 import com.android.tradefed.result.TestSummary;
@@ -36,8 +35,8 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Arrays;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java
index 792b15e..aa22703 100644
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java
+++ b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/CtsTestTest.java
@@ -15,10 +15,10 @@
  */
 package com.android.cts.tradefed.testtype;
 
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.UnitTests;
 import com.android.cts.tradefed.build.StubCtsBuildHelper;
 import com.android.cts.tradefed.result.PlanCreator;
-import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
index 4c879b4..a5f8ad6 100644
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
+++ b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/DeqpTestRunnerTest.java
@@ -15,18 +15,16 @@
  */
 package com.android.cts.tradefed.testtype;
 
-import com.android.cts.tradefed.build.StubCtsBuildHelper;
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.cts.tradefed.UnitTests;
-import com.android.cts.util.AbiUtils;
+import com.android.cts.tradefed.build.StubCtsBuildHelper;
 import com.android.ddmlib.IDevice;
 import com.android.ddmlib.IShellOutputReceiver;
 import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.testrunner.ITestRunListener;
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.ITestDevice;
 import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IAbi;
 import com.android.tradefed.util.IRunUtil;
 import com.android.tradefed.util.RunInterruptedException;
 
@@ -38,7 +36,6 @@
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java
index bd48c51..8655885 100644
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java
+++ b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPackageXmlParserTest.java
@@ -16,7 +16,7 @@
 
 package com.android.cts.tradefed.testtype;
 
-import com.android.cts.util.AbiUtils;
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
 
@@ -100,7 +100,7 @@
             assertEquals("com.example", def.getAppNameSpace());
             assertEquals("android.example", def.getAppPackageName());
             assertEquals("android.test.InstrumentationTestRunner", def.getRunner());
-            assertTrue(AbiUtils.isAbiSupportedByCts(def.getAbi().getName()));
+            assertTrue(AbiUtils.isAbiSupportedByCompatibility(def.getAbi().getName()));
         }
     }
 
diff --git a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java
index 5b28539..be260ea 100644
--- a/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java
+++ b/tools/tradefed-host/tests/src/com/android/cts/tradefed/testtype/TestPlanTest.java
@@ -16,7 +16,7 @@
 
 package com.android.cts.tradefed.testtype;
 
-import com.android.cts.util.AbiUtils;
+import com.android.compatibility.common.util.AbiUtils;
 import com.android.ddmlib.testrunner.TestIdentifier;
 import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
 
@@ -75,7 +75,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        mPlan = new TestPlan("plan", AbiUtils.getAbisSupportedByCts());
+        mPlan = new TestPlan("plan", AbiUtils.getAbisSupportedByCompatibility());
     }
 
     /**
@@ -91,7 +91,7 @@
      * @param plan
      */
     private void assertTestData(TestPlan plan) {
-        Set<String> abis = AbiUtils.getAbisSupportedByCts();
+        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
         assertEquals(2 * abis.size(), plan.getTestIds().size());
         List<String> sortedAbis = new ArrayList<String>(abis);
         Collections.sort(sortedAbis);
@@ -112,7 +112,7 @@
      */
     public void testParse_exclude() throws ParseException  {
         mPlan.parse(getStringAsStream(TEST_EXCLUDED_DATA));
-        Set<String> abis = AbiUtils.getAbisSupportedByCts();
+        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
         assertEquals(abis.size(), mPlan.getTestIds().size());
 
         for (String abi : abis) {
@@ -136,7 +136,7 @@
      * @param plan
      */
     private void assertMultiExcluded(TestPlan plan) {
-        Set<String> abis = AbiUtils.getAbisSupportedByCts();
+        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
         assertEquals(abis.size(), plan.getTestIds().size());
 
         for (String abi : abis) {
@@ -154,7 +154,7 @@
      */
     public void testParse_classExclude() throws ParseException  {
         mPlan.parse(getStringAsStream(TEST_CLASS_EXCLUDED_DATA));
-        Set<String> abis = AbiUtils.getAbisSupportedByCts();
+        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
         assertEquals(abis.size(), mPlan.getTestIds().size());
 
         for (String abi : abis) {
@@ -179,14 +179,14 @@
      * @throws IOException
      */
     public void testSerialize_packages() throws ParseException, IOException  {
-        Set<String> abis = AbiUtils.getAbisSupportedByCts();
+        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
         for (String abi : abis) {
             mPlan.addPackage(AbiUtils.createId(abi, TEST_NAME1));
             mPlan.addPackage(AbiUtils.createId(abi, TEST_NAME2));
         }
         ByteArrayOutputStream outStream = new ByteArrayOutputStream();
         mPlan.serialize(outStream);
-        TestPlan parsedPlan = new TestPlan("parsed", AbiUtils.getAbisSupportedByCts());
+        TestPlan parsedPlan = new TestPlan("parsed", AbiUtils.getAbisSupportedByCompatibility());
         parsedPlan.parse(getStringAsStream(outStream.toString()));
         // parsedPlan should contain same contents as TEST_DATA
         assertTestData(parsedPlan);
@@ -196,7 +196,7 @@
      * Test serializing and deserializing plan with multiple excluded tests
      */
     public void testSerialize_multiExclude() throws ParseException, IOException  {
-        Set<String> abis = AbiUtils.getAbisSupportedByCts();
+        Set<String> abis = AbiUtils.getAbisSupportedByCompatibility();
 
         for (String abi : abis) {
             String test1Id = AbiUtils.createId(abi, TEST_NAME1);
@@ -208,7 +208,7 @@
         }
         ByteArrayOutputStream outStream = new ByteArrayOutputStream();
         mPlan.serialize(outStream);
-        TestPlan parsedPlan = new TestPlan("parsed", AbiUtils.getAbisSupportedByCts());
+        TestPlan parsedPlan = new TestPlan("parsed", AbiUtils.getAbisSupportedByCompatibility());
         parsedPlan.parse(getStringAsStream(outStream.toString()));
         // parsedPlan should contain same contents as TEST_DATA
         assertMultiExcluded(parsedPlan);
diff --git a/tools/utils/Android.mk b/tools/utils/Android.mk
index 0ba5cf4..d26abb1 100644
--- a/tools/utils/Android.mk
+++ b/tools/utils/Android.mk
@@ -25,6 +25,6 @@
 LOCAL_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
 
 LOCAL_JAVA_LIBRARIES := junit
-LOCAL_STATIC_JAVA_LIBRARIES := ctsabiutilslib vogarexpectlib
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-host-util vogarexpectlib
 
 include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tools/utils/CollectAllTests.java b/tools/utils/CollectAllTests.java
index 83c451e..e1ff982 100644
--- a/tools/utils/CollectAllTests.java
+++ b/tools/utils/CollectAllTests.java
@@ -13,7 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import com.android.cts.util.AbiUtils;
+
+import com.android.compatibility.common.util.AbiUtils;
 
 import org.junit.runner.RunWith;
 import org.w3c.dom.Document;
diff --git a/tools/utils/VogarUtils.java b/tools/utils/VogarUtils.java
index 8e77e7c..77c62da 100644
--- a/tools/utils/VogarUtils.java
+++ b/tools/utils/VogarUtils.java
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-import com.android.cts.util.AbiUtils;
-
 import vogar.Expectation;
 import vogar.ExpectationStore;
 import vogar.ModeId;
 import vogar.Result;
 
+import com.android.compatibility.common.util.AbiUtils;
+
 import java.io.File;
 import java.io.FilenameFilter;
 import java.io.IOException;
diff --git a/tools/vm-tests-tf/Android.mk b/tools/vm-tests-tf/Android.mk
index b1cbe37..ded63bf 100644
--- a/tools/vm-tests-tf/Android.mk
+++ b/tools/vm-tests-tf/Android.mk
@@ -69,7 +69,6 @@
 vmteststf_dep_jars += $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/, jack.jar)
 vmteststf_dep_jars += $(private_jill_jarjar_asm)
 
-$(vmteststf_jar): PRIVATE_JACK_VM_ARGS := $(LOCAL_JACK_VM_ARGS)
 $(vmteststf_jar): PRIVATE_JACK_EXTRA_ARGS := $(LOCAL_JACK_EXTRA_ARGS)
 
 ifdef LOCAL_JACK_ENABLED
@@ -113,7 +112,7 @@
 		$(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_ARGS),$(PRIVATE_JACK_EXTRA_ARGS)) --output-dex $(PRIVATE_INTERMEDIATES_DEXCORE_JAR).tmp \
+	$(hide) $(call call-jack,$(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 .