Merge "Fix CST test failure on non-telephony device and a couple of exceptions" into lmp-dev
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index a08c34f..4bbd783 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -34,16 +34,17 @@
     CtsAppTestStubs \
     CtsDeviceAdmin \
     CtsDeviceOpenGl \
+    CtsDeviceOwnerApp \
     CtsDeviceTaskswitchingAppA \
     CtsDeviceTaskswitchingAppB \
     CtsDeviceTaskswitchingControl \
     CtsDeviceUi \
+    CtsIntentReceiverApp \
+    CtsManagedProfileApp \
     CtsMonkeyApp \
     CtsMonkeyApp2 \
-    CtsProfileOwnerApp \
     CtsSomeAccessibilityServices \
     CtsThemeDeviceApp \
-    SignatureTest \
     TestDeviceSetup \
     CtsUiAutomatorApp \
     CtsUsbSerialTestApp \
@@ -113,6 +114,7 @@
     CtsRsCppTestCases \
     CtsSaxTestCases \
     CtsSecurityTestCases \
+    CtsSignatureTestCases \
     CtsSpeechTestCases \
     CtsTelephonyTestCases \
     CtsTextTestCases \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 3bb9a01..0183fa2 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -728,18 +728,6 @@
             </intent-filter>
         </receiver>
 
-        <activity android:name=".sensors.AccelerometerTestActivity"
-                  android:label="@string/snsr_accel_test"
-                android:screenOrientation="nosensor">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/test_category_sensors" />
-            <meta-data android:name="test_required_features"
-                       android:value="android.hardware.sensor.accelerometer" />
-        </activity>
-
         <activity android:name=".sensors.AccelerometerMeasurementTestActivity"
                   android:label="@string/snsr_accel_m_test"
                   android:screenOrientation="locked">
@@ -752,17 +740,6 @@
                        android:value="android.hardware.sensor.accelerometer"/>
         </activity>
 
-        <activity android:name=".sensors.GyroscopeTestActivity" android:label="@string/snsr_gyro_test"
-                android:screenOrientation="nosensor">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/test_category_sensors" />
-            <meta-data android:name="test_required_features"
-                       android:value="android.hardware.sensor.gyroscope" />
-        </activity>
-
         <activity android:name=".sensors.GyroscopeMeasurementTestActivity"
                   android:label="@string/snsr_gyro_m_test"
                   android:screenOrientation="locked">
@@ -811,7 +788,8 @@
                        android:value="android.hardware.sensor.accelerometer" />
         </activity>
 
-        <activity android:name=".sensors.RotationVectorTestActivity"
+        <!-- TODO: enable when a full set of verifications can be implemented -->
+        <!--activity android:name=".sensors.RotationVectorTestActivity"
                   android:label="@string/snsr_rot_vec_test"
                   android:screenOrientation="locked">
             <intent-filter>
@@ -821,7 +799,7 @@
             <meta-data android:name="test_category" android:value="@string/test_category_sensors" />
             <meta-data android:name="test_required_features"
                        android:value="android.hardware.sensor.gyroscope" />
-        </activity>
+        </activity-->
 
         <activity android:name=".sensors.BatchingTestActivity"
                   android:label="@string/snsr_batch_test"
@@ -835,7 +813,7 @@
                        android:value="android.hardware.sensor.accelerometer" />
         </activity>
 
-        <!-- TODO: enable test when a more reliable way to identify time synchronization is available -->
+        <!-- TODO: enable when a more reliable way to identify time synchronization is available -->
         <!--activity android:name=".sensors.SensorSynchronizationTestActivity"
                   android:label="@string/snsr_synch_test"
                   android:screenOrientation="locked">
@@ -1131,6 +1109,7 @@
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
+                <category android:name="android.intent.category.LEANBACK_LAUNCHER" />
             </intent-filter>
         </activity-alias>
 
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 8f28706..38e0ced 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -504,14 +504,14 @@
         facing the ceiling.</string>
     <string name="snsr_accel_test_face_down">Place the device on a flat surface with the screen
         facing it.</string>
-    <string name="snsr_accel_test_right_side">Place the device resting vertically on its right
-        side.</string>
-    <string name="snsr_accel_test_left_side">Place the device resting vertically on its left
-        side.</string>
-    <string name="snsr_accel_test_top_side">Place the device resting vertically on its top
-        side.</string>
-    <string name="snsr_accel_test_bottom_side">Place the device resting vertically on its bottom
-        side.</string>
+    <string name="snsr_accel_test_right_side">Place the device in a flat surface resting vertically
+        on its right side.</string>
+    <string name="snsr_accel_test_left_side">Place the device in a flat surface resting vertically
+        on its left side.</string>
+    <string name="snsr_accel_test_top_side">Place the device in a flat surface resting vertically
+        on its top side.</string>
+    <string name="snsr_accel_test_bottom_side">Place the device in a flat surface resting vertically
+        on its bottom side.</string>
 
     <!-- Gyroscope -->
     <string name="snsr_gyro_test">Gyroscope Test</string>
@@ -558,7 +558,8 @@
 
     <!-- Sensor Batching -->
     <string name="snsr_batch_test">Sensor Batching Tests</string>
-    <string name="snsr_batching_walking_needed">Once the test begins, you will have to walk.</string>
+    <string name="snsr_batching_walking_needed">Once the test begins, you will have to take the
+        device in your hand and walk.</string>
     <string name="snsr_batching_fifo_count">FifoReservedEventCount=%1$d. Expected to be at most FifoMaxEventCount=%2$d.</string>
 
     <!-- Sensor Synchronization -->
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index 6319133..20ccd81 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -194,6 +194,9 @@
 
     public static final Feature[] ALL_LMP_FEATURES = {
             new Feature(PackageManager.FEATURE_SENSOR_HEART_RATE_ECG, false),
+            new Feature("android.hardware.ethernet", false),
+            new Feature("android.software.backup", false),
+            new Feature("android.software.print", false),
     };
 
     @Override
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerMeasurementTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerMeasurementTestActivity.java
index 945e9ab..dfcf120 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerMeasurementTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerMeasurementTestActivity.java
@@ -107,10 +107,11 @@
 
     private String delayedVerifyMeasurements(int descriptionResId, float ... expectations)
             throws Throwable {
-        appendText(descriptionResId);
-        appendText(R.string.snsr_test_play_sound);
-        waitForUser();
-        Thread.sleep(TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS));
+        SensorTestLogger logger = getTestLogger();
+        logger.logInstructions(descriptionResId);
+        logger.logWaitForSound();
+        waitForUserToBegin();
+        Thread.sleep(TimeUnit.MILLISECONDS.convert(7, TimeUnit.SECONDS));
 
         try {
             return verifyMeasurements(expectations);
@@ -121,9 +122,10 @@
 
     private String verifyMeasurements(int descriptionResId, float ... expectations)
             throws Throwable {
-        appendText(descriptionResId);
-        appendText(R.string.snsr_device_steady);
-        waitForUser();
+        SensorTestLogger logger = getTestLogger();
+        logger.logInstructions(descriptionResId);
+        logger.logInstructions(R.string.snsr_device_steady);
+        waitForUserToBegin();
 
         return verifyMeasurements(expectations);
     }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
index 597f5fb..0d4f755e 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/AccelerometerTestActivity.java
@@ -31,7 +31,10 @@
  * CTS Verifier case for verifying correct integration of accelerometer.
  * Displays a wedge using OpenGL that, on a correctly-integrated device, always
  * points down.
+ *
+ * @deprecated It has been replaced by {@link AccelerometerMeasurementTestActivity}
  */
+@Deprecated
 public class AccelerometerTestActivity extends PassFailButtons.Activity {
     private GLSurfaceView mGLSurfaceView;
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/GyroscopeTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/GyroscopeTestActivity.java
index 7a7a7f5..f886e75 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/GyroscopeTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/GyroscopeTestActivity.java
@@ -36,7 +36,10 @@
  * Manual test for testing the gyroscope sensor. This test consists of 6 steps for all the
  * different ways to rotate the device along the x, y, and z axis. It also raises a warning
  * if the values seem to high and may be degrees.
+ *
+ * @deprecated It has been replaced by {@link GyroscopeMeasurementTestActivity}
  */
+@Deprecated
 public class GyroscopeTestActivity extends PassFailButtons.Activity {
 
     private static final int NUM_STAGES = 6;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorSynchronizationTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorSynchronizationTestActivity.java
index eeb4bf0..b5ffc2a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorSynchronizationTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorSynchronizationTestActivity.java
@@ -1,7 +1,7 @@
 
 package com.android.cts.verifier.sensors;
 
-import com.android.cts.verifier.sensors.base.BaseSensorSemiAutomatedTestActivity;
+import com.android.cts.verifier.sensors.base.SensorCtsVerifierTestActivity;
 
 import junit.framework.Assert;
 
@@ -25,8 +25,11 @@
  */
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 public class SensorSynchronizationTestActivity
-        extends BaseSensorSemiAutomatedTestActivity
+        extends SensorCtsVerifierTestActivity
         implements SensorEventListener {
+    public SensorSynchronizationTestActivity() {
+        super(SensorSynchronizationTestActivity.class);
+    }
 
     private final double NANOS_PER_MILLI = 1e6;
     private final int DATA_COLLECTION_TIME_IN_MS = 5000;
@@ -132,7 +135,7 @@
         Assert.assertTrue("Gyroscope did not detect any movement", gyrMovementDetected);
     }
 
-    private void executeCrossSensorTest() throws Throwable {
+    public String testCrossSensorSynchronization() throws Throwable {
         appendText("This test provides a rough indication of cross-sensor timestamp synchronization.");
         appendText("Hold device still in hand and click 'Next'");
         waitForUser();
@@ -144,6 +147,7 @@
 
         stopDataCollection();
         analyzeData();
+        return null;
     }
 
     protected double angleBetweenVecsDegrees(float[] vec1, float[] vec2) {
@@ -156,11 +160,6 @@
     }
 
     @Override
-    protected void onRun() throws Throwable {
-        executeCrossSensorTest();
-    }
-
-    @Override
     public void onSensorChanged(SensorEvent sensorEvent) {
         mSensorEvents.add(new TestSensorEvent(sensorEvent, SystemClock.elapsedRealtimeNanos()));
     }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorValueAccuracyActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorValueAccuracyActivity.java
index b720ffb..b6d7cd6 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorValueAccuracyActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorValueAccuracyActivity.java
@@ -96,7 +96,7 @@
     }
 
     public String testGyroscopeCalibratedUncalibrated() throws Throwable {
-        appendText(R.string.snsr_keep_device_rotating_clockwise);
+        getTestLogger().logInstructions(R.string.snsr_keep_device_rotating_clockwise);
         return verifyCalibratedUncalibrated(
                 Sensor.TYPE_GYROSCOPE,
                 Sensor.TYPE_GYROSCOPE_UNCALIBRATED,
@@ -113,8 +113,8 @@
             int instructionsResId,
             float expectedNorm,
             float threshold) {
-        appendText(instructionsResId);
-        waitForUser();
+        getTestLogger().logInstructions(instructionsResId);
+        waitForUserToBegin();
 
         TestSensorEnvironment environment =
                 new TestSensorEnvironment(getApplicationContext(), sensorType, SENSOR_RATE);
@@ -151,8 +151,9 @@
             int calibratedSensorType,
             int uncalibratedSensorType,
             float threshold) throws Throwable {
-        appendText(R.string.snsr_no_interaction);
-        waitForUser();
+        SensorTestLogger logger = getTestLogger();
+        logger.logInstructions(R.string.snsr_no_interaction);
+        waitForUserToBegin();
 
         Sensor calibratedSensor = mSensorManager.getDefaultSensor(calibratedSensorType);
         if (calibratedSensor == null) {
@@ -167,7 +168,7 @@
         final long timeout = TimeUnit.SECONDS.toMillis(10);
         startDataCollection(calibratedSensor);
         startDataCollection(uncalibratedSensor);
-        appendText(R.string.snsr_test_play_sound);
+        logger.logWaitForSound();
         Thread.sleep(timeout);
         stopDataCollection();
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SignificantMotionTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SignificantMotionTestActivity.java
index fbc56c2..a84a045 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SignificantMotionTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SignificantMotionTestActivity.java
@@ -67,7 +67,7 @@
                 false /* vibrate */);
     }
 
-    public String testNotTriggerAfterCancell() throws Throwable {
+    public String testNotTriggerAfterCancel() throws Throwable {
         return runTest(
                 R.string.snsr_significant_motion_test_cancel,
                 false /* isMotionExpected */,
@@ -107,12 +107,13 @@
     }
 
     public String testTriggerDeactivation() throws Throwable {
-        appendText(R.string.snsr_significant_motion_test_deactivation);
-        waitForUser();
+        SensorTestLogger logger = getTestLogger();
+        logger.logInstructions(R.string.snsr_significant_motion_test_deactivation);
+        waitForUserToBegin();
 
         TriggerVerifier verifier = new TriggerVerifier();
         mSensorManager.requestTriggerSensor(verifier, mSensorSignificantMotion);
-        appendText(R.string.snsr_test_play_sound);
+        logger.logWaitForSound();
 
         // wait for the first event to trigger
         verifier.verifyEventTriggered();
@@ -137,8 +138,9 @@
             boolean isMotionExpected,
             boolean cancelEventNotification,
             boolean vibrate) throws Throwable {
-        appendText(instructionsResId);
-        waitForUser();
+        SensorTestLogger logger = getTestLogger();
+        logger.logInstructions(instructionsResId);
+        waitForUserToBegin();
 
         if (vibrate) {
             vibrate(VIBRATE_DURATION_MILLIS);
@@ -154,7 +156,7 @@
                     getString(R.string.snsr_significant_motion_cancelation),
                     mSensorManager.cancelTriggerSensor(verifier, mSensorSignificantMotion));
         }
-        appendText(R.string.snsr_test_play_sound);
+        logger.logWaitForSound();
 
         String result;
         try {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java
index e3e934c..76d12d9 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java
@@ -139,7 +139,7 @@
             vibrate(VIBRATE_PATTERN);
         }
         startMeasurements();
-        appendText(R.string.snsr_test_play_sound);
+        getTestLogger().logWaitForSound();
 
         Thread.sleep(TimeUnit.SECONDS.toMillis(TEST_DURATION_SECONDS));
         mCheckForMotion = false;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/BaseSensorSemiAutomatedTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/BaseSensorSemiAutomatedTestActivity.java
deleted file mode 100644
index 9f2f5c4..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/BaseSensorSemiAutomatedTestActivity.java
+++ /dev/null
@@ -1,61 +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.verifier.sensors.base;
-
-import com.android.cts.verifier.sensors.reporting.SensorTestDetails;
-
-import android.hardware.cts.helpers.SensorTestStateNotSupportedException;
-
-/**
- * Base class to author a single Sensor semi-automated test case.
- *
- * @deprecated use {@link BaseSensorTestActivity} instead.
- */
-@Deprecated
-public abstract class BaseSensorSemiAutomatedTestActivity extends BaseSensorTestActivity {
-    public BaseSensorSemiAutomatedTestActivity() {
-        super(BaseSensorSemiAutomatedTestActivity.class);
-    }
-
-    @Override
-    public SensorTestDetails executeTests() {
-        String summary = "";
-        SensorTestDetails.ResultCode resultCode = SensorTestDetails.ResultCode.PASS;
-        try {
-            onRun();
-        } catch(SensorTestStateNotSupportedException e) {
-            // the sensor state is not supported in the device, log a warning and skip the test
-            resultCode = SensorTestDetails.ResultCode.SKIPPED;
-            summary = e.getMessage();
-        } catch(Throwable e) {
-            resultCode = SensorTestDetails.ResultCode.FAIL;
-            summary = e.getMessage();
-        }
-        return new SensorTestDetails(getTestClassName(), resultCode, summary);
-    }
-
-    /**
-     * This is the method that subclasses will implement to define the operations that need to be
-     * verified.
-     * Any exception thrown will cause the test to fail, additionally mAssert can be used to verify
-     * the tests state.
-     *
-     * throws Throwable
-     */
-    @Deprecated
-    protected abstract void onRun() throws Throwable;
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/BaseSensorTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/BaseSensorTestActivity.java
index 236c180..068869f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/BaseSensorTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/BaseSensorTestActivity.java
@@ -237,11 +237,6 @@
     }
 
     @Deprecated
-    protected void appendText(int resId, int textColor) {
-        mTestLogger.logInstructions(resId);
-    }
-
-    @Deprecated
     protected void appendText(String text, int textColor) {
         appendText(text);
     }
diff --git a/development/ide/eclipse/.classpath b/development/ide/eclipse/.classpath
index fafcc32..98939ba 100644
--- a/development/ide/eclipse/.classpath
+++ b/development/ide/eclipse/.classpath
@@ -1,101 +1,101 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-    <classpathentry kind="lib" path="prebuilts/misc/common/ddmlib/ddmlib-prebuilt.jar"/>
-    <classpathentry kind="lib" path="prebuilts/misc/common/tradefed/tradefed-prebuilt.jar"/>
-    <classpathentry kind="src" path="cts/apps/CtsVerifier/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/appsecurity/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/appsecurity/test-apps/AppWithData/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/monkey/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/monkey/test-apps/CtsMonkeyApp/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/monkey/test-apps/CtsMonkeyApp2/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/sample/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/sample/app/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/theme/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/theme/app/src"/>
-    <classpathentry kind="src" path="cts/hostsidetests/usb/src"/>
-    <classpathentry kind="src" path="cts/libs/vogar-expect/src"/>
-    <classpathentry kind="src" path="cts/libs/commonutil/src"/>
-    <classpathentry kind="src" path="cts/libs/deviceutil/src"/>
-    <classpathentry kind="src" path="cts/libs/json/src"/>
-    <classpathentry kind="src" path="cts/libs/testserver/src"/>
-    <classpathentry kind="src" path="cts/libs/wrappedgtest/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/deviceTests/browserbench/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/deviceTests/dram/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/deviceTests/filesystemperf/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/deviceTests/opengl/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/deviceTests/simplecpu/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/deviceTests/ui/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/deviceTests/videoperf/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/hostTests/jank/app/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/hostTests/jank/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/hostTests/uihost/appA/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/hostTests/uihost/appB/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/hostTests/uihost/control/src"/>
-    <classpathentry kind="src" path="cts/suite/cts/hostTests/uihost/src"/>
-    <classpathentry kind="src" path="cts/tests/ProcessTest/src"/>
-    <classpathentry kind="src" path="cts/tests/ProcessTest/NoShareUidApp/src"/>
-    <classpathentry kind="src" path="cts/tests/ProcessTest/ShareUidApp/src"/>
-    <classpathentry kind="src" path="cts/tests/SignatureTest/src"/>
-    <classpathentry kind="src" path="cts/tests/SignatureTest/tests/src"/>
-    <classpathentry kind="src" path="cts/tests/acceleration/src"/>
-    <classpathentry kind="src" path="cts/tests/core/runner/src"/>
-    <classpathentry kind="src" path="cts/tests/deviceadmin/src"/>
-    <classpathentry kind="src" path="cts/tests/sample/src"/>
-    <classpathentry kind="src" path="cts/tests/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/acceleration/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/accessibility/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/accessibilityservice/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/accounts/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/admin/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/animation/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/app/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/bluetooth/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/content/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/database/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/dpi/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/dpi2/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/drm/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/gesture/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/graphics/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/graphics2/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/hardware/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/jni/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/location/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/media/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/mediastress/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/net/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/opengl/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/openglperf/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/os/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/permission/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/permission2/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/preference/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/preference2/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/provider/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/renderscript/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/security/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/speech/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/telephony/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/text/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/textureview/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/util/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/view/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/webkit/src"/>
-    <classpathentry kind="src" path="cts/tests/tests/widget/src"/>
-    <classpathentry kind="src" path="cts/tools/cts-api-coverage/src"/>
-    <classpathentry kind="src" path="cts/tools/cts-java-scanner/src"/>
-    <classpathentry kind="src" path="cts/tools/cts-java-scanner-doclet/src"/>
-    <classpathentry kind="src" path="cts/tools/cts-native-scanner/src"/>
-    <classpathentry kind="src" path="cts/tools/cts-reference-app-lib/src"/>
-    <classpathentry kind="src" path="cts/tools/cts-xml-generator/src"/>
-    <classpathentry kind="src" path="cts/tools/dasm/src"/>
-    <classpathentry kind="src" path="cts/tools/device-setup/TestDeviceSetup/src"/>
-    <classpathentry kind="src" path="cts/tools/dex-tools/src"/>
-    <classpathentry kind="src" path="cts/tools/signature-tools/src"/>
-    <classpathentry kind="src" path="cts/tools/signature-tools/test"/>
-    <classpathentry kind="src" path="cts/tools/tradefed-host/src"/>
-    <classpathentry kind="src" path="cts/tools/tradefed-host/tests/src"/>
-    <classpathentry kind="src" path="cts/tools/utils"/>
-    <classpathentry kind="src" path="cts/tools/vm-tests-tf/src"/>
-    <classpathentry kind="src" path="external/easymock/src"/>
+        <classpathentry kind="lib" path="prebuilts/misc/common/ddmlib/ddmlib-prebuilt.jar"/>
+        <classpathentry kind="lib" path="prebuilts/misc/common/tradefed/tradefed-prebuilt.jar"/>
+        <classpathentry kind="src" path="cts/apps/CtsVerifier/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/appsecurity/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/appsecurity/test-apps/AppWithData/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/monkey/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/monkey/test-apps/CtsMonkeyApp/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/monkey/test-apps/CtsMonkeyApp2/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/sample/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/sample/app/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/theme/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/theme/app/src"/>
+        <classpathentry kind="src" path="cts/hostsidetests/usb/src"/>
+        <classpathentry kind="src" path="cts/libs/vogar-expect/src"/>
+        <classpathentry kind="src" path="cts/libs/commonutil/src"/>
+        <classpathentry kind="src" path="cts/libs/deviceutil/src"/>
+        <classpathentry kind="src" path="cts/libs/json/src"/>
+        <classpathentry kind="src" path="cts/libs/testserver/src"/>
+        <classpathentry kind="src" path="cts/libs/wrappedgtest/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/deviceTests/browserbench/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/deviceTests/dram/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/deviceTests/filesystemperf/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/deviceTests/opengl/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/deviceTests/simplecpu/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/deviceTests/ui/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/deviceTests/videoperf/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/hostTests/jank/app/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/hostTests/jank/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/hostTests/uihost/appA/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/hostTests/uihost/appB/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/hostTests/uihost/control/src"/>
+        <classpathentry kind="src" path="cts/suite/cts/hostTests/uihost/src"/>
+        <classpathentry kind="src" path="cts/tests/ProcessTest/src"/>
+        <classpathentry kind="src" path="cts/tests/ProcessTest/NoShareUidApp/src"/>
+        <classpathentry kind="src" path="cts/tests/ProcessTest/ShareUidApp/src"/>
+        <classpathentry kind="src" path="cts/tests/signature/src"/>
+        <classpathentry kind="src" path="cts/tests/signature-tests/src"/>
+        <classpathentry kind="src" path="cts/tests/acceleration/src"/>
+        <classpathentry kind="src" path="cts/tests/core/runner/src"/>
+        <classpathentry kind="src" path="cts/tests/deviceadmin/src"/>
+        <classpathentry kind="src" path="cts/tests/sample/src"/>
+        <classpathentry kind="src" path="cts/tests/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/acceleration/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/accessibility/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/accessibilityservice/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/accounts/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/admin/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/animation/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/app/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/bluetooth/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/content/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/database/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/dpi/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/dpi2/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/drm/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/gesture/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/graphics/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/graphics2/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/hardware/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/jni/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/location/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/media/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/mediastress/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/net/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/opengl/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/openglperf/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/os/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/permission/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/permission2/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/preference/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/preference2/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/provider/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/renderscript/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/security/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/speech/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/telephony/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/text/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/textureview/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/util/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/view/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/webkit/src"/>
+        <classpathentry kind="src" path="cts/tests/tests/widget/src"/>
+        <classpathentry kind="src" path="cts/tools/cts-api-coverage/src"/>
+        <classpathentry kind="src" path="cts/tools/cts-java-scanner/src"/>
+        <classpathentry kind="src" path="cts/tools/cts-java-scanner-doclet/src"/>
+        <classpathentry kind="src" path="cts/tools/cts-native-scanner/src"/>
+        <classpathentry kind="src" path="cts/tools/cts-reference-app-lib/src"/>
+        <classpathentry kind="src" path="cts/tools/cts-xml-generator/src"/>
+        <classpathentry kind="src" path="cts/tools/dasm/src"/>
+        <classpathentry kind="src" path="cts/tools/device-setup/TestDeviceSetup/src"/>
+        <classpathentry kind="src" path="cts/tools/dex-tools/src"/>
+        <classpathentry kind="src" path="cts/tools/signature-tools/src"/>
+        <classpathentry kind="src" path="cts/tools/signature-tools/test"/>
+        <classpathentry kind="src" path="cts/tools/tradefed-host/src"/>
+        <classpathentry kind="src" path="cts/tools/tradefed-host/tests/src"/>
+        <classpathentry kind="src" path="cts/tools/utils"/>
+        <classpathentry kind="src" path="cts/tools/vm-tests-tf/src"/>
+        <classpathentry kind="src" path="external/easymock/src"/>
 </classpath>
diff --git a/development/ide/eclipse/genclasspath.sh b/development/ide/eclipse/genclasspath.sh
index 00ee9b3..9b90d82 100755
--- a/development/ide/eclipse/genclasspath.sh
+++ b/development/ide/eclipse/genclasspath.sh
@@ -13,6 +13,5 @@
 
 echo '<?xml version="1.0" encoding="UTF-8"?>'
 echo '<classpath>'
-cat $ANDROID_BUILD_TOP/cts/development/ide/eclipse/.classpath | grep classpathentry
-cat $ANDROID_BUILD_TOP/development/ide/eclipse/.classpath | grep classpathentry
+cat $ANDROID_BUILD_TOP/cts/development/ide/eclipse/.classpath $ANDROID_BUILD_TOP/development/ide/eclipse/.classpath | grep classpathentry | sort
 echo '</classpath>'
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk b/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
similarity index 95%
rename from hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
rename to hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
index baf540b..e621933 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/Android.mk
@@ -16,7 +16,7 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_PACKAGE_NAME := CtsProfileOwnerApp
+LOCAL_PACKAGE_NAME := CtsDeviceOwnerApp
 
 LOCAL_MODULE_TAGS := optional
 
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
new file mode 100644
index 0000000..7a196bf
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.cts.deviceowner" >
+
+    <uses-sdk android:minSdkVersion="20"/>
+
+    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+        <receiver
+            android:name="com.android.cts.deviceowner.BaseDeviceOwnerTest$BasicAdminReceiver"
+            android:permission="android.permission.BIND_DEVICE_ADMIN">
+            <meta-data android:name="android.app.device_admin"
+                       android:resource="@xml/device_admin" />
+            <intent-filter>
+                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
+            </intent-filter>
+        </receiver>
+        <activity android:name="com.android.cts.deviceowner.ExampleIntentReceivingActivity1">
+            <intent-filter>
+                <action android:name="com.android.cts.deviceowner.EXAMPLE_ACTION" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="com.android.cts.deviceowner.ExampleIntentReceivingActivity2">
+            <intent-filter>
+                <action android:name="com.android.cts.deviceowner.EXAMPLE_ACTION" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+
+        <activity
+            android:name="com.android.cts.deviceowner.LockTaskUtilityActivity" />
+        <activity
+            android:name="com.android.cts.deviceowner.ApplicationRestrictionActivity" />
+    </application>
+
+    <instrumentation android:name="android.test.InstrumentationTestRunner"
+                     android:targetPackage="com.android.cts.deviceowner"
+                     android:label="Device Owner CTS tests"/>
+</manifest>
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/res/xml/device_admin.xml b/hostsidetests/devicepolicy/app/DeviceOwner/res/xml/device_admin.xml
new file mode 100644
index 0000000..fe58d38
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/res/xml/device_admin.xml
@@ -0,0 +1,6 @@
+<device-admin xmlns:android="http://schemas.android.com/apk/res/android" android:visible="false">
+    <uses-policies>
+        <reset-password />
+        <limit-password />
+    </uses-policies>
+</device-admin>
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionActivity.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionActivity.java
new file mode 100644
index 0000000..4d8e4f2
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionActivity.java
@@ -0,0 +1,94 @@
+/*
+ * 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.deviceowner;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.UserManager;
+
+/**
+ * Test activity for setApplicationRestrictions().
+ *
+ * The actual test will set restrictions for this package, and the purpose of this
+ * activity is to listen for the ACTION_APPLICATION_RESTRICTIONS_CHANGED broadcast
+ * and relay the retrieved restriction bundle back to the test for validation.
+ */
+public class ApplicationRestrictionActivity extends Activity {
+
+    // Incoming intent type
+    public static final String FINISH = "finishActivity";
+
+    // Outgoing broadcast
+    public static final String REGISTERED_ACTION =
+            "com.android.cts.deviceowner.APP_RESTRICTION_REGISTERED";
+    public static final String RESTRICTION_ACTION =
+            "com.android.cts.deviceowner.APP_RESTRICTION_VALUE";
+
+    private UserManager mUserManager;
+
+    private final BroadcastReceiver mAppRestrictionReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            broadcastRestriction();
+        }
+    };
+
+    private void broadcastRestriction() {
+        Bundle restrictions = mUserManager.getApplicationRestrictions(getPackageName());
+        Intent intent = new Intent(RESTRICTION_ACTION);
+        intent.putExtra("value", restrictions);
+        sendBroadcast(intent);
+    }
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        handleIntent(intent);
+    }
+
+    @Override
+    protected void onCreate(android.os.Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        handleIntent(getIntent());
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        mUserManager = (UserManager) getSystemService(Context.USER_SERVICE);
+        IntentFilter filter = new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
+        registerReceiver(mAppRestrictionReceiver, filter);
+        sendBroadcast(new Intent(REGISTERED_ACTION));
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        unregisterReceiver(mAppRestrictionReceiver);
+    }
+
+    private void handleIntent(Intent intent) {
+        if (intent.getBooleanExtra(FINISH, false)) {
+            finish();
+        }
+    }
+
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionsTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionsTest.java
new file mode 100644
index 0000000..5e03de9
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ApplicationRestrictionsTest.java
@@ -0,0 +1,199 @@
+/*
+ * 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.deviceowner;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Functionality tests for setApplicationRestrictions and getApplicationRestrictions
+ * in DevicePolicyManager.
+ *
+ * First of all, these two APIs are executed locally to assert that what you set
+ * can later be retrieved via the getter. It also fires up an external activity
+ * (which runs in com.google.android.xts.gmscore, unlike the test code itself
+ * which runs in the test target package com.google.android.gms due to
+ * instrumentation) to observe an application's view of its restrictions.
+ * The activity listens to ACTION_APPLICATION_RESTRICTIONS_CHANGED broadcast
+ * which is fired by the system whenever its restriction is modified,
+ * and relays the value back to this test for verification.
+ */
+public class ApplicationRestrictionsTest extends BaseDeviceOwnerTest {
+
+    private static final String[] testStrings = new String[] {
+            "<bad/>",
+            ">worse!\"£$%^&*()'<",
+            "<JSON>\"{ \\\"One\\\": { \\\"OneOne\\\": \\\"11\\\", \\\""
+                    + "OneTwo\\\": \\\"12\\\" }, \\\"Two\\\": \\\"2\\\" } <JSON/>\""
+    };
+
+    private final Semaphore mOnRegisteredSemaphore = new Semaphore(0);
+    private final Semaphore mOnRestrictionSemaphore = new Semaphore(0);
+    private Bundle mReceivedRestrictions;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(ApplicationRestrictionActivity.REGISTERED_ACTION);
+        filter.addAction(ApplicationRestrictionActivity.RESTRICTION_ACTION);
+        mContext.registerReceiver(mReceiver, filter);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mContext.unregisterReceiver(mReceiver);
+        super.tearDown();
+    }
+
+    public void testSetApplicationRestrictions() {
+        final String CTS_PACKAGE = PACKAGE_NAME;
+        final String OTHER_PACKAGE = CTS_PACKAGE + "dummy";
+
+        startAndWait();
+
+        Bundle bundle0 = createBundle0();
+        Bundle bundle1 = createBundle1();
+
+        // Test setting restrictions
+        mDevicePolicyManager.setApplicationRestrictions(getWho(), CTS_PACKAGE, bundle0);
+        mDevicePolicyManager.setApplicationRestrictions(getWho(), OTHER_PACKAGE, bundle1);
+
+        // Retrieve restrictions locally and make sure they are what we put in.
+        assertBundle0(mDevicePolicyManager.getApplicationRestrictions(getWho(), CTS_PACKAGE));
+        assertBundle1(mDevicePolicyManager.getApplicationRestrictions(getWho(), OTHER_PACKAGE));
+
+        // The test activity should have received a change_restriction broadcast
+        // and relay the value back to us.
+        assertBundle0(waitForChangedRestriction());
+
+        // Test overwriting
+        mDevicePolicyManager.setApplicationRestrictions(getWho(), CTS_PACKAGE, bundle1);
+        assertBundle1(mDevicePolicyManager.getApplicationRestrictions(getWho(), CTS_PACKAGE));
+        assertBundle1(waitForChangedRestriction());
+
+        // Cleanup
+        mDevicePolicyManager.setApplicationRestrictions(getWho(), CTS_PACKAGE, new Bundle());
+        assertTrue(
+                mDevicePolicyManager.getApplicationRestrictions(getWho(), CTS_PACKAGE).isEmpty());
+        assertTrue(waitForChangedRestriction().isEmpty());
+        mDevicePolicyManager.setApplicationRestrictions(getWho(), OTHER_PACKAGE, new Bundle());
+        assertTrue(
+                mDevicePolicyManager.getApplicationRestrictions(getWho(), OTHER_PACKAGE).isEmpty());
+
+        finish();
+    }
+
+    // Should be consistent with assertBundle0
+    private Bundle createBundle0() {
+        Bundle result = new Bundle();
+        // Tests for four allowed types: Integer, Boolean, String and String[]
+        // Also test for string escaping handling
+        result.putBoolean("boolean_0", false);
+        result.putBoolean("boolean_1", true);
+        result.putInt("integer", 0x7fffffff);
+        // If a null is stored, "" will be read back
+        result.putString("empty", "");
+        result.putString("string", "text");
+        result.putStringArray("string[]", testStrings);
+        return result;
+    }
+
+    // Should be consistent with createBundle0
+    private void assertBundle0(Bundle bundle) {
+        assertEquals(6, bundle.size());
+        assertEquals(false, bundle.getBoolean("boolean_0"));
+        assertEquals(true, bundle.getBoolean("boolean_1"));
+        assertEquals(0x7fffffff, bundle.getInt("integer"));
+        assertEquals("", bundle.getString("empty"));
+        assertEquals("text", bundle.getString("string"));
+
+        String[] strings = bundle.getStringArray("string[]");
+        assertTrue(strings != null && strings.length == testStrings.length);
+        for (int i = 0; i < strings.length; i++) {
+            assertEquals(strings[i], testStrings[i]);
+        }
+    }
+
+    // Should be consistent with assertBundle1
+    private Bundle createBundle1() {
+        Bundle result = new Bundle();
+        result.putInt("dummy", 1);
+        return result;
+    }
+
+    // Should be consistent with createBundle1
+    private void assertBundle1(Bundle bundle) {
+        assertEquals(1, bundle.size());
+        assertEquals(1, bundle.getInt("dummy"));
+    }
+
+    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            if (ApplicationRestrictionActivity.REGISTERED_ACTION.equals(action)) {
+                mOnRegisteredSemaphore.release();
+            } else if (ApplicationRestrictionActivity.RESTRICTION_ACTION.equals(action)) {
+                mReceivedRestrictions = intent.getBundleExtra("value");
+                mOnRestrictionSemaphore.release();
+            }
+        }
+    };
+
+    private void startTestActivity(String command) {
+        Intent intent = new Intent();
+        intent.setClassName(PACKAGE_NAME, ApplicationRestrictionActivity.class.getName());
+        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
+
+        if (command != null) {
+            intent.putExtra(command, true);
+        }
+        mContext.startActivity(intent);
+    }
+
+    private void startAndWait() {
+        startTestActivity(null);
+        // Wait until the activity has registered its broadcast receiver and ready for incoming
+        // restriction changes.
+        try {
+            assertTrue(mOnRegisteredSemaphore.tryAcquire(5, TimeUnit.SECONDS));
+        } catch (InterruptedException e) {
+            fail("Start ApplicationRestrictionActivity interrupted");
+        }
+    }
+
+    private Bundle waitForChangedRestriction() {
+        try {
+            assertTrue(mOnRestrictionSemaphore.tryAcquire(5, TimeUnit.SECONDS));
+        } catch (InterruptedException e) {
+            fail("getRestrictionsAndWait() interrupted");
+        }
+
+        return mReceivedRestrictions;
+    }
+
+    private void finish() {
+        startTestActivity(ApplicationRestrictionActivity.FINISH);
+    }
+
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BaseDeviceOwnerTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BaseDeviceOwnerTest.java
new file mode 100644
index 0000000..e4f5134
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/BaseDeviceOwnerTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.deviceowner;
+
+import android.app.admin.DeviceAdminReceiver;
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.test.AndroidTestCase;
+
+/**
+ * Base class for device-owner based tests.
+ *
+ * This class handles making sure that the test is the device owner
+ * and that it has an active admin registered, so that all tests may
+ * assume these are done. The admin component can be accessed through
+ * {@link #getWho()}.
+ */
+public class BaseDeviceOwnerTest extends AndroidTestCase {
+
+    public static class BasicAdminReceiver extends DeviceAdminReceiver {
+    }
+
+    public static final String PACKAGE_NAME = BaseDeviceOwnerTest.class.getPackage().getName();
+
+    protected DevicePolicyManager mDevicePolicyManager;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mDevicePolicyManager = (DevicePolicyManager)
+                mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
+        assertTrue(mDevicePolicyManager.isAdminActive(getWho()));
+        assertTrue(mDevicePolicyManager.isDeviceOwnerApp(PACKAGE_NAME));
+    }
+
+    public static ComponentName getWho() {
+        return new ComponentName(PACKAGE_NAME, BasicAdminReceiver.class.getName());
+    }
+}
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CaCertManagementTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CaCertManagementTest.java
new file mode 100644
index 0000000..9127dab
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/CaCertManagementTest.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.cts.deviceowner;
+
+import static com.android.cts.deviceowner.FakeKeys.FAKE_RSA_1;
+import static com.android.cts.deviceowner.FakeKeys.FAKE_DSA_1;
+
+import java.io.ByteArrayInputStream;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.Certificate;
+import java.util.List;
+
+public class CaCertManagementTest extends BaseDeviceOwnerTest {
+    public void testCanRetrieveListOfInstalledCaCerts() {
+        List<byte[]> caCerts = mDevicePolicyManager.getInstalledCaCerts(getWho());
+        assertNotNull(caCerts);
+    }
+
+    public void testCanInstallAndUninstallACaCert()
+    throws CertificateException {
+        assertFalse(hasCaCertInstalled(FAKE_RSA_1.caCertificate));
+        assertFalse(hasCaCertInstalled(FAKE_DSA_1.caCertificate));
+        assertTrue(mDevicePolicyManager.installCaCert(getWho(), FAKE_RSA_1.caCertificate));
+        assertTrue(hasCaCertInstalled(FAKE_RSA_1.caCertificate));
+        assertFalse(hasCaCertInstalled(FAKE_DSA_1.caCertificate));
+        mDevicePolicyManager.uninstallCaCert(getWho(), FAKE_RSA_1.caCertificate);
+        assertFalse(hasCaCertInstalled(FAKE_RSA_1.caCertificate));
+        assertFalse(hasCaCertInstalled(FAKE_DSA_1.caCertificate));
+    }
+
+    public void testUninstallationIsSelective() throws CertificateException {
+        assertTrue(mDevicePolicyManager.installCaCert(getWho(), FAKE_RSA_1.caCertificate));
+        assertTrue(mDevicePolicyManager.installCaCert(getWho(), FAKE_DSA_1.caCertificate));
+        mDevicePolicyManager.uninstallCaCert(getWho(), FAKE_DSA_1.caCertificate);
+        assertTrue(hasCaCertInstalled(FAKE_RSA_1.caCertificate));
+        assertFalse(hasCaCertInstalled(FAKE_DSA_1.caCertificate));
+        mDevicePolicyManager.uninstallCaCert(getWho(), FAKE_RSA_1.caCertificate);
+    }
+
+    public void testCanUninstallAllUserCaCerts() throws CertificateException {
+        assertTrue(mDevicePolicyManager.installCaCert(getWho(), FAKE_RSA_1.caCertificate));
+        assertTrue(mDevicePolicyManager.installCaCert(getWho(), FAKE_DSA_1.caCertificate));
+        mDevicePolicyManager.uninstallAllUserCaCerts(getWho());
+        assertFalse(hasCaCertInstalled(FAKE_RSA_1.caCertificate));
+        assertFalse(hasCaCertInstalled(FAKE_DSA_1.caCertificate));
+    }
+
+    private boolean hasCaCertInstalled(byte [] caCert) throws CertificateException {
+        boolean result = mDevicePolicyManager.hasCaCertInstalled(getWho(), caCert);
+        assertEquals(result, containsCertificate(
+            mDevicePolicyManager.getInstalledCaCerts(getWho()), caCert));
+        return result;
+    }
+
+    private static boolean containsCertificate(List<byte[]> certificates, byte [] toMatch)
+            throws CertificateException {
+        Certificate certificateToMatch = readCertificate(toMatch);
+        for (byte[] certBuffer : certificates) {
+            Certificate cert = readCertificate(certBuffer);
+            if (certificateToMatch.equals(cert)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static Certificate readCertificate(byte[] certBuffer) throws CertificateException {
+        final CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
+        return certFactory.generateCertificate(new ByteArrayInputStream(certBuffer));
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ClearDeviceOwnerTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ClearDeviceOwnerTest.java
new file mode 100644
index 0000000..f10124a
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ClearDeviceOwnerTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.deviceowner;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.test.AndroidTestCase;
+
+public class ClearDeviceOwnerTest extends AndroidTestCase {
+
+    private DevicePolicyManager mDevicePolicyManager;
+
+    @Override
+    protected void tearDown() throws Exception {
+        mDevicePolicyManager = (DevicePolicyManager)
+                mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
+        if (mDevicePolicyManager != null) {
+            removeActiveAdmin(BaseDeviceOwnerTest.getWho());
+            if (mDevicePolicyManager.isDeviceOwnerApp(BaseDeviceOwnerTest.PACKAGE_NAME)) {
+                mDevicePolicyManager.clearDeviceOwnerApp(BaseDeviceOwnerTest.PACKAGE_NAME);
+            }
+            assertFalse(mDevicePolicyManager.isAdminActive(BaseDeviceOwnerTest.getWho()));
+            assertFalse(mDevicePolicyManager.isDeviceOwnerApp(BaseDeviceOwnerTest.PACKAGE_NAME));
+        }
+
+        super.tearDown();
+    }
+
+    // This test clears the device owner and active admin on tearDown(). To be called from the host
+    // side test once a test case is finished.
+    public void testClearDeviceOwner() {
+    }
+
+    private void removeActiveAdmin(ComponentName cn) throws InterruptedException {
+        if (mDevicePolicyManager.isAdminActive(cn)) {
+            mDevicePolicyManager.removeActiveAdmin(cn);
+            for (int i = 0; i < 1000 && mDevicePolicyManager.isAdminActive(cn); i++) {
+                Thread.sleep(100);
+            }
+        }
+    }
+}
diff --git a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/AbstractClass.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceOwnerSetupTest.java
similarity index 62%
copy from tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/AbstractClass.java
copy to hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceOwnerSetupTest.java
index d24d691..e6441ef 100644
--- a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/AbstractClass.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/DeviceOwnerSetupTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * 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.
@@ -14,11 +14,14 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest.tests.data;
+package com.android.cts.deviceowner;
 
-/**
-* This class is used as reference data for the JDiffClassDescriptionTest tests.
-*/
-public abstract class AbstractClass {
+
+public class DeviceOwnerSetupTest extends BaseDeviceOwnerTest {
+
+    // This test verifies that the setup assertions are working to verify
+    // we are the device owner and have a valid active admin.
+    public void testEmptyTest() {
+    }
 
 }
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java
similarity index 61%
copy from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java
copy to hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java
index 2cd3ad9..03ca9a4 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity1.java
@@ -13,24 +13,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+
+package com.android.cts.deviceowner;
 
 import android.app.Activity;
+import android.content.Intent;
 import android.os.Bundle;
-import android.util.Log;
 
-/**
- * Activity that lives in the managed profile.
- */
-public class ManagedProfileActivity extends Activity {
-    private static final String TAG = ManagedProfileActivity.class.getName();
-
-    public static final String ACTION =
-            "com.android.cts.profileowner.ACTION_TEST_MANAGED_ACTIVITY";
+public class ExampleIntentReceivingActivity1 extends Activity {
+    public static final String CONFIRM_ACTION = "com.android.cts.deviceowner.CONFIRM_1";
 
     @Override
-    public void onCreate(Bundle savedInstanceState) {
+    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        Log.i(TAG, "Roger that!");
+        if (getIntent().getAction().equals(PersistentIntentResolvingTest.EXAMPLE_ACTION)) {
+            sendBroadcast(new Intent(CONFIRM_ACTION));
+        }
+        finish();
     }
-}
\ No newline at end of file
+}
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity2.java
similarity index 61%
copy from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java
copy to hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity2.java
index 2cd3ad9..65ccb36 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ExampleIntentReceivingActivity2.java
@@ -13,24 +13,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+
+package com.android.cts.deviceowner;
 
 import android.app.Activity;
+import android.content.Intent;
 import android.os.Bundle;
-import android.util.Log;
 
-/**
- * Activity that lives in the managed profile.
- */
-public class ManagedProfileActivity extends Activity {
-    private static final String TAG = ManagedProfileActivity.class.getName();
-
-    public static final String ACTION =
-            "com.android.cts.profileowner.ACTION_TEST_MANAGED_ACTIVITY";
+public class ExampleIntentReceivingActivity2 extends Activity {
+    public static final String CONFIRM_ACTION = "com.android.cts.deviceowner.CONFIRM_2";
 
     @Override
-    public void onCreate(Bundle savedInstanceState) {
+    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        Log.i(TAG, "Roger that!");
+        if (getIntent().getAction().equals(PersistentIntentResolvingTest.EXAMPLE_ACTION)) {
+            sendBroadcast(new Intent(CONFIRM_ACTION));
+        }
+        finish();
     }
-}
\ No newline at end of file
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/FakeKeys.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/FakeKeys.java
new file mode 100644
index 0000000..11df8e5
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/FakeKeys.java
@@ -0,0 +1,469 @@
+/*
+ * 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.deviceowner;
+
+// Copied from cts/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
+
+public class FakeKeys {
+    /*
+     * The keys and certificates below are generated with:
+     *
+     * openssl req -new -x509 -days 3650 -extensions v3_ca -keyout cakey.pem -out cacert.pem
+     * openssl req -newkey rsa:1024 -keyout userkey.pem -nodes -days 3650 -out userkey.req
+     * mkdir -p demoCA/newcerts
+     * touch demoCA/index.txt
+     * echo "01" > demoCA/serial
+     * openssl ca -out usercert.pem -in userkey.req -cert cacert.pem -keyfile cakey.pem -days 3650
+     */
+    public static class FAKE_RSA_1 {
+        /**
+         * Generated from above and converted with:
+         *
+         * openssl pkcs8 -topk8 -outform d -in userkey.pem -nocrypt | xxd -i | sed 's/0x/(byte) 0x/g'
+         */
+        public static final byte[] privateKey = {
+            (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x78, (byte) 0x02, (byte) 0x01,
+            (byte) 0x00, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a,
+            (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01,
+            (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x82,
+            (byte) 0x02, (byte) 0x62, (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x5e,
+            (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x81, (byte) 0x81,
+            (byte) 0x00, (byte) 0xce, (byte) 0x29, (byte) 0xeb, (byte) 0xf6, (byte) 0x5b,
+            (byte) 0x25, (byte) 0xdc, (byte) 0xa1, (byte) 0xa6, (byte) 0x2c, (byte) 0x66,
+            (byte) 0xcb, (byte) 0x20, (byte) 0x90, (byte) 0x27, (byte) 0x86, (byte) 0x8a,
+            (byte) 0x44, (byte) 0x71, (byte) 0x50, (byte) 0xda, (byte) 0xd3, (byte) 0x02,
+            (byte) 0x77, (byte) 0x55, (byte) 0xe9, (byte) 0xe8, (byte) 0x08, (byte) 0xf3,
+            (byte) 0x36, (byte) 0x9a, (byte) 0xae, (byte) 0xab, (byte) 0x04, (byte) 0x6d,
+            (byte) 0x00, (byte) 0x99, (byte) 0xbf, (byte) 0x7d, (byte) 0x0f, (byte) 0x67,
+            (byte) 0x8b, (byte) 0x1d, (byte) 0xd4, (byte) 0x2b, (byte) 0x7c, (byte) 0xcb,
+            (byte) 0xcd, (byte) 0x33, (byte) 0xc7, (byte) 0x84, (byte) 0x30, (byte) 0xe2,
+            (byte) 0x45, (byte) 0x21, (byte) 0xb3, (byte) 0x75, (byte) 0xf5, (byte) 0x79,
+            (byte) 0x02, (byte) 0xda, (byte) 0x50, (byte) 0xa3, (byte) 0x8b, (byte) 0xce,
+            (byte) 0xc3, (byte) 0x8e, (byte) 0x0f, (byte) 0x25, (byte) 0xeb, (byte) 0x08,
+            (byte) 0x2c, (byte) 0xdd, (byte) 0x1c, (byte) 0xcf, (byte) 0xff, (byte) 0x3b,
+            (byte) 0xde, (byte) 0xb6, (byte) 0xaa, (byte) 0x2a, (byte) 0xa9, (byte) 0xc4,
+            (byte) 0x8a, (byte) 0x24, (byte) 0x24, (byte) 0xe6, (byte) 0x29, (byte) 0x0d,
+            (byte) 0x98, (byte) 0x4c, (byte) 0x32, (byte) 0xa1, (byte) 0x7b, (byte) 0x23,
+            (byte) 0x2b, (byte) 0x42, (byte) 0x30, (byte) 0xee, (byte) 0x78, (byte) 0x08,
+            (byte) 0x47, (byte) 0xad, (byte) 0xf2, (byte) 0x96, (byte) 0xd5, (byte) 0xf1,
+            (byte) 0x62, (byte) 0x42, (byte) 0x2d, (byte) 0x35, (byte) 0x19, (byte) 0xb4,
+            (byte) 0x3c, (byte) 0xc9, (byte) 0xc3, (byte) 0x5f, (byte) 0x03, (byte) 0x16,
+            (byte) 0x3a, (byte) 0x23, (byte) 0xac, (byte) 0xcb, (byte) 0xce, (byte) 0x9e,
+            (byte) 0x51, (byte) 0x2e, (byte) 0x6d, (byte) 0x02, (byte) 0x03, (byte) 0x01,
+            (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x81, (byte) 0x80, (byte) 0x16,
+            (byte) 0x59, (byte) 0xc3, (byte) 0x24, (byte) 0x1d, (byte) 0x33, (byte) 0x98,
+            (byte) 0x9c, (byte) 0xc9, (byte) 0xc8, (byte) 0x2c, (byte) 0x88, (byte) 0xbf,
+            (byte) 0x0a, (byte) 0x01, (byte) 0xce, (byte) 0xfb, (byte) 0x34, (byte) 0x7a,
+            (byte) 0x58, (byte) 0x7a, (byte) 0xb0, (byte) 0xbf, (byte) 0xa6, (byte) 0xb2,
+            (byte) 0x60, (byte) 0xbe, (byte) 0x70, (byte) 0x21, (byte) 0xf5, (byte) 0xfc,
+            (byte) 0x85, (byte) 0x0d, (byte) 0x33, (byte) 0x58, (byte) 0xa1, (byte) 0xe5,
+            (byte) 0x09, (byte) 0x36, (byte) 0x84, (byte) 0xb2, (byte) 0x04, (byte) 0x0a,
+            (byte) 0x02, (byte) 0xd3, (byte) 0x88, (byte) 0x1f, (byte) 0x0c, (byte) 0x2b,
+            (byte) 0x1d, (byte) 0xe9, (byte) 0x3d, (byte) 0xe7, (byte) 0x79, (byte) 0xf9,
+            (byte) 0x32, (byte) 0x5c, (byte) 0x8a, (byte) 0x75, (byte) 0x49, (byte) 0x12,
+            (byte) 0xe4, (byte) 0x05, (byte) 0x26, (byte) 0xd4, (byte) 0x2e, (byte) 0x9e,
+            (byte) 0x1f, (byte) 0xcc, (byte) 0x54, (byte) 0xad, (byte) 0x33, (byte) 0x8d,
+            (byte) 0x99, (byte) 0x00, (byte) 0xdc, (byte) 0xf5, (byte) 0xb4, (byte) 0xa2,
+            (byte) 0x2f, (byte) 0xba, (byte) 0xe5, (byte) 0x62, (byte) 0x30, (byte) 0x6d,
+            (byte) 0xe6, (byte) 0x3d, (byte) 0xeb, (byte) 0x24, (byte) 0xc2, (byte) 0xdc,
+            (byte) 0x5f, (byte) 0xb7, (byte) 0x16, (byte) 0x35, (byte) 0xa3, (byte) 0x98,
+            (byte) 0x98, (byte) 0xa8, (byte) 0xef, (byte) 0xe8, (byte) 0xc4, (byte) 0x96,
+            (byte) 0x6d, (byte) 0x38, (byte) 0xab, (byte) 0x26, (byte) 0x6d, (byte) 0x30,
+            (byte) 0xc2, (byte) 0xa0, (byte) 0x44, (byte) 0xe4, (byte) 0xff, (byte) 0x7e,
+            (byte) 0xbe, (byte) 0x7c, (byte) 0x33, (byte) 0xa5, (byte) 0x10, (byte) 0xad,
+            (byte) 0xd7, (byte) 0x1e, (byte) 0x13, (byte) 0x20, (byte) 0xb3, (byte) 0x1f,
+            (byte) 0x41, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xf1, (byte) 0x89,
+            (byte) 0x07, (byte) 0x0f, (byte) 0xe8, (byte) 0xcf, (byte) 0xab, (byte) 0x13,
+            (byte) 0x2a, (byte) 0x8f, (byte) 0x88, (byte) 0x80, (byte) 0x11, (byte) 0x9a,
+            (byte) 0x79, (byte) 0xb6, (byte) 0x59, (byte) 0x3a, (byte) 0x50, (byte) 0x6e,
+            (byte) 0x57, (byte) 0x37, (byte) 0xab, (byte) 0x2a, (byte) 0xd2, (byte) 0xaa,
+            (byte) 0xd9, (byte) 0x72, (byte) 0x73, (byte) 0xff, (byte) 0x8b, (byte) 0x47,
+            (byte) 0x76, (byte) 0xdd, (byte) 0xdc, (byte) 0xf5, (byte) 0x97, (byte) 0x44,
+            (byte) 0x3a, (byte) 0x78, (byte) 0xbe, (byte) 0x17, (byte) 0xb4, (byte) 0x22,
+            (byte) 0x6f, (byte) 0xe5, (byte) 0x23, (byte) 0x70, (byte) 0x1d, (byte) 0x10,
+            (byte) 0x5d, (byte) 0xba, (byte) 0x16, (byte) 0x81, (byte) 0xf1, (byte) 0x45,
+            (byte) 0xce, (byte) 0x30, (byte) 0xb4, (byte) 0xab, (byte) 0x80, (byte) 0xe4,
+            (byte) 0x98, (byte) 0x31, (byte) 0x02, (byte) 0x41, (byte) 0x00, (byte) 0xda,
+            (byte) 0x82, (byte) 0x9d, (byte) 0x3f, (byte) 0xca, (byte) 0x2f, (byte) 0xe1,
+            (byte) 0xd4, (byte) 0x86, (byte) 0x77, (byte) 0x48, (byte) 0xa6, (byte) 0xab,
+            (byte) 0xab, (byte) 0x1c, (byte) 0x42, (byte) 0x5c, (byte) 0xd5, (byte) 0xc7,
+            (byte) 0x46, (byte) 0x59, (byte) 0x91, (byte) 0x3f, (byte) 0xfc, (byte) 0xcc,
+            (byte) 0xec, (byte) 0xc2, (byte) 0x40, (byte) 0x12, (byte) 0x2c, (byte) 0x8d,
+            (byte) 0x1f, (byte) 0xa2, (byte) 0x18, (byte) 0x88, (byte) 0xee, (byte) 0x82,
+            (byte) 0x4a, (byte) 0x5a, (byte) 0x5e, (byte) 0x88, (byte) 0x20, (byte) 0xe3,
+            (byte) 0x7b, (byte) 0xe0, (byte) 0xd8, (byte) 0x3a, (byte) 0x52, (byte) 0x9a,
+            (byte) 0x26, (byte) 0x6a, (byte) 0x04, (byte) 0xec, (byte) 0xe8, (byte) 0xb9,
+            (byte) 0x48, (byte) 0x40, (byte) 0xe1, (byte) 0xe1, (byte) 0x83, (byte) 0xa6,
+            (byte) 0x67, (byte) 0xa6, (byte) 0xfd, (byte) 0x02, (byte) 0x41, (byte) 0x00,
+            (byte) 0x89, (byte) 0x72, (byte) 0x3e, (byte) 0xb0, (byte) 0x90, (byte) 0xfd,
+            (byte) 0x4c, (byte) 0x0e, (byte) 0xd6, (byte) 0x13, (byte) 0x63, (byte) 0xcb,
+            (byte) 0xed, (byte) 0x38, (byte) 0x88, (byte) 0xb6, (byte) 0x79, (byte) 0xc4,
+            (byte) 0x33, (byte) 0x6c, (byte) 0xf6, (byte) 0xf8, (byte) 0xd8, (byte) 0xd0,
+            (byte) 0xbf, (byte) 0x9d, (byte) 0x35, (byte) 0xac, (byte) 0x69, (byte) 0xd2,
+            (byte) 0x2b, (byte) 0xc1, (byte) 0xf9, (byte) 0x24, (byte) 0x7b, (byte) 0xce,
+            (byte) 0xcd, (byte) 0xcb, (byte) 0xa7, (byte) 0xb2, (byte) 0x7a, (byte) 0x0a,
+            (byte) 0x27, (byte) 0x19, (byte) 0xc9, (byte) 0xaf, (byte) 0x0d, (byte) 0x21,
+            (byte) 0x89, (byte) 0x88, (byte) 0x7c, (byte) 0xad, (byte) 0x9e, (byte) 0x8d,
+            (byte) 0x47, (byte) 0x6d, (byte) 0x3f, (byte) 0xce, (byte) 0x7b, (byte) 0xa1,
+            (byte) 0x74, (byte) 0xf1, (byte) 0xa0, (byte) 0xa1, (byte) 0x02, (byte) 0x41,
+            (byte) 0x00, (byte) 0xd9, (byte) 0xa8, (byte) 0xf5, (byte) 0xfe, (byte) 0xce,
+            (byte) 0xe6, (byte) 0x77, (byte) 0x6b, (byte) 0xfe, (byte) 0x2d, (byte) 0xe0,
+            (byte) 0x1e, (byte) 0xb6, (byte) 0x2e, (byte) 0x12, (byte) 0x4e, (byte) 0x40,
+            (byte) 0xaf, (byte) 0x6a, (byte) 0x7b, (byte) 0x37, (byte) 0x49, (byte) 0x2a,
+            (byte) 0x96, (byte) 0x25, (byte) 0x83, (byte) 0x49, (byte) 0xd4, (byte) 0x0c,
+            (byte) 0xc6, (byte) 0x78, (byte) 0x25, (byte) 0x24, (byte) 0x90, (byte) 0x90,
+            (byte) 0x06, (byte) 0x15, (byte) 0x9e, (byte) 0xfe, (byte) 0xf9, (byte) 0xdf,
+            (byte) 0x5b, (byte) 0xf3, (byte) 0x7e, (byte) 0x38, (byte) 0x70, (byte) 0xeb,
+            (byte) 0x57, (byte) 0xd0, (byte) 0xd9, (byte) 0xa7, (byte) 0x0e, (byte) 0x14,
+            (byte) 0xf7, (byte) 0x95, (byte) 0x68, (byte) 0xd5, (byte) 0xc8, (byte) 0xab,
+            (byte) 0x9d, (byte) 0x3a, (byte) 0x2b, (byte) 0x51, (byte) 0xf9, (byte) 0x02,
+            (byte) 0x41, (byte) 0x00, (byte) 0x96, (byte) 0xdf, (byte) 0xe9, (byte) 0x67,
+            (byte) 0x6c, (byte) 0xdc, (byte) 0x90, (byte) 0x14, (byte) 0xb4, (byte) 0x1d,
+            (byte) 0x22, (byte) 0x33, (byte) 0x4a, (byte) 0x31, (byte) 0xc1, (byte) 0x9d,
+            (byte) 0x2e, (byte) 0xff, (byte) 0x9a, (byte) 0x2a, (byte) 0x95, (byte) 0x4b,
+            (byte) 0x27, (byte) 0x74, (byte) 0xcb, (byte) 0x21, (byte) 0xc3, (byte) 0xd2,
+            (byte) 0x0b, (byte) 0xb2, (byte) 0x46, (byte) 0x87, (byte) 0xf8, (byte) 0x28,
+            (byte) 0x01, (byte) 0x8b, (byte) 0xd8, (byte) 0xb9, (byte) 0x4b, (byte) 0xcd,
+            (byte) 0x9a, (byte) 0x96, (byte) 0x41, (byte) 0x0e, (byte) 0x36, (byte) 0x6d,
+            (byte) 0x40, (byte) 0x42, (byte) 0xbc, (byte) 0xd9, (byte) 0xd3, (byte) 0x7b,
+            (byte) 0xbc, (byte) 0xa7, (byte) 0x92, (byte) 0x90, (byte) 0xdd, (byte) 0xa1,
+            (byte) 0x9c, (byte) 0xce, (byte) 0xa1, (byte) 0x87, (byte) 0x11, (byte) 0x51
+        };
+
+        /**
+         * Generated from above and converted with:
+         *
+         * openssl x509 -outform d -in cacert.pem | xxd -i | sed 's/0x/(byte) 0x/g'
+         */
+        public static final byte[] caCertificate = {
+            (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0xce, (byte) 0x30, (byte) 0x82,
+            (byte) 0x02, (byte) 0x37, (byte) 0xa0, (byte) 0x03, (byte) 0x02, (byte) 0x01,
+            (byte) 0x02, (byte) 0x02, (byte) 0x09, (byte) 0x00, (byte) 0xe1, (byte) 0x6a,
+            (byte) 0xa2, (byte) 0xf4, (byte) 0x2e, (byte) 0x55, (byte) 0x48, (byte) 0x0a,
+            (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a, (byte) 0x86,
+            (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01, (byte) 0x01,
+            (byte) 0x05, (byte) 0x05, (byte) 0x00, (byte) 0x30, (byte) 0x4f, (byte) 0x31,
+            (byte) 0x0b, (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+            (byte) 0x04, (byte) 0x06, (byte) 0x13, (byte) 0x02, (byte) 0x55, (byte) 0x53,
+            (byte) 0x31, (byte) 0x0b, (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03,
+            (byte) 0x55, (byte) 0x04, (byte) 0x08, (byte) 0x13, (byte) 0x02, (byte) 0x43,
+            (byte) 0x41, (byte) 0x31, (byte) 0x16, (byte) 0x30, (byte) 0x14, (byte) 0x06,
+            (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x07, (byte) 0x13, (byte) 0x0d,
+            (byte) 0x4d, (byte) 0x6f, (byte) 0x75, (byte) 0x6e, (byte) 0x74, (byte) 0x61,
+            (byte) 0x69, (byte) 0x6e, (byte) 0x20, (byte) 0x56, (byte) 0x69, (byte) 0x65,
+            (byte) 0x77, (byte) 0x31, (byte) 0x1b, (byte) 0x30, (byte) 0x19, (byte) 0x06,
+            (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x0a, (byte) 0x13, (byte) 0x12,
+            (byte) 0x41, (byte) 0x6e, (byte) 0x64, (byte) 0x72, (byte) 0x6f, (byte) 0x69,
+            (byte) 0x64, (byte) 0x20, (byte) 0x54, (byte) 0x65, (byte) 0x73, (byte) 0x74,
+            (byte) 0x20, (byte) 0x43, (byte) 0x61, (byte) 0x73, (byte) 0x65, (byte) 0x73,
+            (byte) 0x30, (byte) 0x1e, (byte) 0x17, (byte) 0x0d, (byte) 0x31, (byte) 0x32,
+            (byte) 0x30, (byte) 0x38, (byte) 0x31, (byte) 0x34, (byte) 0x31, (byte) 0x36,
+            (byte) 0x35, (byte) 0x35, (byte) 0x34, (byte) 0x34, (byte) 0x5a, (byte) 0x17,
+            (byte) 0x0d, (byte) 0x32, (byte) 0x32, (byte) 0x30, (byte) 0x38, (byte) 0x31,
+            (byte) 0x32, (byte) 0x31, (byte) 0x36, (byte) 0x35, (byte) 0x35, (byte) 0x34,
+            (byte) 0x34, (byte) 0x5a, (byte) 0x30, (byte) 0x4f, (byte) 0x31, (byte) 0x0b,
+            (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04,
+            (byte) 0x06, (byte) 0x13, (byte) 0x02, (byte) 0x55, (byte) 0x53, (byte) 0x31,
+            (byte) 0x0b, (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+            (byte) 0x04, (byte) 0x08, (byte) 0x13, (byte) 0x02, (byte) 0x43, (byte) 0x41,
+            (byte) 0x31, (byte) 0x16, (byte) 0x30, (byte) 0x14, (byte) 0x06, (byte) 0x03,
+            (byte) 0x55, (byte) 0x04, (byte) 0x07, (byte) 0x13, (byte) 0x0d, (byte) 0x4d,
+            (byte) 0x6f, (byte) 0x75, (byte) 0x6e, (byte) 0x74, (byte) 0x61, (byte) 0x69,
+            (byte) 0x6e, (byte) 0x20, (byte) 0x56, (byte) 0x69, (byte) 0x65, (byte) 0x77,
+            (byte) 0x31, (byte) 0x1b, (byte) 0x30, (byte) 0x19, (byte) 0x06, (byte) 0x03,
+            (byte) 0x55, (byte) 0x04, (byte) 0x0a, (byte) 0x13, (byte) 0x12, (byte) 0x41,
+            (byte) 0x6e, (byte) 0x64, (byte) 0x72, (byte) 0x6f, (byte) 0x69, (byte) 0x64,
+            (byte) 0x20, (byte) 0x54, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x20,
+            (byte) 0x43, (byte) 0x61, (byte) 0x73, (byte) 0x65, (byte) 0x73, (byte) 0x30,
+            (byte) 0x81, (byte) 0x9f, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09,
+            (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d,
+            (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x03,
+            (byte) 0x81, (byte) 0x8d, (byte) 0x00, (byte) 0x30, (byte) 0x81, (byte) 0x89,
+            (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00, (byte) 0xa3, (byte) 0x72,
+            (byte) 0xab, (byte) 0xd0, (byte) 0xe4, (byte) 0xad, (byte) 0x2f, (byte) 0xe7,
+            (byte) 0xe2, (byte) 0x79, (byte) 0x07, (byte) 0x36, (byte) 0x3d, (byte) 0x0c,
+            (byte) 0x8d, (byte) 0x42, (byte) 0x9a, (byte) 0x0a, (byte) 0x33, (byte) 0x64,
+            (byte) 0xb3, (byte) 0xcd, (byte) 0xb2, (byte) 0xd7, (byte) 0x3a, (byte) 0x42,
+            (byte) 0x06, (byte) 0x77, (byte) 0x45, (byte) 0x29, (byte) 0xe9, (byte) 0xcb,
+            (byte) 0xb7, (byte) 0x4a, (byte) 0xd6, (byte) 0xee, (byte) 0xad, (byte) 0x01,
+            (byte) 0x91, (byte) 0x9b, (byte) 0x0c, (byte) 0x59, (byte) 0xa1, (byte) 0x03,
+            (byte) 0xfa, (byte) 0xf0, (byte) 0x5a, (byte) 0x7c, (byte) 0x4f, (byte) 0xf7,
+            (byte) 0x8d, (byte) 0x36, (byte) 0x0f, (byte) 0x1f, (byte) 0x45, (byte) 0x7d,
+            (byte) 0x1b, (byte) 0x31, (byte) 0xa1, (byte) 0x35, (byte) 0x0b, (byte) 0x00,
+            (byte) 0xed, (byte) 0x7a, (byte) 0xb6, (byte) 0xc8, (byte) 0x4e, (byte) 0xa9,
+            (byte) 0x86, (byte) 0x4c, (byte) 0x7b, (byte) 0x99, (byte) 0x57, (byte) 0x41,
+            (byte) 0x12, (byte) 0xef, (byte) 0x6b, (byte) 0xbc, (byte) 0x3d, (byte) 0x60,
+            (byte) 0xf2, (byte) 0x99, (byte) 0x1a, (byte) 0xcd, (byte) 0xed, (byte) 0x56,
+            (byte) 0xa4, (byte) 0xe5, (byte) 0x36, (byte) 0x9f, (byte) 0x24, (byte) 0x1f,
+            (byte) 0xdc, (byte) 0x89, (byte) 0x40, (byte) 0xc8, (byte) 0x99, (byte) 0x92,
+            (byte) 0xab, (byte) 0x4a, (byte) 0xb5, (byte) 0x61, (byte) 0x45, (byte) 0x62,
+            (byte) 0xff, (byte) 0xa3, (byte) 0x45, (byte) 0x65, (byte) 0xaf, (byte) 0xf6,
+            (byte) 0x27, (byte) 0x30, (byte) 0x51, (byte) 0x0e, (byte) 0x0e, (byte) 0xeb,
+            (byte) 0x79, (byte) 0x0c, (byte) 0xbe, (byte) 0xb3, (byte) 0x0a, (byte) 0x6f,
+            (byte) 0x29, (byte) 0x06, (byte) 0xdc, (byte) 0x2f, (byte) 0x6b, (byte) 0x51,
+            (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0xa3,
+            (byte) 0x81, (byte) 0xb1, (byte) 0x30, (byte) 0x81, (byte) 0xae, (byte) 0x30,
+            (byte) 0x1d, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x1d, (byte) 0x0e,
+            (byte) 0x04, (byte) 0x16, (byte) 0x04, (byte) 0x14, (byte) 0x33, (byte) 0x05,
+            (byte) 0xee, (byte) 0xfe, (byte) 0x6f, (byte) 0x60, (byte) 0xc7, (byte) 0xf9,
+            (byte) 0xa9, (byte) 0xd2, (byte) 0x73, (byte) 0x5c, (byte) 0x8f, (byte) 0x6d,
+            (byte) 0xa2, (byte) 0x2f, (byte) 0x97, (byte) 0x8e, (byte) 0x5d, (byte) 0x51,
+            (byte) 0x30, (byte) 0x7f, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x1d,
+            (byte) 0x23, (byte) 0x04, (byte) 0x78, (byte) 0x30, (byte) 0x76, (byte) 0x80,
+            (byte) 0x14, (byte) 0x33, (byte) 0x05, (byte) 0xee, (byte) 0xfe, (byte) 0x6f,
+            (byte) 0x60, (byte) 0xc7, (byte) 0xf9, (byte) 0xa9, (byte) 0xd2, (byte) 0x73,
+            (byte) 0x5c, (byte) 0x8f, (byte) 0x6d, (byte) 0xa2, (byte) 0x2f, (byte) 0x97,
+            (byte) 0x8e, (byte) 0x5d, (byte) 0x51, (byte) 0xa1, (byte) 0x53, (byte) 0xa4,
+            (byte) 0x51, (byte) 0x30, (byte) 0x4f, (byte) 0x31, (byte) 0x0b, (byte) 0x30,
+            (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x06,
+            (byte) 0x13, (byte) 0x02, (byte) 0x55, (byte) 0x53, (byte) 0x31, (byte) 0x0b,
+            (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04,
+            (byte) 0x08, (byte) 0x13, (byte) 0x02, (byte) 0x43, (byte) 0x41, (byte) 0x31,
+            (byte) 0x16, (byte) 0x30, (byte) 0x14, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+            (byte) 0x04, (byte) 0x07, (byte) 0x13, (byte) 0x0d, (byte) 0x4d, (byte) 0x6f,
+            (byte) 0x75, (byte) 0x6e, (byte) 0x74, (byte) 0x61, (byte) 0x69, (byte) 0x6e,
+            (byte) 0x20, (byte) 0x56, (byte) 0x69, (byte) 0x65, (byte) 0x77, (byte) 0x31,
+            (byte) 0x1b, (byte) 0x30, (byte) 0x19, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+            (byte) 0x04, (byte) 0x0a, (byte) 0x13, (byte) 0x12, (byte) 0x41, (byte) 0x6e,
+            (byte) 0x64, (byte) 0x72, (byte) 0x6f, (byte) 0x69, (byte) 0x64, (byte) 0x20,
+            (byte) 0x54, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x43,
+            (byte) 0x61, (byte) 0x73, (byte) 0x65, (byte) 0x73, (byte) 0x82, (byte) 0x09,
+            (byte) 0x00, (byte) 0xe1, (byte) 0x6a, (byte) 0xa2, (byte) 0xf4, (byte) 0x2e,
+            (byte) 0x55, (byte) 0x48, (byte) 0x0a, (byte) 0x30, (byte) 0x0c, (byte) 0x06,
+            (byte) 0x03, (byte) 0x55, (byte) 0x1d, (byte) 0x13, (byte) 0x04, (byte) 0x05,
+            (byte) 0x30, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0xff, (byte) 0x30,
+            (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a, (byte) 0x86, (byte) 0x48,
+            (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x05,
+            (byte) 0x05, (byte) 0x00, (byte) 0x03, (byte) 0x81, (byte) 0x81, (byte) 0x00,
+            (byte) 0x8c, (byte) 0x30, (byte) 0x42, (byte) 0xfa, (byte) 0xeb, (byte) 0x1a,
+            (byte) 0x26, (byte) 0xeb, (byte) 0xda, (byte) 0x56, (byte) 0x32, (byte) 0xf2,
+            (byte) 0x9d, (byte) 0xa5, (byte) 0x24, (byte) 0xd8, (byte) 0x3a, (byte) 0xda,
+            (byte) 0x30, (byte) 0xa6, (byte) 0x8b, (byte) 0x46, (byte) 0xfe, (byte) 0xfe,
+            (byte) 0xdb, (byte) 0xf1, (byte) 0xe6, (byte) 0xe1, (byte) 0x7c, (byte) 0x1b,
+            (byte) 0xe7, (byte) 0x77, (byte) 0x00, (byte) 0xa1, (byte) 0x1c, (byte) 0x19,
+            (byte) 0x17, (byte) 0x73, (byte) 0xb0, (byte) 0xf0, (byte) 0x9d, (byte) 0xf3,
+            (byte) 0x4f, (byte) 0xb6, (byte) 0xbc, (byte) 0xc7, (byte) 0x47, (byte) 0x85,
+            (byte) 0x2a, (byte) 0x4a, (byte) 0xa1, (byte) 0xa5, (byte) 0x58, (byte) 0xf5,
+            (byte) 0xc5, (byte) 0x1a, (byte) 0x51, (byte) 0xb1, (byte) 0x04, (byte) 0x80,
+            (byte) 0xee, (byte) 0x3a, (byte) 0xec, (byte) 0x2f, (byte) 0xe1, (byte) 0xfd,
+            (byte) 0x58, (byte) 0xeb, (byte) 0xed, (byte) 0x82, (byte) 0x9e, (byte) 0x38,
+            (byte) 0xa3, (byte) 0x24, (byte) 0x75, (byte) 0xf7, (byte) 0x3e, (byte) 0xc2,
+            (byte) 0xc5, (byte) 0x27, (byte) 0xeb, (byte) 0x6f, (byte) 0x7b, (byte) 0x50,
+            (byte) 0xda, (byte) 0x43, (byte) 0xdc, (byte) 0x3b, (byte) 0x0b, (byte) 0x6f,
+            (byte) 0x78, (byte) 0x8f, (byte) 0xb0, (byte) 0x66, (byte) 0xe1, (byte) 0x12,
+            (byte) 0x87, (byte) 0x5f, (byte) 0x97, (byte) 0x7b, (byte) 0xca, (byte) 0x14,
+            (byte) 0x79, (byte) 0xf7, (byte) 0xe8, (byte) 0x6c, (byte) 0x72, (byte) 0xdb,
+            (byte) 0x91, (byte) 0x65, (byte) 0x17, (byte) 0x54, (byte) 0xe0, (byte) 0x74,
+            (byte) 0x1d, (byte) 0xac, (byte) 0x47, (byte) 0x04, (byte) 0x12, (byte) 0xe0,
+            (byte) 0xc3, (byte) 0x66, (byte) 0x19, (byte) 0x05, (byte) 0x2e, (byte) 0x7e,
+            (byte) 0xf1, (byte) 0x61
+        };
+    }
+
+    /*
+     * The keys and certificates below are generated with:
+     *
+     * openssl req -new -x509 -days 3650 -extensions v3_ca -keyout cakey.pem -out cacert.pem
+     * openssl dsaparam -out dsaparam.pem 1024
+     * openssl req -newkey dsa:dsaparam.pem -keyout userkey.pem -nodes -days 3650 -out userkey.req
+     * mkdir -p demoCA/newcerts
+     * touch demoCA/index.txt
+     * echo "01" > demoCA/serial
+     * openssl ca -out usercert.pem -in userkey.req -cert cacert.pem -keyfile cakey.pem -days 3650
+     */
+    public static class FAKE_DSA_1 {
+        /**
+         * Generated from above and converted with: openssl pkcs8 -topk8 -outform d
+         * -in userkey.pem -nocrypt | xxd -i | sed 's/0x/(byte) 0x/g'
+         */
+        public static final byte[] privateKey = {
+            (byte) 0x30, (byte) 0x82, (byte) 0x01, (byte) 0x4c, (byte) 0x02, (byte) 0x01,
+            (byte) 0x00, (byte) 0x30, (byte) 0x82, (byte) 0x01, (byte) 0x2c, (byte) 0x06,
+            (byte) 0x07, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0xce, (byte) 0x38,
+            (byte) 0x04, (byte) 0x01, (byte) 0x30, (byte) 0x82, (byte) 0x01, (byte) 0x1f,
+            (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00, (byte) 0xb3, (byte) 0x23,
+            (byte) 0xf7, (byte) 0x86, (byte) 0xbd, (byte) 0x3b, (byte) 0x86, (byte) 0xcc,
+            (byte) 0xc3, (byte) 0x91, (byte) 0xc0, (byte) 0x30, (byte) 0x32, (byte) 0x02,
+            (byte) 0x47, (byte) 0x35, (byte) 0x01, (byte) 0xef, (byte) 0xee, (byte) 0x98,
+            (byte) 0x13, (byte) 0x56, (byte) 0x49, (byte) 0x47, (byte) 0xb5, (byte) 0x20,
+            (byte) 0xa8, (byte) 0x60, (byte) 0xcb, (byte) 0xc0, (byte) 0xd5, (byte) 0x77,
+            (byte) 0xc1, (byte) 0x69, (byte) 0xcd, (byte) 0x18, (byte) 0x34, (byte) 0x92,
+            (byte) 0xf2, (byte) 0x6a, (byte) 0x2a, (byte) 0x10, (byte) 0x59, (byte) 0x1c,
+            (byte) 0x91, (byte) 0x20, (byte) 0x51, (byte) 0xca, (byte) 0x37, (byte) 0xb2,
+            (byte) 0x87, (byte) 0xa6, (byte) 0x8a, (byte) 0x02, (byte) 0xfd, (byte) 0x45,
+            (byte) 0x46, (byte) 0xf9, (byte) 0x76, (byte) 0xb1, (byte) 0x35, (byte) 0x38,
+            (byte) 0x8d, (byte) 0xff, (byte) 0x4c, (byte) 0x5d, (byte) 0x75, (byte) 0x8f,
+            (byte) 0x66, (byte) 0x15, (byte) 0x7d, (byte) 0x7b, (byte) 0xda, (byte) 0xdb,
+            (byte) 0x57, (byte) 0x39, (byte) 0xff, (byte) 0x91, (byte) 0x3f, (byte) 0xdd,
+            (byte) 0xe2, (byte) 0xb4, (byte) 0x22, (byte) 0x60, (byte) 0x4c, (byte) 0x32,
+            (byte) 0x3b, (byte) 0x9d, (byte) 0x34, (byte) 0x9f, (byte) 0xb9, (byte) 0x5d,
+            (byte) 0x75, (byte) 0xb9, (byte) 0xd3, (byte) 0x7f, (byte) 0x11, (byte) 0xba,
+            (byte) 0xb7, (byte) 0xc8, (byte) 0x32, (byte) 0xc6, (byte) 0xce, (byte) 0x71,
+            (byte) 0x91, (byte) 0xd3, (byte) 0x32, (byte) 0xaf, (byte) 0x4d, (byte) 0x7e,
+            (byte) 0x7c, (byte) 0x15, (byte) 0xf7, (byte) 0x71, (byte) 0x2c, (byte) 0x52,
+            (byte) 0x65, (byte) 0x4d, (byte) 0xa9, (byte) 0x81, (byte) 0x25, (byte) 0x35,
+            (byte) 0xce, (byte) 0x0b, (byte) 0x5b, (byte) 0x56, (byte) 0xfe, (byte) 0xf1,
+            (byte) 0x02, (byte) 0x15, (byte) 0x00, (byte) 0xeb, (byte) 0x4e, (byte) 0x7f,
+            (byte) 0x7a, (byte) 0x31, (byte) 0xb3, (byte) 0x7d, (byte) 0x8d, (byte) 0xb2,
+            (byte) 0xf7, (byte) 0xaf, (byte) 0xad, (byte) 0xb1, (byte) 0x42, (byte) 0x92,
+            (byte) 0xf3, (byte) 0x6c, (byte) 0xe4, (byte) 0xed, (byte) 0x8b, (byte) 0x02,
+            (byte) 0x81, (byte) 0x81, (byte) 0x00, (byte) 0x81, (byte) 0xc8, (byte) 0x36,
+            (byte) 0x48, (byte) 0xdb, (byte) 0x71, (byte) 0x2b, (byte) 0x91, (byte) 0xce,
+            (byte) 0x6d, (byte) 0xbc, (byte) 0xb8, (byte) 0xf9, (byte) 0xcb, (byte) 0x50,
+            (byte) 0x91, (byte) 0x10, (byte) 0x8a, (byte) 0xf8, (byte) 0x37, (byte) 0x50,
+            (byte) 0xda, (byte) 0x4f, (byte) 0xc8, (byte) 0x4d, (byte) 0x73, (byte) 0xcb,
+            (byte) 0x4d, (byte) 0xb0, (byte) 0x19, (byte) 0x54, (byte) 0x5a, (byte) 0xf3,
+            (byte) 0x6c, (byte) 0xc9, (byte) 0xd8, (byte) 0x96, (byte) 0xd9, (byte) 0xb0,
+            (byte) 0x54, (byte) 0x7e, (byte) 0x7d, (byte) 0xe2, (byte) 0x58, (byte) 0x0e,
+            (byte) 0x5f, (byte) 0xc0, (byte) 0xce, (byte) 0xb9, (byte) 0x5c, (byte) 0xe3,
+            (byte) 0xd3, (byte) 0xdf, (byte) 0xcf, (byte) 0x45, (byte) 0x74, (byte) 0xfb,
+            (byte) 0xe6, (byte) 0x20, (byte) 0xe7, (byte) 0xfc, (byte) 0x0f, (byte) 0xca,
+            (byte) 0xdb, (byte) 0xc0, (byte) 0x0b, (byte) 0xe1, (byte) 0x5a, (byte) 0x16,
+            (byte) 0x1d, (byte) 0xb3, (byte) 0x2e, (byte) 0xe5, (byte) 0x5f, (byte) 0x89,
+            (byte) 0x17, (byte) 0x73, (byte) 0x50, (byte) 0xd1, (byte) 0x4a, (byte) 0x60,
+            (byte) 0xb7, (byte) 0xaa, (byte) 0xf0, (byte) 0xc7, (byte) 0xc5, (byte) 0x03,
+            (byte) 0x4e, (byte) 0x36, (byte) 0x51, (byte) 0x9e, (byte) 0x2f, (byte) 0xfa,
+            (byte) 0xf3, (byte) 0xd6, (byte) 0x58, (byte) 0x14, (byte) 0x02, (byte) 0xb4,
+            (byte) 0x41, (byte) 0xd6, (byte) 0x72, (byte) 0x6f, (byte) 0x58, (byte) 0x5b,
+            (byte) 0x2d, (byte) 0x23, (byte) 0xc0, (byte) 0x75, (byte) 0x4f, (byte) 0x39,
+            (byte) 0xa8, (byte) 0x6a, (byte) 0xdf, (byte) 0x79, (byte) 0x21, (byte) 0xf2,
+            (byte) 0x77, (byte) 0x91, (byte) 0x3f, (byte) 0x1c, (byte) 0x4d, (byte) 0x48,
+            (byte) 0x78, (byte) 0xcd, (byte) 0xed, (byte) 0x79, (byte) 0x23, (byte) 0x04,
+            (byte) 0x17, (byte) 0x02, (byte) 0x15, (byte) 0x00, (byte) 0xc7, (byte) 0xe7,
+            (byte) 0xe2, (byte) 0x6b, (byte) 0x14, (byte) 0xe6, (byte) 0x31, (byte) 0x12,
+            (byte) 0xb2, (byte) 0x1e, (byte) 0xd4, (byte) 0xf2, (byte) 0x9b, (byte) 0x2c,
+            (byte) 0xf6, (byte) 0x54, (byte) 0x4c, (byte) 0x12, (byte) 0xe8, (byte) 0x22
+
+        };
+
+        /**
+         * Generated from above and converted with:
+         *
+         * openssl x509 -outform d -in cacert.pem | xxd -i | sed 's/0x/(byte) 0x/g'
+         */
+        public static final byte[] caCertificate = new byte[] {
+            (byte) 0x30, (byte) 0x82, (byte) 0x02, (byte) 0x8a, (byte) 0x30, (byte) 0x82,
+            (byte) 0x01, (byte) 0xf3, (byte) 0xa0, (byte) 0x03, (byte) 0x02, (byte) 0x01,
+            (byte) 0x02, (byte) 0x02, (byte) 0x09, (byte) 0x00, (byte) 0x87, (byte) 0xc0,
+            (byte) 0x68, (byte) 0x7f, (byte) 0x42, (byte) 0x92, (byte) 0x0b, (byte) 0x7a,
+            (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09, (byte) 0x2a, (byte) 0x86,
+            (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d, (byte) 0x01, (byte) 0x01,
+            (byte) 0x05, (byte) 0x05, (byte) 0x00, (byte) 0x30, (byte) 0x5e, (byte) 0x31,
+            (byte) 0x0b, (byte) 0x30, (byte) 0x09, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+            (byte) 0x04, (byte) 0x06, (byte) 0x13, (byte) 0x02, (byte) 0x41, (byte) 0x55,
+            (byte) 0x31, (byte) 0x13, (byte) 0x30, (byte) 0x11, (byte) 0x06, (byte) 0x03,
+            (byte) 0x55, (byte) 0x04, (byte) 0x08, (byte) 0x0c, (byte) 0x0a, (byte) 0x53,
+            (byte) 0x6f, (byte) 0x6d, (byte) 0x65, (byte) 0x2d, (byte) 0x53, (byte) 0x74,
+            (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x31, (byte) 0x21, (byte) 0x30,
+            (byte) 0x1f, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x0a,
+            (byte) 0x0c, (byte) 0x18, (byte) 0x49, (byte) 0x6e, (byte) 0x74, (byte) 0x65,
+            (byte) 0x72, (byte) 0x6e, (byte) 0x65, (byte) 0x74, (byte) 0x20, (byte) 0x57,
+            (byte) 0x69, (byte) 0x64, (byte) 0x67, (byte) 0x69, (byte) 0x74, (byte) 0x73,
+            (byte) 0x20, (byte) 0x50, (byte) 0x74, (byte) 0x79, (byte) 0x20, (byte) 0x4c,
+            (byte) 0x74, (byte) 0x64, (byte) 0x31, (byte) 0x17, (byte) 0x30, (byte) 0x15,
+            (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x03, (byte) 0x0c,
+            (byte) 0x0e, (byte) 0x63, (byte) 0x61, (byte) 0x2e, (byte) 0x65, (byte) 0x78,
+            (byte) 0x61, (byte) 0x6d, (byte) 0x70, (byte) 0x6c, (byte) 0x65, (byte) 0x2e,
+            (byte) 0x63, (byte) 0x6f, (byte) 0x6d, (byte) 0x30, (byte) 0x1e, (byte) 0x17,
+            (byte) 0x0d, (byte) 0x31, (byte) 0x33, (byte) 0x30, (byte) 0x38, (byte) 0x32,
+            (byte) 0x37, (byte) 0x32, (byte) 0x33, (byte) 0x33, (byte) 0x31, (byte) 0x32,
+            (byte) 0x39, (byte) 0x5a, (byte) 0x17, (byte) 0x0d, (byte) 0x32, (byte) 0x33,
+            (byte) 0x30, (byte) 0x38, (byte) 0x32, (byte) 0x35, (byte) 0x32, (byte) 0x33,
+            (byte) 0x33, (byte) 0x31, (byte) 0x32, (byte) 0x39, (byte) 0x5a, (byte) 0x30,
+            (byte) 0x5e, (byte) 0x31, (byte) 0x0b, (byte) 0x30, (byte) 0x09, (byte) 0x06,
+            (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x06, (byte) 0x13, (byte) 0x02,
+            (byte) 0x41, (byte) 0x55, (byte) 0x31, (byte) 0x13, (byte) 0x30, (byte) 0x11,
+            (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04, (byte) 0x08, (byte) 0x0c,
+            (byte) 0x0a, (byte) 0x53, (byte) 0x6f, (byte) 0x6d, (byte) 0x65, (byte) 0x2d,
+            (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x31,
+            (byte) 0x21, (byte) 0x30, (byte) 0x1f, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+            (byte) 0x04, (byte) 0x0a, (byte) 0x0c, (byte) 0x18, (byte) 0x49, (byte) 0x6e,
+            (byte) 0x74, (byte) 0x65, (byte) 0x72, (byte) 0x6e, (byte) 0x65, (byte) 0x74,
+            (byte) 0x20, (byte) 0x57, (byte) 0x69, (byte) 0x64, (byte) 0x67, (byte) 0x69,
+            (byte) 0x74, (byte) 0x73, (byte) 0x20, (byte) 0x50, (byte) 0x74, (byte) 0x79,
+            (byte) 0x20, (byte) 0x4c, (byte) 0x74, (byte) 0x64, (byte) 0x31, (byte) 0x17,
+            (byte) 0x30, (byte) 0x15, (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x04,
+            (byte) 0x03, (byte) 0x0c, (byte) 0x0e, (byte) 0x63, (byte) 0x61, (byte) 0x2e,
+            (byte) 0x65, (byte) 0x78, (byte) 0x61, (byte) 0x6d, (byte) 0x70, (byte) 0x6c,
+            (byte) 0x65, (byte) 0x2e, (byte) 0x63, (byte) 0x6f, (byte) 0x6d, (byte) 0x30,
+            (byte) 0x81, (byte) 0x9f, (byte) 0x30, (byte) 0x0d, (byte) 0x06, (byte) 0x09,
+            (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7, (byte) 0x0d,
+            (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x03,
+            (byte) 0x81, (byte) 0x8d, (byte) 0x00, (byte) 0x30, (byte) 0x81, (byte) 0x89,
+            (byte) 0x02, (byte) 0x81, (byte) 0x81, (byte) 0x00, (byte) 0xa4, (byte) 0xc7,
+            (byte) 0x06, (byte) 0xba, (byte) 0xdf, (byte) 0x2b, (byte) 0xee, (byte) 0xd2,
+            (byte) 0xb9, (byte) 0xe4, (byte) 0x52, (byte) 0x21, (byte) 0x68, (byte) 0x2b,
+            (byte) 0x83, (byte) 0xdf, (byte) 0xe3, (byte) 0x9c, (byte) 0x08, (byte) 0x73,
+            (byte) 0xdd, (byte) 0x90, (byte) 0xea, (byte) 0x97, (byte) 0x0c, (byte) 0x96,
+            (byte) 0x20, (byte) 0xb1, (byte) 0xee, (byte) 0x11, (byte) 0xd5, (byte) 0xd4,
+            (byte) 0x7c, (byte) 0x44, (byte) 0x96, (byte) 0x2e, (byte) 0x6e, (byte) 0xa2,
+            (byte) 0xb2, (byte) 0xa3, (byte) 0x4b, (byte) 0x0f, (byte) 0x32, (byte) 0x90,
+            (byte) 0xaf, (byte) 0x5c, (byte) 0x6f, (byte) 0x00, (byte) 0x88, (byte) 0x45,
+            (byte) 0x4e, (byte) 0x9b, (byte) 0x26, (byte) 0xc1, (byte) 0x94, (byte) 0x3c,
+            (byte) 0xfe, (byte) 0x10, (byte) 0xbd, (byte) 0xda, (byte) 0xf2, (byte) 0x8d,
+            (byte) 0x03, (byte) 0x52, (byte) 0x32, (byte) 0x11, (byte) 0xff, (byte) 0xf6,
+            (byte) 0xf9, (byte) 0x6e, (byte) 0x8f, (byte) 0x0f, (byte) 0xc8, (byte) 0x0a,
+            (byte) 0x48, (byte) 0x39, (byte) 0x33, (byte) 0xb9, (byte) 0x0c, (byte) 0xb3,
+            (byte) 0x2b, (byte) 0xab, (byte) 0x7d, (byte) 0x79, (byte) 0x6f, (byte) 0x57,
+            (byte) 0x5b, (byte) 0xb8, (byte) 0x84, (byte) 0xb6, (byte) 0xcc, (byte) 0xe8,
+            (byte) 0x30, (byte) 0x78, (byte) 0xff, (byte) 0x92, (byte) 0xe5, (byte) 0x43,
+            (byte) 0x2e, (byte) 0xef, (byte) 0x66, (byte) 0x98, (byte) 0xb4, (byte) 0xfe,
+            (byte) 0xa2, (byte) 0x40, (byte) 0xf2, (byte) 0x1f, (byte) 0xd0, (byte) 0x86,
+            (byte) 0x16, (byte) 0xc8, (byte) 0x45, (byte) 0xc4, (byte) 0x52, (byte) 0xcb,
+            (byte) 0x31, (byte) 0x5c, (byte) 0x9f, (byte) 0x32, (byte) 0x3b, (byte) 0xf7,
+            (byte) 0x19, (byte) 0x08, (byte) 0xc7, (byte) 0x00, (byte) 0x21, (byte) 0x7d,
+            (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0xa3,
+            (byte) 0x50, (byte) 0x30, (byte) 0x4e, (byte) 0x30, (byte) 0x1d, (byte) 0x06,
+            (byte) 0x03, (byte) 0x55, (byte) 0x1d, (byte) 0x0e, (byte) 0x04, (byte) 0x16,
+            (byte) 0x04, (byte) 0x14, (byte) 0x47, (byte) 0x82, (byte) 0xa3, (byte) 0xf1,
+            (byte) 0xc2, (byte) 0x7e, (byte) 0x3a, (byte) 0xde, (byte) 0x4f, (byte) 0x30,
+            (byte) 0x4c, (byte) 0x7f, (byte) 0x72, (byte) 0x81, (byte) 0x15, (byte) 0x32,
+            (byte) 0xda, (byte) 0x7f, (byte) 0x58, (byte) 0x18, (byte) 0x30, (byte) 0x1f,
+            (byte) 0x06, (byte) 0x03, (byte) 0x55, (byte) 0x1d, (byte) 0x23, (byte) 0x04,
+            (byte) 0x18, (byte) 0x30, (byte) 0x16, (byte) 0x80, (byte) 0x14, (byte) 0x47,
+            (byte) 0x82, (byte) 0xa3, (byte) 0xf1, (byte) 0xc2, (byte) 0x7e, (byte) 0x3a,
+            (byte) 0xde, (byte) 0x4f, (byte) 0x30, (byte) 0x4c, (byte) 0x7f, (byte) 0x72,
+            (byte) 0x81, (byte) 0x15, (byte) 0x32, (byte) 0xda, (byte) 0x7f, (byte) 0x58,
+            (byte) 0x18, (byte) 0x30, (byte) 0x0c, (byte) 0x06, (byte) 0x03, (byte) 0x55,
+            (byte) 0x1d, (byte) 0x13, (byte) 0x04, (byte) 0x05, (byte) 0x30, (byte) 0x03,
+            (byte) 0x01, (byte) 0x01, (byte) 0xff, (byte) 0x30, (byte) 0x0d, (byte) 0x06,
+            (byte) 0x09, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86, (byte) 0xf7,
+            (byte) 0x0d, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x05, (byte) 0x00,
+            (byte) 0x03, (byte) 0x81, (byte) 0x81, (byte) 0x00, (byte) 0x08, (byte) 0x7f,
+            (byte) 0x6a, (byte) 0x48, (byte) 0x90, (byte) 0x7b, (byte) 0x9b, (byte) 0x72,
+            (byte) 0x13, (byte) 0xa7, (byte) 0xef, (byte) 0x6b, (byte) 0x0b, (byte) 0x59,
+            (byte) 0xe5, (byte) 0x49, (byte) 0x72, (byte) 0x3a, (byte) 0xc8, (byte) 0x84,
+            (byte) 0xcc, (byte) 0x23, (byte) 0x18, (byte) 0x4c, (byte) 0xec, (byte) 0xc7,
+            (byte) 0xef, (byte) 0xcb, (byte) 0xa7, (byte) 0xbe, (byte) 0xe4, (byte) 0xef,
+            (byte) 0x8f, (byte) 0xc6, (byte) 0x06, (byte) 0x8c, (byte) 0xc0, (byte) 0xe4,
+            (byte) 0x2f, (byte) 0x2a, (byte) 0xc0, (byte) 0x35, (byte) 0x7d, (byte) 0x5e,
+            (byte) 0x19, (byte) 0x29, (byte) 0x8c, (byte) 0xb9, (byte) 0xf1, (byte) 0x1e,
+            (byte) 0xaf, (byte) 0x82, (byte) 0xd8, (byte) 0xe3, (byte) 0x88, (byte) 0xe1,
+            (byte) 0x31, (byte) 0xc8, (byte) 0x82, (byte) 0x1f, (byte) 0x83, (byte) 0xa9,
+            (byte) 0xde, (byte) 0xfe, (byte) 0x4b, (byte) 0xe2, (byte) 0x78, (byte) 0x64,
+            (byte) 0xed, (byte) 0xa4, (byte) 0x7b, (byte) 0xee, (byte) 0x8d, (byte) 0x71,
+            (byte) 0x1b, (byte) 0x44, (byte) 0xe6, (byte) 0xb7, (byte) 0xe8, (byte) 0xc5,
+            (byte) 0x9a, (byte) 0x93, (byte) 0x92, (byte) 0x6f, (byte) 0x6f, (byte) 0xdb,
+            (byte) 0xbd, (byte) 0xd7, (byte) 0x03, (byte) 0x85, (byte) 0xa9, (byte) 0x5f,
+            (byte) 0x53, (byte) 0x5f, (byte) 0x5d, (byte) 0x30, (byte) 0xc6, (byte) 0xd9,
+            (byte) 0xce, (byte) 0x34, (byte) 0xa8, (byte) 0xbe, (byte) 0x31, (byte) 0x47,
+            (byte) 0x1c, (byte) 0xa4, (byte) 0x7f, (byte) 0xc0, (byte) 0x2c, (byte) 0xbc,
+            (byte) 0xfe, (byte) 0x1a, (byte) 0x31, (byte) 0xd8, (byte) 0x77, (byte) 0x4d,
+            (byte) 0xfc, (byte) 0x45, (byte) 0x84, (byte) 0xfc, (byte) 0x45, (byte) 0x12,
+            (byte) 0xab, (byte) 0x50, (byte) 0xe4, (byte) 0x45, (byte) 0xe5, (byte) 0x11
+        };
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementTest.java
new file mode 100644
index 0000000..fe2bdda
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/KeyManagementTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.deviceowner;
+
+import static com.android.cts.deviceowner.FakeKeys.FAKE_RSA_1;
+
+import android.app.admin.DevicePolicyManager;
+
+import java.io.ByteArrayInputStream;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.Certificate;
+import java.security.KeyFactory;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.spec.InvalidKeySpecException;
+import java.security.spec.PKCS8EncodedKeySpec;
+
+public class KeyManagementTest extends BaseDeviceOwnerTest {
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        assertTrue(mDevicePolicyManager.resetPassword("test", 0));
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mDevicePolicyManager.setPasswordQuality(getWho(),
+                DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
+        mDevicePolicyManager.setPasswordMinimumLength(getWho(), 0);
+        assertTrue(mDevicePolicyManager.resetPassword("", 0));
+        super.tearDown();
+    }
+
+    public void testCanInstallValidRsaKeypair()
+            throws CertificateException, NoSuchAlgorithmException, InvalidKeySpecException {
+        final String alias = "com.android.test.valid-rsa-key-1";
+        final PrivateKey privKey = getPrivateKey(FAKE_RSA_1.privateKey , "RSA");
+        final Certificate cert = getCertificate(FAKE_RSA_1.caCertificate);
+        assertTrue(mDevicePolicyManager.installKeyPair(getWho(), privKey, cert, alias));
+    }
+
+    public void testNullKeyParamsFailGracefully()
+            throws CertificateException, NoSuchAlgorithmException, InvalidKeySpecException {
+        final String alias = "com.android.test.null-key-1";
+        final PrivateKey privKey = getPrivateKey(FAKE_RSA_1.privateKey, "RSA");
+        final Certificate cert = getCertificate(FAKE_RSA_1.caCertificate);
+        try {
+            assertFalse(mDevicePolicyManager.installKeyPair(getWho(), null, cert, alias));
+        } catch (NullPointerException accept) {
+            // Accept either false return value or NPE
+        }
+        try {
+            assertFalse(mDevicePolicyManager.installKeyPair(getWho(), privKey, null, alias));
+        } catch (NullPointerException accept) {
+            // Accept either false return value or NPE
+        }
+    }
+
+    public void testNullAdminComponentIsDenied()
+            throws CertificateException, NoSuchAlgorithmException, InvalidKeySpecException {
+        final String alias = "com.android.test.null-admin-1";
+        final PrivateKey privKey = getPrivateKey(FAKE_RSA_1.privateKey, "RSA");
+        final Certificate cert = getCertificate(FAKE_RSA_1.caCertificate);
+        try {
+            assertFalse(mDevicePolicyManager.installKeyPair(null, privKey, cert, alias));
+            fail("Exception should have been thrown for null ComponentName");
+        } catch (SecurityException | NullPointerException expected) {
+        }
+    }
+
+    PrivateKey getPrivateKey(final byte[] key, String type)
+            throws NoSuchAlgorithmException, InvalidKeySpecException {
+        return KeyFactory.getInstance(type).generatePrivate(
+                new PKCS8EncodedKeySpec(key));
+    }
+
+    Certificate getCertificate(byte[] cert) throws CertificateException {
+        return CertificateFactory.getInstance("X.509").generateCertificate(
+                new ByteArrayInputStream(cert));
+    }
+
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskTest.java
new file mode 100644
index 0000000..c0ca8e2
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskTest.java
@@ -0,0 +1,293 @@
+/*
+ * 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.deviceowner;
+
+import android.app.ActivityManager;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.provider.Settings;
+
+// This is not a standard test of an android activity (such as
+// ActivityInstrumentationTestCase2) as it is attempting to test the actual
+// life cycle and how it is affected by lock task, rather than mock intents
+// and setup.
+public class LockTaskTest extends BaseDeviceOwnerTest {
+
+    private static final String TEST_PACKAGE = "com.google.android.example.somepackage";
+
+    /**
+     * The tests below need to keep detailed track of the state of the activity
+     * that is started and stopped frequently.  To do this it sends a number of
+     * broadcasts that are caught here and translated into booleans (as well as
+     * notify some locks in case we are waiting).  There is also an action used
+     * to specify that the activity has finished handling the current command
+     * (INTENT_ACTION).
+     */
+    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            String action = intent.getAction();
+            if (LockTaskUtilityActivity.CREATE_ACTION.equals(action)) {
+                synchronized (mActivityRunningLock) {
+                    mIsActivityRunning = true;
+                    mActivityRunningLock.notify();
+                }
+            } else if (LockTaskUtilityActivity.DESTROY_ACTION.equals(action)) {
+                synchronized (mActivityRunningLock) {
+                    mIsActivityRunning = false;
+                    mActivityRunningLock.notify();
+                }
+            } else if (LockTaskUtilityActivity.RESUME_ACTION.equals(action)) {
+                synchronized (mActivityResumedLock) {
+                    mIsActivityResumed = true;
+                    mActivityResumedLock.notify();
+                }
+            } else if (LockTaskUtilityActivity.PAUSE_ACTION.equals(action)) {
+                synchronized (mActivityResumedLock) {
+                    mIsActivityResumed = false;
+                    mActivityResumedLock.notify();
+                }
+            } else if (LockTaskUtilityActivity.INTENT_ACTION.equals(action)) {
+                // Notify that intent has been handled.
+                synchronized (LockTaskTest.this) {
+                    mIntentHandled = true;
+                    LockTaskTest.this.notify();
+                }
+            }
+        }
+    };
+
+    private boolean mIsActivityRunning;
+    private boolean mIsActivityResumed;
+    private final Object mActivityRunningLock = new Object();
+    private final Object mActivityResumedLock = new Object();
+    private Boolean mIntentHandled;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(LockTaskUtilityActivity.CREATE_ACTION);
+        filter.addAction(LockTaskUtilityActivity.DESTROY_ACTION);
+        filter.addAction(LockTaskUtilityActivity.INTENT_ACTION);
+        filter.addAction(LockTaskUtilityActivity.RESUME_ACTION);
+        filter.addAction(LockTaskUtilityActivity.PAUSE_ACTION);
+        mContext.registerReceiver(mReceiver, filter);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mContext.unregisterReceiver(mReceiver);
+        super.tearDown();
+    }
+
+    public void testSetLockTaskPackages() {
+        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { TEST_PACKAGE });
+        assertTrue(mDevicePolicyManager.isLockTaskPermitted(TEST_PACKAGE));
+
+        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[0]);
+        assertFalse(mDevicePolicyManager.isLockTaskPermitted(TEST_PACKAGE));
+    }
+
+    // Start lock task, verify that ActivityManager knows thats what is going on.
+    public void testStartLockTask() {
+        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { PACKAGE_NAME });
+        startLockTask();
+        waitForResume();
+
+        // Verify that activity open and activity manager is in lock task.
+        ActivityManager activityManager = (ActivityManager)
+                mContext.getSystemService(Context.ACTIVITY_SERVICE);
+        assertTrue(activityManager.isInLockTaskMode());
+        assertTrue(mIsActivityRunning);
+        assertTrue(mIsActivityResumed);
+
+        stopAndFinish(activityManager);
+    }
+
+    // Verifies that the act of finishing is blocked by ActivityManager in lock task.
+    // This results in onDestroy not being called until stopLockTask is called before finish.
+    public void testCannotFinish() {
+        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { PACKAGE_NAME });
+        startLockTask();
+
+        // If lock task has not exited then the activity shouldn't actually receive onDestroy.
+        finishAndWait();
+        ActivityManager activityManager = (ActivityManager)
+                mContext.getSystemService(Context.ACTIVITY_SERVICE);
+        assertTrue(activityManager.isInLockTaskMode());
+        assertTrue(mIsActivityRunning);
+
+        stopAndFinish(activityManager);
+    }
+
+    // This test has the UtilityActivity trigger starting another activity (settings)
+    // this should be permitted as a part of lock task (since it isn't a new task).
+    // As a result onPause should be called as it goes to a new activity.
+// TODO: Reinstate once we make this test not flaky (if fails on Nexus 7 v2 most of the time,
+//       especially if testCannotStartActivityOutsideTask() is commented out.
+//    public void testStartActivityWithinTask() {
+//        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { PACKAGE_NAME });
+//        startLockTask();
+//        waitForResume();
+//
+//        Intent launchIntent = new Intent(Settings.ACTION_SETTINGS);
+//        Intent lockTaskUtility = getLockTaskUtility();
+//        lockTaskUtility.putExtra(LockTaskUtilityActivity.START_ACTIVITY, launchIntent);
+//        mContext.startActivity(lockTaskUtility);
+//
+//        synchronized (mActivityResumedLock) {
+//            if (mIsActivityResumed) {
+//                try {
+//                    mActivityResumedLock.wait(60000);
+//                } catch (InterruptedException e) {
+//                }
+//                assertFalse(mIsActivityResumed);
+//            }
+//        }
+//        stopAndFinish(null);
+//    }
+
+    // This launches an activity that is not part of the current task and therefore
+    // should be blocked.  This is verified by making sure that the activity does
+    // not get a call to onPause.
+// TODO: Reinstate once we make this test not flaky (if fails on Nexus 7 v2 most of the time) 
+//    public void testCannotStartActivityOutsideTask() {
+//        mDevicePolicyManager.setLockTaskPackages(getWho(), new String[] { PACKAGE_NAME });
+//        startLockTask();
+//        waitForResume();
+//
+//        Intent launchIntent = new Intent(Settings.ACTION_SETTINGS);
+//        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+//        mContext.startActivity(launchIntent);
+//
+//        synchronized (mActivityResumedLock) {
+//            try {
+//                mActivityResumedLock.wait(90000);
+//            } catch (InterruptedException e) {
+//            }
+//            assertTrue(mIsActivityResumed);
+//        }
+//        stopAndFinish(null);
+//    }
+
+    /**
+     * Call stopLockTask and finish on the LockTaskUtilityActivity.
+     *
+     * Verify that the activity is no longer running.
+     *
+     * If activityManager is not null then verify that the ActivityManager
+     * is no longer in lock task mode.
+     */
+    private void stopAndFinish(ActivityManager activityManager) {
+        stopLockTask();
+        finishAndWait();
+        if (activityManager != null) {
+            assertFalse(activityManager.isInLockTaskMode());
+        }
+        assertFalse(mIsActivityRunning);
+    }
+
+    /**
+     * Call finish on the LockTaskUtilityActivity and wait for
+     * onDestroy to be called.
+     */
+    private void finishAndWait() {
+        synchronized (mActivityRunningLock) {
+            finish();
+            if (mIsActivityRunning) {
+                try {
+                    mActivityRunningLock.wait(20000);
+                } catch (InterruptedException e) {
+                }
+            }
+        }
+    }
+
+    /**
+     * Wait for onPause to be called on the LockTaskUtilityActivity.
+     */
+    private void waitForResume() {
+        // It may take a moment for the resume to come in.
+        synchronized (mActivityResumedLock) {
+            if (!mIsActivityResumed) {
+                try {
+                    mActivityResumedLock.wait(20000);
+                } catch (InterruptedException e) {
+                }
+            }
+        }
+    }
+
+    /**
+     * Calls startLockTask on the LockTaskUtilityActivity
+     */
+    private void startLockTask() {
+        Intent intent = getLockTaskUtility();
+        intent.putExtra(LockTaskUtilityActivity.START_LOCK_TASK, true);
+        startAndWait(intent);
+    }
+
+    /**
+     * Calls stopLockTask on the LockTaskUtilityActivity
+     */
+    private void stopLockTask() {
+        Intent intent = getLockTaskUtility();
+        intent.putExtra(LockTaskUtilityActivity.STOP_LOCK_TASK, true);
+        startAndWait(intent);
+    }
+
+    /**
+     * Calls finish on the LockTaskUtilityActivity
+     */
+    private void finish() {
+        Intent intent = getLockTaskUtility();
+        intent.putExtra(LockTaskUtilityActivity.FINISH, true);
+        startAndWait(intent);
+    }
+
+    /**
+     * Sends a command intent to the LockTaskUtilityActivity and waits
+     * to receive the broadcast back confirming it has finished processing
+     * the command.
+     */
+    private void startAndWait(Intent intent) {
+        mIntentHandled = false;
+        synchronized (this) {
+            mContext.startActivity(intent);
+            // Give 20 secs to finish.
+            try {
+                wait(20000);
+            } catch (InterruptedException e) {
+            }
+            assertTrue(mIntentHandled);
+        }
+    }
+
+    /**
+     * Get basic intent that points at the LockTaskUtilityActivity.
+     *
+     * This intent includes the flags to make it act as single top.
+     */
+    private Intent getLockTaskUtility() {
+        Intent intent = new Intent();
+        intent.setClassName(PACKAGE_NAME, LockTaskUtilityActivity.class.getName());
+        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
+        return intent;
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskUtilityActivity.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskUtilityActivity.java
new file mode 100644
index 0000000..2901f5b
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/LockTaskUtilityActivity.java
@@ -0,0 +1,83 @@
+/*
+ * 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.deviceowner;
+
+import android.app.Activity;
+import android.content.Intent;
+
+public class LockTaskUtilityActivity extends Activity {
+
+    public static final String START_LOCK_TASK = "startLockTask";
+    public static final String STOP_LOCK_TASK = "stopLockTask";
+    public static final String START_ACTIVITY = "startActivity";
+    public static final String FINISH = "finish";
+
+    public static final String CREATE_ACTION = "com.android.cts.deviceowner.LOCK_TASK_CREATE";
+    public static final String DESTROY_ACTION = "com.android.cts.deviceowner.LOCK_TASK_DESTROY";
+    public static final String PAUSE_ACTION = "com.android.cts.deviceowner.LOCK_TASK_PAUSE";
+    public static final String RESUME_ACTION = "com.android.cts.deviceowner.LOCK_TASK_RESUME";
+    public static final String INTENT_ACTION = "com.android.cts.deviceowner.LOCK_TASK_INTENT";
+
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        handleIntent(intent);
+    }
+
+    @Override
+    protected void onCreate(android.os.Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        sendBroadcast(new Intent(CREATE_ACTION));
+        handleIntent(getIntent());
+    }
+
+    @Override
+    protected void onDestroy() {
+        sendBroadcast(new Intent(DESTROY_ACTION));
+        super.onDestroy();
+    }
+
+    @Override
+    protected void onResume() {
+        sendBroadcast(new Intent(RESUME_ACTION));
+        super.onResume();
+    }
+
+    @Override
+    protected void onPause() {
+        sendBroadcast(new Intent(PAUSE_ACTION));
+        super.onPause();
+    }
+
+    private void handleIntent(Intent intent) {
+        if (intent.getBooleanExtra(START_LOCK_TASK, false)) {
+            startLockTask();
+        }
+        if (intent.getBooleanExtra(STOP_LOCK_TASK, false)) {
+            stopLockTask();
+        }
+        if (intent.hasExtra(START_ACTIVITY)) {
+            Intent i = intent.getParcelableExtra(START_ACTIVITY);
+            startActivity(i);
+        }
+        if (intent.getBooleanExtra(FINISH, false)) {
+            finish();
+        }
+        sendBroadcast(new Intent(INTENT_ACTION));
+    }
+
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PersistentIntentResolvingTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PersistentIntentResolvingTest.java
new file mode 100644
index 0000000..fcef05f
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/PersistentIntentResolvingTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.deviceowner;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.SystemClock;
+
+public class PersistentIntentResolvingTest extends BaseDeviceOwnerTest {
+    public static final String EXAMPLE_ACTION = "com.android.cts.deviceowner.EXAMPLE_ACTION";
+
+    private boolean mReceivedConfirmationFrom1;
+    private boolean mReceivedConfirmationFrom2;
+    private BroadcastReceiver mReceiver;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(ExampleIntentReceivingActivity1.CONFIRM_ACTION);
+        filter.addAction(ExampleIntentReceivingActivity2.CONFIRM_ACTION);
+
+        mReceiver = new ConfirmReceiver();
+        mContext.registerReceiver(mReceiver, filter);
+
+        synchronized(this) {
+            mReceivedConfirmationFrom1 = false;
+            mReceivedConfirmationFrom2 = false;
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mDevicePolicyManager.clearPackagePersistentPreferredActivities(getWho(), PACKAGE_NAME);
+        mContext.unregisterReceiver(mReceiver);
+
+        super.tearDown();
+    }
+
+    public void testNoPersistentPreferredActivityYieldsResolverActivity() {
+        sendExampleIntent();
+        SystemClock.sleep(5000);
+
+        // Default behavior: intent results in resolver activity, since there are two potential
+        // receivers. No intent is received.
+        synchronized(this) {
+            assertFalse(mReceivedConfirmationFrom1);
+            assertFalse(mReceivedConfirmationFrom2);
+        }
+    }
+
+    public void testAddPersistentPreferredActivityYieldsReceptionAtTarget() {
+        addPersistentPreferredActivity();
+        sendExampleIntent();
+        SystemClock.sleep(5000);
+
+        // Persistent preferred activity present: intent should be received by activity 2.
+        synchronized(this) {
+            assertFalse(mReceivedConfirmationFrom1);
+            assertTrue(mReceivedConfirmationFrom2);
+        }
+    }
+
+    public void testAddAndClearPersistentPreferredActivitiesYieldsResolverActivity() {
+        addPersistentPreferredActivity();
+        mDevicePolicyManager.clearPackagePersistentPreferredActivities(getWho(), PACKAGE_NAME);
+
+        sendExampleIntent();
+        SystemClock.sleep(5000);
+
+        // Default behavior: intent results in resolver activity, since there are two potential
+        // receivers. No intent is received.
+        synchronized(this) {
+            assertFalse(mReceivedConfirmationFrom1);
+            assertFalse(mReceivedConfirmationFrom2);
+        }
+    }
+
+    public class ConfirmReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(ExampleIntentReceivingActivity1.CONFIRM_ACTION)) {
+                synchronized (PersistentIntentResolvingTest.this) {
+                    mReceivedConfirmationFrom1 = true;
+                }
+            } else if (intent.getAction().equals(ExampleIntentReceivingActivity2
+                            .CONFIRM_ACTION)) {
+                synchronized (PersistentIntentResolvingTest.this) {
+                    mReceivedConfirmationFrom2 = true;
+                }
+            }
+        }
+    }
+
+    private void sendExampleIntent() {
+        Intent exampleIntent = new Intent(EXAMPLE_ACTION);
+        exampleIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        mContext.startActivity(exampleIntent);
+    }
+
+    private void addPersistentPreferredActivity() {
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(EXAMPLE_ACTION);
+        filter.addCategory(Intent.CATEGORY_DEFAULT);
+        ComponentName targetComponent = new ComponentName(PACKAGE_NAME,
+                ExampleIntentReceivingActivity2.class.getName());
+        mDevicePolicyManager.addPersistentPreferredActivity(getWho(), filter, targetComponent);
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ScreenCaptureDisabledTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ScreenCaptureDisabledTest.java
new file mode 100644
index 0000000..59b9773
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/ScreenCaptureDisabledTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.deviceowner;
+
+import android.app.admin.DevicePolicyManager;
+
+/**
+ * Tests for {@link DevicePolicyManager#setScreenCaptureDisabled} and
+ * {@link DevicePolicyManager#getScreenCaptureDisabled} APIs.
+ */
+public class ScreenCaptureDisabledTest extends BaseDeviceOwnerTest {
+
+    public void testSetScreenCaptureDisabled_false() throws Exception {
+        mDevicePolicyManager.setScreenCaptureDisabled(getWho(), false);
+        assertFalse(mDevicePolicyManager.getScreenCaptureDisabled(getWho()));
+    }
+
+    public void testSetScreenCaptureDisabled_true() throws Exception {
+        mDevicePolicyManager.setScreenCaptureDisabled(getWho(), true);
+        assertTrue(mDevicePolicyManager.getScreenCaptureDisabled(getWho()));
+    }
+
+    public void testSetScreenCaptureDisabled_anyAdminTrue() {
+        mDevicePolicyManager.setScreenCaptureDisabled(getWho(), true);
+        assertTrue(mDevicePolicyManager.getScreenCaptureDisabled(null /* any admin */));
+    }
+
+    public void testSetScreenCaptureDisabled_anyAdminFalse() {
+        mDevicePolicyManager.setScreenCaptureDisabled(getWho(), false);
+        assertFalse(mDevicePolicyManager.getScreenCaptureDisabled(null /* any admin */));
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
similarity index 89%
copy from hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
copy to hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
index baf540b..62c7f28 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/IntentReceiver/Android.mk
@@ -16,7 +16,7 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_PACKAGE_NAME := CtsProfileOwnerApp
+LOCAL_PACKAGE_NAME := CtsIntentReceiverApp
 
 LOCAL_MODULE_TAGS := optional
 
@@ -24,7 +24,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
+LOCAL_JAVA_LIBRARIES := android.test.runner
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/IntentReceiver/AndroidManifest.xml b/hostsidetests/devicepolicy/app/IntentReceiver/AndroidManifest.xml
new file mode 100644
index 0000000..ab01ffb
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/IntentReceiver/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.cts.intent.receiver">
+
+    <uses-sdk android:minSdkVersion="19"/>
+
+    <application>
+        <activity android:name="com.android.cts.intent.receiver.IntentReceiverActivity">
+            <intent-filter>
+                <action android:name="com.android.cts.action.READ_FROM_URI" />
+                <action android:name="com.android.cts.action.WRITE_TO_URI" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
diff --git a/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/IntentReceiverActivity.java b/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/IntentReceiverActivity.java
new file mode 100644
index 0000000..2389402
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/IntentReceiver/src/com/android/cts/intent/receiver/IntentReceiverActivity.java
@@ -0,0 +1,92 @@
+/*
+ * 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.intent.receiver;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+
+/**
+ * Class to receive intents sent across profile boundaries, and read/write to content uri specified
+ * in these intents to test cross-profile content uris.
+ */
+public class IntentReceiverActivity extends Activity {
+
+    private static final String TAG = "IntentReceiverActivity";
+
+    private static final String ACTION_READ_FROM_URI = "com.android.cts.action.READ_FROM_URI";
+
+    private static final String ACTION_WRITE_TO_URI = "com.android.cts.action.WRITE_TO_URI";
+
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        Intent received = getIntent();
+        String action = received.getAction();
+
+        if (ACTION_READ_FROM_URI.equals(action)) {
+            Intent result = new Intent();
+            String message = getFirstLineFromUri(getIntent().getClipData().getItemAt(0).getUri());
+            Log.i(TAG, "message received in reading test: " + message);
+            result.putExtra("extra_response", message);
+            setResult(message != null ? Activity.RESULT_OK : Activity.RESULT_CANCELED, result);
+        } else if (ACTION_WRITE_TO_URI.equals(action)) {
+            Intent result = new Intent();
+            String message = received.getStringExtra("extra_message");
+            Log.i(TAG, "message received in writing test: " + message);
+            Uri uri = getIntent().getClipData().getItemAt(0).getUri();
+            boolean succeded = writeToUri(uri, message);
+            setResult(succeded ? Activity.RESULT_OK : Activity.RESULT_CANCELED);
+        }
+        finish();
+    }
+
+    /**
+     * Returns the first line of the file associated with uri.
+     */
+    private String getFirstLineFromUri(Uri uri) {
+        try {
+            InputStream is = getContentResolver().openInputStream(uri);
+            BufferedReader r = new BufferedReader(new InputStreamReader(is));
+            return r.readLine();
+        } catch (IOException e) {
+            Log.e(TAG, "could not read the uri " + uri, e);
+            return null;
+        }
+    }
+
+    private boolean writeToUri(Uri uri, String text) {
+        try {
+            OutputStreamWriter writer = new OutputStreamWriter(
+                    getContentResolver().openOutputStream(uri));
+            writer.write(text);
+            writer.flush();
+            writer.close();
+            return true;
+        } catch (IOException e) {
+            Log.e(TAG, "could not write to the uri " + uri, e);
+            return false;
+        }
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk b/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
similarity index 90%
copy from hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
copy to hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
index baf540b..46e3cf7 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/Android.mk
@@ -16,7 +16,7 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_PACKAGE_NAME := CtsProfileOwnerApp
+LOCAL_PACKAGE_NAME := CtsManagedProfileApp
 
 LOCAL_MODULE_TAGS := optional
 
@@ -26,6 +26,8 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
 
+LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4
+
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml b/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml
new file mode 100644
index 0000000..e156a4f
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/AndroidManifest.xml
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.cts.managedprofile">
+
+    <uses-sdk android:minSdkVersion="20"/>
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+        <receiver
+            android:name="com.android.cts.managedprofile.BaseManagedProfileTest$BasicAdminReceiver"
+            android:permission="android.permission.BIND_DEVICE_ADMIN">
+            <meta-data android:name="android.app.device_admin"
+                       android:resource="@xml/device_admin" />
+            <intent-filter>
+                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
+            </intent-filter>
+        </receiver>
+        <activity android:name=".PrimaryUserFilterSetterActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.DEFAULT"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".ComponentDisablingActivity" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.DEFAULT"/>
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".ManagedProfileActivity">
+            <intent-filter>
+                <category android:name="android.intent.category.DEFAULT"/>
+                <action android:name="com.android.cts.managedprofile.ACTION_TEST_MANAGED_ACTIVITY" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".PrimaryUserActivity">
+            <intent-filter>
+                <category android:name="android.intent.category.DEFAULT"/>
+                <action android:name="com.android.cts.managedprofile.ACTION_TEST_PRIMARY_ACTIVITY" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".AllUsersActivity">
+            <intent-filter>
+                <category android:name="android.intent.category.DEFAULT"/>
+                <action android:name="com.android.cts.managedprofile.ACTION_TEST_ALL_ACTIVITY" />
+            </intent-filter>
+        </activity>
+        <activity android:name=".crossprofilecontent.IntentSenderActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+            </intent-filter>
+        </activity>
+        <provider
+            android:name="android.support.v4.content.FileProvider"
+            android:authorities="com.android.cts.managedprofile.fileprovider"
+            android:grantUriPermissions="true"
+            android:exported="false">
+            <meta-data
+                android:name="android.support.FILE_PROVIDER_PATHS"
+                android:resource="@xml/filepaths" />
+        </provider>
+    </application>
+
+    <instrumentation android:name="android.test.InstrumentationTestRunner"
+                     android:targetPackage="com.android.cts.managedprofile"
+                     android:label="Managed Profile CTS Tests"/>
+</manifest>
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/res/values/strings.xml b/hostsidetests/devicepolicy/app/ManagedProfile/res/values/strings.xml
similarity index 100%
rename from hostsidetests/devicepolicy/app/ProfileOwner/res/values/strings.xml
rename to hostsidetests/devicepolicy/app/ManagedProfile/res/values/strings.xml
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/res/xml/device_admin.xml b/hostsidetests/devicepolicy/app/ManagedProfile/res/xml/device_admin.xml
similarity index 100%
rename from hostsidetests/devicepolicy/app/ProfileOwner/res/xml/device_admin.xml
rename to hostsidetests/devicepolicy/app/ManagedProfile/res/xml/device_admin.xml
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/res/xml/filepaths.xml b/hostsidetests/devicepolicy/app/ManagedProfile/res/xml/filepaths.xml
new file mode 100644
index 0000000..f7bf461
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/res/xml/filepaths.xml
@@ -0,0 +1,17 @@
+<!-- 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.
+-->
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+    <files-path path="texts/" name="texts" />
+</paths>
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/BaseProfileOwnerTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BaseManagedProfileTest.java
similarity index 78%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/BaseProfileOwnerTest.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BaseManagedProfileTest.java
index daee77f..2a54d97 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/BaseProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/BaseManagedProfileTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 import android.app.admin.DeviceAdminReceiver;
 import android.app.admin.DevicePolicyManager;
@@ -27,7 +27,7 @@
  * This class handles making sure that the test is the profile owner and that it has an active admin
  * registered, so that all tests may assume these are done.
  */
-public class BaseProfileOwnerTest extends AndroidTestCase {
+public class BaseManagedProfileTest extends AndroidTestCase {
 
     public static class BasicAdminReceiver extends DeviceAdminReceiver {
     }
@@ -44,9 +44,11 @@
        mDevicePolicyManager = (DevicePolicyManager)
                mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
        assertNotNull(mDevicePolicyManager);
-       // TODO: Only check this if we are running as the profile user. Otherwise, maybe check
-       // that there is a profile and that the below holds for it? If we don't want to do these
-       // checks, we could get rid for this class altogether.
+
+       // TODO: Only check the below if we are running as the profile user. If running under the
+       // user owner, can we check that there is a profile and that the below holds for it? If we
+       // don't want to do these checks every time we could get rid of this class altogether and
+       // just have a single test case running under the profile user that do them.
        assertTrue(mDevicePolicyManager.isAdminActive(ADMIN_RECEIVER_COMPONENT));
        assertTrue(mDevicePolicyManager.isProfileOwnerApp(
                ADMIN_RECEIVER_COMPONENT.getPackageName()));
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/ProfileOwnerSetupTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ManagedProfileSetupTest.java
similarity index 84%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/ProfileOwnerSetupTest.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ManagedProfileSetupTest.java
index 6fc0eb9..b95194e 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/ProfileOwnerSetupTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/ManagedProfileSetupTest.java
@@ -13,14 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 
-public class ProfileOwnerSetupTest extends BaseProfileOwnerTest {
+public class ManagedProfileSetupTest extends BaseManagedProfileTest {
 
     // This test verifies that the setUp assertions on the base class are working to verify
     // we are the profile owner and have a valid active admin.
-    public void testProfileOwnerSetup() {
+    public void testManagedProfileSetup() {
         // Empty test. We just want the assertions from super.setUp() to be executed.
     }
 
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/WipeDataTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/WipeDataTest.java
similarity index 93%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/WipeDataTest.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/WipeDataTest.java
index 2213d3b..b548c96 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/WipeDataTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/WipeDataTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
@@ -22,7 +22,7 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 
-import com.android.cts.profileowner.BaseProfileOwnerTest.BasicAdminReceiver;
+import com.android.cts.managedprofile.BaseManagedProfileTest.BasicAdminReceiver;
 
 import org.junit.Ignore;
 
@@ -30,7 +30,7 @@
  * Test wipeData() for use in managed profile. If called from a managed profile, wipeData() should
  * remove the current managed profile. Also, no erasing of external storage should be allowed.
  */
-public class WipeDataTest extends BaseProfileOwnerTest {
+public class WipeDataTest extends BaseManagedProfileTest {
 
     private UserManager mUserManager;
 
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofilecontent/CrossProfileContentTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofilecontent/CrossProfileContentTest.java
new file mode 100644
index 0000000..aa9506b
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofilecontent/CrossProfileContentTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.managedprofile.crossprofilecontent;
+
+import static com.android.cts.managedprofile.BaseManagedProfileTest.ADMIN_RECEIVER_COMPONENT;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.test.ActivityInstrumentationTestCase2;
+
+public class CrossProfileContentTest extends
+        ActivityInstrumentationTestCase2<IntentSenderActivity> {
+
+    private static final String MESSAGE = "Sample Message";
+
+    public CrossProfileContentTest() {
+        super(IntentSenderActivity.class);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        DevicePolicyManager dpm = (DevicePolicyManager)
+               getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
+        dpm.clearCrossProfileIntentFilters(ADMIN_RECEIVER_COMPONENT);
+        super.tearDown();
+    }
+
+    public void testReceiverCanRead() {
+        String response = getActivity().testReceiverCanRead(MESSAGE);
+        assertEquals(response, MESSAGE);
+    }
+
+    public void testReceiverCanWrite() {
+        String response = getActivity().testReceiverCanWrite(MESSAGE);
+        assertEquals(response, MESSAGE);
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofilecontent/IntentSenderActivity.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofilecontent/IntentSenderActivity.java
new file mode 100644
index 0000000..6c8020f
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofilecontent/IntentSenderActivity.java
@@ -0,0 +1,168 @@
+/*
+ * 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.managedprofile.crossprofilecontent;
+
+import static com.android.cts.managedprofile.BaseManagedProfileTest.ADMIN_RECEIVER_COMPONENT;
+
+import android.app.admin.DevicePolicyManager;
+import android.app.Activity;
+import android.content.ClipData;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.support.v4.content.FileProvider;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class IntentSenderActivity extends Activity {
+
+    private final static String TAG = "IntentSenderActivity";
+
+    private final CountDownLatch mLatch = new CountDownLatch(1);
+
+    private static final String ACTION_READ_FROM_URI = "com.android.cts.action.READ_FROM_URI";
+
+    private static final String ACTION_WRITE_TO_URI = "com.android.cts.action.WRITE_TO_URI";
+
+    private static final int TEST_RECEIVER_CAN_READ = 1;
+    private static final int TEST_RECEIVER_CAN_WRITE = 2;
+
+    private static final int WAIT_FOR_RESPONSE_TIMEOUT_SECONDS = 5;
+
+    private String mResponse;
+
+    private Uri mUriToWrite;
+
+    private DevicePolicyManager mDevicePolicyManager;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mDevicePolicyManager = (DevicePolicyManager)
+                getSystemService(Context.DEVICE_POLICY_SERVICE);
+    }
+
+    /**
+     * This method will send an intent to a receiver in another profile.
+     * This intent will have, in the ClipData, a uri whose associated file stores this message.
+     * The receiver will read the message from the uri, and put it inside the result intent.
+     * This method returns the response in the result intent, or null if no response was received.
+     */
+    String testReceiverCanRead(String message) {
+        IntentFilter testIntentFilter = new IntentFilter();
+        testIntentFilter.addAction(ACTION_READ_FROM_URI);
+        mDevicePolicyManager.addCrossProfileIntentFilter(ADMIN_RECEIVER_COMPONENT, testIntentFilter,
+                DevicePolicyManager.FLAG_PARENT_CAN_ACCESS_MANAGED);
+
+        Intent intent = new Intent(ACTION_READ_FROM_URI);
+        intent.setClipData(ClipData.newRawUri("", getUriWithTextInFile("reading_test", message)));
+        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+        startActivityForResult(intent, TEST_RECEIVER_CAN_READ);
+        try {
+            mLatch.await(WAIT_FOR_RESPONSE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            return null;
+        }
+        return mResponse;
+    }
+
+    /**
+     * This method will send an intent to a receiver in another profile.
+     * This intent will have a message in an extra, and a uri specified by the ClipData.
+     * The receiver will read the message from the extra, and write it to the uri in
+     * the ClipData.
+     * This method returns what has been written in the uri.
+     */
+    String testReceiverCanWrite(String message) {
+        IntentFilter testIntentFilter = new IntentFilter();
+        testIntentFilter.addAction(ACTION_WRITE_TO_URI);
+        mDevicePolicyManager.addCrossProfileIntentFilter(ADMIN_RECEIVER_COMPONENT, testIntentFilter,
+                DevicePolicyManager.FLAG_PARENT_CAN_ACCESS_MANAGED);
+        // It's the receiver of the intent that should write to the uri, not us. So, for now, we
+        // write an empty string.
+        mUriToWrite = getUriWithTextInFile("writing_test", "");
+        Intent intent = new Intent(ACTION_WRITE_TO_URI);
+        intent.setClipData(ClipData.newRawUri("", mUriToWrite));
+        intent.putExtra("extra_message", message);
+        intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION
+                | Intent.FLAG_GRANT_READ_URI_PERMISSION);
+        startActivityForResult(intent, TEST_RECEIVER_CAN_WRITE);
+        try {
+            mLatch.await(WAIT_FOR_RESPONSE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            return null;
+        }
+        return mResponse;
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        if (requestCode == TEST_RECEIVER_CAN_READ) {
+            if (resultCode == Activity.RESULT_OK) {
+                mResponse = data.getStringExtra("extra_response");
+                Log.i(TAG, "response received in reading test: " + mResponse);
+            }
+        } else if (requestCode == TEST_RECEIVER_CAN_WRITE) {
+            if (resultCode == Activity.RESULT_OK) {
+                mResponse = getFirstLineFromUri(mUriToWrite);
+                Log.i(TAG, "response received in writing test: " + mResponse);
+            }
+        }
+        mLatch.countDown();
+        finish();
+    }
+
+    private Uri getUriWithTextInFile(String name, String text) {
+        String filename = getFilesDir() + File.separator + "texts" + File.separator + name + ".txt";
+        Log.i(TAG, "Creating file " + filename + " with text \"" + text + "\"");
+        final File file = new File(filename);
+        file.getParentFile().mkdirs(); // If the folder doesn't exists it is created
+        try {
+            FileWriter writer = new FileWriter(file);
+            writer.write(text);
+            writer.close();
+        } catch(IOException e) {
+            Log.e(TAG, "Could not create file " + filename + " with text " + text);
+            return null;
+        }
+        return FileProvider.getUriForFile(this,
+                "com.android.cts.managedprofile.fileprovider", file);
+    }
+
+    /**
+     * Returns the first line of the file associated with uri.
+     */
+    private String getFirstLineFromUri(Uri uri) {
+        try {
+            InputStream is = getContentResolver().openInputStream(uri);
+            BufferedReader r = new BufferedReader(new InputStreamReader(is));
+            return r.readLine();
+        } catch (IOException e) {
+            Log.e(TAG, "could not read the uri " + uri);
+            return null;
+        }
+    }
+}
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/AllUsersActivity.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/AllUsersActivity.java
similarity index 90%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/AllUsersActivity.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/AllUsersActivity.java
index fbbfac5..7260acd 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/AllUsersActivity.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/AllUsersActivity.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -26,7 +26,7 @@
     private static final String TAG = AllUsersActivity.class.getName();
 
     public static final String ACTION =
-            "com.android.cts.profileowner.ACTION_TEST_ALL_ACTIVITY";
+            "com.android.cts.managedprofile.ACTION_TEST_ALL_ACTIVITY";
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
diff --git a/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ComponentDisablingActivity.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ComponentDisablingActivity.java
new file mode 100644
index 0000000..03922da
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ComponentDisablingActivity.java
@@ -0,0 +1,47 @@
+/*
+ * 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.managedprofile;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.os.Process;
+import android.util.Log;
+
+/**
+ * Class that disables a given component for the user it's running in.
+ */
+public class ComponentDisablingActivity extends Activity {
+
+    private static final String TAG = ComponentDisablingActivity.class.getName();
+    public static final String EXTRA_PACKAGE = "extra-package";
+    public static final String EXTRA_CLASS_NAME = "extra-class-name";
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        String extraClassName = getIntent().getStringExtra(EXTRA_CLASS_NAME);
+        String extraPackage = getIntent().getStringExtra(EXTRA_PACKAGE);
+
+        Log.i(TAG, "Disabling: " + extraPackage + "/" + extraClassName + " for user "
+                + Process.myUserHandle());
+        PackageManager packageManager = getPackageManager();
+        packageManager.setComponentEnabledSetting(new ComponentName(extraPackage, extraClassName),
+                PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+                PackageManager.DONT_KILL_APP);
+    }
+}
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ManagedProfileActivity.java
similarity index 90%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ManagedProfileActivity.java
index 2cd3ad9..a91f633 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileActivity.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ManagedProfileActivity.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -26,7 +26,7 @@
     private static final String TAG = ManagedProfileActivity.class.getName();
 
     public static final String ACTION =
-            "com.android.cts.profileowner.ACTION_TEST_MANAGED_ACTIVITY";
+            "com.android.cts.managedprofile.ACTION_TEST_MANAGED_ACTIVITY";
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ManagedProfileTest.java
similarity index 97%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileTest.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ManagedProfileTest.java
index 9ce08bb..0e3822b 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/ManagedProfileTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 import android.app.admin.DevicePolicyManager;
 import android.content.Intent;
@@ -27,7 +27,7 @@
  * in the primary profile, one to {@code ManagedProfileActivity.ACTION} in the secondary profile,
  * and one to {@code AllUsersActivity.ACTION} in both profiles.
  */
-public class ManagedProfileTest extends BaseProfileOwnerTest {
+public class ManagedProfileTest extends BaseManagedProfileTest {
 
     private PackageManager mPackageManager;
 
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserActivity.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserActivity.java
similarity index 90%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserActivity.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserActivity.java
index 0f18e96..f6fa172 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserActivity.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserActivity.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -26,7 +26,7 @@
     private static final String TAG = PrimaryUserActivity.class.getName();
 
     public static final String ACTION =
-            "com.android.cts.profileowner.ACTION_TEST_PRIMARY_ACTIVITY";
+            "com.android.cts.managedprofile.ACTION_TEST_PRIMARY_ACTIVITY";
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserFilterSetterActivity.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserFilterSetterActivity.java
similarity index 92%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserFilterSetterActivity.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserFilterSetterActivity.java
index b44227d..c00ced5 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserFilterSetterActivity.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserFilterSetterActivity.java
@@ -1,4 +1,4 @@
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
@@ -8,7 +8,7 @@
 import android.os.Bundle;
 import android.util.Log;
 
-import static com.android.cts.profileowner.BaseProfileOwnerTest.ADMIN_RECEIVER_COMPONENT;
+import static com.android.cts.managedprofile.BaseManagedProfileTest.ADMIN_RECEIVER_COMPONENT;
 
 /**
  * Class that sets the cross-profile intent filters required to test intent filtering from
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserTest.java b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserTest.java
similarity index 97%
rename from hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserTest.java
rename to hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserTest.java
index cd665a9..af400a7 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/crossprofileintentfilters/PrimaryUserTest.java
+++ b/hostsidetests/devicepolicy/app/ManagedProfile/src/com/android/cts/managedprofile/crossprofileintentfilters/PrimaryUserTest.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.cts.profileowner;
+package com.android.cts.managedprofile;
 
 import android.app.admin.DevicePolicyManager;
 import android.content.Intent;
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/ProfileOwner/AndroidManifest.xml
deleted file mode 100644
index e78ef37..0000000
--- a/hostsidetests/devicepolicy/app/ProfileOwner/AndroidManifest.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.cts.profileowner">
-
-    <uses-sdk android:minSdkVersion="20"/>
-
-    <application>
-        <uses-library android:name="android.test.runner" />
-        <receiver
-            android:name="com.android.cts.profileowner.BaseProfileOwnerTest$BasicAdminReceiver"
-            android:permission="android.permission.BIND_DEVICE_ADMIN">
-            <meta-data android:name="android.app.device_admin"
-                       android:resource="@xml/device_admin" />
-            <intent-filter>
-                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
-            </intent-filter>
-        </receiver>
-        <activity android:name=".PrimaryUserFilterSetterActivity">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <action android:name="com.android.cts.profileowner.ACTION_TEST_SET_FILTERS" />
-                <category android:name="android.intent.category.DEFAULT"/>
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-        <activity android:name=".ManagedProfileActivity">
-            <intent-filter>
-                <category android:name="android.intent.category.DEFAULT"/>
-                <action android:name="com.android.cts.profileowner.ACTION_TEST_MANAGED_ACTIVITY" />
-            </intent-filter>
-        </activity>
-        <activity android:name=".PrimaryUserActivity">
-            <intent-filter>
-                <category android:name="android.intent.category.DEFAULT"/>
-                <action android:name="com.android.cts.profileowner.ACTION_TEST_PRIMARY_ACTIVITY" />
-            </intent-filter>
-        </activity>
-        <activity android:name=".AllUsersActivity">
-            <intent-filter>
-                <category android:name="android.intent.category.DEFAULT"/>
-                <action android:name="com.android.cts.profileowner.ACTION_TEST_ALL_ACTIVITY" />
-            </intent-filter>
-        </activity>
-    </application>
-
-    <instrumentation android:name="android.test.InstrumentationTestRunner"
-                     android:targetPackage="com.android.cts.profileowner"
-                     android:label="Profile Owner CTS Tests"/>
-</manifest>
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
similarity index 60%
rename from hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ProfileOwnerTest.java
rename to hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
index a98f950..abd5a99 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
@@ -39,25 +39,20 @@
 import javax.annotation.Nullable;
 
 /**
- * Set of tests for Profile Owner use cases.
+ * Base class for device policy tests. It offers utility methods to run tests, set device or profile
+ * owner, etc.
  */
-public class ProfileOwnerTest extends DeviceTestCase implements IBuildReceiver {
+public class BaseDevicePolicyTest extends DeviceTestCase implements IBuildReceiver {
 
     private static final String RUNNER = "android.test.InstrumentationTestRunner";
 
-    private static final String PROFILE_OWNER_PKG = "com.android.cts.profileowner";
-    private static final String PROFILE_OWNER_APK = "CtsProfileOwnerApp.apk";
-
-    private static final String ADMIN_RECEIVER_TEST_CLASS =
-            PROFILE_OWNER_PKG + ".BaseProfileOwnerTest$BasicAdminReceiver";
-
     private static final String[] REQUIRED_DEVICE_FEATURES = new String[] {
         "android.software.managed_users",
         "android.software.device_admin" };
 
     private CtsBuildHelper mCtsBuild;
-    private int mUserId;
-    private boolean mHasFeature;
+
+    protected boolean mHasFeature;
 
     @Override
     public void setBuild(IBuildInfo buildInfo) {
@@ -68,144 +63,38 @@
     protected void setUp() throws Exception {
         super.setUp();
         assertNotNull(mCtsBuild);  // ensure build has been set before test is run.
-        mHasFeature = hasDeviceFeatures(REQUIRED_DEVICE_FEATURES);
-
-        if (mHasFeature) {
-            mUserId = createUser();
-            installApp(PROFILE_OWNER_APK);
-            setProfileOwner(PROFILE_OWNER_PKG + "/" + ADMIN_RECEIVER_TEST_CLASS);
-            startManagedProfile();
-        }
+        mHasFeature = getDevice().getApiLevel() >= 21 /* Build.VERSION_CODES.L */
+                && hasDeviceFeatures(REQUIRED_DEVICE_FEATURES);
     }
 
-    /**
-     * Initializes the user that underlies the managed profile.
-     * This is required so that apps can run on it.
-     */
-    private void startManagedProfile() throws Exception  {
-        String command = "am start-user " + mUserId;
-        String commandOutput = getDevice().executeShellCommand(command);
-        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
-        assertTrue(commandOutput.startsWith("Success:"));
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        if (mHasFeature) {
-            // Remove the user that we created on setUp(), and the app that we installed.
-            String removeUserCommand = "pm remove-user " + mUserId;
-            CLog.logAndDisplay(LogLevel.INFO, "Output for command " + removeUserCommand + ": "
-                    + getDevice().executeShellCommand(removeUserCommand));
-            getDevice().uninstallPackage(PROFILE_OWNER_PKG);
-        }
-
-        super.tearDown();
-    }
-
-    /**
-     *  wipData() test removes the managed profile, so it needs to separated from other tests.
-     */
-    public void testWipeData() throws Exception {
-        if (!mHasFeature) {
-            return;
-        }
-        assertTrue(listUsers().contains(mUserId));
-        assertTrue(runDeviceTestsAsUser(PROFILE_OWNER_PKG, PROFILE_OWNER_PKG + ".WipeDataTest", mUserId));
-        // Note: the managed profile is removed by this test, which will make removeUserCommand in
-        // tearDown() to complain, but that should be OK since its result is not asserted.
-        assertFalse(listUsers().contains(mUserId));
-    }
-
-    public void testProfileOwner() throws Exception {
-        if (!mHasFeature) {
-            return;
-        }
-        String[] testClassNames = {
-                "ProfileOwnerSetupTest",
-        };
-        for (String className : testClassNames) {
-            String testClass = PROFILE_OWNER_PKG + "." + className;
-            assertTrue(runDeviceTestsAsUser(PROFILE_OWNER_PKG, testClass, mUserId));
-        }
-    }
-
-    public void testCrossProfileIntentFilters() throws Exception {
-        if (!mHasFeature) {
-            return;
-        }
-        // Set up activities: ManagedProfileActivity will only be enabled in the managed profile and
-        // PrimaryUserActivity only in the primary one
-        disableActivityForUser("ManagedProfileActivity", 0);
-        disableActivityForUser("PrimaryUserActivity", mUserId);
-
-        assertTrue(runDeviceTestsAsUser(PROFILE_OWNER_PKG,
-                PROFILE_OWNER_PKG + ".ManagedProfileTest", mUserId));
-
-        // Set up filters from primary to managed profile
-        String command = "am start -W --user " + mUserId  + " " + PROFILE_OWNER_PKG
-                + "/.PrimaryUserFilterSetterActivity";
-        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": "
-              + getDevice().executeShellCommand(command));
-        assertTrue(runDeviceTests(PROFILE_OWNER_PKG, PROFILE_OWNER_PKG + ".PrimaryUserTest"));
-        // TODO: Test with startActivity
-        // TODO: Test with CtsVerifier for disambiguation cases
-    }
-
-    private void disableActivityForUser(String activityName, int userId)
-            throws DeviceNotAvailableException {
-        String command = "pm disable --user " + userId + " " + PROFILE_OWNER_PKG + "/."
-                + activityName;
-        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": "
-                + getDevice().executeShellCommand(command));
-    }
-
-    private boolean hasDeviceFeatures(String[] requiredFeatures)
-            throws DeviceNotAvailableException {
-        // TODO: Move this logic to ITestDevice.
-        String command = "pm list features";
-        String commandOutput = getDevice().executeShellCommand(command);
-
-        // Extract the id of the new user.
-        HashSet<String> availableFeatures = new HashSet<String>();
-        for (String feature: commandOutput.split("\\s+")) {
-            // Each line in the output of the command has the format "feature:{FEATURE_VALUE}".
-            String[] tokens = feature.split(":");
-            assertTrue(tokens.length > 1);
-            assertEquals("feature", tokens[0]);
-            availableFeatures.add(tokens[1]);
-        }
-
-        for (String requiredFeature : requiredFeatures) {
-            if(!availableFeatures.contains(requiredFeature)) {
-                CLog.logAndDisplay(LogLevel.INFO, "Device doesn't have required feature "
-                        + requiredFeature + ". Tests won't run.");
-                return false;
-            }
-        }
-        return true;
-    }
-
-    private void installApp(String fileName)
+    protected void installApp(String fileName)
             throws FileNotFoundException, DeviceNotAvailableException {
         String installResult = getDevice().installPackage(mCtsBuild.getTestApp(fileName), true);
         assertNull(String.format("Failed to install %s, Reason: %s", fileName, installResult),
                 installResult);
     }
 
-    private int createUser() throws DeviceNotAvailableException {
-        String command =
-                "pm create-user --profileOf 0 --managed TestProfile_" + System.currentTimeMillis();
+    /** Initializes the user with the given id. This is required so that apps can run on it. */
+    protected void startUser(int userId) throws DeviceNotAvailableException {
+        String command = "am start-user " + userId;
         String commandOutput = getDevice().executeShellCommand(command);
         CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
-
-        // Extract the id of the new user.
-        String[] tokens = commandOutput.split("\\s+");
-        assertTrue(tokens.length > 0);
-        assertEquals("Success:", tokens[0]);
-        return Integer.parseInt(tokens[tokens.length-1]);
+        assertTrue(commandOutput.startsWith("Success:"));
     }
 
-    private ArrayList<Integer> listUsers() throws DeviceNotAvailableException {
+    protected int getMaxNumberOfUsersSupported() throws DeviceNotAvailableException {
+        // TODO: move this to ITestDevice once it supports users
+        String command = "pm get-max-users";
+        String commandOutput = getDevice().executeShellCommand(command);
+        try {
+            return Integer.parseInt(commandOutput.substring(commandOutput.lastIndexOf(" ")).trim());
+        } catch (NumberFormatException e) {
+            fail("Failed to parse result: " + commandOutput);
+        }
+        return 0;
+    }
+
+    protected ArrayList<Integer> listUsers() throws DeviceNotAvailableException {
         String command = "pm list users";
         String commandOutput = getDevice().executeShellCommand(command);
 
@@ -225,21 +114,21 @@
         return users;
     }
 
-    private void setProfileOwner(String componentName) throws DeviceNotAvailableException {
-        String command = "dpm set-profile-owner '" + componentName + "' " + mUserId;
-        String commandOutput = getDevice().executeShellCommand(command);
-        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
-        assertTrue(commandOutput.startsWith("Success:"));
+    protected void removeUser(int userId) throws DeviceNotAvailableException  {
+        String removeUserCommand = "pm remove-user " + userId;
+        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + removeUserCommand + ": "
+                + getDevice().executeShellCommand(removeUserCommand));
     }
 
     /** Returns true if the specified tests passed. Tests are run as user owner. */
-    private boolean runDeviceTests(String pkgName, @Nullable String testClassName)
+    protected boolean runDeviceTests(String pkgName, @Nullable String testClassName)
             throws DeviceNotAvailableException {
         return runDeviceTests(pkgName, testClassName, null /*testMethodName*/, null /*userId*/);
     }
 
     /** Returns true if the specified tests passed. Tests are run as given user. */
-    private boolean runDeviceTestsAsUser(String pkgName, @Nullable String testClassName, int userId)
+    protected boolean runDeviceTestsAsUser(
+            String pkgName, @Nullable String testClassName, int userId)
             throws DeviceNotAvailableException {
         return runDeviceTests(pkgName, testClassName, null /*testMethodName*/, userId);
     }
@@ -256,8 +145,8 @@
 
     /** Helper method to run tests and return the listener that collected the results. */
     private TestRunResult doRunTests(
-            String pkgName, @Nullable String testClassName, @Nullable String testMethodName)
-            throws DeviceNotAvailableException {
+            String pkgName, String testClassName,
+            String testMethodName) throws DeviceNotAvailableException {
         RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(
                 pkgName, RUNNER, getDevice().getIDevice());
         if (testClassName != null && testMethodName != null) {
@@ -305,4 +194,30 @@
             }
         }
     }
+
+    private boolean hasDeviceFeatures(String[] requiredFeatures)
+            throws DeviceNotAvailableException {
+        // TODO: Move this logic to ITestDevice.
+        String command = "pm list features";
+        String commandOutput = getDevice().executeShellCommand(command);
+
+        // Extract the id of the new user.
+        HashSet<String> availableFeatures = new HashSet<String>();
+        for (String feature: commandOutput.split("\\s+")) {
+            // Each line in the output of the command has the format "feature:{FEATURE_VALUE}".
+            String[] tokens = feature.split(":");
+            assertTrue(tokens.length > 1);
+            assertEquals("feature", tokens[0]);
+            availableFeatures.add(tokens[1]);
+        }
+
+        for (String requiredFeature : requiredFeatures) {
+            if(!availableFeatures.contains(requiredFeature)) {
+                CLog.logAndDisplay(LogLevel.INFO, "Device doesn't have required feature "
+                        + requiredFeature + ". Tests won't run.");
+                return false;
+            }
+        }
+        return true;
+    }
 }
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
new file mode 100644
index 0000000..39e2b95
--- /dev/null
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.devicepolicy;
+
+import com.android.ddmlib.Log.LogLevel;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.log.LogUtil.CLog;
+
+/**
+ * Set of tests for Device Owner use cases.
+ */
+public class DeviceOwnerTest extends BaseDevicePolicyTest {
+
+    private static final String DEVICE_OWNER_PKG = "com.android.cts.deviceowner";
+    private static final String DEVICE_OWNER_APK = "CtsDeviceOwnerApp.apk";
+
+    private static final String ADMIN_RECEIVER_TEST_CLASS =
+            DEVICE_OWNER_PKG + ".BaseDeviceOwnerTest$BasicAdminReceiver";
+    private static final String CLEAR_DEVICE_OWNER_TEST_CLASS =
+            DEVICE_OWNER_PKG + ".ClearDeviceOwnerTest";
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        if (mHasFeature) {
+            installApp(DEVICE_OWNER_APK);
+            setDeviceOwner(DEVICE_OWNER_PKG + "/" + ADMIN_RECEIVER_TEST_CLASS);
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mHasFeature) {
+            assertTrue("Failed to remove device owner.",
+                    runDeviceTests(DEVICE_OWNER_PKG, CLEAR_DEVICE_OWNER_TEST_CLASS));
+            getDevice().uninstallPackage(DEVICE_OWNER_PKG);
+        }
+
+        super.tearDown();
+    }
+
+    public void testApplicationRestrictions() throws Exception {
+        executeDeviceOwnerTest("ApplicationRestrictionsTest");
+    }
+
+    public void testCaCertManagement() throws Exception {
+        executeDeviceOwnerTest("CaCertManagementTest");
+    }
+
+    public void testDeviceOwnerSetup() throws Exception {
+        executeDeviceOwnerTest("DeviceOwnerSetupTest");
+    }
+
+    public void testKeyManagement() throws Exception {
+        executeDeviceOwnerTest("KeyManagementTest");
+    }
+
+    public void testLockTask() throws Exception {
+        executeDeviceOwnerTest("LockTaskTest");
+    }
+
+    public void testPersistentIntentResolving() throws Exception {
+        executeDeviceOwnerTest("PersistentIntentResolvingTest");
+    }
+
+    public void testScreenCaptureDisabled() throws Exception {
+        executeDeviceOwnerTest("ScreenCaptureDisabledTest");
+    }
+
+    private void executeDeviceOwnerTest(String testClassName) throws Exception {
+        if (!mHasFeature) {
+            return;
+        }
+        String testClass = DEVICE_OWNER_PKG + "." + testClassName;
+        assertTrue(runDeviceTests(DEVICE_OWNER_PKG, testClass));
+    }
+
+    private void setDeviceOwner(String componentName) throws DeviceNotAvailableException {
+        String command = "dpm set-device-owner '" + componentName + "'";
+        String commandOutput = getDevice().executeShellCommand(command);
+        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
+        assertTrue(commandOutput.startsWith("Success:"));
+    }
+
+}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
new file mode 100644
index 0000000..7fc33f0
--- /dev/null
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -0,0 +1,157 @@
+/*
+ * 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.devicepolicy;
+
+import com.android.ddmlib.Log.LogLevel;
+import com.android.tradefed.device.DeviceNotAvailableException;
+import com.android.tradefed.log.LogUtil.CLog;
+
+/**
+ * Set of tests for Managed Profile use cases.
+ */
+public class ManagedProfileTest extends BaseDevicePolicyTest {
+
+    private static final String MANAGED_PROFILE_PKG = "com.android.cts.managedprofile";
+    private static final String MANAGED_PROFILE_APK = "CtsManagedProfileApp.apk";
+
+    private static final String INTENT_RECEIVER_PKG = "com.android.cts.intent.receiver";
+    private static final String INTENT_RECEIVER_APK = "CtsIntentReceiverApp.apk";
+
+    private static final String ADMIN_RECEIVER_TEST_CLASS =
+            MANAGED_PROFILE_PKG + ".BaseManagedProfileTest$BasicAdminReceiver";
+
+    private int mUserId;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // We need multi user to be supported in order to create a profile of the user owner.
+        mHasFeature = mHasFeature && (getMaxNumberOfUsersSupported() > 1);
+
+        if (mHasFeature) {
+            mUserId = createManagedProfile();
+            installApp(MANAGED_PROFILE_APK);
+            setProfileOwner(MANAGED_PROFILE_PKG + "/" + ADMIN_RECEIVER_TEST_CLASS, mUserId);
+            startUser(mUserId);
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mHasFeature) {
+            removeUser(mUserId);
+            getDevice().uninstallPackage(MANAGED_PROFILE_PKG);
+        }
+
+        super.tearDown();
+    }
+
+    public void testManagedProfileSetup() throws Exception {
+        if (!mHasFeature) {
+            return;
+        }
+        assertTrue(runDeviceTestsAsUser(
+                MANAGED_PROFILE_PKG, MANAGED_PROFILE_PKG + ".ManagedProfileSetupTest", mUserId));
+    }
+
+    /**
+     *  wipeData() test removes the managed profile, so it needs to separated from other tests.
+     */
+    public void testWipeData() throws Exception {
+        if (!mHasFeature) {
+            return;
+        }
+        assertTrue(listUsers().contains(mUserId));
+        assertTrue(runDeviceTestsAsUser(
+                MANAGED_PROFILE_PKG, MANAGED_PROFILE_PKG + ".WipeDataTest", mUserId));
+        // Note: the managed profile is removed by this test, which will make removeUserCommand in
+        // tearDown() to complain, but that should be OK since its result is not asserted.
+        assertFalse(listUsers().contains(mUserId));
+    }
+
+    public void testCrossProfileIntentFilters() throws Exception {
+        if (!mHasFeature) {
+            return;
+        }
+        // Set up activities: ManagedProfileActivity will only be enabled in the managed profile and
+        // PrimaryUserActivity only in the primary one
+        disableActivityForUser("ManagedProfileActivity", 0);
+        disableActivityForUser("PrimaryUserActivity", mUserId);
+
+        assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG,
+                MANAGED_PROFILE_PKG + ".ManagedProfileTest", mUserId));
+
+        // Set up filters from primary to managed profile
+        String command = "am start -W --user " + mUserId  + " " + MANAGED_PROFILE_PKG
+                + "/.PrimaryUserFilterSetterActivity";
+        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": "
+              + getDevice().executeShellCommand(command));
+        assertTrue(runDeviceTests(MANAGED_PROFILE_PKG, MANAGED_PROFILE_PKG + ".PrimaryUserTest"));
+        // TODO: Test with startActivity
+        // TODO: Test with CtsVerifier for disambiguation cases
+    }
+
+    public void testCrossProfileContent() throws Exception {
+        if (!mHasFeature) {
+            return;
+        }
+        try {
+            installApp(INTENT_RECEIVER_APK);
+
+            String command = "pm uninstall --user " + mUserId + " " + INTENT_RECEIVER_PKG;
+            CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": "
+                    + getDevice().executeShellCommand(command));
+
+            assertTrue(runDeviceTestsAsUser(MANAGED_PROFILE_PKG,
+                    MANAGED_PROFILE_PKG + ".crossprofilecontent.CrossProfileContentTest", mUserId));
+        } finally {
+            getDevice().uninstallPackage(INTENT_RECEIVER_PKG);
+        }
+    }
+
+    private void disableActivityForUser(String activityName, int userId)
+            throws DeviceNotAvailableException {
+        String command = "am start -W --user " + userId
+                + " --es extra-package " + MANAGED_PROFILE_PKG
+                + " --es extra-class-name " + MANAGED_PROFILE_PKG + "." + activityName + " "
+                + MANAGED_PROFILE_PKG + "/.ComponentDisablingActivity ";
+        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": "
+                + getDevice().executeShellCommand(command));
+    }
+
+    private int createManagedProfile() throws DeviceNotAvailableException {
+        String command =
+                "pm create-user --profileOf 0 --managed TestProfile_" + System.currentTimeMillis();
+        String commandOutput = getDevice().executeShellCommand(command);
+        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
+
+        // Extract the id of the new user.
+        String[] tokens = commandOutput.split("\\s+");
+        assertTrue(tokens.length > 0);
+        assertEquals("Success:", tokens[0]);
+        return Integer.parseInt(tokens[tokens.length-1]);
+    }
+
+    private void setProfileOwner(String componentName, int userId)
+            throws DeviceNotAvailableException {
+        String command = "dpm set-profile-owner '" + componentName + "' " + userId;
+        String commandOutput = getDevice().executeShellCommand(command);
+        CLog.logAndDisplay(LogLevel.INFO, "Output for command " + command + ": " + commandOutput);
+        assertTrue(commandOutput.startsWith("Success:"));
+    }
+}
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 100f448..894b824 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
@@ -115,7 +115,7 @@
         @Override
         public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
             // necessary as testMetrics passed from CollectingTestListerner is empty
-            mCtsReport = testMetrics.get("CTS_TEST_REPORT");
+            mCtsReport = testMetrics.get("CTS_TEST_RESULT");
             super.testEnded(test, testMetrics);
         }
     }
diff --git a/tests/SignatureTest/src/android/tests/sigtest/SignatureTestLog.java b/tests/SignatureTest/src/android/tests/sigtest/SignatureTestLog.java
deleted file mode 100644
index 7cd9663..0000000
--- a/tests/SignatureTest/src/android/tests/sigtest/SignatureTestLog.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.tests.sigtest;
-
-import android.util.Log;
-
-public class SignatureTestLog {
-    private static final String TAG = "CTSSignatureTest";
-
-    public static void e(String msg, Exception e) {
-        Log.e(TAG, msg, e);
-    }
-
-    public static void d(String msg) {
-        Log.d(TAG, msg);
-    }
-}
diff --git a/tests/SignatureTest/tests/Android.mk b/tests/SignatureTest/tests/Android.mk
deleted file mode 100644
index 0796670..0000000
--- a/tests/SignatureTest/tests/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-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
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := SignatureTestTests
-
-LOCAL_INSTRUMENTATION_FOR := SignatureTest
-
-LOCAL_PROGUARD_FLAGS := -ignorewarnings
-
-LOCAL_DEX_PREOPT := false
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
-
-include $(BUILD_PACKAGE)
diff --git a/tests/SignatureTest/tests/AndroidManifest.xml b/tests/SignatureTest/tests/AndroidManifest.xml
deleted file mode 100644
index 49b3827..0000000
--- a/tests/SignatureTest/tests/AndroidManifest.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 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="android.tests.sigtest.tests">
-
-    <application>
-        <uses-library android:name="android.test.runner"/>
-    </application>
-
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.tests.sigtest"
-                     android:label="SignatureTest Functional Testset"/>
-
-</manifest>
diff --git a/tests/core/ctscore.mk b/tests/core/ctscore.mk
index 95f4634..fea0b07 100644
--- a/tests/core/ctscore.mk
+++ b/tests/core/ctscore.mk
@@ -25,4 +25,8 @@
 
 LOCAL_JNI_SHARED_LIBRARIES := libjavacoretests
 
+# Include both the 32 and 64 bit versions of libjavacoretests,
+# where applicable.
+LOCAL_MULTILIB := both
+
 include $(BUILD_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk b/tests/signature-tests/Android.mk
similarity index 69%
copy from hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
copy to tests/signature-tests/Android.mk
index baf540b..f17ee47 100644
--- a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
+++ b/tests/signature-tests/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2014 The Android Open Source Project
+# Copyright (C) 2010 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,20 +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_PACKAGE_NAME := CtsProfileOwnerApp
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-
+# Include all test java files.
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_JAVA_LIBRARIES := android.test.runner cts-junit
+LOCAL_MODULE := signature-tests
+LOCAL_MODULE_TAGS := optional
+LOCAL_JAVA_LIBRARIES := tradefed-prebuilt cts-tradefed signature-hostside
 
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_CTS_PACKAGE)
+include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/tests/signature-tests/run_unit_tests.sh b/tests/signature-tests/run_unit_tests.sh
new file mode 100755
index 0000000..19ce8d2
--- /dev/null
+++ b/tests/signature-tests/run_unit_tests.sh
@@ -0,0 +1,48 @@
+#!/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.
+
+# helper script for running the signature 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 hosttestlib.jar signature-hostside.jar signature-tests.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 android.signature.cts.tests.AllTests "$@"
+
diff --git a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/AllTests.java b/tests/signature-tests/src/android/signature/cts/tests/AllTests.java
similarity index 70%
rename from tests/SignatureTest/tests/src/android/tests/sigtest/tests/AllTests.java
rename to tests/signature-tests/src/android/signature/cts/tests/AllTests.java
index 096cb02..56916f4 100644
--- a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/AllTests.java
+++ b/tests/signature-tests/src/android/signature/cts/tests/AllTests.java
@@ -14,18 +14,23 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest.tests;
+package android.signature.cts.tests;
 
-import android.test.TestSuiteProvider;
-import android.test.suitebuilder.TestSuiteBuilder;
-
+import junit.framework.Test;
 import junit.framework.TestSuite;
 
 /**
  * Finds all instrumentation and unit tests for this application.
  */
-public class AllTests implements TestSuiteProvider {
-    public TestSuite getTestSuite() {
-        return new TestSuiteBuilder(getClass()).includeAllPackagesUnderHere().build();
+public class AllTests extends TestSuite {
+
+    public AllTests() {
+        super();
+
+        addTestSuite(JDiffClassDescriptionTest.class);
+    }
+
+    public static Test suite() {
+        return new AllTests();
     }
 }
diff --git a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/JDiffClassDescriptionTest.java b/tests/signature-tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java
similarity index 61%
rename from tests/SignatureTest/tests/src/android/tests/sigtest/tests/JDiffClassDescriptionTest.java
rename to tests/signature-tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java
index b5bf49e..ffb81ce 100644
--- a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/JDiffClassDescriptionTest.java
+++ b/tests/signature-tests/src/android/signature/cts/tests/JDiffClassDescriptionTest.java
@@ -14,48 +14,53 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest.tests;
+package android.signature.cts.tests;
 
-import android.test.InstrumentationTestCase;
-import android.tests.sigtest.JDiffClassDescription;
-import android.tests.sigtest.ResultObserver;
-import android.tests.sigtest.SignatureTest.FAILURE_TYPE;
+import android.signature.cts.FailureType;
+import android.signature.cts.JDiffClassDescription;
+import android.signature.cts.ResultObserver;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
 
 import java.lang.reflect.Modifier;
 
 /**
  * Test class for JDiffClassDescription.
  */
-public class JDiffClassDescriptionTest extends InstrumentationTestCase {
+public class JDiffClassDescriptionTest extends TestCase {
+
     private class NoFailures implements ResultObserver {
-        public void notifyFailure(FAILURE_TYPE type, String name, String errmsg) {
-            JDiffClassDescriptionTest.this.fail("Saw unexpected test failure: " + name + " failure type: " + type);
+        @Override
+        public void notifyFailure(FailureType type, String name, String errmsg) {
+            Assert.fail("Saw unexpected test failure: " + name + " failure type: " + type);
         }
     }
 
     private class ExpectFailure implements ResultObserver {
-        private FAILURE_TYPE expectedType;
+        private FailureType expectedType;
         private boolean failureSeen;
 
-        public ExpectFailure(FAILURE_TYPE expectedType) {
+        public ExpectFailure(FailureType expectedType) {
             this.expectedType = expectedType;
         }
 
-        public void notifyFailure(FAILURE_TYPE type, String name, String errMsg) {
+        @Override
+        public void notifyFailure(FailureType type, String name, String errMsg) {
             if (type == expectedType) {
                 if (failureSeen) {
-                    JDiffClassDescriptionTest.this.fail("Saw second test failure: " + name + " failure type: " + type);
+                    Assert.fail("Saw second test failure: " + name + " failure type: " + type);
                 } else {
                     // We've seen the error, mark it and keep going
                     failureSeen = true;
                 }
             } else {
-                JDiffClassDescriptionTest.this.fail("Saw unexpected test failure: " + name + " failure type: " + type);
+                Assert.fail("Saw unexpected test failure: " + name + " failure type: " + type);
             }
         }
-        
+
         public void validate() {
-            JDiffClassDescriptionTest.this.assertTrue(failureSeen);
+            Assert.assertTrue(failureSeen);
         }
     }
 
@@ -74,24 +79,23 @@
      * @return the new JDiffClassDescription
      */
     private JDiffClassDescription createNormalClass(ResultObserver observer) {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "NormalClass", observer);
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "NormalClass", observer);
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC);
         return clz;
-    }    
+    }
 
     public void testNormalClassCompliance() {
         JDiffClassDescription clz = createNormalClass();
         clz.checkSignatureCompliance();
-        assertEquals(clz.toSignatureString(),
-        "public class NormalClass");
+        assertEquals(clz.toSignatureString(), "public class NormalClass");
     }
 
     public void testMissingClass() {
-        ExpectFailure observer = new ExpectFailure(FAILURE_TYPE.MISSING_CLASS);
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data",
-                "NoSuchClass",
-                observer);
+        ExpectFailure observer = new ExpectFailure(FailureType.MISSING_CLASS);
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "NoSuchClass", observer);
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.checkSignatureCompliance();
         observer.validate();
@@ -99,88 +103,110 @@
 
     public void testSimpleConstructor() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffConstructor constructor = new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PUBLIC);
+        JDiffClassDescription.JDiffConstructor constructor =
+                new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PUBLIC);
         clz.addConstructor(constructor);
         clz.checkSignatureCompliance();
         assertEquals(constructor.toSignatureString(), "public NormalClass()");
     }
+
     public void testOneArgConstructor() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffConstructor constructor = new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PRIVATE);
+        JDiffClassDescription.JDiffConstructor constructor =
+                new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PRIVATE);
         constructor.addParam("java.lang.String");
         clz.addConstructor(constructor);
         clz.checkSignatureCompliance();
         assertEquals(constructor.toSignatureString(), "private NormalClass(java.lang.String)");
     }
+
     public void testConstructorThrowsException() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffConstructor constructor = new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PROTECTED);
+        JDiffClassDescription.JDiffConstructor constructor =
+                new JDiffClassDescription.JDiffConstructor("NormalClass", Modifier.PROTECTED);
         constructor.addParam("java.lang.String");
         constructor.addParam("java.lang.String");
-        constructor.addException("android.tests.sigtest.tests.data.NormalException");
+        constructor.addException("android.signature.cts.tests.data.NormalException");
         clz.addConstructor(constructor);
         clz.checkSignatureCompliance();
-        assertEquals(constructor.toSignatureString(), "protected NormalClass(java.lang.String, " +
-                "java.lang.String) throws android.tests.sigtest.tests.data.NormalException");
+        assertEquals(constructor.toSignatureString(),
+                "protected NormalClass(java.lang.String, java.lang.String) " +
+                "throws android.signature.cts.tests.data.NormalException");
     }
+
     public void testPackageProtectedConstructor() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffConstructor constructor = new JDiffClassDescription.JDiffConstructor("NormalClass", 0);
+        JDiffClassDescription.JDiffConstructor constructor =
+                new JDiffClassDescription.JDiffConstructor("NormalClass", 0);
         constructor.addParam("java.lang.String");
         constructor.addParam("java.lang.String");
         constructor.addParam("java.lang.String");
         clz.addConstructor(constructor);
         clz.checkSignatureCompliance();
-        assertEquals(constructor.toSignatureString(), "NormalClass(java.lang.String, java.lang.String, java.lang.String)");
+        assertEquals(constructor.toSignatureString(),
+                "NormalClass(java.lang.String, java.lang.String, java.lang.String)");
     }
 
     public void testStaticMethod() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("staticMethod", Modifier.STATIC | Modifier.PUBLIC, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "staticMethod", Modifier.STATIC | Modifier.PUBLIC, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
         assertEquals(method.toSignatureString(), "public static void staticMethod()");
     }
+
     public void testSyncMethod() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("syncMethod", Modifier.SYNCHRONIZED | Modifier.PUBLIC, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "syncMethod", Modifier.SYNCHRONIZED | Modifier.PUBLIC, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
         assertEquals(method.toSignatureString(), "public synchronized void syncMethod()");
     }
+
     public void testPackageProtectMethod() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("packageProtectedMethod", 0, "boolean");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "packageProtectedMethod", 0, "boolean");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
         assertEquals(method.toSignatureString(), "boolean packageProtectedMethod()");
     }
+
     public void testPrivateMethod() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("privateMethod", Modifier.PRIVATE, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "privateMethod", Modifier.PRIVATE, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
         assertEquals(method.toSignatureString(), "private void privateMethod()");
     }
+
     public void testProtectedMethod() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("protectedMethod", Modifier.PROTECTED, "java.lang.String");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "protectedMethod", Modifier.PROTECTED, "java.lang.String");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
         assertEquals(method.toSignatureString(), "protected java.lang.String protectedMethod()");
     }
+
     public void testThrowsMethod() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("throwsMethod", Modifier.PUBLIC, "void");
-        method.addException("android.tests.sigtest.tests.data.NormalException");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "throwsMethod", Modifier.PUBLIC, "void");
+        method.addException("android.signature.cts.tests.data.NormalException");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
-        assertEquals(method.toSignatureString(), "public void throwsMethod() throws" + 
-                " android.tests.sigtest.tests.data.NormalException");
+        assertEquals(method.toSignatureString(), "public void throwsMethod() " +
+                "throws android.signature.cts.tests.data.NormalException");
     }
+
     public void testNativeMethod() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("nativeMethod", Modifier.PUBLIC | Modifier.NATIVE, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "nativeMethod", Modifier.PUBLIC | Modifier.NATIVE, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
         assertEquals(method.toSignatureString(), "public native void nativeMethod()");
@@ -188,207 +214,259 @@
 
     public void testFinalField() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("FINAL_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.FINAL);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "FINAL_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.FINAL);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "public final java.lang.String FINAL_FIELD");
     }
+
     public void testStaticField() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("STATIC_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.STATIC);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "STATIC_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.STATIC);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "public static java.lang.String STATIC_FIELD");
     }
+
     public void testVolatileFiled() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("VOLATILE_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.VOLATILE);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "VOLATILE_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.VOLATILE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "public volatile java.lang.String VOLATILE_FIELD");
     }
+
     public void testTransientField() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("TRANSIENT_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.TRANSIENT);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "TRANSIENT_FIELD", "java.lang.String", Modifier.PUBLIC | Modifier.TRANSIENT);
         clz.addField(field);
         clz.checkSignatureCompliance();
-        assertEquals(field.toSignatureString(), "public transient java.lang.String TRANSIENT_FIELD");
+        assertEquals(field.toSignatureString(),
+                "public transient java.lang.String TRANSIENT_FIELD");
     }
+
     public void testPacakgeField() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("PACAKGE_FIELD", "java.lang.String", 0);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "PACAKGE_FIELD", "java.lang.String", 0);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "java.lang.String PACAKGE_FIELD");
     }
+
     public void testPrivateField() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("PRIVATE_FIELD", "java.lang.String", Modifier.PRIVATE);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "PRIVATE_FIELD", "java.lang.String", Modifier.PRIVATE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "private java.lang.String PRIVATE_FIELD");
     }
+
     public void testProtectedField() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("PROTECTED_FIELD", "java.lang.String", Modifier.PROTECTED);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "PROTECTED_FIELD", "java.lang.String", Modifier.PROTECTED);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(field.toSignatureString(), "protected java.lang.String PROTECTED_FIELD");
     }
 
     public void testInnerClass() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "NormalClass.InnerClass", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "NormalClass.InnerClass", new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC);
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("innerClassData", "java.lang.String", Modifier.PRIVATE);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "innerClassData", "java.lang.String", Modifier.PRIVATE);
         clz.addField(field);
         clz.checkSignatureCompliance();
         assertEquals(clz.toSignatureString(), "public class NormalClass.InnerClass");
     }
+
     public void testInnerInnerClass() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "NormalClass.InnerClass.InnerInnerClass", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "NormalClass.InnerClass.InnerInnerClass",
+                new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC);
-        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField("innerInnerClassData", "java.lang.String", Modifier.PRIVATE);
+        JDiffClassDescription.JDiffField field = new JDiffClassDescription.JDiffField(
+                "innerInnerClassData", "java.lang.String", Modifier.PRIVATE);
         clz.addField(field);
         clz.checkSignatureCompliance();
-        assertEquals(clz.toSignatureString(), "public class NormalClass.InnerClass.InnerInnerClass");
+        assertEquals(clz.toSignatureString(),
+                "public class NormalClass.InnerClass.InnerInnerClass");
     }
+
     public void testInnerInterface() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "NormalClass.InnerInterface", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "NormalClass.InnerInterface", new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.INTERFACE);
         clz.setModifier(Modifier.PUBLIC | Modifier.STATIC | Modifier.ABSTRACT);
-        clz.addMethod(new JDiffClassDescription.JDiffMethod("doSomething", Modifier.PUBLIC, "void"));
+        clz.addMethod(
+                new JDiffClassDescription.JDiffMethod("doSomething", Modifier.PUBLIC, "void"));
         clz.checkSignatureCompliance();
         assertEquals(clz.toSignatureString(), "public interface NormalClass.InnerInterface");
     }
+
     public void testInterface() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "NormalInterface", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "NormalInterface", new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.INTERFACE);
         clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
-        clz.addMethod(new JDiffClassDescription.JDiffMethod("doSomething", Modifier.PUBLIC, "void"));
+        clz.addMethod(
+                new JDiffClassDescription.JDiffMethod("doSomething", Modifier.PUBLIC, "void"));
         clz.checkSignatureCompliance();
         assertEquals(clz.toSignatureString(), "public interface NormalInterface");
     }
+
     public void testFinalClass() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "FinalClass", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "FinalClass", new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
         clz.checkSignatureCompliance();
         assertEquals(clz.toSignatureString(), "public final class FinalClass");
     }
-    /** Test the case where the API declares the method not
-     *  synchronized, but it actually is. */
+
+    /**
+     * Test the case where the API declares the method not synchronized, but it
+     * actually is.
+     */
     public void testAddingSync() {
-        ExpectFailure observer = new ExpectFailure(FAILURE_TYPE.MISMATCH_METHOD);
+        ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_METHOD);
         JDiffClassDescription clz = createNormalClass(observer);
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("syncMethod", Modifier.PUBLIC, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "syncMethod", Modifier.PUBLIC, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
         observer.validate();
     }
-    /** Test the case where the API declares the method is
-     *  synchronized, but it actually is not. */
+
+    /**
+     * Test the case where the API declares the method is synchronized, but it
+     * actually is not.
+     */
     public void testRemovingSync() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("notSyncMethod", Modifier.SYNCHRONIZED | Modifier.PUBLIC, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "notSyncMethod", Modifier.SYNCHRONIZED | Modifier.PUBLIC, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
     }
-    /** API says method is not native, but it actually is.
-     *  http://b/1839558
+
+    /**
+     * API says method is not native, but it actually is. http://b/1839558
      */
     public void testAddingNative() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("nativeMethod", Modifier.PUBLIC, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "nativeMethod", Modifier.PUBLIC, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
     }
-    /** API says method is native, but actually isn't.
-     *  http://b/1839558
+
+    /**
+     * API says method is native, but actually isn't. http://b/1839558
      */
     public void testRemovingNative() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("notNativeMethod", Modifier.NATIVE | Modifier.PUBLIC, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "notNativeMethod", Modifier.NATIVE | Modifier.PUBLIC, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
     }
+
     public void testAbstractClass() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "AbstractClass", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "AbstractClass", new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
         clz.checkSignatureCompliance();
         assertEquals(clz.toSignatureString(), "public abstract class AbstractClass");
     }
-    /** API lists class as abstract, reflection does not.
-     * http://b/1839622
+
+    /**
+     * API lists class as abstract, reflection does not. http://b/1839622
      */
     public void testRemovingAbstractFromAClass() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "NormalClass", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "NormalClass", new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC | Modifier.ABSTRACT);
         clz.checkSignatureCompliance();
     }
-    /** reflection lists class as abstract, api does not.
-     * http://b/1839622
+
+    /**
+     * reflection lists class as abstract, api does not. http://b/1839622
      */
     public void testAddingAbstractToAClass() {
-        ExpectFailure observer = new ExpectFailure(FAILURE_TYPE.MISMATCH_CLASS);
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data",
-                "AbstractClass", 
-                observer);
+        ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_CLASS);
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "AbstractClass", observer);
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC);
         clz.checkSignatureCompliance();
         observer.validate();
     }
+
     public void testFinalMethod() {
         JDiffClassDescription clz = createNormalClass();
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("finalMethod", Modifier.PUBLIC | Modifier.FINAL, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "finalMethod", Modifier.PUBLIC | Modifier.FINAL, "void");
         clz.addMethod(method);
         clz.checkSignatureCompliance();
         assertEquals(method.toSignatureString(), "public final void finalMethod()");
     }
+
     /**
      * Final Class, API lists methods as non-final, reflection has it as final.
      * http://b/1839589
      */
     public void testAddingFinalToAMethodInAFinalClass() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "FinalClass", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "FinalClass", new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("finalMethod", Modifier.PUBLIC, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "finalMethod", Modifier.PUBLIC, "void");
         clz.addMethod(method);
-        clz.checkSignatureCompliance();        
+        clz.checkSignatureCompliance();
     }
+
     /**
      * Final Class, API lists methods as final, reflection has it as non-final.
      * http://b/1839589
      */
     public void testRemovingFinalToAMethodInAFinalClass() {
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", "FinalClass", new NoFailures());
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "FinalClass", new NoFailures());
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC | Modifier.FINAL);
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("nonFinalMethod", 
-                Modifier.PUBLIC | Modifier.FINAL, 
-                "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "nonFinalMethod", Modifier.PUBLIC | Modifier.FINAL, "void");
         clz.addMethod(method);
-        clz.checkSignatureCompliance();        
+        clz.checkSignatureCompliance();
     }
+
     /**
-     * non-final Class, API lists methods as non-final, reflection has it as final.
-     * http://b/1839589
-     */  
+     * non-final Class, API lists methods as non-final, reflection has it as
+     * final. http://b/1839589
+     */
     public void testAddingFinalToAMethodInANonFinalClass() {
-        ExpectFailure observer = new ExpectFailure(FAILURE_TYPE.MISMATCH_METHOD);
-        JDiffClassDescription clz = new JDiffClassDescription("android.tests.sigtest.tests.data", 
-                "NormalClass", 
-                observer);
+        ExpectFailure observer = new ExpectFailure(FailureType.MISMATCH_METHOD);
+        JDiffClassDescription clz = new JDiffClassDescription(
+                "android.signature.cts.tests.data", "NormalClass", observer);
         clz.setType(JDiffClassDescription.JDiffType.CLASS);
         clz.setModifier(Modifier.PUBLIC);
-        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod("finalMethod", Modifier.PUBLIC, "void");
+        JDiffClassDescription.JDiffMethod method = new JDiffClassDescription.JDiffMethod(
+                "finalMethod", Modifier.PUBLIC, "void");
         clz.addMethod(method);
-        clz.checkSignatureCompliance();  
+        clz.checkSignatureCompliance();
         observer.validate();
     }
 }
diff --git a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/AbstractClass.java b/tests/signature-tests/src/android/signature/cts/tests/data/AbstractClass.java
similarity index 94%
rename from tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/AbstractClass.java
rename to tests/signature-tests/src/android/signature/cts/tests/data/AbstractClass.java
index d24d691..527e7eb 100644
--- a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/AbstractClass.java
+++ b/tests/signature-tests/src/android/signature/cts/tests/data/AbstractClass.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest.tests.data;
+package android.signature.cts.tests.data;
 
 /**
 * This class is used as reference data for the JDiffClassDescriptionTest tests.
diff --git a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/FinalClass.java b/tests/signature-tests/src/android/signature/cts/tests/data/FinalClass.java
similarity index 95%
rename from tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/FinalClass.java
rename to tests/signature-tests/src/android/signature/cts/tests/data/FinalClass.java
index 4c871f0..395e166 100644
--- a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/FinalClass.java
+++ b/tests/signature-tests/src/android/signature/cts/tests/data/FinalClass.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest.tests.data;
+package android.signature.cts.tests.data;
 
 /**
  * This class is used as reference data for the
diff --git a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalClass.java b/tests/signature-tests/src/android/signature/cts/tests/data/NormalClass.java
similarity index 97%
rename from tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalClass.java
rename to tests/signature-tests/src/android/signature/cts/tests/data/NormalClass.java
index 9cd54ab..5acd696 100644
--- a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalClass.java
+++ b/tests/signature-tests/src/android/signature/cts/tests/data/NormalClass.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest.tests.data;
+package android.signature.cts.tests.data;
 
 /**
  * This class is used as reference data for the
diff --git a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalException.java b/tests/signature-tests/src/android/signature/cts/tests/data/NormalException.java
similarity index 94%
rename from tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalException.java
rename to tests/signature-tests/src/android/signature/cts/tests/data/NormalException.java
index cc3d725..b2dd52d 100644
--- a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalException.java
+++ b/tests/signature-tests/src/android/signature/cts/tests/data/NormalException.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest.tests.data;
+package android.signature.cts.tests.data;
 
 import java.lang.Exception;
 
diff --git a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalInterface.java b/tests/signature-tests/src/android/signature/cts/tests/data/NormalInterface.java
similarity index 95%
rename from tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalInterface.java
rename to tests/signature-tests/src/android/signature/cts/tests/data/NormalInterface.java
index 3200b76..899f4cc 100644
--- a/tests/SignatureTest/tests/src/android/tests/sigtest/tests/data/NormalInterface.java
+++ b/tests/signature-tests/src/android/signature/cts/tests/data/NormalInterface.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest.tests.data;
+package android.signature.cts.tests.data;
 
 /**
  * This class is used as reference data for the
diff --git a/tests/SignatureTest/Android.mk b/tests/signature/Android.mk
similarity index 84%
rename from tests/SignatureTest/Android.mk
rename to tests/signature/Android.mk
index fc794e8..53ba50d 100644
--- a/tests/SignatureTest/Android.mk
+++ b/tests/signature/Android.mk
@@ -20,11 +20,11 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_PACKAGE_NAME := SignatureTest
+LOCAL_PACKAGE_NAME := CtsSignatureTestCases
 
 LOCAL_SDK_VERSION := current
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
 
 # To be passed in on command line
 CTS_API_VERSION ?= current
@@ -84,5 +84,18 @@
 android_api_description :=
 CTS_API_VERSION :=
 
-# Use the following include to make our test apk.
-include $(call all-makefiles-under,$(LOCAL_PATH))
+# signature-hostside java library (for testing)
+# ============================================================
+
+include $(CLEAR_VARS)
+
+# These files are for device-side only, so filter-out for host library
+LOCAL_DEVICE_ONLY_SOURCES := %/SignatureTest.java
+
+LOCAL_SRC_FILES := $(filter-out $(LOCAL_DEVICE_ONLY_SOURCES), $(call all-java-files-under, src))
+
+LOCAL_MODULE := signature-hostside
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/tests/SignatureTest/AndroidManifest.xml b/tests/signature/AndroidManifest.xml
similarity index 90%
rename from tests/SignatureTest/AndroidManifest.xml
rename to tests/signature/AndroidManifest.xml
index 89d8590..e42302e 100644
--- a/tests/SignatureTest/AndroidManifest.xml
+++ b/tests/signature/AndroidManifest.xml
@@ -16,7 +16,7 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="android.tests.sigtest">
+          package="android.signature">
     <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 
     <application>
@@ -24,7 +24,7 @@
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="android.tests.sigtest"
+                     android:targetPackage="android.signature"
                      android:label="API Signature Test"/>
 
 </manifest>
\ No newline at end of file
diff --git a/tests/SignatureTest/res/raw/excludepackages.txt b/tests/signature/res/raw/excludepackages.txt
similarity index 100%
rename from tests/SignatureTest/res/raw/excludepackages.txt
rename to tests/signature/res/raw/excludepackages.txt
diff --git a/tests/signature/src/android/signature/cts/FailureType.java b/tests/signature/src/android/signature/cts/FailureType.java
new file mode 100644
index 0000000..5aaebc4
--- /dev/null
+++ b/tests/signature/src/android/signature/cts/FailureType.java
@@ -0,0 +1,16 @@
+package android.signature.cts;
+
+/**
+ * Define the type of the signature check failures.
+ */
+public enum FailureType {
+    MISSING_CLASS,
+    MISSING_INTERFACE,
+    MISSING_METHOD,
+    MISSING_FIELD,
+    MISMATCH_CLASS,
+    MISMATCH_INTERFACE,
+    MISMATCH_METHOD,
+    MISMATCH_FIELD,
+    CAUGHT_EXCEPTION,
+}
diff --git a/tests/SignatureTest/src/android/tests/sigtest/JDiffClassDescription.java b/tests/signature/src/android/signature/cts/JDiffClassDescription.java
similarity index 94%
rename from tests/SignatureTest/src/android/tests/sigtest/JDiffClassDescription.java
rename to tests/signature/src/android/signature/cts/JDiffClassDescription.java
index 36360d6..7ea9911 100644
--- a/tests/SignatureTest/src/android/tests/sigtest/JDiffClassDescription.java
+++ b/tests/signature/src/android/signature/cts/JDiffClassDescription.java
@@ -14,9 +14,7 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest;
-
-import android.tests.sigtest.SignatureTest.FAILURE_TYPE;
+package android.signature.cts;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -83,9 +81,8 @@
      */
     public JDiffClassDescription(String pkg, String className) {
         this(pkg, className, new ResultObserver() {
-            public void notifyFailure(FAILURE_TYPE type,
-                    String name,
-                    String errorMessage) {
+            @Override
+            public void notifyFailure(FailureType type, String name, String errorMessage) {
                 // This is a null result observer that doesn't do anything.
             }
         });
@@ -99,9 +96,7 @@
      * @param className the name of the class.
      * @param resultObserver the resultObserver to get results with.
      */
-    public JDiffClassDescription(String pkg,
-            String className,
-            ResultObserver resultObserver) {
+    public JDiffClassDescription(String pkg, String className, ResultObserver resultObserver) {
         mPackageName = pkg;
         mShortClassName = className;
         mResultObserver = resultObserver;
@@ -144,7 +139,6 @@
     }
 
     static String convertModifiersToAccessLevel(int modifiers) {
-        String accessLevel = "";
         if ((modifiers & Modifier.PUBLIC) != 0) {
             return "public";
         } else if ((modifiers & Modifier.PRIVATE) != 0) {
@@ -500,7 +494,7 @@
 
                 Method m = findMatchingMethod(method);
                 if (m == null) {
-                    mResultObserver.notifyFailure(FAILURE_TYPE.MISSING_METHOD,
+                    mResultObserver.notifyFailure(FailureType.MISSING_METHOD,
                             method.toReadableString(mAbsoluteClassName),
                             "No method with correct signature found:" +
                             method.toSignatureString());
@@ -521,15 +515,15 @@
                     }
 
                     if (!areMethodModifiedCompatibile(method, m)) {
-                        mResultObserver.notifyFailure(FAILURE_TYPE.MISMATCH_METHOD,
+                        mResultObserver.notifyFailure(FailureType.MISMATCH_METHOD,
                                 method.toReadableString(mAbsoluteClassName),
                                 "Non-compatible method found when looking for " +
                                 method.toSignatureString());
                     }
                 }
             } catch (Exception e) {
-                SignatureTestLog.e("Got exception when checking method compliance", e);
-                mResultObserver.notifyFailure(FAILURE_TYPE.CAUGHT_EXCEPTION,
+                loge("Got exception when checking method compliance", e);
+                mResultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION,
                         method.toReadableString(mAbsoluteClassName),
                 "Exception!");
             }
@@ -583,7 +577,6 @@
     @SuppressWarnings("unchecked")
     private Method findMatchingMethod(JDiffMethod method) {
         Method[] methods = mClass.getDeclaredMethods();
-        boolean found = false;
 
         for (Method m : methods) {
             if (matches(method, m)) {
@@ -637,7 +630,7 @@
             try {
                 Constructor<?> c = findMatchingConstructor(con);
                 if (c == null) {
-                    mResultObserver.notifyFailure(FAILURE_TYPE.MISSING_METHOD,
+                    mResultObserver.notifyFailure(FailureType.MISSING_METHOD,
                             con.toReadableString(mAbsoluteClassName),
                             "No method with correct signature found:" +
                             con.toSignatureString());
@@ -647,15 +640,15 @@
                     }
                     if (c.getModifiers() != con.mModifier) {
                         mResultObserver.notifyFailure(
-                                FAILURE_TYPE.MISMATCH_METHOD,
+                                FailureType.MISMATCH_METHOD,
                                 con.toReadableString(mAbsoluteClassName),
                                 "Non-compatible method found when looking for " +
                                 con.toSignatureString());
                     }
                 }
             } catch (Exception e) {
-                SignatureTestLog.e("Got exception when checking constructor compliance", e);
-                mResultObserver.notifyFailure(FAILURE_TYPE.CAUGHT_EXCEPTION,
+                loge("Got exception when checking constructor compliance", e);
+                mResultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION,
                         con.toReadableString(mAbsoluteClassName),
                 "Exception!");
             }
@@ -716,12 +709,12 @@
             try {
                 Field f = findMatchingField(field);
                 if (f == null) {
-                    mResultObserver.notifyFailure(FAILURE_TYPE.MISSING_FIELD,
+                    mResultObserver.notifyFailure(FailureType.MISSING_FIELD,
                             field.toReadableString(mAbsoluteClassName),
                             "No field with correct signature found:" +
                             field.toSignatureString());
                 } else if (f.getModifiers() != field.mModifier) {
-                    mResultObserver.notifyFailure(FAILURE_TYPE.MISMATCH_FIELD,
+                    mResultObserver.notifyFailure(FailureType.MISMATCH_FIELD,
                             field.toReadableString(mAbsoluteClassName),
                             "Non-compatible field modifiers found when looking for " +
                             field.toSignatureString());
@@ -735,7 +728,7 @@
                     }
                     if (genericTypeName == null || !genericTypeName.equals(field.mFieldType)) {
                         mResultObserver.notifyFailure(
-                                FAILURE_TYPE.MISMATCH_FIELD,
+                                FailureType.MISMATCH_FIELD,
                                 field.toReadableString(mAbsoluteClassName),
                                 "Non-compatible field type found when looking for " +
                                 field.toSignatureString());
@@ -743,10 +736,11 @@
                 }
 
             } catch (Exception e) {
-                SignatureTestLog.e("Got exception when checking field compliance", e);
-                mResultObserver.notifyFailure(FAILURE_TYPE.CAUGHT_EXCEPTION,
+                loge("Got exception when checking field compliance", e);
+                mResultObserver.notifyFailure(
+                        FailureType.CAUGHT_EXCEPTION,
                         field.toReadableString(mAbsoluteClassName),
-                "Exception!");
+                        "Exception!");
             }
         }
     }
@@ -880,11 +874,11 @@
             if (mClass == null) {
                 // No class found, notify the observer according to the class type
                 if (JDiffType.INTERFACE.equals(mClassType)) {
-                    mResultObserver.notifyFailure(FAILURE_TYPE.MISSING_INTERFACE,
+                    mResultObserver.notifyFailure(FailureType.MISSING_INTERFACE,
                             mAbsoluteClassName,
                             "Classloader is unable to find " + mAbsoluteClassName);
                 } else {
-                    mResultObserver.notifyFailure(FAILURE_TYPE.MISSING_CLASS,
+                    mResultObserver.notifyFailure(FailureType.MISSING_CLASS,
                             mAbsoluteClassName,
                             "Classloader is unable to find " + mAbsoluteClassName);
                 }
@@ -920,10 +914,11 @@
                 }
             }
         } catch (Exception e) {
-            SignatureTestLog.e("Got exception when checking field compliance", e);
-            mResultObserver.notifyFailure(FAILURE_TYPE.CAUGHT_EXCEPTION,
+            loge("Got exception when checking field compliance", e);
+            mResultObserver.notifyFailure(
+                    FailureType.CAUGHT_EXCEPTION,
                     mAbsoluteClassName,
-            "Exception!");
+                    "Exception!");
         }
     }
 
@@ -974,11 +969,11 @@
 
     private void logMismatchInterfaceSignature(String classFullName, String errorMessage) {
         if (JDiffType.INTERFACE.equals(mClassType)) {
-            mResultObserver.notifyFailure(FAILURE_TYPE.MISMATCH_INTERFACE,
+            mResultObserver.notifyFailure(FailureType.MISMATCH_INTERFACE,
                     classFullName,
                     errorMessage);
         } else {
-            mResultObserver.notifyFailure(FAILURE_TYPE.MISMATCH_CLASS,
+            mResultObserver.notifyFailure(FailureType.MISMATCH_CLASS,
                     classFullName,
                     errorMessage);
         }
@@ -1026,7 +1021,7 @@
                 }
             }
         } catch (ClassNotFoundException e) {
-            SignatureTestLog.e("ClassNotFoundException for " + mPackageName + "." + mShortClassName, e);
+            loge("ClassNotFoundException for " + mPackageName + "." + mShortClassName, e);
             return null;
         }
         return null;
@@ -1195,4 +1190,8 @@
         // canonicalize them to one form.
         return paramType.replace("<? extends java.lang.Object>", "<?>");
     }
+
+    private static void loge(String message, Exception exception) {
+        System.err.println(String.format("%s: %s", message, exception));
+    }
 }
diff --git a/tests/SignatureTest/src/android/tests/sigtest/ResultObserver.java b/tests/signature/src/android/signature/cts/ResultObserver.java
similarity index 81%
rename from tests/SignatureTest/src/android/tests/sigtest/ResultObserver.java
rename to tests/signature/src/android/signature/cts/ResultObserver.java
index e9d2260..33234e9 100644
--- a/tests/SignatureTest/src/android/tests/sigtest/ResultObserver.java
+++ b/tests/signature/src/android/signature/cts/ResultObserver.java
@@ -14,9 +14,8 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest;
+package android.signature.cts;
 
-import android.tests.sigtest.SignatureTest.FAILURE_TYPE;
 /**
  * Interface for saving signature test result.
  */
@@ -27,8 +26,6 @@
      * @param name Name of the failed element (interface/class/method/field)
      * @param errorMessage a descriptive message indicating why it failed.
      */
-    void notifyFailure(FAILURE_TYPE type,
-                       String name,
-                       String errorMessage);
+    void notifyFailure(FailureType type, String name, String errorMessage);
 
 }
diff --git a/tests/SignatureTest/src/android/tests/sigtest/SignatureTest.java b/tests/signature/src/android/signature/cts/SignatureTest.java
similarity index 91%
rename from tests/SignatureTest/src/android/tests/sigtest/SignatureTest.java
rename to tests/signature/src/android/signature/cts/SignatureTest.java
index 8ae02ac3..e3099a9 100644
--- a/tests/SignatureTest/src/android/tests/sigtest/SignatureTest.java
+++ b/tests/signature/src/android/signature/cts/SignatureTest.java
@@ -14,13 +14,15 @@
  * limitations under the License.
  */
 
-package android.tests.sigtest;
+package android.signature.cts;
 
 import android.content.res.Resources;
+import android.signature.R;
+import android.signature.cts.JDiffClassDescription.JDiffConstructor;
+import android.signature.cts.JDiffClassDescription.JDiffField;
+import android.signature.cts.JDiffClassDescription.JDiffMethod;
 import android.test.AndroidTestCase;
-import android.tests.sigtest.JDiffClassDescription.JDiffConstructor;
-import android.tests.sigtest.JDiffClassDescription.JDiffField;
-import android.tests.sigtest.JDiffClassDescription.JDiffMethod;
+import android.util.Log;
 
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
@@ -37,6 +39,8 @@
  */
 public class SignatureTest extends AndroidTestCase {
 
+    private static final String TAG = SignatureTest.class.getSimpleName();
+
     private static final String TAG_ROOT = "api";
     private static final String TAG_PACKAGE = "package";
     private static final String TAG_CLASS = "class";
@@ -70,26 +74,12 @@
     private HashSet<String> mKeyTagSet;
     private TestResultObserver mResultObserver;
 
-    /**
-     * Define the type of the signature check failures.
-     */
-    public static enum FAILURE_TYPE {
-        MISSING_CLASS,
-        MISSING_INTERFACE,
-        MISSING_METHOD,
-        MISSING_FIELD,
-        MISMATCH_CLASS,
-        MISMATCH_INTERFACE,
-        MISMATCH_METHOD,
-        MISMATCH_FIELD,
-        CAUGHT_EXCEPTION,
-    }
-
     private class TestResultObserver implements ResultObserver {
         boolean mDidFail = false;
         StringBuilder mErrorString = new StringBuilder();
 
-        public void notifyFailure(FAILURE_TYPE type, String name, String errorMessage) {
+        @Override
+        public void notifyFailure(FailureType type, String name, String errorMessage) {
             mDidFail = true;
             mErrorString.append("\n");
             mErrorString.append(type.toString().toLowerCase());
@@ -116,12 +106,14 @@
     public void testSignature() {
         Resources r = getContext().getResources();
         Class rClass = R.xml.class;
+        logd(String.format("Class: %s", rClass.toString()));
         Field[] fs = rClass.getFields();
         for (Field f : fs) {
+            logd(String.format("Field: %s", fs.toString()));
             try {
                 start(r.getXml(f.getInt(rClass)));
             } catch (Exception e) {
-                mResultObserver.notifyFailure(FAILURE_TYPE.CAUGHT_EXCEPTION, e.getMessage(),
+                mResultObserver.notifyFailure(FailureType.CAUGHT_EXCEPTION, e.getMessage(),
                         e.getMessage());
             }
         }
@@ -150,6 +142,11 @@
      * Signature test entry point.
      */
     private void start(XmlPullParser parser) throws XmlPullParserException, IOException {
+        logd(String.format("Parser: %s", parser.getName()));
+        logd(String.format("Parser: %s", parser.getNamespace()));
+        logd(String.format("Parser: %s", parser.getLineNumber()));
+        logd(String.format("Parser: %s", parser.getColumnNumber()));
+        logd(String.format("Parser: %s", parser.getPositionDescription()));
         JDiffClassDescription currentClass = null;
         String currentPackage = "";
         JDiffMethod currentMethod = null;
@@ -332,4 +329,12 @@
         }
         return modifier;
     }
+
+    public static void loge(String msg, Exception e) {
+        Log.e(TAG, msg, e);
+    }
+
+    public static void logd(String msg) {
+        Log.d(TAG, msg);
+    }
 }
diff --git a/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java b/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java
index 408efe7..7d3fc5e 100644
--- a/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java
+++ b/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java
@@ -98,6 +98,10 @@
                 expectedMinimumMemory = isXLarge ? 256 : 128;
                 break;
 
+            case DisplayMetrics.DENSITY_560:
+                expectedMinimumMemory = isXLarge ? 512 : 256;
+                break;
+
             case DisplayMetrics.DENSITY_XXXHIGH:
                 expectedMinimumMemory = isXLarge ? 512 : 256;
                 break;
diff --git a/tests/tests/content/AndroidManifest.xml b/tests/tests/content/AndroidManifest.xml
index a5caba8..f7080ae 100644
--- a/tests/tests/content/AndroidManifest.xml
+++ b/tests/tests/content/AndroidManifest.xml
@@ -187,6 +187,15 @@
             </intent-filter>
         </activity>
 
+        <activity android:name="com.android.cts.content.ReadableFileReceiverActivity"
+                  android:exported="true">
+            <intent-filter>
+                <action android:name="android.intent.action.SEND" />
+                <action android:name="android.intent.action.SEND_MULTIPLE" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
+        </activity>
+
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
index e7b6ed7..62fc83a 100644
--- a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
@@ -641,7 +641,8 @@
     }
 
     public void testCheckCallingOrSelfPermission() {
-        int retValue = mContextWrapper.checkCallingOrSelfPermission("android.permission.GET_TASKS");
+        int retValue = mContextWrapper.checkCallingOrSelfPermission(
+                "android.permission.SET_WALLPAPER");
         assertEquals(PackageManager.PERMISSION_GRANTED, retValue);
     }
 
@@ -705,7 +706,7 @@
         }
 
         // Test with invalid uid and included granted permission.
-        returnValue = mContextWrapper.checkPermission("android.permission.GET_TASKS", 1, -11);
+        returnValue = mContextWrapper.checkPermission("android.permission.SET_WALLPAPER", 1, -11);
         assertEquals(PackageManager.PERMISSION_DENIED, returnValue);
     }
 
diff --git a/tests/tests/content/src/android/content/cts/ReadableFileReceiverActivity.java b/tests/tests/content/src/android/content/cts/ReadableFileReceiverActivity.java
new file mode 100644
index 0000000..bab516e
--- /dev/null
+++ b/tests/tests/content/src/android/content/cts/ReadableFileReceiverActivity.java
@@ -0,0 +1,120 @@
+/*
+ * 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.content;
+
+import android.app.Activity;
+import android.content.ClipData;
+import android.content.ClipData.Item;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ReadableFileReceiverActivity extends Activity {
+    public static final String ACTION_CONFIRM_READ_SUCCESS
+        = "com.android.cts.content.action.CONFIRM_READ_SUCCESS";
+    private static final String TAG = ReadableUriExtraToClipDataTest.TAG;
+
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        Intent intent = getIntent();
+
+        // Check action.
+        String action = intent.getAction();
+        if (Intent.ACTION_SEND.equals(action)
+                || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
+            readFilesFromClipDataUri(intent);
+        }
+
+        finish();
+    }
+
+    // Sends ACTION_FILE_READY intent when read from clipdata uri is succesful
+    // and read data matches the data written by the test.
+    private void readFilesFromClipDataUri(Intent intent) {
+        if ((intent.getFlags() & Intent.FLAG_GRANT_READ_URI_PERMISSION) == 0) {
+
+            // Note: since this activity is in the same package as the test we can read from the
+            // file regardless of this permission, but in general this permission is required.
+            Log.e(TAG, "Intent.FLAG_GRANT_READ_URI_PERMISSION was not granted.");
+            return;
+        }
+
+        List<File> files = getFilesFromIntent(intent);
+        if (files == null) {
+            Log.e(TAG, "Could not get files from clipdata.");
+            return;
+        }
+        for (File file : files) {
+            if (!testFileContents(file)) {
+                Log.e(TAG, "File contents of " + file.getPath()
+                        + " is incorrect or could not be verified.");
+                return;
+            }
+        }
+        Intent confirmIntent = new Intent(ACTION_CONFIRM_READ_SUCCESS);
+        sendBroadcast(confirmIntent);
+    }
+
+    private ArrayList<File> getFilesFromIntent(Intent intent) {
+        ClipData clipData = intent.getClipData();
+        if (clipData == null) {
+            Log.e(TAG, "ClipData missing.");
+            return null;
+        }
+        if (clipData.getItemCount() == 0) {
+            Log.e(TAG, "Uri missing in ClipData.");
+            return null;
+        }
+
+        ArrayList<File> result = new ArrayList<File>();
+        for (int i = 0; i < clipData.getItemCount(); i++) {
+            Uri filePath = clipData.getItemAt(i).getUri();
+            if (filePath == null) {
+                Log.e(TAG, "Uri missing in ClipData.");
+                return null;
+            }
+            try {
+                result.add(new File(filePath.getPath()));
+            } catch (IllegalArgumentException e) {
+                Log.e(TAG, "Cannot get file at Uri.");
+                return null;
+            }
+        }
+        return result;
+    }
+
+    private boolean testFileContents(File file) {
+        char[] buffer = new char[ReadableUriExtraToClipDataTest.TEST_INPUT.length()];
+        try {
+            FileReader reader = new FileReader(file);
+            reader.read(buffer);
+            reader.close();
+        } catch (IOException e) {
+            Log.e(TAG, "Error while reading file " + file.getPath() + ".");
+            return false;
+        }
+        String fileContents = new String(buffer);
+        return ReadableUriExtraToClipDataTest.TEST_INPUT.equals(fileContents);
+    }
+}
\ No newline at end of file
diff --git a/tests/tests/content/src/android/content/cts/ReadableUriExtraToClipDataTest.java b/tests/tests/content/src/android/content/cts/ReadableUriExtraToClipDataTest.java
new file mode 100644
index 0000000..129d964
--- /dev/null
+++ b/tests/tests/content/src/android/content/cts/ReadableUriExtraToClipDataTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.content;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.Uri;
+import android.provider.MediaStore;
+import android.test.AndroidTestCase;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.List;
+
+public class ReadableUriExtraToClipDataTest extends AndroidTestCase {
+    private static final List<String> FILE_NAMES = Arrays.asList("testFile1.txt", "testFile2.txt");
+    private static final List<File> mTestFiles = new ArrayList<File>();
+    private static final ArrayList<Uri> mTestFileUris = new ArrayList<Uri>();
+    private final Semaphore mReadSuccessSemaphore = new Semaphore(0);
+
+    public static final String TEST_INPUT = "testString";
+    public static final String TAG = "ReadableUriExtraToClipDataTest";
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        assertEquals(0, mReadSuccessSemaphore.availablePermits());
+
+        BroadcastReceiver mReceiver = new BroadcastReceiver() {
+                @Override
+                public void onReceive(Context context, Intent intent) {
+                    mReadSuccessSemaphore.release();
+                }
+            };
+        IntentFilter filter = new IntentFilter();
+        filter.addAction(ReadableFileReceiverActivity.ACTION_CONFIRM_READ_SUCCESS);
+        getContext().registerReceiver(mReceiver, filter);
+
+        for (String fileName : FILE_NAMES) {
+            File testFile = new File(getContext().getFilesDir() + File.separator + fileName);
+            writeTestInputToFile(testFile);
+            mTestFiles.add(testFile);
+            mTestFileUris.add(Uri.fromFile(testFile));
+        }
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        for (File testFile : mTestFiles) {
+            if (testFile.exists()) {
+                assertTrue(testFile.delete());
+            }
+        }
+        mTestFiles.clear();
+        mTestFileUris.clear();
+        super.tearDown();
+    }
+
+    public void testUriExtraStreamMigratedToClipData_sendIntent() {
+        Intent intent = new Intent(Intent.ACTION_SEND);
+        intent.setComponent(new ComponentName(getContext(), ReadableFileReceiverActivity.class));
+        intent.putExtra(Intent.EXTRA_STREAM, mTestFileUris.get(0));
+        intent.setType("*/*");
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+        getContext().startActivity(intent);
+
+        waitForConfirmationReadSuccess();
+    }
+
+    public void testUriExtraStreamMigratedToClipData_sendMultipleIntent() {
+        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
+        intent.setComponent(new ComponentName(getContext(), ReadableFileReceiverActivity.class));
+        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, mTestFileUris);
+        intent.setType("*/*");
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+        getContext().startActivity(intent);
+
+        waitForConfirmationReadSuccess();
+    }
+
+    private void writeTestInputToFile(File file) {
+        try {
+            FileWriter writer = new FileWriter(file);
+            writer.write(TEST_INPUT);
+            writer.flush();
+            writer.close();
+        } catch (IOException e) {
+            fail(e.toString());
+            return;
+        }
+    }
+
+    private void waitForConfirmationReadSuccess() {
+        try {
+            assertTrue(mReadSuccessSemaphore.tryAcquire(5, TimeUnit.SECONDS));
+        } catch (InterruptedException e) {
+            fail(e.toString());
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StillCaptureTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StillCaptureTest.java
index 2f5409d..9766a45 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StillCaptureTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StillCaptureTest.java
@@ -65,8 +65,8 @@
     // 60 second to accommodate the possible long exposure time.
     private static final int EXIF_DATETIME_ERROR_MARGIN_SEC = 60;
     private static final float EXIF_FOCAL_LENGTH_ERROR_MARGIN = 0.001f;
-    // TODO: exposure time error margin need to be scaled with exposure time.
-    private static final float EXIF_EXPOSURE_TIME_ERROR_MARGIN_SEC = 0.002f;
+    private static final float EXIF_EXPOSURE_TIME_ERROR_MARGIN_RATIO = 0.05f;
+    private static final float EXIF_EXPOSURE_TIME_MIN_ERROR_MARGIN_SEC = 0.002f;
     private static final float EXIF_APERTURE_ERROR_MARGIN = 0.001f;
     private static final Location sTestLocation0 = new Location(LocationManager.GPS_PROVIDER);
     private static final Location sTestLocation1 = new Location(LocationManager.GPS_PROVIDER);
@@ -1121,8 +1121,10 @@
                 double exposureTimeValue = Double.parseDouble(exposureTime);
                 long expTimeResult = result.get(CaptureResult.SENSOR_EXPOSURE_TIME);
                 double expected = expTimeResult / 1e9;
+                double tolerance = expected * EXIF_EXPOSURE_TIME_ERROR_MARGIN_RATIO;
+                tolerance = Math.max(tolerance, EXIF_EXPOSURE_TIME_MIN_ERROR_MARGIN_SEC);
                 mCollector.expectEquals("Exif exposure time doesn't match", expected,
-                        exposureTimeValue, EXIF_EXPOSURE_TIME_ERROR_MARGIN_SEC);
+                        exposureTimeValue, tolerance);
             }
         }
 
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java
index a62107b..d72a2ce 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java
@@ -58,7 +58,7 @@
     private TestSensorEventListener mTestSensorEventListener;
 
     /**
-     * @Deprecated Use {@link #TestSensorManager(TestSensorEnvironment)} instead.
+     * @deprecated Use {@link #TestSensorManager(TestSensorEnvironment)} instead.
      */
     @Deprecated
     public TestSensorManager(
diff --git a/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java b/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java
index 9679f82..225c623 100644
--- a/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java
+++ b/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java
@@ -128,6 +128,30 @@
         }
     }
 
+    /**
+     * Asserts that a domain, if it exists, is only running the listed executables.
+     *
+     * @param domain
+     *  The domain or SELinux context to check.
+     * @param executables
+     *  The path of the allowed executables or application package names.
+     */
+    private void assertDomainHasExecutable(String domain, String... executables)
+            throws FileNotFoundException {
+        List<ProcessDetails> procs = ProcessDetails.getProcessMap().get(domain);
+        if (procs == null) {
+            return; // domain doesn't exist
+        }
+
+        Set<String> execList = new HashSet<String>(Arrays.asList(executables));
+
+        for (ProcessDetails p : procs) {
+            String msg = "Expected one of \"" + execList + "\" in SELinux domain \""
+                + domain + "\"" + " Found: \"" + p + "\"";
+            assertTrue(msg, execList.contains(p.procTitle));
+        }
+    }
+
     /* Init is always there */
     public void testInitDomain() throws FileNotFoundException {
         assertDomainOne("u:r:init:s0", "/init");
@@ -198,9 +222,12 @@
         assertDomainOne("u:r:system_server:s0", "system_server");
     }
 
-    /* Some OEMs do not use sdcardd so transient */
+    /*
+     * Some OEMs do not use sdcardd so transient. Other OEMs have multiple sdcards
+     * so they run the daemon multiple times.
+     */
     public void testSdcarddDomain() throws FileNotFoundException {
-        assertDomainZeroOrOne("u:r:sdcardd:s0", "/system/bin/sdcard");
+        assertDomainHasExecutable("u:r:sdcardd:s0", "/system/bin/sdcard");
     }
 
     /* Watchdogd may or may not be there */
diff --git a/tools/tradefed-host/res/report/cts_result.xsl b/tools/tradefed-host/res/report/cts_result.xsl
index 3c914dc..7bc216b 100644
--- a/tools/tradefed-host/res/report/cts_result.xsl
+++ b/tools/tradefed-host/res/report/cts_result.xsl
@@ -339,8 +339,7 @@
                             <TD class="rowtitle">Host Info</TD>
                             <TD>
                                 <xsl:value-of select="TestResult/HostInfo/@name"/>
-                                (<xsl:value-of select="TestResult/HostInfo/Os/@name"/> - 
-                                  <xsl:value-of select="TestResult/HostInfo/Os/@version"/>)
+                                (<xsl:value-of select="TestResult/HostInfo/Os/@name"/> - <xsl:value-of select="TestResult/HostInfo/Os/@version"/>)
                             </TD>
                         </TR>
                         <TR>
@@ -467,7 +466,9 @@
                             <TD class="package" colspan="3">
                                 <xsl:variable name="href"><xsl:value-of select="@appPackageName"/></xsl:variable>
                                 <a name="{$href}">Compatibility Test Package: <xsl:value-of select="@appPackageName"/>
-                                abi: <xsl:value-of select="@abi"/>
+                                <xsl:if test="@abi">
+                                  ABI: <xsl:value-of select="@abi"/>
+                                </xsl:if>
                                 </a>
                             </TD>
                         </TR>
@@ -512,7 +513,7 @@
                                                 <xsl:if test="@result='pass'">
                                                     <TD class="pass">
                                                         <div style="text-align: center; margin-left:auto; margin-right:auto;">
-                                                            known problem
+                                                            Known problem
                                                         </div>
                                                     </TD>
                                                     <TD class="failuredetails"></TD>
@@ -585,7 +586,7 @@
         </DIV>
     </xsl:template>
 
-    <!-- Take a delimited string and insert line breaks after a some number of elements. --> 
+    <!-- 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" />
@@ -595,7 +596,7 @@
             <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>
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 db1b2dd..c185cec 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,8 +1,10 @@
 package com.android.cts.tradefed.testtype;
 
+import com.android.cts.tradefed.build.CtsBuildHelper;
 import com.android.cts.util.AbiUtils;
 import com.android.ddmlib.MultiLineReceiver;
 import com.android.ddmlib.testrunner.TestIdentifier;
+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;
@@ -10,9 +12,12 @@
 import com.android.tradefed.result.ITestInvocationListener;
 import com.android.tradefed.result.LogDataType;
 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.io.File;
+import java.io.FileNotFoundException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -25,8 +30,12 @@
  *
  * Supports running drawElements Quality Program tests found under external/deqp.
  */
-public class DeqpTestRunner implements IDeviceTest, IRemoteTest {
-    final private int TESTCASE_BATCH_LIMIT = 1000;
+public class DeqpTestRunner implements IBuildReceiver, IDeviceTest, IRemoteTest {
+
+    private static final String DEQP_ONDEVICE_APK = "com.drawelements.deqp.apk";
+    private static final String DEQP_ONDEVICE_PKG = "com.drawelements.deqp";
+
+    private final int TESTCASE_BATCH_LIMIT = 1000;
 
     private boolean mLogData;
 
@@ -36,6 +45,7 @@
     private final String mName;
     private Collection<TestIdentifier> mTests;
     private IAbi mAbi;
+    private CtsBuildHelper mCtsBuild;
 
     private TestIdentifier mCurrentTestId;
     private boolean mGotTestResult;
@@ -58,6 +68,14 @@
     }
 
     /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setBuild(IBuildInfo buildInfo) {
+        mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
+    }
+
+    /**
      * Enable or disable raw dEQP test log collection.
      */
     public void setCollectLogs(boolean logData) {
@@ -420,6 +438,29 @@
     }
 
     /**
+     * Install dEQP OnDevice Package
+     */
+    private void installTestApk() throws DeviceNotAvailableException {
+        try {
+            File apkFile = mCtsBuild.getTestApp(DEQP_ONDEVICE_APK);
+            String[] options = {AbiUtils.createAbiFlag(mAbi.getName())};
+            String errorCode = getDevice().installPackage(apkFile, true, options);
+            if (errorCode != null) {
+                CLog.e("Failed to install %s. Reason: %s", DEQP_ONDEVICE_APK, errorCode);
+            }
+        } catch (FileNotFoundException e) {
+            CLog.e("Could not find test apk %s", DEQP_ONDEVICE_APK);
+        }
+    }
+
+    /**
+     * Uninstall dEQP OnDevice Package
+     */
+    private void uninstallTestApk() throws DeviceNotAvailableException {
+        getDevice().uninstallPackage(DEQP_ONDEVICE_PKG);
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -429,6 +470,10 @@
         if ((mName.equals( "dEQP-GLES3") && isSupportedGles(mDevice, 3, 0))
             || (mName.equals("dEQP-GLES31") && isSupportedGles(mDevice, 3, 1))) {
 
+            // Make sure there is no pre-existing package form earlier interrupted test run.
+            uninstallTestApk();
+            installTestApk();
+
             while (!mTests.isEmpty()) {
                 executeTests(listener);
 
@@ -445,16 +490,18 @@
 
                         source.cancel();
                     }
-                if (!mGotTestResult) {
-                    mListener.testFailed(mCurrentTestId,
-                        "Log doesn't contain test result");
-                }
+                    if (!mGotTestResult) {
+                        mListener.testFailed(mCurrentTestId,
+                            "Log doesn't contain test result");
+                    }
 
                     mListener.testEnded(mCurrentTestId, emptyMap);
                     mCurrentTestId = null;
                     mListener.testRunEnded(0, emptyMap);
                 }
             }
+
+            uninstallTestApk();
         } else {
             /* Pass all tests if OpenGL ES version is not supported */
             Map <String, String> emptyMap = Collections.emptyMap();
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 45c176a..2eccb50 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
@@ -60,9 +60,6 @@
     public static final String UIAUTOMATOR_TEST = "uiAutomator";
     public static final String JUNIT_DEVICE_TEST = "jUnitDeviceTest";
 
-    private static final String SIGNATURE_TEST_METHOD = "testSignature";
-    private static final String SIGNATURE_TEST_CLASS = "android.tests.sigtest.SignatureTest";
-
     private String mAppPackageName = null;
     private String mAppNameSpace = null;
     private String mName = null;
@@ -70,7 +67,6 @@
     private String mTestType = null;
     private String mJarPath = null;
     private String mRunTimeArgs = null;
-    private boolean mIsSignatureTest = false;
     private String mTestPackageName = null;
     private String mDigest = null;
     private IAbi mAbi = null;
@@ -176,14 +172,6 @@
         return mJarPath;
     }
 
-    void setIsSignatureCheck(boolean isSignatureCheckTest) {
-        mIsSignatureTest = isSignatureCheckTest;
-    }
-
-    boolean isSignatureCheck() {
-        return mIsSignatureTest;
-    }
-
     void setTestPackageName(String testPackageName) {
         mTestPackageName = testPackageName;
     }
@@ -288,26 +276,6 @@
         } else if (UIAUTOMATOR_TEST.equals(mTestType)) {
             UiAutomatorJarTest uiautomatorTest = new UiAutomatorJarTest();
             return setUiAutomatorTest(uiautomatorTest);
-        } else if (mIsSignatureTest) {
-            // TODO: hardcode the runner/class/method for now, since current package xml points to
-            // specialized instrumentation. Eventually this special case for signatureTest can be
-            // removed, and it can be treated just like a normal InstrumentationTest
-            CLog.d("Creating signature test %s", mName);
-            CtsInstrumentationApkTest instrTest = new CtsInstrumentationApkTest();
-            instrTest.setPackageName(mAppNameSpace);
-            instrTest.setRunnerName("android.test.InstrumentationTestRunner");
-            instrTest.setClassName(SIGNATURE_TEST_CLASS);
-            instrTest.setMethodName(SIGNATURE_TEST_METHOD);
-            instrTest.setAbi(mAbi);
-            mTests.clear();
-            // set expected tests to the single signature test
-            TestIdentifier t = new TestIdentifier(
-                    SIGNATURE_TEST_CLASS, SIGNATURE_TEST_METHOD);
-            mTests.add(t);
-            // mName means 'apk file name' for instrumentation tests
-            instrTest.addInstallApk(String.format("%s.apk", mName), mAppNameSpace);
-            mDigest = generateDigest(testCaseDir, String.format("%s.apk", mName));
-            return instrTest;
         } else if (JUNIT_DEVICE_TEST.equals(mTestType)){
             CLog.d("Creating JUnit device test %s", mName);
             JUnitDeviceTest jUnitDeviceTest = new JUnitDeviceTest();
@@ -438,7 +406,7 @@
     }
 
     /**
-     * Get the collection of tests in this test package.
+     * {@inheritDoc}
      */
     @Override
     public Collection<TestIdentifier> getTests() {
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 4c549e2..ce91a8a 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
@@ -84,7 +84,14 @@
             Set<TestPackageDef> defs = parser.getTestPackageDefs();
             if (!defs.isEmpty()) {
                 for (TestPackageDef def : defs) {
-                    mTestMap.get(def.getAbi().getName()).put(def.getAppPackageName(), def);
+                    String name = def.getAppPackageName();
+                    String abi = def.getAbi().getName();
+                    if (def.getTests().size() > 0) {
+                        mTestMap.get(abi).put(name, def);
+                    } else {
+                        Log.i(LOG_TAG, String.format("No tests in %s for %s, skipping",
+                                name, abi));
+                    }
                 }
             } else {
                 Log.w(LOG_TAG, String.format("Could not find test package info in xml file %s",
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 71279c7..8f4f1b0 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
@@ -82,7 +82,6 @@
                 final String packageName = attributes.getValue("name");
                 final String runnerName = attributes.getValue("runner");
                 final String jarPath = attributes.getValue("jarPath");
-                final boolean signatureCheck = parseBoolean(attributes.getValue("signatureCheck"));
                 final String javaPackageFilter = attributes.getValue("javaPackageFilter");
                 final String targetBinaryName = attributes.getValue("targetBinaryName");
                 final String targetNameSpace = attributes.getValue("targetNameSpace");
@@ -98,7 +97,6 @@
                     packageDef.setRunner(runnerName);
                     packageDef.setTestType(testType);
                     packageDef.setJarPath(jarPath);
-                    packageDef.setIsSignatureCheck(signatureCheck);
                     packageDef.setRunTimeArgs(runTimeArgs);
                     if (!"".equals(javaPackageFilter)) {
                         packageDef.setTestPackageName(javaPackageFilter);
diff --git a/tools/tradefed-host/tests/Android.mk b/tools/tradefed-host/tests/Android.mk
index 7d4ab4a..2734a5b 100644
--- a/tools/tradefed-host/tests/Android.mk
+++ b/tools/tradefed-host/tests/Android.mk
@@ -24,6 +24,4 @@
 LOCAL_JAVA_LIBRARIES := tradefed-prebuilt cts-tradefed
 LOCAL_STATIC_JAVA_LIBRARIES := easymock
 
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-
+include $(BUILD_HOST_JAVA_LIBRARY)
\ No newline at end of file
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index cdd6e10..85adb0c 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -78,9 +78,6 @@
     """Generate test descriptions for all packages."""
     pool = Pool(processes=2)
 
-    # individually generate descriptions not following conventions
-    pool.apply_async(GenerateSignatureCheckDescription, [self.test_repository])
-
     # generate test descriptions for android tests
     results = []
     pool.close()
@@ -118,7 +115,7 @@
     plan.Exclude('android\.performance.*')
     self.__WritePlan(plan, 'SDK')
 
-    plan.Exclude(r'android\.tests\.sigtest')
+    plan.Exclude(r'android\.signature')
     plan.Exclude(r'android\.core.*')
     self.__WritePlan(plan, 'Android')
 
@@ -137,10 +134,6 @@
     self.__WritePlan(plan, 'VM-TF')
 
     plan = tools.TestPlan(packages)
-    plan.Include(r'android\.tests\.sigtest')
-    self.__WritePlan(plan, 'Signature')
-
-    plan = tools.TestPlan(packages)
     plan.Include(r'android\.tests\.appsecurity')
     self.__WritePlan(plan, 'AppSecurity')
 
@@ -328,6 +321,7 @@
       'android.rscpp' : [],
       'android.rsg' : [],
       'android.sax' : [],
+      'android.signature' : [],
       'android.speech' : [],
       'android.tests.appsecurity' : [],
       'android.text' : [],
@@ -370,7 +364,7 @@
       'android.location2' : [],
       'android.print' : [],
       'android.renderscriptlegacy' : [],
-      'android.tests.sigtest' : [],
+      'android.signature' : [],
       'android.tv' : [],
       'android.uiautomation' : [],
       'android.uirendering' : [],
@@ -434,18 +428,6 @@
 def LogGenerateDescription(name):
   print 'Generating test description for package %s' % name
 
-def GenerateSignatureCheckDescription(test_repository):
-  """Generate the test description for the signature check."""
-  LogGenerateDescription('android.tests.sigtest')
-  package = tools.TestPackage('SignatureTest', 'android.tests.sigtest')
-  package.AddAttribute('appNameSpace', 'android.tests.sigtest')
-  package.AddAttribute('signatureCheck', 'true')
-  package.AddAttribute('runner', '.InstrumentationRunner')
-  package.AddTest('android.tests.sigtest.SignatureTest.testSignature')
-  description = open(os.path.join(test_repository, 'SignatureTest.xml'), 'w')
-  package.WriteDescription(description)
-  description.close()
-
 if __name__ == '__main__':
   builder = CtsBuilder(sys.argv)
   result = builder.GenerateTestDescriptions()