Merge "Add 64bit support to tests and runners in CTS" into lmp-dev
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index c052a71..2be82a4 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -39,6 +39,7 @@
     CtsDeviceUi \
     CtsMonkeyApp \
     CtsMonkeyApp2 \
+    CtsProfileOwnerApp \
     CtsSomeAccessibilityServices \
     CtsTestStubs \
     CtsThemeDeviceApp \
@@ -136,6 +137,7 @@
 cts_host_libraries := \
     CtsAdbTests \
     CtsAppSecurityTests \
+    CtsDevicePolicyManagerTestCases \
     CtsHostJank \
     CtsHostUi \
     CtsMonkeyTestCases \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 3306151..e151325 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -760,6 +760,16 @@
             <meta-data android:name="test_category" android:value="@string/test_category_sensors"/>
         </activity>
 
+        <activity android:name=".sensors.SensorBatchingTestsActivity"
+                  android:label="@string/snsr_sensor_batching_tests"
+                  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"/>
+        </activity>
+
         <activity android:name=".sensors.SensorIntegrationTestsActivity"
                   android:label="@string/snsr_sensor_integration_tests">
             <intent-filter>
diff --git a/apps/CtsVerifier/res/layout/snsr_instruction.xml b/apps/CtsVerifier/res/layout/snsr_instruction.xml
index 66c7386..e7369c7 100644
--- a/apps/CtsVerifier/res/layout/snsr_instruction.xml
+++ b/apps/CtsVerifier/res/layout/snsr_instruction.xml
@@ -14,6 +14,7 @@
      limitations under the License.
 -->
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:textColor="?android:attr/textColorSecondary"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:paddingBottom="@dimen/snsr_log_padding_bottom"
diff --git a/apps/CtsVerifier/res/layout/snsr_message.xml b/apps/CtsVerifier/res/layout/snsr_message.xml
new file mode 100644
index 0000000..cef35ca
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/snsr_message.xml
@@ -0,0 +1,24 @@
+<?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.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:textStyle="italic"
+        android:textColor="?android:attr/textColorTertiary"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingTop="@dimen/snsr_log_padding_top"
+        android:paddingLeft="@dimen/snsr_boxed_padding_left"
+        android:paddingRight="@dimen/snsr_boxed_padding_right"
+        android:paddingBottom="@dimen/snsr_log_padding_bottom" />
diff --git a/apps/CtsVerifier/res/layout/snsr_test_title.xml b/apps/CtsVerifier/res/layout/snsr_test_title.xml
index 2a458e7..374fb54 100644
--- a/apps/CtsVerifier/res/layout/snsr_test_title.xml
+++ b/apps/CtsVerifier/res/layout/snsr_test_title.xml
@@ -14,10 +14,11 @@
      limitations under the License.
 -->
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:textStyle="bold"
+        android:textColor="?android:attr/textColorPrimary"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:paddingBottom="@dimen/snsr_boxed_padding_bottom"
         android:paddingTop="@dimen/snsr_boxed_padding_top"
         android:paddingLeft="@dimen/snsr_boxed_padding_left"
-        android:paddingRight="@dimen/snsr_boxed_padding_right"
-        android:textStyle="bold" />
+        android:paddingRight="@dimen/snsr_boxed_padding_right" />
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index a3b920f..ea86111 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -432,7 +432,6 @@
     <string name="snsr_executing_test">\nExecuting test case \'%1$s\'..\n</string>
     <string name="snsr_orientation_portrait">[Device orientation]: Portrait.</string>
     <string name="snsr_orientation_landscape">[Device orientation]: Landscape.</string>
-    <string name="snsr_register_listener">Expected to be able to register sensor listener. Found=%b.</string>
 
     <!-- Strings to interact with users in Sensor Tests -->
     <string name="snsr_test_play_sound">A sound will be played once the verification is complete...</string>
@@ -517,8 +516,6 @@
     <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_fifo_count">FifoReservedEventCount=%1$d. Expected to be at most FifoMaxEventCount=%2$d.</string>
-    <string name="snsr_batching_first_event_arrival">Batched events expected to arrive after %1$d ns. Found=%2$d ns.</string>
-    <string name="snsr_batching_flush_complete">Event \'onFlushComplete\' expected. Found=%1$b.</string>
 
     <!-- Sensor Synchronization -->
     <string name="snsr_synch_test">Sensor Synchronization Test</string>
@@ -555,6 +552,7 @@
     <string name="snsr_single_sensor_tests">CTS Single Sensor Tests</string>
     <string name="snsr_sensor_integration_tests">CTS Sensor Integration Tests</string>
     <string name="snsr_sensor_test">CTS Sensor Test</string>
+    <string name="snsr_sensor_batching_tests">CTS Sensor Batching Tests</string>
 
     <!-- Strings for Sample Test Activities -->
     <string name="share_button_text">Share</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerHardwareScanFilterActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerHardwareScanFilterActivity.java
index bf66acd..dd7e66c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerHardwareScanFilterActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleScannerHardwareScanFilterActivity.java
@@ -51,7 +51,6 @@
         setPassFailButtonClickListeners();
         setInfoResources(R.string.ble_scanner_scan_filter_name,
                          R.string.ble_scanner_scan_filter_info, -1);
-        getPassButton().setEnabled(false);
 
         mScanResultListView = (ListView)findViewById(R.id.ble_scan_result_list);
         mAdapter = new MapAdapter();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerService.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerService.java
index 5606041..91b3a6c 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerService.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerService.java
@@ -65,6 +65,8 @@
             "com.android.cts.verifier.bluetooth.BLE_DESCRIPTOR_WRITE_REQUEST";
     public static final String BLE_EXECUTE_WRITE =
             "com.android.cts.verifier.bluetooth.BLE_EXECUTE_WRITE";
+    public static final String BLE_OPEN_FAIL =
+            "com.android.cts.verifier.bluetooth.BLE_OPEN_FAIL";
 
     private static final UUID SERVICE_UUID =
             UUID.fromString("00009999-0000-1000-8000-00805f9b34fb");
@@ -90,11 +92,16 @@
         mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
         mGattServer = mBluetoothManager.openGattServer(this, mCallbacks);
         mService = createService();
-        mGattServer.addService(mService);
+        if (mGattServer != null) {
+            mGattServer.addService(mService);
+        }
         mDevice = null;
         mReliableWriteValue = null;
 
         mHandler = new Handler();
+        if (mGattServer == null) {
+            notifyOpenFail();
+        }
     }
 
     @Override
@@ -110,6 +117,9 @@
     @Override
     public void onDestroy() {
         super.onDestroy();
+        if (mGattServer == null) {
+           return;
+        }
         if (mDevice != null) mGattServer.cancelConnection(mDevice);
         mGattServer.close();
     }
@@ -126,6 +136,12 @@
         descriptor.setValue(writeValue.getBytes());
     }
 
+    private void notifyOpenFail() {
+        if (DEBUG) Log.d(TAG, "notifyOpenFail");
+        Intent intent = new Intent(BLE_OPEN_FAIL);
+        sendBroadcast(intent);
+    }
+
     private void notifyConnected() {
         if (DEBUG) Log.d(TAG, "notifyConnected");
         Intent intent = new Intent(BLE_SERVER_CONNECTED);
@@ -216,6 +232,10 @@
         TimerTask task = new TimerTask() {
             @Override
             public void run() {
+                if (mGattServer == null) {
+                    if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                    return;
+                }
                 BluetoothGattCharacteristic characteristic =
                         mService.getCharacteristic(UPDATE_CHARACTERISTIC_UUID);
                 if (characteristic == null) return;
@@ -268,7 +288,11 @@
 
         @Override
         public void onCharacteristicReadRequest(BluetoothDevice device, int requestId,
-                            int offset, BluetoothGattCharacteristic characteristic) {
+                int offset, BluetoothGattCharacteristic characteristic) {
+            if (mGattServer == null) {
+                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                return;
+            }
             if (DEBUG) Log.d(TAG, "onCharacteristicReadRequest()");
 
             notifyCharacteristicReadRequest();
@@ -278,9 +302,13 @@
 
         @Override
         public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId,
-                                                 BluetoothGattCharacteristic characteristic,
-                                                 boolean preparedWrite, boolean responseNeeded,
-                                                 int offset, byte[] value) {
+                BluetoothGattCharacteristic characteristic,
+                boolean preparedWrite, boolean responseNeeded,
+                int offset, byte[] value) {
+            if (mGattServer == null) {
+                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                return;
+            }
             if (DEBUG) Log.d(TAG, "onCharacteristicWriteRequest: preparedWrite=" + preparedWrite);
 
             notifyCharacteristicWriteRequest();
@@ -293,7 +321,11 @@
 
         @Override
         public void onDescriptorReadRequest(BluetoothDevice device, int requestId,
-                                            int offset, BluetoothGattDescriptor descriptor) {
+                int offset, BluetoothGattDescriptor descriptor) {
+            if (mGattServer == null) {
+                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                return;
+            }
             if (DEBUG) Log.d(TAG, "onDescriptorReadRequest(): (descriptor == getDescriptor())="
                                   + (descriptor == getDescriptor()));
 
@@ -304,9 +336,13 @@
 
         @Override
         public void onDescriptorWriteRequest(BluetoothDevice device, int requestId,
-                                             BluetoothGattDescriptor descriptor,
-                                             boolean preparedWrite, boolean responseNeeded,
-                                             int offset,  byte[] value) {
+                BluetoothGattDescriptor descriptor,
+                boolean preparedWrite, boolean responseNeeded,
+                int offset,  byte[] value) {
+            if (mGattServer == null) {
+                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                return;
+            }
             if (DEBUG) Log.d(TAG, "onDescriptorWriteRequest(): (descriptor == getDescriptor())="
                                   + (descriptor == getDescriptor()));
 
@@ -318,6 +354,10 @@
 
         @Override
         public void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute) {
+            if (mGattServer == null) {
+                if (DEBUG) Log.d(TAG, "GattServer is null, return");
+                return;
+            }
             if (DEBUG) Log.d(TAG, "onExecuteWrite");
             if (execute) {
                 notifyExecuteWrite();
@@ -326,4 +366,5 @@
             }
         }
     };
-}
\ No newline at end of file
+}
+
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerStartActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerStartActivity.java
index 089afde..e8e35d5 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerStartActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/bluetooth/BleServerStartActivity.java
@@ -34,6 +34,7 @@
 import android.widget.ImageView;
 import android.widget.ListView;
 import android.widget.TextView;
+import android.widget.Toast;
 
 public class BleServerStartActivity extends PassFailButtons.Activity {
 
@@ -70,6 +71,7 @@
         filter.addAction(BleServerService.BLE_DESCRIPTOR_WRITE_REQUEST);
         filter.addAction(BleServerService.BLE_EXECUTE_WRITE);
         filter.addAction(BleServerService.BLE_SERVER_DISCONNECTED);
+        filter.addAction(BleServerService.BLE_OPEN_FAIL);
         registerReceiver(onBroadcast, filter);
     }
 
@@ -126,6 +128,15 @@
             } else if (action == BleServerService.BLE_SERVER_DISCONNECTED) {
                 mTestAdapter.setTestPass(7);
                 mAllPassed |= 0x80;
+            } else if (action == BleServerService.BLE_OPEN_FAIL) {
+                setTestResultAndFinish(false);
+                runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        Toast.makeText(BleServerStartActivity.this, "Cannot open GattService",
+                                Toast.LENGTH_SHORT).show();
+                    }
+                });
             }
             mTestAdapter.notifyDataSetChanged();
             if (mAllPassed == 0xFF) getPassButton().setEnabled(true);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nls/NotificationListenerVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/nls/NotificationListenerVerifierActivity.java
index 842c024..5e9db53 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nls/NotificationListenerVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nls/NotificationListenerVerifierActivity.java
@@ -425,7 +425,7 @@
                     new MockListener.StringListResultCatcher() {
                 @Override
                 public void accept(List<String> result) {
-                    if (result.size() > 0 && result.contains(mTag1)) {
+                    if (result != null && result.size() > 0 && result.contains(mTag1)) {
                         mStatus[i] = PASS;
                     } else {
                         logWithStack("failed testNotificationRecieved");
@@ -444,7 +444,7 @@
             public void accept(List<String> result) {
                 boolean pass = false;
                 Set<String> found = new HashSet<String>();
-                if (result.size() > 0) {
+                if (result != null && result.size() > 0) {
                     pass = true;
                     for(String payloadData : result) {
                         try {
@@ -513,7 +513,7 @@
                     new MockListener.StringListResultCatcher() {
                 @Override
                 public void accept(List<String> result) {
-                    if (result.size() > 0 && result.contains(mTag1)) {
+                    if (result != null && result.size() > 0 && result.contains(mTag1)) {
                         mStatus[i] = PASS;
                         next();
                     } else {
@@ -546,7 +546,8 @@
                     new MockListener.StringListResultCatcher() {
                 @Override
                 public void accept(List<String> result) {
-                    if (result.size() == 2 && result.contains(mTag2) && result.contains(mTag3)) {
+                    if (result != null && result.size() == 2
+                            && result.contains(mTag2) && result.contains(mTag3)) {
                         mStatus[i] = PASS;
                         next();
                     } else {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ProjectionOffscreenActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ProjectionOffscreenActivity.java
index 5f32cfd..f992618 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ProjectionOffscreenActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/projection/offscreen/ProjectionOffscreenActivity.java
@@ -185,6 +185,13 @@
         }
 
         Image image = reader.acquireLatestImage();
+
+        // No new images available
+        if (image == null) {
+            Log.w(TAG, "onImageAvailable called but no image!");
+            return;
+        }
+
         if (mTestStatus == TestStatus.RUNNING) {
             int ret = scanImage(image);
             if (ret == -1) {
@@ -244,9 +251,7 @@
             offset += rowPadding;
         }
 
-        // Return a color if it represents more than one quarter of the pixels.
-        // We use this threshold in case the display is being letterboxed when
-        // mirroring so there might be large black bars on the sides, which is normal.
+        // Return a color if it represents all of the pixels.
         Log.d(TAG, "- Pixels: " + blackPixels + " black, "
                 + bluePixels + " blue, "
                 + otherPixels + " other");
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
index 009e644..42bd6ad 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BatchingTestActivity.java
@@ -19,22 +19,15 @@
 import com.android.cts.verifier.R;
 import com.android.cts.verifier.sensors.base.SensorCtsVerifierTestActivity;
 
-import junit.framework.Assert;
-
 import android.content.Context;
 import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener2;
 import android.hardware.SensorManager;
-import android.hardware.cts.helpers.SensorNotSupportedException;
-import android.hardware.cts.helpers.TestSensorEvent;
+import android.hardware.cts.helpers.sensoroperations.TestSensorFlushOperation;
+import android.hardware.cts.helpers.sensoroperations.TestSensorOperation;
+import android.hardware.cts.helpers.sensoroperations.VerifiableSensorOperation;
 import android.os.Bundle;
 import android.os.PowerManager;
-import android.os.SystemClock;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -44,27 +37,19 @@
  * If a sensor supports the batching mode, FifoReservedEventCount for that sensor should be greater
  * than one.
  */
-public class BatchingTestActivity
-        extends SensorCtsVerifierTestActivity
-        implements SensorEventListener2 {
+public class BatchingTestActivity extends SensorCtsVerifierTestActivity {
     public BatchingTestActivity() {
         super(BatchingTestActivity.class);
     }
 
-    private final long TWO_SECONDS_MILLIS = TimeUnit.SECONDS.toMillis(2);
-    private static final long DATA_COLLECTION_TIME_IN_MS = TimeUnit.SECONDS.toMillis(10);
-    private final long MIN_BATCH_TIME_NANOS = TimeUnit.SECONDS.toNanos(5);
-    private final long MAX_BATCH_REPORT_LATENCY_US = DATA_COLLECTION_TIME_IN_MS * 500;
+    private static final int SENSOR_BATCHING_RATE_US = SensorManager.SENSOR_DELAY_FASTEST;
+    private static final int REPORT_LATENCY_10_SEC = 10;
+    private static final int BATCHING_PADDING_TIME_S = 2;
 
-    private final List<TestSensorEvent> mSensorEvents = new ArrayList<TestSensorEvent>();
+    // we are testing sensors that only trigger based on external events, so leave enough time for
+    // such events to generate
+    private static final int REPORT_LATENCY_25_SEC = 25;
 
-    private SensorManager mSensorManager;
-
-    private volatile Sensor mSensorUnderTest;
-    private volatile long mTimeFirstBatchedEventReceivedNanos;
-
-    private CountDownLatch mSensorEventReceived;
-    private CountDownLatch mFlushCompleteReceived;
     private PowerManager.WakeLock mWakeLock;
 
     @Override
@@ -74,7 +59,6 @@
 
     @Override
     protected void activitySetUp() throws InterruptedException {
-        mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
         PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
         mWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "BatchingTests");
 
@@ -88,147 +72,106 @@
         restoreSensorFeatures();
     }
 
-    // TODO: refactor to discover all available sensors of each type and dinamically generate test
+    // TODO: refactor to discover all available sensors of each type and dynamically generate test
     // cases for all of them
-    public String testStepCounter() throws Throwable {
-        return runTest(Sensor.TYPE_STEP_COUNTER, R.string.snsr_batching_walking_needed);
+    public String testStepCounter_batching() throws Throwable {
+        return runBatchTest(
+                Sensor.TYPE_STEP_COUNTER,
+                REPORT_LATENCY_25_SEC,
+                R.string.snsr_batching_walking_needed);
     }
 
-    public String testStepDetector() throws Throwable {
-        return  runTest(Sensor.TYPE_STEP_DETECTOR, R.string.snsr_batching_walking_needed);
+    public String testStepCounter_flush() throws Throwable {
+        return runFlushTest(
+                Sensor.TYPE_STEP_COUNTER,
+                REPORT_LATENCY_25_SEC,
+                R.string.snsr_batching_walking_needed);
     }
 
-    public String testProximity() throws Throwable {
-        return runTest(Sensor.TYPE_PROXIMITY, R.string.snsr_interaction_needed);
+    public String testStepDetector_batching() throws Throwable {
+        return  runBatchTest(
+                Sensor.TYPE_STEP_DETECTOR,
+                REPORT_LATENCY_25_SEC,
+                R.string.snsr_batching_walking_needed);
     }
 
-    public String testLight() throws Throwable {
-        return runTest(Sensor.TYPE_LIGHT, R.string.snsr_interaction_needed);
+    public String testStepDetector_flush() throws Throwable {
+        return  runFlushTest(
+                Sensor.TYPE_STEP_DETECTOR,
+                REPORT_LATENCY_25_SEC,
+                R.string.snsr_batching_walking_needed);
     }
 
-    // TODO: move sensors that do not require interaction to CTS
-    public String testGameRotationVector() throws Throwable {
-        return runTest(Sensor.TYPE_GAME_ROTATION_VECTOR, R.string.snsr_no_interaction);
+    public String testProximity_batching() throws Throwable {
+        return runBatchTest(
+                Sensor.TYPE_PROXIMITY,
+                REPORT_LATENCY_10_SEC,
+                R.string.snsr_interaction_needed);
     }
 
-    public String testGeomagneticRotationVector() throws Throwable {
-        return runTest(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, R.string.snsr_no_interaction);
+    public String testProximity_flush() throws Throwable {
+        return runFlushTest(
+                Sensor.TYPE_PROXIMITY,
+                REPORT_LATENCY_10_SEC,
+                R.string.snsr_interaction_needed);
     }
 
-    public String testAccelerometer() throws Throwable {
-        return runTest(Sensor.TYPE_ACCELEROMETER, R.string.snsr_no_interaction);
+    public String testLight_batching() throws Throwable {
+        return runBatchTest(
+                Sensor.TYPE_LIGHT,
+                REPORT_LATENCY_10_SEC,
+                R.string.snsr_interaction_needed);
     }
 
-    public String testGyroscope() throws Throwable {
-        return runTest(Sensor.TYPE_GYROSCOPE, R.string.snsr_no_interaction);
+    public String testLight_flush() throws Throwable {
+        return runFlushTest(
+                Sensor.TYPE_LIGHT,
+                REPORT_LATENCY_10_SEC,
+                R.string.snsr_interaction_needed);
     }
 
-    public String testGyroscopeUncalibrated() throws Throwable {
-        return runTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, R.string.snsr_no_interaction);
+    private String runBatchTest(int sensorType, int maxBatchReportLatencySec, int instructionsResId)
+            throws Throwable {
+        getTestLogger().logInstructions(instructionsResId);
+        waitForUserToBegin();
+
+        Context context = getApplicationContext();
+        int maxBatchReportLatencyUs = (int) TimeUnit.SECONDS.toMicros(maxBatchReportLatencySec);
+        int testDurationSec = maxBatchReportLatencySec + BATCHING_PADDING_TIME_S;
+        TestSensorOperation operation = new TestSensorOperation(
+                context,
+                sensorType,
+                SENSOR_BATCHING_RATE_US,
+                maxBatchReportLatencyUs,
+                testDurationSec,
+                TimeUnit.SECONDS);
+
+        return executeTest(operation);
     }
 
-    public String testMagneticField() throws Throwable {
-        return runTest(Sensor.TYPE_MAGNETIC_FIELD, R.string.snsr_no_interaction);
+    private String runFlushTest(int sensorType, int maxBatchReportLatencySec, int instructionsResId)
+            throws Throwable {
+        getTestLogger().logInstructions(instructionsResId);
+        waitForUserToBegin();
+
+        Context context = getApplicationContext();
+        int maxBatchReportLatencyUs = (int) TimeUnit.SECONDS.toMicros(maxBatchReportLatencySec);
+        int flushDurationSec = maxBatchReportLatencySec / 2;
+        TestSensorFlushOperation operation = new TestSensorFlushOperation(
+                context,
+                sensorType,
+                SENSOR_BATCHING_RATE_US,
+                maxBatchReportLatencyUs,
+                flushDurationSec,
+                TimeUnit.SECONDS);
+
+        return executeTest(operation);
     }
 
-    public String testMagneticFieldUncalibrated() throws Throwable {
-        return runTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, R.string.snsr_no_interaction);
-    }
-
-    public String testRotationVector() throws Throwable {
-        return runTest(Sensor.TYPE_ROTATION_VECTOR, R.string.snsr_no_interaction);
-    }
-
-    // TODO: split batching and flush scenarios
-    private String runTest(int sensorType, int instructionsResId) throws Throwable {
-        mSensorUnderTest = mSensorManager.getDefaultSensor(sensorType);
-        // TODO: add exception for batching not supported
-        if (mSensorUnderTest == null || mSensorUnderTest.getFifoMaxEventCount() < 1) {
-            throw new SensorNotSupportedException(Sensor.TYPE_STEP_COUNTER);
-        }
-
-        appendText(instructionsResId);
-        waitForUser();
-
-        // Register to wait for first sensor event arrival, and when FIFO has been flushed
-        mSensorEventReceived = new CountDownLatch(1);
-        mFlushCompleteReceived = new CountDownLatch(1);
-        mSensorEvents.clear();
-
-        int fifoReservedEventCount = mSensorUnderTest.getFifoReservedEventCount();
-        int fifoMaxEventCount = mSensorUnderTest.getFifoMaxEventCount();
-        String fifoMessage = getString(
-                R.string.snsr_batching_fifo_count,
-                fifoReservedEventCount,
-                fifoMaxEventCount);
-        Assert.assertTrue(fifoMessage, fifoReservedEventCount <= fifoMaxEventCount);
-
-        // Time when start batching
-        mTimeFirstBatchedEventReceivedNanos = 0;
-        long timeBatchingStartedNanos = SystemClock.elapsedRealtimeNanos();
-
-        // Batch with the fastest rate and set report latency large enough to ensure full batching
-        // occurs
-        boolean registerResult = mSensorManager.registerListener(
-                this /* listener */,
-                mSensorUnderTest,
-                SensorManager.SENSOR_DELAY_FASTEST,
-                (int) MAX_BATCH_REPORT_LATENCY_US);
-        Assert.assertTrue(
-                getString(R.string.snsr_register_listener, registerResult),
-                registerResult);
-
-        // add a buffer to the duration of the test for timeout
-        mSensorEventReceived
-                .await(DATA_COLLECTION_TIME_IN_MS + TWO_SECONDS_MILLIS, TimeUnit.MILLISECONDS);
-        // TODO: add delayed assertion for await
-
-        // verify the minimum batching time
-        long firstTimeArrivalDelta = mTimeFirstBatchedEventReceivedNanos - timeBatchingStartedNanos;
-        String firstTimeArrivalMessage = getString(
-                R.string.snsr_batching_first_event_arrival,
-                MIN_BATCH_TIME_NANOS,
-                firstTimeArrivalDelta);
-        Assert.assertTrue(firstTimeArrivalMessage, firstTimeArrivalDelta >= MIN_BATCH_TIME_NANOS);
-
-        // batch a bit more to test the flush
-        long sleepTime = TimeUnit.NANOSECONDS.toMillis(MIN_BATCH_TIME_NANOS / 2);
-        Thread.sleep(sleepTime);
-        mSensorManager.flush(this);
-
-        boolean flushAwaitSuccess = mFlushCompleteReceived
-                .await(DATA_COLLECTION_TIME_IN_MS + TWO_SECONDS_MILLIS, TimeUnit.MILLISECONDS);
-        Assert.assertTrue(
-                getString(R.string.snsr_batching_flush_complete, flushAwaitSuccess),
-                flushAwaitSuccess);
-
-        playSound();
-        // TODO: use SensorTestVerifications to check for event ordering and event gap
+    private String executeTest(VerifiableSensorOperation operation) {
+        operation.addDefaultVerifications();
+        operation.setLogEvents(true);
+        operation.execute();
         return null;
     }
-
-    @Override
-    public void onSensorChanged(SensorEvent sensorEvent) {
-        long elapsedTime = SystemClock.elapsedRealtimeNanos();
-        if (sensorEvent.sensor.getType() != mSensorUnderTest.getType()) {
-            // TODO: add delayed assertion
-            return;
-        }
-
-        mSensorEvents.add(new TestSensorEvent(sensorEvent, elapsedTime));
-        if (mTimeFirstBatchedEventReceivedNanos == 0) {
-            mTimeFirstBatchedEventReceivedNanos = elapsedTime;
-            mSensorEventReceived.countDown();
-        }
-    }
-
-    @Override
-    public void onAccuracyChanged(Sensor sensor, int accuracy) {
-    }
-
-    @Override
-    public void onFlushCompleted(Sensor sensor) {
-        mSensorManager.unregisterListener(this);
-        mFlushCompleteReceived.countDown();
-    }
 }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorBatchingTestsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorBatchingTestsActivity.java
new file mode 100644
index 0000000..d1923cc
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SensorBatchingTestsActivity.java
@@ -0,0 +1,31 @@
+/*
+ * 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.verifier.sensors;
+
+import com.android.cts.verifier.sensors.base.SensorCtsTestActivity;
+
+import android.hardware.cts.SensorBatchingTests;
+
+/**
+ * Activity to execute CTS sensor batching tests.
+ * It is a wrapper for {@link SensorBatchingTests} running with AndroidJUnitRunner.
+ */
+public class SensorBatchingTestsActivity extends SensorCtsTestActivity {
+    public SensorBatchingTestsActivity() {
+        super(SensorBatchingTests.class);
+    }
+}
\ No newline at end of file
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 78430e3..221c92a 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java
@@ -29,8 +29,9 @@
 import android.hardware.cts.helpers.MovementDetectorHelper;
 import android.hardware.cts.helpers.TestSensorEvent;
 import android.os.SystemClock;
+import android.view.MotionEvent;
 import android.view.View;
-import android.view.View.OnClickListener;
+import android.widget.ScrollView;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -66,6 +67,10 @@
     private final List<TestSensorEvent> mStepCounterEvents = new ArrayList<TestSensorEvent>();
     private final List<TestSensorEvent> mStepDetectorEvents = new ArrayList<TestSensorEvent>();
 
+    /**
+     * A flag that indicates if the test is interested in registering steps reported by the
+     * operator. The registration of events happens by tapping the screen throughout the test.
+     */
     private volatile boolean mCheckForMotion;
 
     @Override
@@ -74,16 +79,19 @@
         mSensorStepCounter = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
         mSensorStepDetector = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
 
-        View screen = findViewById(R.id.log_layout);
-        screen.setOnClickListener(new OnClickListener() {
+        ScrollView scrollView = (ScrollView) findViewById(R.id.log_scroll_view);
+        scrollView.setOnTouchListener(new View.OnTouchListener() {
             @Override
-            public void onClick(View v) {
+            public boolean onTouch(View v, MotionEvent event) {
+                // during movement of the device, the ScrollView will detect user taps as attempts
+                // to scroll, when in reality they are taps in the layout
+                // to overcome the fact that a ScrollView cannot be disabled from scrolling, we
+                // listen for ACTION_UP events instead of click events in the child layout
                 long elapsedTime = SystemClock.elapsedRealtimeNanos();
-                if (mCheckForMotion) {
-                    playSound();
-                    mTimestampsUserReported.add(SystemClock.elapsedRealtimeNanos());
-                    appendText(getString(R.string.snsr_step_reported, elapsedTime));
+                if (event.getAction() == MotionEvent.ACTION_UP) {
+                    logUserReportedStep(elapsedTime);
                 }
+                return false;
             }
         });
     }
@@ -123,8 +131,8 @@
         mMoveDetected = false;
         mCheckForMotion = false;
 
-        appendText(instructionsResId);
-        waitForUser();
+        getTestLogger().logMessage(instructionsResId);
+        waitForUserToBegin();
 
         mCheckForMotion = (expectedSteps > 0);
         if (vibrate) {
@@ -299,16 +307,25 @@
         int type = event.sensor.getType();
         if (type == Sensor.TYPE_STEP_COUNTER) {
             mStepCounterEvents.add(new TestSensorEvent(event, elapsedRealtimeNanos));
-            String counterMessage = getString(
+            getTestLogger().logMessage(
                     R.string.snsr_step_counter_event,
                     elapsedRealtimeNanos,
                     (int) event.values[0]);
-            appendText(counterMessage);
         } else if (type == Sensor.TYPE_STEP_DETECTOR) {
             mStepDetectorEvents.add(new TestSensorEvent(event, elapsedRealtimeNanos));
-            appendText(getString(R.string.snsr_step_detector_event, elapsedRealtimeNanos));
+            getTestLogger().logMessage(R.string.snsr_step_detector_event, elapsedRealtimeNanos);
 
         }
         // TODO: with delayed assertions check events of other types are tracked
     }
+
+    private void logUserReportedStep(long timestamp) {
+        if (!mCheckForMotion) {
+            return;
+        }
+
+        playSound();
+        mTimestampsUserReported.add(timestamp);
+        getTestLogger().logMessage(R.string.snsr_step_reported, timestamp);
+    }
 }
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 2938dff..04603cb 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
@@ -402,6 +402,12 @@
             textAppender.append();
         }
 
+        public void logMessage(int messageResId, Object ... params) {
+            TextAppender textAppender = new TextAppender(R.layout.snsr_message);
+            textAppender.setText(getString(messageResId, params));
+            textAppender.append();
+        }
+
         public void logTestDetails(SensorTestDetails testDetails) {
             String name = testDetails.getName();
             String summary = testDetails.getSummary();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestActivity.java
index 1479248..6bdc8d2 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestActivity.java
@@ -20,10 +20,11 @@
 import com.android.cts.verifier.R;
 import com.android.cts.verifier.sensors.reporting.SensorTestDetails;
 
-import junit.framework.TestResult;
+import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.junit.internal.runners.JUnit38ClassRunner;
+import org.junit.internal.runners.SuiteMethod;
 import org.junit.runner.Computer;
 import org.junit.runner.Description;
 import org.junit.runner.JUnitCore;
@@ -93,27 +94,35 @@
     }
 
     /**
-     * A {@link RunnerBuilder} that is used to inject during execution a {@link SensorTestSuite}.
+     * A {@link RunnerBuilder} that is used to inject during execution a {@link SensorCtsTestSuite}.
      */
     private class SensorRunnerBuilder extends RunnerBuilder {
         @Override
         public Runner runnerForClass(Class<?> testClass) throws Throwable {
-            TestSuite testSuite = new SensorTestSuite(testClass);
-            return new JUnit38ClassRunner(testSuite);
-        }
-    }
-
-    /**
-     * A {@link TestSuite} that is used to inject during execution a {@link SensorCtsTestResult}.
-     */
-    private class SensorTestSuite extends TestSuite {
-        public SensorTestSuite(Class<?> testClass) {
-            super(testClass);
+            TestSuite testSuite;
+            if (hasSuiteMethod(testClass)) {
+                Test test = SuiteMethod.testFromSuiteMethod(testClass);
+                if (test instanceof TestSuite) {
+                    testSuite = (TestSuite) test;
+                } else {
+                    throw new IllegalArgumentException(
+                            testClass.getName() + "#suite() did not return a TestSuite.");
+                }
+            } else {
+                testSuite = new TestSuite(testClass);
+            }
+            SensorCtsTestSuite sensorTestSuite =
+                    new SensorCtsTestSuite(getApplicationContext(), testSuite);
+            return new JUnit38ClassRunner(sensorTestSuite);
         }
 
-        @Override
-        public void run(TestResult testResult) {
-            super.run(new SensorCtsTestResult(getApplicationContext(), testResult));
+        private boolean hasSuiteMethod(Class testClass) {
+            try {
+                testClass.getMethod("suite");
+                return true;
+            } catch (NoSuchMethodException e) {
+                return false;
+            }
         }
     }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestSuite.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestSuite.java
new file mode 100644
index 0000000..bbf76a7
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/base/SensorCtsTestSuite.java
@@ -0,0 +1,90 @@
+/*
+ * 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.verifier.sensors.base;
+
+import junit.framework.Test;
+import junit.framework.TestResult;
+import junit.framework.TestSuite;
+
+import android.content.Context;
+
+import java.util.Enumeration;
+
+/**
+ * A wrapper class for a {@link TestSuite}.
+ *
+ * It provides a way to inject a {@link SensorCtsTestResult} during execution.
+ */
+class SensorCtsTestSuite extends TestSuite {
+    private final Context mContext;
+    private final TestSuite mWrappedTestSuite;
+
+    public SensorCtsTestSuite(Context context, TestSuite testSuite) {
+        mContext = context;
+        mWrappedTestSuite = testSuite;
+    }
+
+    @Override
+    public void run(TestResult testResult) {
+        mWrappedTestSuite.run(new SensorCtsTestResult(mContext, testResult));
+    }
+
+    @Override
+    public void addTest(Test test) {
+        mWrappedTestSuite.addTest(test);
+    }
+
+    @Override
+    public int countTestCases() {
+        return mWrappedTestSuite.countTestCases();
+    }
+
+    @Override
+    public String getName() {
+        return mWrappedTestSuite.getName();
+    }
+
+    @Override
+    public void runTest(Test test, TestResult testResult) {
+        mWrappedTestSuite.runTest(test, testResult);
+    }
+
+    @Override
+    public void setName(String name) {
+        mWrappedTestSuite.setName(name);
+    }
+
+    @Override
+    public Test testAt(int index) {
+        return mWrappedTestSuite.testAt(index);
+    }
+
+    @Override
+    public int testCount() {
+        return mWrappedTestSuite.testCount();
+    }
+
+    @Override
+    public Enumeration<Test> tests() {
+        return mWrappedTestSuite.tests();
+    }
+
+    @Override
+    public String toString() {
+        return mWrappedTestSuite.toString();
+    }
+}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/reporting/SensorTestDetails.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/reporting/SensorTestDetails.java
index 9a9b1cb..6ca4e30 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/reporting/SensorTestDetails.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/reporting/SensorTestDetails.java
@@ -64,7 +64,7 @@
     public SensorTestDetails(Context context, String name, Result result) {
         this(context,
                 name,
-                result.getRunCount(),
+                result.getRunCount() - result.getFailureCount() - result.getIgnoreCount(),
                 result.getIgnoreCount(),
                 result.getFailureCount());
     }
diff --git a/hostsidetests/devicepolicy/Android.mk b/hostsidetests/devicepolicy/Android.mk
new file mode 100644
index 0000000..1f51494
--- /dev/null
+++ b/hostsidetests/devicepolicy/Android.mk
@@ -0,0 +1,32 @@
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := CtsDevicePolicyManagerTestCases
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_JAVA_LIBRARIES := junit ddmlib-prebuilt tradefed-prebuilt tools-common-prebuilt cts-tradefed
+
+LOCAL_CTS_TEST_PACKAGE := android.adminhostside
+
+include $(BUILD_CTS_HOST_JAVA_LIBRARY)
+
+# Build the test APKs using their own makefiles
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/devicepolicy/app/Android.mk b/hostsidetests/devicepolicy/app/Android.mk
new file mode 100644
index 0000000..a22ef3f
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/Android.mk
@@ -0,0 +1,20 @@
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Build the test APKs using their own makefiles
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk b/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
new file mode 100644
index 0000000..a845163
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/Android.mk
@@ -0,0 +1,31 @@
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := CtsProfileOwnerApp
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/ProfileOwner/AndroidManifest.xml
new file mode 100644
index 0000000..1aaf99f
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/AndroidManifest.xml
@@ -0,0 +1,38 @@
+<?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>
+    </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/app/ProfileOwner/res/values/strings.xml b/hostsidetests/devicepolicy/app/ProfileOwner/res/values/strings.xml
new file mode 100644
index 0000000..640b8b5
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/res/values/strings.xml
@@ -0,0 +1,20 @@
+<?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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- Label for this package -->
+    <string name="label">Android CTS - Profile Owner</string>
+</resources>
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/res/xml/device_admin.xml b/hostsidetests/devicepolicy/app/ProfileOwner/res/xml/device_admin.xml
new file mode 100644
index 0000000..8f39ed0
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/res/xml/device_admin.xml
@@ -0,0 +1,19 @@
+<!-- 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.
+-->
+<device-admin xmlns:android="http://schemas.android.com/apk/res/android" android:visible="false">
+    <uses-policies>
+        <wipe-data />
+    </uses-policies>
+</device-admin>
diff --git a/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/BaseProfileOwnerTest.java b/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/BaseProfileOwnerTest.java
new file mode 100644
index 0000000..e7ccc74
--- /dev/null
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/BaseProfileOwnerTest.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.profileowner;
+
+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 profile-owner based tests.
+ *
+ * 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 static class BasicAdminReceiver extends DeviceAdminReceiver {
+    }
+
+    static final ComponentName ADMIN_RECEIVER_COMPONENT = new ComponentName(
+            BasicAdminReceiver.class.getPackage().getName(), BasicAdminReceiver.class.getName());
+
+    protected DevicePolicyManager mDevicePolicyManager;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+       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.
+       assertTrue(mDevicePolicyManager.isAdminActive(ADMIN_RECEIVER_COMPONENT));
+       assertTrue(mDevicePolicyManager.isProfileOwnerApp(
+               ADMIN_RECEIVER_COMPONENT.getPackageName()));
+    }
+}
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/ProfileOwnerSetupTest.java
similarity index 61%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/ProfileOwnerSetupTest.java
index 16e76c9..6fc0eb9 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/hostsidetests/devicepolicy/app/ProfileOwner/src/com/android/cts/profileowner/ProfileOwnerSetupTest.java
@@ -13,14 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package com.android.cts.profileowner;
 
-package android.os.cts;
 
-public class TaggedPointer {
+public class ProfileOwnerSetupTest extends BaseProfileOwnerTest {
 
-    static {
-        System.loadLibrary("cts_jni");
+    // 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() {
+        // Empty test. We just want the assertions from super.setUp() to be executed.
     }
 
-    public static native boolean hasTaggedPointer();
 }
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ProfileOwnerTest.java
new file mode 100644
index 0000000..e2f2f4e
--- /dev/null
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ProfileOwnerTest.java
@@ -0,0 +1,227 @@
+/*
+ * 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.cts.tradefed.build.CtsBuildHelper;
+import com.android.ddmlib.Log.LogLevel;
+import com.android.ddmlib.testrunner.InstrumentationResultParser;
+import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
+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;
+import com.android.tradefed.result.CollectingTestListener;
+import com.android.tradefed.result.TestResult;
+import com.android.tradefed.result.TestResult.TestStatus;
+import com.android.tradefed.result.TestRunResult;
+import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.tradefed.testtype.IBuildReceiver;
+
+import java.io.FileNotFoundException;
+import java.util.HashSet;
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
+/**
+ * Set of tests for Profile Owner use cases.
+ */
+public class ProfileOwnerTest 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;
+
+    @Override
+    public void setBuild(IBuildInfo buildInfo) {
+        mCtsBuild = CtsBuildHelper.createBuildHelper(buildInfo);
+    }
+
+    @Override
+    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);
+        }
+    }
+
+    @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();
+    }
+
+    public void testProfileOwner() throws Exception {
+        if (!mHasFeature) {
+            return;
+        }
+        // Runs all tests classes from the package, as the profile user.
+        assertTrue(runDeviceTestsAsUser(PROFILE_OWNER_PKG, null /*testClassName*/, mUserId));
+    }
+
+    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)
+            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();
+        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) 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:"));
+    }
+
+    /** Returns true if the specified tests passed. Tests are run as user owner. */
+    private 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)
+            throws DeviceNotAvailableException {
+        return runDeviceTests(pkgName, testClassName, null /*testMethodName*/, userId);
+    }
+
+    private boolean runDeviceTests(String pkgName, @Nullable String testClassName,
+            @Nullable String testMethodName, @Nullable Integer userId)
+            throws DeviceNotAvailableException {
+        TestRunResult runResult = (userId == null)
+                ? doRunTests(pkgName, testClassName, testMethodName)
+                : doRunTestsAsUser(pkgName, testClassName, testMethodName, userId);
+        printTestResult(runResult);
+        return !runResult.hasFailedTests() && runResult.getNumPassedTests() > 0;
+    }
+
+    /** 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 {
+        RemoteAndroidTestRunner testRunner = new RemoteAndroidTestRunner(
+                pkgName, RUNNER, getDevice().getIDevice());
+        if (testClassName != null && testMethodName != null) {
+            testRunner.setMethodName(testClassName, testMethodName);
+        } else if (testClassName != null) {
+            testRunner.setClassName(testClassName);
+        }
+
+        CollectingTestListener listener = new CollectingTestListener();
+        assertTrue(getDevice().runInstrumentationTests(testRunner, listener));
+        return listener.getCurrentRunResults();
+    }
+
+    private TestRunResult doRunTestsAsUser(String pkgName, @Nullable String testClassName,
+            @Nullable String testMethodName, int userId)
+            throws DeviceNotAvailableException {
+        // TODO: move this to RemoteAndroidTestRunner once it supports users. Should be straight
+        // forward to add a RemoteAndroidTestRunner.setUser(userId) method. Then we can merge both
+        // doRunTests* methods.
+        StringBuilder testsToRun = new StringBuilder();
+        if (testClassName != null) {
+            testsToRun.append("-e class " + testClassName);
+            if (testMethodName != null) {
+                testsToRun.append("#" + testMethodName);
+            }
+        }
+        String command = "am instrument --user " + userId + " -w -r " + testsToRun + " "
+                + pkgName + "/" + RUNNER;
+        CLog.i("Running " + command);
+
+        CollectingTestListener listener = new CollectingTestListener();
+        InstrumentationResultParser parser = new InstrumentationResultParser(pkgName, listener);
+        getDevice().executeShellCommand(command, parser);
+        return listener.getCurrentRunResults();
+    }
+
+    private void printTestResult(TestRunResult runResult) {
+        for (Map.Entry<TestIdentifier, TestResult> testEntry :
+                runResult.getTestResults().entrySet()) {
+            TestResult testResult = testEntry.getValue();
+            CLog.logAndDisplay(LogLevel.INFO,
+                    "Test " + testEntry.getKey() + ": " + testResult.getStatus());
+            if (testResult.getStatus() != TestStatus.PASSED) {
+                CLog.logAndDisplay(LogLevel.WARN, testResult.getStackTrace());
+            }
+        }
+    }
+}
diff --git a/hostsidetests/theme/app/Android.mk b/hostsidetests/theme/app/Android.mk
index d7ca509..1be2983 100644
--- a/hostsidetests/theme/app/Android.mk
+++ b/hostsidetests/theme/app/Android.mk
@@ -32,7 +32,7 @@
 
 #Flags to tell the Android Asset Packaging Tool not to strip for some densities
 LOCAL_AAPT_FLAGS = -c land -c xx_YY -c cs -c small -c normal -c large -c xlarge \
- -c 640dpi -c 480dpi -c 400dpi -c 320dpi -c 240dpi -c 213dpi -c 160dpi -c 120dpi
+ -c 640dpi -c 560dpi -c 480dpi -c 400dpi -c 320dpi -c 240dpi -c 213dpi -c 160dpi -c 120dpi
 
 LOCAL_PACKAGE_NAME := CtsThemeDeviceApp
 
diff --git a/hostsidetests/theme/app/res/drawable-560dpi/display_info.png b/hostsidetests/theme/app/res/drawable-560dpi/display_info.png
new file mode 100644
index 0000000..babe0da
--- /dev/null
+++ b/hostsidetests/theme/app/res/drawable-560dpi/display_info.png
Binary files differ
diff --git a/hostsidetests/theme/app/src/android/theme/app/DisplayInfoActivity.java b/hostsidetests/theme/app/src/android/theme/app/DisplayInfoActivity.java
index 12504c1..f263eef 100644
--- a/hostsidetests/theme/app/src/android/theme/app/DisplayInfoActivity.java
+++ b/hostsidetests/theme/app/src/android/theme/app/DisplayInfoActivity.java
@@ -68,6 +68,9 @@
             case DisplayMetrics.DENSITY_XXHIGH:
                 return "xxhdpi";
 
+            case DisplayMetrics.DENSITY_560:
+                return "560dpi";
+
             case DisplayMetrics.DENSITY_XXXHIGH:
                 return "xxxhdpi";
 
diff --git a/hostsidetests/theme/assets/21/560dpi.zip b/hostsidetests/theme/assets/21/560dpi.zip
new file mode 100644
index 0000000..eff363c
--- /dev/null
+++ b/hostsidetests/theme/assets/21/560dpi.zip
Binary files differ
diff --git a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
index fded180..90a0c72 100644
--- a/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
+++ b/hostsidetests/theme/src/android/theme/cts/ThemeHostTest.java
@@ -362,6 +362,8 @@
                 return "400dpi";
             case 480:
                 return "xxhdpi";
+            case 560:
+                return "560dpi";
             case 640:
                 return "xxxhdpi";
             default:
diff --git a/tests/Android.mk b/tests/Android.mk
index f66946a..19dafe0 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -19,13 +19,10 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)\
               $(call all-renderscript-files-under, src)\
-              src/android/app/cts/ISecondary.aidl\
-              src/android/os/cts/IEmptyService.aidl\
+              src/android/app/cts/ISecondary.aidl
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_JNI_SHARED_LIBRARIES := libcts_jni
-
 # Resource unit tests use a private locale and some densities
 LOCAL_AAPT_FLAGS = -c xx_YY -c cs -c small -c normal -c large -c xlarge \
         -c 320dpi -c 240dpi -c 160dpi -c 32dpi \
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 645eb3b..9190da8 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -858,16 +858,6 @@
             </intent-filter>
         </receiver>
 
-        <!-- Used for PackageManager test, don't delete this MockContentProvider provider -->
-        <provider android:name="android.content.cts.MockContentProvider" android:authorities="ctstest"
-            android:multiprocess="false" />
-        <provider android:name="android.content.cts.DummyProvider"
-            android:authorities="android.content.cts.dummyprovider"
-            android:multiprocess="true" />
-        <provider android:name="android.content.cts.MockRemoteContentProvider"
-            android:authorities="remotectstest"
-            android:process=":remoteprovider" android:multiprocess="false" />
-
         <activity android:name="android.app.cts.ChildTabActivity" android:label="ChildTabActivity" />
 
         <activity android:name="android.app.cts.LauncherActivityStub"
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 706a663..3802c73 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -69,5 +69,16 @@
     "android.hardware.camera2.cts.AllocationTest#testParamSensitivity"
   ],
   bug: 17530117
+},
+{
+  description: "these tests locks the screen with an emtpy password or swipe-to-unlock, blocking subsequent test to dismiss keyguard",
+  names: [
+    "android.admin.cts.DevicePolicyManagerTest#testPasswordQuality_something",
+    "android.admin.cts.DevicePolicyManagerTest#testPasswordQuality_numeric",
+    "android.admin.cts.DevicePolicyManagerTest#testPasswordQuality_alphabetic",
+    "android.admin.cts.DevicePolicyManagerTest#testPasswordQuality_alphanumeric",
+    "android.admin.cts.DevicePolicyManagerTest#testGetMaximumFailedPasswordsForWipe"
+  ],
+  bug: 17496766
 }
 ]
diff --git a/tests/res/layout/autocompletetextview_layout.xml b/tests/res/layout/autocompletetextview_layout.xml
index be1d284..c2404d5 100644
--- a/tests/res/layout/autocompletetextview_layout.xml
+++ b/tests/res/layout/autocompletetextview_layout.xml
@@ -28,5 +28,6 @@
         android:completionThreshold="1"
         android:completionHint="@string/tabs_1"
         android:layout_width="match_parent" 
-        android:layout_height="wrap_content" />
+        android:layout_height="wrap_content"
+        android:inputType="none"/>
 </LinearLayout>
diff --git a/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java b/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
index 654fb0d..5e72a78 100644
--- a/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
+++ b/tests/tests/appwidget/src/android/appwidget/cts/AppWidgetTest.java
@@ -40,7 +40,6 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
-import android.content.pm.UserInfo;
 import android.cts.appwidget.R;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
@@ -136,6 +135,7 @@
     public void testBindAppWidget() throws Exception {
         // Create a host and start listening.
         AppWidgetHost host = new AppWidgetHost(getInstrumentation().getTargetContext(), 0);
+        host.deleteHost();
         host.startListening();
 
         // Allocate an app widget id to bind.
@@ -150,7 +150,7 @@
         assertFalse(widgetBound);
 
         // Well, app do not have this permission unless explicitly granted
-        // by the user. Now we will pretent for the user and grant it.
+        // by the user. Now we will pretend for the user and grant it.
         grantBindAppWidgetPermission();
 
         try {
@@ -163,36 +163,28 @@
             host.deleteAppWidgetId(appWidgetId);
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(appWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
     }
 
     public void testAppWidgetProviderCallbacks() throws Exception {
-        final AtomicInteger disabledCallCounter = new AtomicInteger();
+        AtomicInteger invocationCounter = new AtomicInteger();
 
         // Set a mock to intercept provider callbacks.
-        AppWidgetProviderCallbacks callbacks = mock(AppWidgetProviderCallbacks.class);
-        doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(InvocationOnMock invocation) throws Throwable {
-                synchronized (mLock) {
-                    disabledCallCounter.incrementAndGet();
-                    mLock.notifyAll();
-                }
-                return null;
-            }
-        }).when(callbacks).onDeleted(any(Context.class), any(int[].class));
+        AppWidgetProviderCallbacks callbacks = createAppWidgetProviderCallbacks(invocationCounter);
         FirstAppWidgetProvider.setCallbacks(callbacks);
 
-        final int firstAppWidgetId;
-        final int secondAppWidgetId;
+        int firstAppWidgetId = 0;
+        int secondAppWidgetId = 0;
 
         final Bundle firstOptions;
         final Bundle secondOptions;
 
         // Create a host and start listening.
         AppWidgetHost host = spy(new AppWidgetHost(getInstrumentation().getTargetContext(), 0));
+        host.deleteHost();
         host.startListening();
 
         // We want to bind a widget.
@@ -208,6 +200,9 @@
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
                     provider.getProfile(), provider.provider, null);
 
+            // Wait for onEnabled and onUpdate
+            waitForCallCount(invocationCounter, 2);
+
             // Update the first widget options.
             firstOptions = new Bundle();
             firstOptions.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, 1);
@@ -216,6 +211,9 @@
             firstOptions.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, 4);
             getAppWidgetManager().updateAppWidgetOptions(firstAppWidgetId, firstOptions);
 
+            // Wait for onAppWidgetOptionsChanged
+            waitForCallCount(invocationCounter, 3);
+
             // Allocate the second app widget id to bind.
             secondAppWidgetId = host.allocateAppWidgetId();
 
@@ -223,6 +221,9 @@
             getAppWidgetManager().bindAppWidgetIdIfAllowed(secondAppWidgetId,
                     provider.getProfile(), provider.provider, null);
 
+            // Wait for onUpdate
+            waitForCallCount(invocationCounter, 4);
+
             // Update the second widget options.
             secondOptions = new Bundle();
             secondOptions.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, 5);
@@ -231,13 +232,20 @@
             secondOptions.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, 8);
             getAppWidgetManager().updateAppWidgetOptions(secondAppWidgetId, secondOptions);
 
+            // Wait for onAppWidgetOptionsChanged
+            waitForCallCount(invocationCounter, 5);
+
             // Delete the first widget.
             host.deleteAppWidgetId(firstAppWidgetId);
 
+            // Wait for onDeleted
+            waitForCallCount(invocationCounter, 6);
+
             // Delete the second widget.
             host.deleteAppWidgetId(secondAppWidgetId);
 
-            waitForCallCount(disabledCallCounter, 1);
+            // Wait for onDeleted and onDisabled
+            waitForCallCount(invocationCounter, 8);
 
             // Make sure the provider callbacks are correct.
             InOrder inOrder = inOrder(callbacks);
@@ -260,38 +268,34 @@
             inOrder.verify(callbacks).onDisabled(any(Context.class));
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(firstAppWidgetId);
+            host.deleteAppWidgetId(secondAppWidgetId);
+            host.deleteHost();
             FirstAppWidgetProvider.setCallbacks(null);
             revokeBindAppWidgetPermission();
         }
     }
 
     public void testTwoAppWidgetProviderCallbacks() throws Exception {
-        final AtomicInteger disabledCallCounter = new AtomicInteger();
+        AtomicInteger invocationCounter = new AtomicInteger();
 
         // Set a mock to intercept first provider callbacks.
-        AppWidgetProviderCallbacks firstCallbacks = mock(AppWidgetProviderCallbacks.class);
+        AppWidgetProviderCallbacks firstCallbacks = createAppWidgetProviderCallbacks(
+                invocationCounter);
         FirstAppWidgetProvider.setCallbacks(firstCallbacks);
 
         // Set a mock to intercept second provider callbacks.
-        AppWidgetProviderCallbacks secondCallbacks = mock(AppWidgetProviderCallbacks.class);
-        doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(InvocationOnMock invocation) throws Throwable {
-                synchronized (mLock) {
-                    disabledCallCounter.incrementAndGet();
-                    mLock.notifyAll();
-                }
-                return null;
-            }
-        }).when(firstCallbacks).onDisabled(any(Context.class));
+        AppWidgetProviderCallbacks secondCallbacks = createAppWidgetProviderCallbacks(
+                invocationCounter);
         SecondAppWidgetProvider.setCallbacks(secondCallbacks);
 
-        final int firstAppWidgetId;
-        final int secondAppWidgetId;
+        int firstAppWidgetId = 0;
+        int secondAppWidgetId = 0;
 
         // Create a host and start listening.
         AppWidgetHost host = spy(new AppWidgetHost(
                 getInstrumentation().getTargetContext(), 0));
+        host.deleteHost();
         host.startListening();
 
         // We want to bind widgets.
@@ -310,6 +314,9 @@
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
                     firstProvider.getProfile(), firstProvider.provider, null);
 
+            // Wait for onEnabled and onUpdate
+            waitForCallCount(invocationCounter, 2);
+
             // Grab the second provider we defined to be bound.
             AppWidgetProviderInfo secondProvider = getSecondAppWidgetProviderInfo();
 
@@ -317,14 +324,20 @@
             getAppWidgetManager().bindAppWidgetIdIfAllowed(secondAppWidgetId,
                     secondProvider.getProfile(), secondProvider.provider, null);
 
+            // Wait for onEnabled and onUpdate
+            waitForCallCount(invocationCounter, 4);
+
             // Delete the first widget.
             host.deleteAppWidgetId(firstAppWidgetId);
 
+            // Wait for onDeleted and onDisabled
+            waitForCallCount(invocationCounter, 6);
+
             // Delete the second widget.
             host.deleteAppWidgetId(secondAppWidgetId);
 
-            // Wait for all callbacks to settle.
-            waitForCallCount(disabledCallCounter, 1);
+            // Wait for onDeleted and onDisabled
+            waitForCallCount(invocationCounter, 8);
 
             // Make sure the first provider callbacks are correct.
             InOrder firstInOrder = inOrder(firstCallbacks);
@@ -345,6 +358,9 @@
             secondInOrder.verify(secondCallbacks).onDisabled(any(Context.class));
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(firstAppWidgetId);
+            host.deleteAppWidgetId(secondAppWidgetId);
+            host.deleteHost();
             FirstAppWidgetProvider.setCallbacks(null);
             SecondAppWidgetProvider.setCallbacks(null);
             revokeBindAppWidgetPermission();
@@ -358,8 +374,12 @@
         // Create a host and start listening.
         AppWidgetHost host = new AppWidgetHost(
                 getInstrumentation().getTargetContext(), 0);
+        host.deleteHost();
         host.startListening();
 
+        int firstAppWidgetId = 0;
+        int secondAppWidgetId = 0;
+
         try {
             // Grab the provider we defined to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
@@ -369,14 +389,14 @@
             assertTrue(widgetsIds.length == 0);
 
             // Allocate the first widget id to bind.
-            final int firstAppWidgetId = host.allocateAppWidgetId();
+            firstAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the first widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
                     provider.getProfile(), provider.provider, null);
 
             // Allocate the second widget id to bind.
-            final int secondAppWidgetId = host.allocateAppWidgetId();
+            secondAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the second widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(secondAppWidgetId,
@@ -387,6 +407,8 @@
             assertTrue(Arrays.equals(widgetsIds, new int[]{firstAppWidgetId, secondAppWidgetId}));
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(firstAppWidgetId);
+            host.deleteAppWidgetId(secondAppWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -399,11 +421,14 @@
         // Create a host and start listening.
         AppWidgetHost host = new AppWidgetHost(
                 getInstrumentation().getTargetContext(), 0);
+        host.deleteHost();
         host.startListening();
 
+        int appWidgetId = 0;
+
         try {
             // Allocate an widget id to bind.
-            final int appWidgetId = host.allocateAppWidgetId();
+            appWidgetId = host.allocateAppWidgetId();
 
             // The widget is not bound, so no info.
             AppWidgetProviderInfo foundProvider = getAppWidgetManager()
@@ -435,6 +460,7 @@
             assertNotNull(previewImage);
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(appWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -447,14 +473,17 @@
         // Create a host and start listening.
         AppWidgetHost host = new AppWidgetHost(
                 getInstrumentation().getTargetContext(), 0);
+        host.deleteHost();
         host.startListening();
 
+        int appWidgetId = 0;
+
         try {
             // Grab the provider we defined to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
 
             // Allocate an widget id to bind.
-            final int appWidgetId = host.allocateAppWidgetId();
+            appWidgetId = host.allocateAppWidgetId();
 
             // Initially we have no options.
             Bundle foundOptions = getAppWidgetManager().getAppWidgetOptions(appWidgetId);
@@ -476,6 +505,7 @@
             assertTrue(equalOptions(setOptions, foundOptions));
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(appWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -488,11 +518,14 @@
         // Create a host and start listening.
         AppWidgetHost host = new AppWidgetHost(
                 getInstrumentation().getTargetContext(), 0);
+        host.deleteHost();
         host.startListening();
 
+        int appWidgetId = 0;
+
         try {
             // Allocate an widget id to bind.
-            final int appWidgetId = host.allocateAppWidgetId();
+            appWidgetId = host.allocateAppWidgetId();
 
             // Grab the provider we defined to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
@@ -513,6 +546,8 @@
             assertTrue(widgetIds.length == 0);
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(appWidgetId);
+            host.deleteHost();
             revokeBindAppWidgetPermission();
         }
     }
@@ -524,26 +559,31 @@
         // Create the first host and start listening.
         AppWidgetHost firstHost = new AppWidgetHost(
                 getInstrumentation().getTargetContext(), 0);
+        firstHost.deleteHost();
         firstHost.startListening();
 
         // Create the second host and start listening.
         AppWidgetHost secondHost = new AppWidgetHost(
                 getInstrumentation().getTargetContext(), 1);
+        secondHost.deleteHost();
         secondHost.startListening();
 
+        int firstAppWidgetId = 0;
+        int secondAppWidgetId = 0;
+
         try {
             // Grab the provider we defined to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
 
             // Allocate the first widget id to bind.
-            final int firstAppWidgetId = firstHost.allocateAppWidgetId();
+            firstAppWidgetId = firstHost.allocateAppWidgetId();
 
             // Bind the first app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
                     provider.getProfile(), provider.provider, null);
 
             // Allocate the second widget id to bind.
-            final int secondAppWidgetId = secondHost.allocateAppWidgetId();
+            secondAppWidgetId = secondHost.allocateAppWidgetId();
 
             // Bind the second app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(secondAppWidgetId,
@@ -561,6 +601,9 @@
             assertTrue(widgetIds.length == 0);
         } finally {
             // Clean up.
+            firstHost.deleteAppWidgetId(firstAppWidgetId);
+            secondHost.deleteAppWidgetId(secondAppWidgetId);
+            AppWidgetHost.deleteAllHosts();
             revokeBindAppWidgetPermission();
         }
     }
@@ -582,14 +625,17 @@
                 }
             }
         };
+        host.deleteHost();
         host.startListening();
 
+        int appWidgetId = 0;
+
         try {
             // Grab the provider we defined to be bound.
             AppWidgetProviderInfo firstLookupProvider = getFirstAppWidgetProviderInfo();
 
             // Allocate a widget id to bind.
-            final int appWidgetId = host.allocateAppWidgetId();
+            appWidgetId = host.allocateAppWidgetId();
 
             // Bind the first app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(appWidgetId,
@@ -609,7 +655,7 @@
             AppWidgetProviderInfo secondLookupProvider = getFirstAppWidgetProviderInfo();
             assertNull(secondLookupProvider);
 
-            // Enable the provider we disbaled.
+            // Enable the provider we disabled.
             packageManager.setComponentEnabledSetting(firstLookupProvider.provider,
                     PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
                     PackageManager.DONT_KILL_APP);
@@ -618,6 +664,7 @@
             waitForCallCount(onProvidersChangedCallCounter, 2);
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(appWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -638,14 +685,18 @@
                 return new MyAppWidgetHostView(context);
             }
         };
+        host.deleteHost();
         host.startListening();
 
+        int firstAppWidgetId = 0;
+        int secondAppWidgetId = 0;
+
         try {
             // Grab the provider to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
 
             // Allocate the first widget id to bind.
-            final int firstAppWidgetId = host.allocateAppWidgetId();
+            firstAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the first app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
@@ -659,7 +710,7 @@
             firstHostView.setOnUpdateAppWidgetListener(firstAppHostViewListener);
 
             // Allocate the second widget id to bind.
-            final int secondAppWidgetId = host.allocateAppWidgetId();
+            secondAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the second app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(secondAppWidgetId,
@@ -702,6 +753,8 @@
                             provider.provider.getPackageName())));
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(firstAppWidgetId);
+            host.deleteAppWidgetId(secondAppWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -722,14 +775,17 @@
                 return new MyAppWidgetHostView(context);
             }
         };
+        host.deleteHost();
         host.startListening();
 
+        int firstAppWidgetId = 0;
+
         try {
             // Grab the provider to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
 
             // Allocate the first widget id to bind.
-            final int firstAppWidgetId = host.allocateAppWidgetId();
+            firstAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the first app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
@@ -768,6 +824,7 @@
             ));
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(firstAppWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -788,14 +845,18 @@
                 return new MyAppWidgetHostView(context);
             }
         };
+        host.deleteHost();
         host.startListening();
 
+        int firstAppWidgetId = 0;
+        int secondAppWidgetId = 0;
+
         try {
             // Grab the provider to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
 
             // Allocate the first widget id to bind.
-            final int firstAppWidgetId = host.allocateAppWidgetId();
+            firstAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the first app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
@@ -809,7 +870,7 @@
             firstHostView.setOnUpdateAppWidgetListener(firstAppHostViewListener);
 
             // Allocate the second widget id to bind.
-            final int secondAppWidgetId = host.allocateAppWidgetId();
+            secondAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the second app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(secondAppWidgetId,
@@ -854,6 +915,8 @@
             );
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(firstAppWidgetId);
+            host.deleteAppWidgetId(secondAppWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -874,15 +937,17 @@
                 return new MyAppWidgetHostView(context);
             }
         };
-
+        host.deleteHost();
         host.startListening();
 
+        int firstAppWidgetId = 0;
+
         try {
             // Grab the provider to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
 
             // Allocate the first widget id to bind.
-            final int firstAppWidgetId = host.allocateAppWidgetId();
+            firstAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the first app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
@@ -913,7 +978,7 @@
 
             waitForCallCount(updateAppWidgetCallCount, 1);
 
-            // Partially update the content for all app widgets (pretent we changed somehting).
+            // Partially update the content for all app widgets (pretend we changed something).
             getAppWidgetManager().partiallyUpdateAppWidget(firstAppWidgetId, content);
 
             waitForCallCount(updateAppWidgetCallCount, 2);
@@ -925,6 +990,7 @@
                             provider.provider.getPackageName())));
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(firstAppWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -946,14 +1012,18 @@
                 return new MyAppWidgetHostView(context);
             }
         };
+        host.deleteHost();
         host.startListening();
 
+        int firstAppWidgetId = 0;
+        int secondAppWidgetId = 0;
+
         try {
             // Grab the provider to be bound.
             AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
 
             // Allocate the first widget id to bind.
-            final int firstAppWidgetId = host.allocateAppWidgetId();
+            firstAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the first app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(firstAppWidgetId,
@@ -977,7 +1047,7 @@
             firstHostView.setOnUpdateAppWidgetListener(firstAppHostViewListener);
 
             // Allocate the second widget id to bind.
-            final int secondAppWidgetId = host.allocateAppWidgetId();
+            secondAppWidgetId = host.allocateAppWidgetId();
 
             // Bind the second app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(secondAppWidgetId,
@@ -1010,7 +1080,7 @@
             waitForCallCount(firstAppWidgetCallCounter, 1);
             waitForCallCount(secondAppWidgetCallCounter, 1);
 
-            // Partially update the content for all app widgets (pretend we changed somehting).
+            // Partially update the content for all app widgets (pretend we changed something).
             getAppWidgetManager().partiallyUpdateAppWidget(new int[] {firstAppWidgetId,
                     secondAppWidgetId}, content);
 
@@ -1029,6 +1099,8 @@
                             provider.provider.getPackageName())));
         } finally {
             // Clean up.
+            host.deleteAppWidgetId(firstAppWidgetId);
+            host.deleteAppWidgetId(secondAppWidgetId);
             host.deleteHost();
             revokeBindAppWidgetPermission();
         }
@@ -1038,16 +1110,20 @@
         // We want to bind widgets.
         grantBindAppWidgetPermission();
 
-        final AtomicInteger getViewCounter = new AtomicInteger();
+        final AtomicInteger invocationCounter = new AtomicInteger();
         final Context context = getInstrumentation().getTargetContext();
 
         // Create a host and start listening.
-        AppWidgetHost host = new AppWidgetHost(context, 0);
+        final AppWidgetHost host = new AppWidgetHost(context, 0);
+        host.deleteHost();
         host.startListening();
 
+        final int appWidgetId;
+
         try {
             // Configure the provider behavior.
-            AppWidgetProviderCallbacks callbacks = mock(AppWidgetProviderCallbacks.class);
+            AppWidgetProviderCallbacks callbacks = createAppWidgetProviderCallbacks(
+                    invocationCounter);
             doAnswer(new Answer<Void>() {
                 @Override
                 public Void answer(InvocationOnMock invocation) throws Throwable {
@@ -1063,6 +1139,11 @@
 
                     getAppWidgetManager().updateAppWidget(appWidgetId, removeViews);
 
+                    synchronized (mLock) {
+                        invocationCounter.incrementAndGet();
+                        mLock.notifyAll();
+                    }
+
                     return null;
                 }
             }).when(callbacks).onUpdate(any(Context.class), any(AppWidgetManager.class),
@@ -1070,15 +1151,18 @@
             FirstAppWidgetProvider.setCallbacks(callbacks);
 
             // Grab the provider to be bound.
-            AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
+            final AppWidgetProviderInfo provider = getFirstAppWidgetProviderInfo();
 
             // Allocate a widget id to bind.
-            final int appWidgetId = host.allocateAppWidgetId();
+            appWidgetId = host.allocateAppWidgetId();
 
             // Bind the app widget.
             getAppWidgetManager().bindAppWidgetIdIfAllowed(appWidgetId,
                     provider.getProfile(), provider.provider, null);
 
+            // Wait for onEnabled and onUpdate
+            waitForCallCount(invocationCounter, 2);
+
             // Configure the app widget service behavior.
             RemoteViewsFactory factory = mock(RemoteViewsFactory.class);
             doAnswer(new Answer<Integer>() {
@@ -1094,7 +1178,7 @@
                             R.layout.collection_widget_item_layout);
                     remoteViews.setTextViewText(R.id.text_view, context.getText(R.string.foo));
                     synchronized (mLock) {
-                        getViewCounter.incrementAndGet();
+                        invocationCounter.incrementAndGet();
                     }
                     return remoteViews;
                 }
@@ -1107,10 +1191,15 @@
             }).when(factory).getViewTypeCount();
             MyAppWidgetService.setFactory(factory);
 
-            host.createView(context, appWidgetId, provider);
+            getInstrumentation().runOnMainSync(new Runnable() {
+                @Override
+                public void run() {
+                    host.createView(context, appWidgetId, provider);
+                }
+            });
 
             // Wait for the interactions to occur.
-            waitForCallCount(getViewCounter, 1);
+            waitForCallCount(invocationCounter, 3);
 
             // Verify the interactions.
             verify(factory, atLeastOnce()).hasStableIds();
@@ -1133,7 +1222,7 @@
                 final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis;
                 final long remainingTimeMillis = OPERATION_TIMEOUT - elapsedTimeMillis;
                 if (remainingTimeMillis <= 0) {
-                    fail("Did not get expected call to onUpdateAppWidget");
+                    fail("Did not get expected call");
                 }
                 try {
                     mLock.wait(remainingTimeMillis);
@@ -1289,15 +1378,98 @@
                 .getSystemService(Context.APPWIDGET_SERVICE);
     }
 
+    private AppWidgetProviderCallbacks createAppWidgetProviderCallbacks(
+            final AtomicInteger callCounter) {
+        // Set a mock to intercept provider callbacks.
+        AppWidgetProviderCallbacks callbacks = mock(AppWidgetProviderCallbacks.class);
+
+        // onEnabled
+        doAnswer(new Answer<Void>() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                synchronized (mLock) {
+                    callCounter.incrementAndGet();
+                    mLock.notifyAll();
+                }
+                return null;
+            }
+        }).when(callbacks).onEnabled(any(Context.class));
+
+        // onUpdate
+        doAnswer(new Answer<Void>() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                synchronized (mLock) {
+                    callCounter.incrementAndGet();
+                    mLock.notifyAll();
+                }
+                return null;
+            }
+        }).when(callbacks).onUpdate(any(Context.class), any(AppWidgetManager.class),
+                any(int[].class));
+
+        // onAppWidgetOptionsChanged
+        doAnswer(new Answer<Void>() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                synchronized (mLock) {
+                    callCounter.incrementAndGet();
+                    mLock.notifyAll();
+                }
+                return null;
+            }
+        }).when(callbacks).onAppWidgetOptionsChanged(any(Context.class),
+                any(AppWidgetManager.class), any(int.class), any(Bundle.class));
+
+        // onDeleted
+        doAnswer(new Answer<Void>() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                synchronized (mLock) {
+                    callCounter.incrementAndGet();
+                    mLock.notifyAll();
+                }
+                return null;
+            }
+        }).when(callbacks).onDeleted(any(Context.class), any(int[].class));
+
+        // onDisabled
+        doAnswer(new Answer<Void>() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                synchronized (mLock) {
+                    callCounter.incrementAndGet();
+                    mLock.notifyAll();
+                }
+                return null;
+            }
+        }).when(callbacks).onDisabled(any(Context.class));
+
+        // onRestored
+        doAnswer(new Answer<Void>() {
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                synchronized (mLock) {
+                    callCounter.incrementAndGet();
+                    mLock.notifyAll();
+                }
+                return null;
+            }
+        }).when(callbacks).onRestored(any(Context.class), any(int[].class),
+                any(int[].class));
+
+        return callbacks;
+    }
+
     private static boolean equalOptions(Bundle first, Bundle second) {
         return first.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH)
                        == second.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH)
                 && first.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT)
                        == second.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT)
                 && first.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)
-                        == second.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)
+                       == second.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH)
                 && first.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT)
-                        == second.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT);
+                       == second.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT);
     }
 
     private static final class OptionsMatcher extends BaseMatcher<Bundle> {
diff --git a/tests/tests/content/Android.mk b/tests/tests/content/Android.mk
index 6f883b6..2c185d9 100644
--- a/tests/tests/content/Android.mk
+++ b/tests/tests/content/Android.mk
@@ -23,12 +23,15 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
+
+# Resource unit tests use a private locale and some densities
+LOCAL_AAPT_FLAGS = -c xx_YY -c cs -c small -c normal -c large -c xlarge \
+        -c 320dpi -c 240dpi -c 160dpi -c 32dpi \
+        -c kok,kok_IN,kok_419,kok_419_VARIANT,kok_Knda_419,kok_Knda_419_VARIANT,kok_VARIANT,kok_Knda,tgl,tgl_PH
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsContentTestCases
 
-LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
-
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/content/AndroidManifest.xml b/tests/tests/content/AndroidManifest.xml
index 8d57e49..b3de29f 100644
--- a/tests/tests/content/AndroidManifest.xml
+++ b/tests/tests/content/AndroidManifest.xml
@@ -18,9 +18,53 @@
     package="com.android.cts.content">
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+    <!-- content sync tests -->
+    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
+    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
+    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
+    <uses-permission android:name="android.permission.READ_SYNC_STATS" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+    <uses-permission android:name="android.permission.SET_WALLPAPER" />
+    <uses-permission android:name="android.permission.BROADCAST_STICKY" />
+    <uses-permission android:name="android.content.cts.permission.TEST_GRANTED" />
 
-    <application>
-        <activity android:name="android.app.cts.MockActivity">
+    <!-- Used for PackageManager test, don't delete this INTERNET permission -->
+    <uses-permission android:name="android.permission.INTERNET" />
+
+    <!-- Used for PackageManager test, don't delete this permission-tree -->
+    <permission-tree android:name="com.android.cts.content.permission.TEST_DYNAMIC"
+                    android:label="Test Tree"/>
+
+    <!-- Used for PackageManager test, don't delete this permission-group -->
+    <permission-group android:name="android.permission-group.COST_MONEY"/>
+    <!-- Used for PackageManager test, don't delete! -->
+    <uses-configuration/>
+    <uses-feature android:name="android.hardware.camera" />
+    <uses-feature android:glEsVersion="0x00020000" />
+    <feature-group/>
+    <feature-group>
+        <uses-feature android:glEsVersion="0x00030000" />
+        <uses-feature android:name="android.hardware.location" />
+    </feature-group>
+    <feature-group>
+        <uses-feature android:glEsVersion="0x00010001" />
+        <uses-feature android:name="android.hardware.camera" />
+    </feature-group>
+
+    <application android:label="Android TestCase"
+                android:icon="@drawable/size_48x48"
+                android:maxRecents="1"
+                android:multiArch="true"
+                android:name="android.content.cts.MockApplication"
+                android:supportsRtl="true">
+        <activity android:name="android.content.cts.MockActivity">
+            <meta-data android:name="android.app.alias"
+                android:resource="@xml/alias" />
+            <meta-data android:name="android.app.intent.filter"
+                android:resource="@xml/intentfilter" />
             <intent-filter>
                 <action android:name="com.android.cts.content.action.TEST_ACTION" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -28,8 +72,8 @@
             </intent-filter>
         </activity>
 
-        <activity-alias android:name="android.app.cts.MockActivity2"
-                android:targetActivity="android.app.cts.MockActivity">
+        <activity-alias android:name="android.content.cts.MockActivity2"
+                android:targetActivity="android.content.cts.MockActivity">
             <intent-filter>
                 <action android:name="com.android.cts.content.action.TEST_ACTION" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -37,13 +81,114 @@
         </activity-alias>
 
         <uses-library android:name="android.test.runner" />
+
+        <service android:name="android.content.cts.MockContextWrapperService" />
+        <activity android:name=".content.ContextWrapperCtsActivity"
+            android:label="ContextWrapperCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+        </activity>
+
+        <receiver android:name="android.content.cts.MockReceiverFirst">
+            <intent-filter android:priority="3">
+                <action android:name="android.content.cts.BroadcastReceiverTest.BROADCAST_TESTABORT" />
+            </intent-filter>
+        </receiver>
+        <receiver android:name="android.content.cts.MockReceiverAbort">
+            <intent-filter android:priority="2">
+                <action android:name="android.content.cts.BroadcastReceiverTest.BROADCAST_TESTABORT" />
+            </intent-filter>
+        </receiver>
+        <receiver android:name="android.content.cts.MockReceiver">
+            <intent-filter android:priority="1">
+                <action android:name="android.content.cts.BroadcastReceiverTest.BROADCAST_MOCKTEST" />
+                <action android:name="android.content.cts.BroadcastReceiverTest.BROADCAST_TESTABORT" />
+                <action android:name="android.content.cts.ContextWrapperTest.BROADCAST_TESTORDER" />
+            </intent-filter>
+        </receiver>
+
+        <activity android:name="android.content.cts.AvailableIntentsActivity"
+            android:label="AvailableIntentsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <!--Test for PackageManager-->
+        <activity android:name="android.content.pm.cts.TestPmActivity"
+                android:icon="@drawable/start">
+            <intent-filter>
+                <action android:name="android.intent.action.PMTEST" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+            <meta-data android:name="android.content.pm.cts.xmltest" android:resource="@xml/pm_test" />
+        </activity>
+        <activity android:name="android.content.pm.cts.TestPmCompare">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.INFO" />
+            </intent-filter>
+        </activity>
+        <!--Test for PackageManager-->
+        <service android:name="android.content.pm.cts.TestPmService">
+            <intent-filter>
+                <action android:name="android.content.pm.cts.activity.PMTEST_SERVICE" />
+            </intent-filter>
+        </service>
+        <!--Test for PackageManager-->
+        <receiver android:name="android.content.pm.cts.PmTestReceiver">
+            <intent-filter>
+                <action android:name="android.content.pm.cts.PackageManagerTest.PMTEST_RECEIVER" />
+            </intent-filter>
+        </receiver>
+
+        <!-- Used for PackageManager test, don't delete this MockContentProvider provider -->
+        <provider android:name="android.content.cts.MockContentProvider" android:authorities="ctstest"
+            android:multiprocess="false" />
+        <provider android:name="android.content.cts.DummyProvider"
+            android:authorities="android.content.cts.dummyprovider"
+            android:multiprocess="true" />
+        <provider android:name="android.content.cts.MockRemoteContentProvider"
+            android:authorities="remotectstest"
+            android:process=":remoteprovider" android:multiprocess="false" />
+
+        <service android:name="android.content.cts.MockService" />
+
+        <service android:name="android.content.cts.MockSyncAdapterService" android:exported="true">
+            <intent-filter>
+                <action android:name="android.content.SyncAdapter" />
+            </intent-filter>
+
+            <meta-data android:name="android.content.SyncAdapter"
+                       android:resource="@xml/syncadapter" />
+        </service>
+
+        <service android:name="android.content.cts.MockAccountService" android:exported="true"
+                 >
+            <intent-filter>
+                <action android:name="android.accounts.AccountAuthenticator" />
+            </intent-filter>
+
+            <meta-data android:name="android.accounts.AccountAuthenticator"
+                       android:resource="@xml/authenticator" />
+        </service>
+
+        <activity android:name="android.content.cts.ClipboardManagerListenerActivity"/>
+
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="com.android.cts.stub"
+                     android:targetPackage="com.android.cts.content"
                      android:label="CTS tests of android.content">
         <meta-data android:name="listener"
             android:value="com.android.cts.runner.CtsTestRunListener" />
     </instrumentation>
+
+    <!--Test for PackageManager, please put this at the very beginning-->
+    <instrumentation android:name="android.content.pm.cts.TestPmInstrumentation"
+        android:targetPackage="android"
+        android:label="PackageManager Instrumentation Test" />
 </manifest>
 
diff --git a/tests/assets/text.txt b/tests/tests/content/assets/text.txt
similarity index 100%
rename from tests/assets/text.txt
rename to tests/tests/content/assets/text.txt
diff --git a/tests/src/android/widget/cts/ViewFlipperStubActivity.java b/tests/tests/content/res/anim/anim_rotate.xml
similarity index 62%
copy from tests/src/android/widget/cts/ViewFlipperStubActivity.java
copy to tests/tests/content/res/anim/anim_rotate.xml
index 2ac331e..4fbadcf 100644
--- a/tests/src/android/widget/cts/ViewFlipperStubActivity.java
+++ b/tests/tests/content/res/anim/anim_rotate.xml
@@ -1,4 +1,5 @@
-/*
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
  * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,21 +13,13 @@
  * 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.widget.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class ViewFlipperStubActivity extends Activity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        setContentView(R.layout.viewflipper_layout);
-    }
-}
-
+<rotate xmlns:android="http://schemas.android.com/apk/res/android"
+    android:interpolator="@android:anim/decelerate_interpolator"
+    android:fromDegrees="0"
+    android:toDegrees="-45"
+    android:toYScale="0.0"
+    android:pivotX="50%"
+    android:pivotY="50%"
+    android:duration="700" />
diff --git a/tests/tests/content/res/color/color1.xml b/tests/tests/content/res/color/color1.xml
new file mode 100755
index 0000000..87034fa
--- /dev/null
+++ b/tests/tests/content/res/color/color1.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_focused="true" android:color="@color/testcolor1"/>
+    <item android:color="@color/testcolor2"/>
+</selector>
diff --git a/tests/tests/content/res/drawable/ic_cts_minitab_selected.png b/tests/tests/content/res/drawable/ic_cts_minitab_selected.png
new file mode 100644
index 0000000..c730050
--- /dev/null
+++ b/tests/tests/content/res/drawable/ic_cts_minitab_selected.png
Binary files differ
diff --git a/tests/tests/content/res/drawable/ic_cts_selected.png b/tests/tests/content/res/drawable/ic_cts_selected.png
new file mode 100644
index 0000000..72a065c
--- /dev/null
+++ b/tests/tests/content/res/drawable/ic_cts_selected.png
Binary files differ
diff --git a/tests/tests/content/res/drawable/icon_black.jpg b/tests/tests/content/res/drawable/icon_black.jpg
new file mode 100644
index 0000000..4c9062a
--- /dev/null
+++ b/tests/tests/content/res/drawable/icon_black.jpg
Binary files differ
diff --git a/tests/tests/content/res/drawable/ninepatch_0.9.png b/tests/tests/content/res/drawable/ninepatch_0.9.png
new file mode 100644
index 0000000..24019d8
--- /dev/null
+++ b/tests/tests/content/res/drawable/ninepatch_0.9.png
Binary files differ
diff --git a/tests/tests/content/res/drawable/ninepatch_1.9.png b/tests/tests/content/res/drawable/ninepatch_1.9.png
new file mode 100644
index 0000000..c56b1db
--- /dev/null
+++ b/tests/tests/content/res/drawable/ninepatch_1.9.png
Binary files differ
diff --git a/tests/tests/content/res/drawable/pass.jpg b/tests/tests/content/res/drawable/pass.jpg
new file mode 100644
index 0000000..2f4b083
--- /dev/null
+++ b/tests/tests/content/res/drawable/pass.jpg
Binary files differ
diff --git a/tests/tests/content/res/drawable/scenery.jpg b/tests/tests/content/res/drawable/scenery.jpg
new file mode 100644
index 0000000..7a6145b
--- /dev/null
+++ b/tests/tests/content/res/drawable/scenery.jpg
Binary files differ
diff --git a/tests/tests/content/res/drawable/size_48x48.jpg b/tests/tests/content/res/drawable/size_48x48.jpg
new file mode 100644
index 0000000..5c2291e
--- /dev/null
+++ b/tests/tests/content/res/drawable/size_48x48.jpg
Binary files differ
diff --git a/tests/tests/content/res/drawable/start.jpg b/tests/tests/content/res/drawable/start.jpg
new file mode 100644
index 0000000..54e05e0
--- /dev/null
+++ b/tests/tests/content/res/drawable/start.jpg
Binary files differ
diff --git a/tests/tests/content/res/drawable/testcolor.xml b/tests/tests/content/res/drawable/testcolor.xml
new file mode 100644
index 0000000..d7b2718
--- /dev/null
+++ b/tests/tests/content/res/drawable/testcolor.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/*
+ * 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.
+ */
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="#FFA6C839"/>
+</selector>
+
diff --git a/tests/tests/content/res/drawable/testimage.jpg b/tests/tests/content/res/drawable/testimage.jpg
new file mode 100644
index 0000000..754df0c
--- /dev/null
+++ b/tests/tests/content/res/drawable/testimage.jpg
Binary files differ
diff --git a/tests/tests/content/res/layout/abslistview_layout.xml b/tests/tests/content/res/layout/abslistview_layout.xml
new file mode 100644
index 0000000..a090ce3
--- /dev/null
+++ b/tests/tests/content/res/layout/abslistview_layout.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<ViewGroup_Layout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/abslistview_root"
+    android:layout_width="25px"
+    android:layout_height="25px" >
+
+   <GridView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
+   <ListView>
+        <TextView
+            android:text="@string/table_layout_first"
+            android:padding="3dip" />
+        <TextView
+            android:text="@string/table_layout_second"
+            android:padding="3dip" />
+        <TextView
+            android:text="@string/table_layout_third"
+            android:padding="3dip" />
+    </ListView>
+</ViewGroup_Layout>
+
diff --git a/tests/tests/content/res/layout/available_intents_layout.xml b/tests/tests/content/res/layout/available_intents_layout.xml
new file mode 100644
index 0000000..5415657
--- /dev/null
+++ b/tests/tests/content/res/layout/available_intents_layout.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+    <TextView android:id="@+id/text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingLeft="4dip"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:text="@string/text_view_hello"/>
+
+</LinearLayout>
diff --git a/tests/tests/content/res/layout/context_layout.xml b/tests/tests/content/res/layout/context_layout.xml
new file mode 100644
index 0000000..6ec6c76
--- /dev/null
+++ b/tests/tests/content/res/layout/context_layout.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <DatePicker
+        android:id="@+id/contextdatepicker_dp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true" />
+
+</RelativeLayout>
diff --git a/tests/tests/content/res/layout/local_sample.xml b/tests/tests/content/res/layout/local_sample.xml
new file mode 100644
index 0000000..6f02e78
--- /dev/null
+++ b/tests/tests/content/res/layout/local_sample.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:padding="4dip"
+    android:gravity="center_horizontal"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:paddingBottom="4dip"
+        android:text="@string/text"/>
+
+    <Button android:id="@+id/go"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/text">
+        <requestFocus />
+    </Button>
+
+</LinearLayout>
+
diff --git a/tests/tests/content/res/raw/testimage.jpg b/tests/tests/content/res/raw/testimage.jpg
new file mode 100644
index 0000000..d3dae03
--- /dev/null
+++ b/tests/tests/content/res/raw/testimage.jpg
Binary files differ
diff --git a/tests/tests/content/res/raw/testmp3.mp3 b/tests/tests/content/res/raw/testmp3.mp3
new file mode 100755
index 0000000..657faf7
--- /dev/null
+++ b/tests/tests/content/res/raw/testmp3.mp3
Binary files differ
diff --git a/tests/assets/text.txt b/tests/tests/content/res/raw/text.txt
similarity index 100%
copy from tests/assets/text.txt
copy to tests/tests/content/res/raw/text.txt
diff --git a/tests/res/values-12key-63x57/configVarying.xml b/tests/tests/content/res/values-12key-63x57/configVarying.xml
similarity index 100%
rename from tests/res/values-12key-63x57/configVarying.xml
rename to tests/tests/content/res/values-12key-63x57/configVarying.xml
diff --git a/tests/res/values-12key-dpad/configVarying.xml b/tests/tests/content/res/values-12key-dpad/configVarying.xml
similarity index 100%
rename from tests/res/values-12key-dpad/configVarying.xml
rename to tests/tests/content/res/values-12key-dpad/configVarying.xml
diff --git a/tests/res/values-12key/configVarying.xml b/tests/tests/content/res/values-12key/configVarying.xml
similarity index 100%
rename from tests/res/values-12key/configVarying.xml
rename to tests/tests/content/res/values-12key/configVarying.xml
diff --git a/tests/res/values-240dpi/configVarying.xml b/tests/tests/content/res/values-240dpi/configVarying.xml
similarity index 100%
rename from tests/res/values-240dpi/configVarying.xml
rename to tests/tests/content/res/values-240dpi/configVarying.xml
diff --git a/tests/res/values-32dpi-keysexposed/configVarying.xml b/tests/tests/content/res/values-32dpi-keysexposed/configVarying.xml
similarity index 100%
rename from tests/res/values-32dpi-keysexposed/configVarying.xml
rename to tests/tests/content/res/values-32dpi-keysexposed/configVarying.xml
diff --git a/tests/res/values-32dpi-stylus/configVarying.xml b/tests/tests/content/res/values-32dpi-stylus/configVarying.xml
similarity index 100%
rename from tests/res/values-32dpi-stylus/configVarying.xml
rename to tests/tests/content/res/values-32dpi-stylus/configVarying.xml
diff --git a/tests/res/values-32dpi/configVarying.xml b/tests/tests/content/res/values-32dpi/configVarying.xml
similarity index 100%
rename from tests/res/values-32dpi/configVarying.xml
rename to tests/tests/content/res/values-32dpi/configVarying.xml
diff --git a/tests/res/values-480x320/configVarying.xml b/tests/tests/content/res/values-480x320/configVarying.xml
similarity index 100%
rename from tests/res/values-480x320/configVarying.xml
rename to tests/tests/content/res/values-480x320/configVarying.xml
diff --git a/tests/res/values-640x400/configVarying.xml b/tests/tests/content/res/values-640x400/configVarying.xml
similarity index 100%
rename from tests/res/values-640x400/configVarying.xml
rename to tests/tests/content/res/values-640x400/configVarying.xml
diff --git a/tests/res/values-b+kok+419+VARIANT/configVarying.xml b/tests/tests/content/res/values-b+kok+419+VARIANT/configVarying.xml
similarity index 100%
rename from tests/res/values-b+kok+419+VARIANT/configVarying.xml
rename to tests/tests/content/res/values-b+kok+419+VARIANT/configVarying.xml
diff --git a/tests/res/values-b+kok+419/configVarying.xml b/tests/tests/content/res/values-b+kok+419/configVarying.xml
similarity index 100%
rename from tests/res/values-b+kok+419/configVarying.xml
rename to tests/tests/content/res/values-b+kok+419/configVarying.xml
diff --git a/tests/res/values-b+kok+IN/configVarying.xml b/tests/tests/content/res/values-b+kok+IN/configVarying.xml
similarity index 100%
rename from tests/res/values-b+kok+IN/configVarying.xml
rename to tests/tests/content/res/values-b+kok+IN/configVarying.xml
diff --git a/tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml b/tests/tests/content/res/values-b+kok+Knda+419+VARIANT/configVarying.xml
similarity index 100%
rename from tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml
rename to tests/tests/content/res/values-b+kok+Knda+419+VARIANT/configVarying.xml
diff --git a/tests/res/values-b+kok+Knda+419/configVarying.xml b/tests/tests/content/res/values-b+kok+Knda+419/configVarying.xml
similarity index 100%
rename from tests/res/values-b+kok+Knda+419/configVarying.xml
rename to tests/tests/content/res/values-b+kok+Knda+419/configVarying.xml
diff --git a/tests/res/values-b+kok+Knda/configVarying.xml b/tests/tests/content/res/values-b+kok+Knda/configVarying.xml
similarity index 100%
rename from tests/res/values-b+kok+Knda/configVarying.xml
rename to tests/tests/content/res/values-b+kok+Knda/configVarying.xml
diff --git a/tests/res/values-b+kok+VARIANT/configVarying.xml b/tests/tests/content/res/values-b+kok+VARIANT/configVarying.xml
similarity index 100%
rename from tests/res/values-b+kok+VARIANT/configVarying.xml
rename to tests/tests/content/res/values-b+kok+VARIANT/configVarying.xml
diff --git a/tests/res/values-b+kok/configVarying.xml b/tests/tests/content/res/values-b+kok/configVarying.xml
similarity index 100%
rename from tests/res/values-b+kok/configVarying.xml
rename to tests/tests/content/res/values-b+kok/configVarying.xml
diff --git a/tests/res/values-b+tgl+PH/configVarying.xml b/tests/tests/content/res/values-b+tgl+PH/configVarying.xml
similarity index 100%
rename from tests/res/values-b+tgl+PH/configVarying.xml
rename to tests/tests/content/res/values-b+tgl+PH/configVarying.xml
diff --git a/tests/res/values-b+tgl/configVarying.xml b/tests/tests/content/res/values-b+tgl/configVarying.xml
similarity index 100%
rename from tests/res/values-b+tgl/configVarying.xml
rename to tests/tests/content/res/values-b+tgl/configVarying.xml
diff --git a/tests/res/values-cs/strings.xml b/tests/tests/content/res/values-cs/strings.xml
similarity index 100%
rename from tests/res/values-cs/strings.xml
rename to tests/tests/content/res/values-cs/strings.xml
diff --git a/tests/res/values-dpad-63x57/configVarying.xml b/tests/tests/content/res/values-dpad-63x57/configVarying.xml
similarity index 100%
rename from tests/res/values-dpad-63x57/configVarying.xml
rename to tests/tests/content/res/values-dpad-63x57/configVarying.xml
diff --git a/tests/res/values-dpad/configVarying.xml b/tests/tests/content/res/values-dpad/configVarying.xml
similarity index 100%
rename from tests/res/values-dpad/configVarying.xml
rename to tests/tests/content/res/values-dpad/configVarying.xml
diff --git a/tests/res/values-fr-rFR/configVarying.xml b/tests/tests/content/res/values-fr-rFR/configVarying.xml
similarity index 100%
rename from tests/res/values-fr-rFR/configVarying.xml
rename to tests/tests/content/res/values-fr-rFR/configVarying.xml
diff --git a/tests/res/values-fr/configVarying.xml b/tests/tests/content/res/values-fr/configVarying.xml
similarity index 100%
rename from tests/res/values-fr/configVarying.xml
rename to tests/tests/content/res/values-fr/configVarying.xml
diff --git a/tests/res/values-h550dp/configVarying.xml b/tests/tests/content/res/values-h550dp/configVarying.xml
similarity index 100%
rename from tests/res/values-h550dp/configVarying.xml
rename to tests/tests/content/res/values-h550dp/configVarying.xml
diff --git a/tests/res/values-h670dp/configVarying.xml b/tests/tests/content/res/values-h670dp/configVarying.xml
similarity index 100%
rename from tests/res/values-h670dp/configVarying.xml
rename to tests/tests/content/res/values-h670dp/configVarying.xml
diff --git a/tests/res/values-keysexposed-12key/configVarying.xml b/tests/tests/content/res/values-keysexposed-12key/configVarying.xml
similarity index 100%
rename from tests/res/values-keysexposed-12key/configVarying.xml
rename to tests/tests/content/res/values-keysexposed-12key/configVarying.xml
diff --git a/tests/res/values-keysexposed-dpad/configVarying.xml b/tests/tests/content/res/values-keysexposed-dpad/configVarying.xml
similarity index 100%
rename from tests/res/values-keysexposed-dpad/configVarying.xml
rename to tests/tests/content/res/values-keysexposed-dpad/configVarying.xml
diff --git a/tests/res/values-keysexposed/configVarying.xml b/tests/tests/content/res/values-keysexposed/configVarying.xml
similarity index 100%
rename from tests/res/values-keysexposed/configVarying.xml
rename to tests/tests/content/res/values-keysexposed/configVarying.xml
diff --git a/tests/res/values-land/configVarying.xml b/tests/tests/content/res/values-land/configVarying.xml
similarity index 100%
rename from tests/res/values-land/configVarying.xml
rename to tests/tests/content/res/values-land/configVarying.xml
diff --git a/tests/res/values-land/dimens.xml b/tests/tests/content/res/values-land/dimens.xml
similarity index 100%
rename from tests/res/values-land/dimens.xml
rename to tests/tests/content/res/values-land/dimens.xml
diff --git a/tests/res/values-large/configVarying.xml b/tests/tests/content/res/values-large/configVarying.xml
similarity index 100%
rename from tests/res/values-large/configVarying.xml
rename to tests/tests/content/res/values-large/configVarying.xml
diff --git a/tests/res/values-mcc110-xx/configVarying.xml b/tests/tests/content/res/values-mcc110-xx/configVarying.xml
similarity index 100%
rename from tests/res/values-mcc110-xx/configVarying.xml
rename to tests/tests/content/res/values-mcc110-xx/configVarying.xml
diff --git a/tests/res/values-mcc111-mnc222/configVarying.xml b/tests/tests/content/res/values-mcc111-mnc222/configVarying.xml
similarity index 100%
rename from tests/res/values-mcc111-mnc222/configVarying.xml
rename to tests/tests/content/res/values-mcc111-mnc222/configVarying.xml
diff --git a/tests/res/values-mcc111-xx-rYY/configVarying.xml b/tests/tests/content/res/values-mcc111-xx-rYY/configVarying.xml
similarity index 100%
rename from tests/res/values-mcc111-xx-rYY/configVarying.xml
rename to tests/tests/content/res/values-mcc111-xx-rYY/configVarying.xml
diff --git a/tests/res/values-mcc111-xx/configVarying.xml b/tests/tests/content/res/values-mcc111-xx/configVarying.xml
similarity index 100%
rename from tests/res/values-mcc111-xx/configVarying.xml
rename to tests/tests/content/res/values-mcc111-xx/configVarying.xml
diff --git a/tests/res/values-mcc111/configVarying.xml b/tests/tests/content/res/values-mcc111/configVarying.xml
similarity index 100%
rename from tests/res/values-mcc111/configVarying.xml
rename to tests/tests/content/res/values-mcc111/configVarying.xml
diff --git a/tests/res/values-mcc112/configVarying.xml b/tests/tests/content/res/values-mcc112/configVarying.xml
similarity index 100%
rename from tests/res/values-mcc112/configVarying.xml
rename to tests/tests/content/res/values-mcc112/configVarying.xml
diff --git a/tests/res/values-mnc220-xx/configVarying.xml b/tests/tests/content/res/values-mnc220-xx/configVarying.xml
similarity index 100%
rename from tests/res/values-mnc220-xx/configVarying.xml
rename to tests/tests/content/res/values-mnc220-xx/configVarying.xml
diff --git a/tests/res/values-mnc222-32dpi/configVarying.xml b/tests/tests/content/res/values-mnc222-32dpi/configVarying.xml
similarity index 100%
rename from tests/res/values-mnc222-32dpi/configVarying.xml
rename to tests/tests/content/res/values-mnc222-32dpi/configVarying.xml
diff --git a/tests/res/values-mnc222-square/configVarying.xml b/tests/tests/content/res/values-mnc222-square/configVarying.xml
similarity index 100%
rename from tests/res/values-mnc222-square/configVarying.xml
rename to tests/tests/content/res/values-mnc222-square/configVarying.xml
diff --git a/tests/res/values-mnc222-xx/configVarying.xml b/tests/tests/content/res/values-mnc222-xx/configVarying.xml
similarity index 100%
rename from tests/res/values-mnc222-xx/configVarying.xml
rename to tests/tests/content/res/values-mnc222-xx/configVarying.xml
diff --git a/tests/res/values-mnc222/configVarying.xml b/tests/tests/content/res/values-mnc222/configVarying.xml
similarity index 100%
rename from tests/res/values-mnc222/configVarying.xml
rename to tests/tests/content/res/values-mnc222/configVarying.xml
diff --git a/tests/res/values-mnc223/configVarying.xml b/tests/tests/content/res/values-mnc223/configVarying.xml
similarity index 100%
rename from tests/res/values-mnc223/configVarying.xml
rename to tests/tests/content/res/values-mnc223/configVarying.xml
diff --git a/tests/res/values-nokeys/configVarying.xml b/tests/tests/content/res/values-nokeys/configVarying.xml
similarity index 100%
rename from tests/res/values-nokeys/configVarying.xml
rename to tests/tests/content/res/values-nokeys/configVarying.xml
diff --git a/tests/res/values-nonav/configVarying.xml b/tests/tests/content/res/values-nonav/configVarying.xml
similarity index 100%
rename from tests/res/values-nonav/configVarying.xml
rename to tests/tests/content/res/values-nonav/configVarying.xml
diff --git a/tests/res/values-normal/configVarying.xml b/tests/tests/content/res/values-normal/configVarying.xml
similarity index 100%
rename from tests/res/values-normal/configVarying.xml
rename to tests/tests/content/res/values-normal/configVarying.xml
diff --git a/tests/res/values-notouch/configVarying.xml b/tests/tests/content/res/values-notouch/configVarying.xml
similarity index 100%
rename from tests/res/values-notouch/configVarying.xml
rename to tests/tests/content/res/values-notouch/configVarying.xml
diff --git a/tests/res/values-small/configVarying.xml b/tests/tests/content/res/values-small/configVarying.xml
similarity index 100%
rename from tests/res/values-small/configVarying.xml
rename to tests/tests/content/res/values-small/configVarying.xml
diff --git a/tests/res/values-square-32dpi/configVarying.xml b/tests/tests/content/res/values-square-32dpi/configVarying.xml
similarity index 100%
rename from tests/res/values-square-32dpi/configVarying.xml
rename to tests/tests/content/res/values-square-32dpi/configVarying.xml
diff --git a/tests/res/values-square-stylus/configVarying.xml b/tests/tests/content/res/values-square-stylus/configVarying.xml
similarity index 100%
rename from tests/res/values-square-stylus/configVarying.xml
rename to tests/tests/content/res/values-square-stylus/configVarying.xml
diff --git a/tests/res/values-square/configVarying.xml b/tests/tests/content/res/values-square/configVarying.xml
similarity index 100%
rename from tests/res/values-square/configVarying.xml
rename to tests/tests/content/res/values-square/configVarying.xml
diff --git a/tests/res/values-stylus-12key/configVarying.xml b/tests/tests/content/res/values-stylus-12key/configVarying.xml
similarity index 100%
rename from tests/res/values-stylus-12key/configVarying.xml
rename to tests/tests/content/res/values-stylus-12key/configVarying.xml
diff --git a/tests/res/values-stylus-keysexposed/configVarying.xml b/tests/tests/content/res/values-stylus-keysexposed/configVarying.xml
similarity index 100%
rename from tests/res/values-stylus-keysexposed/configVarying.xml
rename to tests/tests/content/res/values-stylus-keysexposed/configVarying.xml
diff --git a/tests/res/values-stylus/configVarying.xml b/tests/tests/content/res/values-stylus/configVarying.xml
similarity index 100%
rename from tests/res/values-stylus/configVarying.xml
rename to tests/tests/content/res/values-stylus/configVarying.xml
diff --git a/tests/res/values-sw590dp-hdpi/configVarying.xml b/tests/tests/content/res/values-sw590dp-hdpi/configVarying.xml
similarity index 100%
rename from tests/res/values-sw590dp-hdpi/configVarying.xml
rename to tests/tests/content/res/values-sw590dp-hdpi/configVarying.xml
diff --git a/tests/res/values-sw590dp-mdpi/configVarying.xml b/tests/tests/content/res/values-sw590dp-mdpi/configVarying.xml
similarity index 100%
rename from tests/res/values-sw590dp-mdpi/configVarying.xml
rename to tests/tests/content/res/values-sw590dp-mdpi/configVarying.xml
diff --git a/tests/res/values-sw590dp-xhdpi/configVarying.xml b/tests/tests/content/res/values-sw590dp-xhdpi/configVarying.xml
similarity index 100%
rename from tests/res/values-sw590dp-xhdpi/configVarying.xml
rename to tests/tests/content/res/values-sw590dp-xhdpi/configVarying.xml
diff --git a/tests/res/values-sw590dp/configVarying.xml b/tests/tests/content/res/values-sw590dp/configVarying.xml
similarity index 100%
rename from tests/res/values-sw590dp/configVarying.xml
rename to tests/tests/content/res/values-sw590dp/configVarying.xml
diff --git a/tests/res/values-sw591dp-hdpi/configVarying.xml b/tests/tests/content/res/values-sw591dp-hdpi/configVarying.xml
similarity index 100%
rename from tests/res/values-sw591dp-hdpi/configVarying.xml
rename to tests/tests/content/res/values-sw591dp-hdpi/configVarying.xml
diff --git a/tests/res/values-sw591dp/configVarying.xml b/tests/tests/content/res/values-sw591dp/configVarying.xml
similarity index 100%
rename from tests/res/values-sw591dp/configVarying.xml
rename to tests/tests/content/res/values-sw591dp/configVarying.xml
diff --git a/tests/res/values-sw600dp-land/configVarying.xml b/tests/tests/content/res/values-sw600dp-land/configVarying.xml
similarity index 100%
rename from tests/res/values-sw600dp-land/configVarying.xml
rename to tests/tests/content/res/values-sw600dp-land/configVarying.xml
diff --git a/tests/res/values-sw600dp-land/dimens.xml b/tests/tests/content/res/values-sw600dp-land/dimens.xml
similarity index 100%
rename from tests/res/values-sw600dp-land/dimens.xml
rename to tests/tests/content/res/values-sw600dp-land/dimens.xml
diff --git a/tests/res/values-sw600dp/configVarying.xml b/tests/tests/content/res/values-sw600dp/configVarying.xml
similarity index 100%
rename from tests/res/values-sw600dp/configVarying.xml
rename to tests/tests/content/res/values-sw600dp/configVarying.xml
diff --git a/tests/res/values-sw600dp/dimens.xml b/tests/tests/content/res/values-sw600dp/dimens.xml
similarity index 100%
rename from tests/res/values-sw600dp/dimens.xml
rename to tests/tests/content/res/values-sw600dp/dimens.xml
diff --git a/tests/res/values-sw720dp/configVarying.xml b/tests/tests/content/res/values-sw720dp/configVarying.xml
similarity index 100%
rename from tests/res/values-sw720dp/configVarying.xml
rename to tests/tests/content/res/values-sw720dp/configVarying.xml
diff --git a/tests/res/values-tl-rPH/configVarying.xml b/tests/tests/content/res/values-tl-rPH/configVarying.xml
similarity index 100%
rename from tests/res/values-tl-rPH/configVarying.xml
rename to tests/tests/content/res/values-tl-rPH/configVarying.xml
diff --git a/tests/res/values-tl/configVarying.xml b/tests/tests/content/res/values-tl/configVarying.xml
similarity index 100%
rename from tests/res/values-tl/configVarying.xml
rename to tests/tests/content/res/values-tl/configVarying.xml
diff --git a/tests/res/values-v10/strings.xml b/tests/tests/content/res/values-v10/strings.xml
similarity index 100%
rename from tests/res/values-v10/strings.xml
rename to tests/tests/content/res/values-v10/strings.xml
diff --git a/tests/res/values-v11/strings.xml b/tests/tests/content/res/values-v11/strings.xml
similarity index 100%
rename from tests/res/values-v11/strings.xml
rename to tests/tests/content/res/values-v11/strings.xml
diff --git a/tests/res/values-v12/strings.xml b/tests/tests/content/res/values-v12/strings.xml
similarity index 100%
rename from tests/res/values-v12/strings.xml
rename to tests/tests/content/res/values-v12/strings.xml
diff --git a/tests/res/values-v13/strings.xml b/tests/tests/content/res/values-v13/strings.xml
similarity index 100%
rename from tests/res/values-v13/strings.xml
rename to tests/tests/content/res/values-v13/strings.xml
diff --git a/tests/res/values-v14/strings.xml b/tests/tests/content/res/values-v14/strings.xml
similarity index 100%
rename from tests/res/values-v14/strings.xml
rename to tests/tests/content/res/values-v14/strings.xml
diff --git a/tests/res/values-v15/strings.xml b/tests/tests/content/res/values-v15/strings.xml
similarity index 100%
rename from tests/res/values-v15/strings.xml
rename to tests/tests/content/res/values-v15/strings.xml
diff --git a/tests/res/values-v16/strings.xml b/tests/tests/content/res/values-v16/strings.xml
similarity index 100%
rename from tests/res/values-v16/strings.xml
rename to tests/tests/content/res/values-v16/strings.xml
diff --git a/tests/res/values-v17/strings.xml b/tests/tests/content/res/values-v17/strings.xml
similarity index 100%
rename from tests/res/values-v17/strings.xml
rename to tests/tests/content/res/values-v17/strings.xml
diff --git a/tests/res/values-v18/strings.xml b/tests/tests/content/res/values-v18/strings.xml
similarity index 100%
rename from tests/res/values-v18/strings.xml
rename to tests/tests/content/res/values-v18/strings.xml
diff --git a/tests/res/values-v19/strings.xml b/tests/tests/content/res/values-v19/strings.xml
similarity index 100%
rename from tests/res/values-v19/strings.xml
rename to tests/tests/content/res/values-v19/strings.xml
diff --git a/tests/res/values-v20/strings.xml b/tests/tests/content/res/values-v20/strings.xml
similarity index 100%
rename from tests/res/values-v20/strings.xml
rename to tests/tests/content/res/values-v20/strings.xml
diff --git a/tests/res/values-v21/strings.xml b/tests/tests/content/res/values-v21/strings.xml
similarity index 100%
rename from tests/res/values-v21/strings.xml
rename to tests/tests/content/res/values-v21/strings.xml
diff --git a/tests/res/values-v22/strings.xml b/tests/tests/content/res/values-v22/strings.xml
similarity index 100%
rename from tests/res/values-v22/strings.xml
rename to tests/tests/content/res/values-v22/strings.xml
diff --git a/tests/res/values-v3/strings.xml b/tests/tests/content/res/values-v3/strings.xml
similarity index 100%
rename from tests/res/values-v3/strings.xml
rename to tests/tests/content/res/values-v3/strings.xml
diff --git a/tests/res/values-v4/strings.xml b/tests/tests/content/res/values-v4/strings.xml
similarity index 100%
rename from tests/res/values-v4/strings.xml
rename to tests/tests/content/res/values-v4/strings.xml
diff --git a/tests/res/values-v5/strings.xml b/tests/tests/content/res/values-v5/strings.xml
similarity index 100%
rename from tests/res/values-v5/strings.xml
rename to tests/tests/content/res/values-v5/strings.xml
diff --git a/tests/res/values-v6/strings.xml b/tests/tests/content/res/values-v6/strings.xml
similarity index 100%
rename from tests/res/values-v6/strings.xml
rename to tests/tests/content/res/values-v6/strings.xml
diff --git a/tests/res/values-v7/strings.xml b/tests/tests/content/res/values-v7/strings.xml
similarity index 100%
rename from tests/res/values-v7/strings.xml
rename to tests/tests/content/res/values-v7/strings.xml
diff --git a/tests/res/values-v8/strings.xml b/tests/tests/content/res/values-v8/strings.xml
similarity index 100%
rename from tests/res/values-v8/strings.xml
rename to tests/tests/content/res/values-v8/strings.xml
diff --git a/tests/res/values-v9/strings.xml b/tests/tests/content/res/values-v9/strings.xml
similarity index 100%
rename from tests/res/values-v9/strings.xml
rename to tests/tests/content/res/values-v9/strings.xml
diff --git a/tests/res/values-w600dp-h550dp/configVarying.xml b/tests/tests/content/res/values-w600dp-h550dp/configVarying.xml
similarity index 100%
rename from tests/res/values-w600dp-h550dp/configVarying.xml
rename to tests/tests/content/res/values-w600dp-h550dp/configVarying.xml
diff --git a/tests/res/values-w600dp/configVarying.xml b/tests/tests/content/res/values-w600dp/configVarying.xml
similarity index 100%
rename from tests/res/values-w600dp/configVarying.xml
rename to tests/tests/content/res/values-w600dp/configVarying.xml
diff --git a/tests/res/values-w720dp-h670dp/configVarying.xml b/tests/tests/content/res/values-w720dp-h670dp/configVarying.xml
similarity index 100%
rename from tests/res/values-w720dp-h670dp/configVarying.xml
rename to tests/tests/content/res/values-w720dp-h670dp/configVarying.xml
diff --git a/tests/res/values-w720dp/configVarying.xml b/tests/tests/content/res/values-w720dp/configVarying.xml
similarity index 100%
rename from tests/res/values-w720dp/configVarying.xml
rename to tests/tests/content/res/values-w720dp/configVarying.xml
diff --git a/tests/res/values-wheel/configVarying.xml b/tests/tests/content/res/values-wheel/configVarying.xml
similarity index 100%
rename from tests/res/values-wheel/configVarying.xml
rename to tests/tests/content/res/values-wheel/configVarying.xml
diff --git a/tests/res/values-xlarge/configVarying.xml b/tests/tests/content/res/values-xlarge/configVarying.xml
similarity index 100%
rename from tests/res/values-xlarge/configVarying.xml
rename to tests/tests/content/res/values-xlarge/configVarying.xml
diff --git a/tests/res/values-xx-32dpi/configVarying.xml b/tests/tests/content/res/values-xx-32dpi/configVarying.xml
similarity index 100%
rename from tests/res/values-xx-32dpi/configVarying.xml
rename to tests/tests/content/res/values-xx-32dpi/configVarying.xml
diff --git a/tests/res/values-xx-rYY/configVarying.xml b/tests/tests/content/res/values-xx-rYY/configVarying.xml
similarity index 100%
rename from tests/res/values-xx-rYY/configVarying.xml
rename to tests/tests/content/res/values-xx-rYY/configVarying.xml
diff --git a/tests/res/values-xx-square/configVarying.xml b/tests/tests/content/res/values-xx-square/configVarying.xml
similarity index 100%
rename from tests/res/values-xx-square/configVarying.xml
rename to tests/tests/content/res/values-xx-square/configVarying.xml
diff --git a/tests/res/values-xx/configVarying.xml b/tests/tests/content/res/values-xx/configVarying.xml
similarity index 100%
rename from tests/res/values-xx/configVarying.xml
rename to tests/tests/content/res/values-xx/configVarying.xml
diff --git a/tests/tests/content/res/values/arrays.xml b/tests/tests/content/res/values/arrays.xml
new file mode 100644
index 0000000..71e0133
--- /dev/null
+++ b/tests/tests/content/res/values/arrays.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<resources>
+    <item type="integer" name="reference" format="integer">101</item>
+
+      <string-array name="strings">
+        <item>zero</item>
+        <item>1</item>
+        <item>@string/reference</item>
+    </string-array>
+
+    <integer-array name="integers">
+        <item>0</item>
+        <item>1</item>
+        <item>@integer/reference</item>
+    </integer-array>
+
+    <array name="difficultyLevel">
+        <item>Easy</item>
+        <item>Medium</item>
+        <item>Hard</item>
+    </array>
+
+    <string-array name="string">
+        <item>Test String 1</item>
+        <item>Test String 2</item>
+        <item>Test String 3</item>
+    </string-array>
+
+    <integer-array name="table_row_layout">
+        <item>1</item>
+        <item>2</item>
+        <item>3</item>
+        <item>4</item>
+        <item>5</item>
+        <item>6</item>
+        <item>7</item>
+        <item>8</item>
+        <item>9</item>
+        <item>10</item>
+    </integer-array>
+</resources>
diff --git a/tests/tests/content/res/values/attrs.xml b/tests/tests/content/res/values/attrs.xml
new file mode 100644
index 0000000..4c3d9db
--- /dev/null
+++ b/tests/tests/content/res/values/attrs.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<resources>
+    <declare-styleable name="Style1">
+        <attr name="Type1" format="integer">
+            <enum name="type" value="28" />
+            <enum name="data" value="0xff00ff00" />
+            <enum name="asset_cookie" value="0" />
+            <enum name="resource_id" value="0" />
+            <enum name="changing_config" value="0" />
+        </attr>
+        <attr name="Type2" format="integer">
+            <enum name="type" value="28" />
+            <enum name="data" value="0xff0000ff" />
+            <enum name="asset_cookie" value="0" />
+            <enum name="resource_id" value="0" />
+            <enum name="changing_config" value="0" />
+        </attr>
+    </declare-styleable>
+    <attr name="type1" format="boolean"/>
+    <attr name="type2" format="boolean"/>
+    <attr name="type3" format="color"/>
+    <attr name="type4" format="reference|color"/>
+    <attr name="type5" format="dimension"/>
+    <attr name="type6" format="dimension"/>
+    <attr name="type7" format="dimension"/>
+    <attr name="type8" format="reference"/>
+    <attr name="type9" format="float"/>
+    <attr name="type10" format="fraction"/>
+    <attr name="type11" format="integer"/>
+    <attr name="type12" format="integer"/>
+    <attr name="type13" format="reference|string"/>
+    <attr name="type14" format="string"/>
+    <attr name="type15" format="reference"/>
+    <attr name="type16" format="string"/>
+    <declare-styleable name="style1">
+        <attr name="type1"/>
+        <attr name="type2"/>
+        <attr name="type3"/>
+        <attr name="type4"/>
+        <attr name="type5"/>
+        <attr name="type6"/>
+        <attr name="type7"/>
+        <attr name="type8"/>
+        <attr name="type9"/>
+        <attr name="type10"/>
+        <attr name="type11"/>
+        <attr name="type12"/>
+        <attr name="type13"/>
+        <attr name="type14"/>
+        <attr name="type15"/>
+        <attr name="type16"/>
+    </declare-styleable>
+    <attr name="testEnum">
+        <enum name="val1" value="1" />
+        <enum name="val2" value="2" />
+        <enum name="val10" value="10" />
+    </attr>
+    <attr name="testFlags">
+        <flag name="bit1" value="0x1" />
+        <flag name="bit2" value="0x2" />
+        <flag name="bit31" value="0x40000000" />
+    </attr>
+    <attr name="testString" format="string" />
+    <declare-styleable name="EnumStyle">
+        <attr name="testEnum" />
+    </declare-styleable>
+    <declare-styleable name="FlagStyle">
+        <attr name="testFlags" />
+    </declare-styleable>
+    <declare-styleable name="TestConfig">
+        <attr name="testString" />
+    </declare-styleable>
+    <!-- Size of text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp).
+         Supported values include the following:<p/>
+    <ul>
+        <li><b>px</b> Pixels</li>
+        <li><b>sp</b> Scaled pixels (scaled to relative pixel size on screen). See {@link android.util.DisplayMetrics} for more information.</li>
+        <li><b>pt</b> Points</li>
+        <li><b>dip</b> Device independent pixels. See {@link android.util.DisplayMetrics} for more information.</li>
+    </ul>
+    -->
+    <attr name="textSize" format="dimension" />
+    <attr name="typeface">
+        <enum name="normal" value="0" />
+        <enum name="sans" value="1" />
+        <enum name="serif" value="2" />
+        <enum name="monospace" value="3" />
+    </attr>
+    <!-- Default text typeface style. -->
+    <attr name="textStyle">
+        <flag name="normal" value="0" />
+        <flag name="bold" value="1" />
+        <flag name="italic" value="2" />
+    </attr>
+    <!-- Color of text (usually same as colorForeground). -->
+    <attr name="textColor" format="reference|color" />
+    <!-- Color of highlighted text. -->
+    <attr name="textColorHighlight" format="reference|color" />
+    <!-- Color of hint text (displayed when the field is empty). -->
+    <attr name="textColorHint" format="reference|color" />
+    <!-- Color of link text (URLs). -->
+    <attr name="textColorLink" format="reference|color" />
+    <declare-styleable name="TextAppearance">
+        <attr name="textColor"/>
+        <attr name="textSize"/>
+        <attr name="textStyle"/>
+        <attr name="typeface"/>
+        <attr name="textColorHighlight"/>
+        <attr name="textColorHint"/>
+        <attr name="textColorLink"/>
+    </declare-styleable>
+    <!-- Integer used to uniquely identify theme overrides. -->
+    <attr name="themeType" format="integer"/>
+    <!-- Theme reference used to override parent theme. -->
+    <attr name="themeOverrideAttr" format="reference"/>
+
+    <!-- Drawable theming attributes -->
+    <attr name="themeBoolean" />
+    <attr name="themeColor" />
+    <attr name="themeFloat" />
+    <attr name="themeInteger" />
+    <attr name="themeDimension" />
+    <attr name="themeDrawable" />
+    <attr name="themeBitmap" />
+    <attr name="themeNinePatch" />
+    <attr name="themeGravity" />
+    <attr name="themeTileMode" />
+    <attr name="themeAngle" />
+</resources>
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/content/res/values/bools.xml
old mode 100644
new mode 100755
similarity index 70%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/content/res/values/bools.xml
index 16e76c9..f119cda
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/content/res/values/bools.xml
@@ -1,5 +1,6 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
@@ -12,15 +13,9 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
+ -->
 
-package android.os.cts;
-
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasTaggedPointer();
-}
+<resources>
+	<bool name="trueRes">true</bool>
+	<bool name="falseRes">false</bool>
+</resources>
diff --git a/tests/src/android/widget/cts/ViewFlipperStubActivity.java b/tests/tests/content/res/values/colors.xml
similarity index 60%
copy from tests/src/android/widget/cts/ViewFlipperStubActivity.java
copy to tests/tests/content/res/values/colors.xml
index 2ac331e..f3cc325 100644
--- a/tests/src/android/widget/cts/ViewFlipperStubActivity.java
+++ b/tests/tests/content/res/values/colors.xml
@@ -1,4 +1,5 @@
-/*
+<?xml version="1.0" encoding="utf-8"?>
+<!--
  * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,21 +13,14 @@
  * 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.widget.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class ViewFlipperStubActivity extends Activity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        setContentView(R.layout.viewflipper_layout);
-    }
-}
-
+<resources>
+    <drawable name="red">#7f00</drawable>
+    <drawable name="blue">#770000ff</drawable>
+    <drawable name="black">#77ffffff</drawable>
+    <drawable name="yellow">#77ffff00</drawable>
+    <color name="testcolor1">#ff00ff00</color>
+    <color name="testcolor2">#ffff0000</color>
+    <color name="failColor">#ff0000ff</color>
+</resources>
diff --git a/tests/tests/content/res/values/configVarying.xml b/tests/tests/content/res/values/configVarying.xml
new file mode 100755
index 0000000..7b7d576
--- /dev/null
+++ b/tests/tests/content/res/values/configVarying.xml
@@ -0,0 +1,30 @@
+<?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.
+-->
+
+<resources>
+    <item type="configVarying" name="simple">simple default</item>
+    <bag type="configVarying" name="bag">
+        <item name="testString">bag default</item>
+    </bag>
+    <item type="configVarying" name="small">default</item>
+    <item type="configVarying" name="normal">default</item>
+    <item type="configVarying" name="large">default</item>
+    <item type="configVarying" name="xlarge">default</item>
+    <item type="configVarying" name="sw">default</item>
+    <item type="configVarying" name="w">default</item>
+    <item type="configVarying" name="h">default</item>
+    <item type="configVarying" name="wh">default</item>
+</resources>
diff --git a/tests/tests/content/res/values/dimens.xml b/tests/tests/content/res/values/dimens.xml
new file mode 100755
index 0000000..bae216f
--- /dev/null
+++ b/tests/tests/content/res/values/dimens.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<resources>
+    <item name="frac100perc" type="dimen" format="fraction">100%</item>
+    <item name="frac1perc" type="dimen" format="fraction">1%</item>
+    <item name="fracp1perc" type="dimen" format="fraction">.1%</item>
+    <item name="fracp01perc" type="dimen" format="fraction">.01%</item>
+    <item name="frac0perc" type="dimen" format="fraction">0%</item>
+    <item name="frac1p1perc" type="dimen" format="fraction">1.1%</item>
+    <item name="frac100p1perc" type="dimen" format="fraction">100.1%</item>
+    <item name="frac25510perc" type="dimen" format="fraction">25510%</item>
+    <item name="frac25610perc" type="dimen" format="fraction">25610%</item>
+    <item name="frac6553510perc" type="dimen" format="fraction">6553510%</item>
+    <item name="frac6553610perc" type="dimen" format="fraction">6553610%</item>
+
+    <item name="frac100pperc" type="dimen" format="fraction">100%p</item>
+    <item name="frac1pperc" type="dimen" format="fraction">1%p</item>
+    <item name="fracp1pperc" type="dimen" format="fraction">.1%p</item>
+    <item name="fracp01pperc" type="dimen" format="fraction">.01%p</item>
+    <item name="frac0pperc" type="dimen" format="fraction">0%p</item>
+    <item name="frac1p1pperc" type="dimen" format="fraction">1.1%p</item>
+    <item name="frac100p1pperc" type="dimen" format="fraction">100.1%p</item>
+    <item name="frac25510pperc" type="dimen" format="fraction">25510%p</item>
+    <item name="frac25610pperc" type="dimen" format="fraction">25610%p</item>
+    <item name="frac6553510pperc" type="dimen" format="fraction">6553510%p</item>
+    <item name="frac6553610pperc" type="dimen" format="fraction">6553610%p</item>
+</resources>
+
diff --git a/tests/tests/content/res/values/resources_test.xml b/tests/tests/content/res/values/resources_test.xml
new file mode 100644
index 0000000..91c2c4a
--- /dev/null
+++ b/tests/tests/content/res/values/resources_test.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<resources>
+     <!-- The width that is used when creating thumbnails of applications. -->
+     <dimen name="thumbnail_width">84dp</dimen>
+     <!-- The height that is used when creating thumbnails of applications. -->
+     <dimen name="thumbnail_height">63dp</dimen>
+     <!-- The standard size (both width and height) of an application icon that
+          will be displayed in the app launcher and elsewhere. -->
+     <dimen name="app_icon_size">48px</dimen>
+     <dimen name="toast_y_offset">64dip</dimen>
+     <plurals name="plurals_test">
+        <item quantity="one">A dog</item>
+        <item quantity="other">Some dogs</item>
+      </plurals>
+     <color name="resource_test_color">#003B3B3B</color>
+     <integer name="resource_test_int">10</integer>
+</resources>
diff --git a/tests/tests/content/res/values/strings.xml b/tests/tests/content/res/values/strings.xml
new file mode 100644
index 0000000..c167278
--- /dev/null
+++ b/tests/tests/content/res/values/strings.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="permlab_testGranted">Test Granted</string>
+    <string name="permdesc_testGranted">Used for running CTS tests, for testing operations
+        where we have the permission.</string>
+    <string name="permlab_testDynamic">Test Dynamic</string>
+    <string name="permdesc_testDynamic">Used for running CTS tests, for testing adding
+        dynamic permissions.</string>
+    <string name="permlab_testDenied">Test Denied</string>
+    <string name="permdesc_testDenied">Used for running CTS tests, for testing operations
+        where we do not have the permission.</string>
+    <string name="explain">1. click start. \n2. if above image shaked, then press pass button,
+         else press failed button.</string>
+    <string name="text_view_hello">Hello! Text view!</string>
+    <string name="text_view_hello_two_lines">Hello! \nText view!</string>
+    <string name="text_view_simple_hint">This is a hint.</string>
+    <string name="text_view_hint">This is a string for testing hint of textview.</string>
+    <string name="activity_forwarding">App/Forwarding</string>
+    <string name="forwarding">$$$</string>
+    <string name="go">Go</string>
+    <string name="back">Back</string>
+    <string name="forward_target">
+        Press back button and notice we don\'t see the previous activity.
+    </string>
+    <string name="edit_text">testing</string>
+    <string name="text">DialogTest</string>
+    <string name="text_country">Country</string>
+    <string name="text_name">Name</string>
+    <string name="hello_world">Hello, World!</string>
+    <string name="hello_android">Hello, Android!</string>
+    <string name="alert_dialog_username">Name:</string>
+    <string name="alert_dialog_password">Password:</string>
+    <string name="alert_dialog_positive">Positive</string>
+    <string name="alert_dialog_negative">Negative</string>
+    <string name="alert_dialog_neutral">Neutral</string>
+    <string name="notify">Notify </string>
+    <string name="tabs_1">testing</string>
+    <string name="table_layout_first">first</string>
+    <string name="table_layout_second">second</string>
+    <string name="table_layout_third">third</string>
+    <string name="table_layout_long">Very long to make the string out of the screen</string>
+    <string name="chronometer_text">Test Chronometer</string>
+    <string name="am">AM</string>
+    <string name="pm">PM</string>
+    <string name="viewgroup_test">ViewGroup test</string>
+    <string name="viewanimator_test">ViewAnimator test</string>
+    <string name="id_ok">OK</string>
+    <string name="id_cancel">Cancel</string>
+    <string name="context_test_string1">This is %s string.</string>
+    <string name="context_test_string2">This is test string.</string>
+    <string name="animationutils_test_instructions">Choose different animations</string>
+    <string name="animationutils_test_alpha">Alpha animation</string>
+    <string name="animationutils_test_scale">Scale animation</string>
+    <string name="animationutils_test_rotate">Rotate animation</string>
+    <string name="animationutils_test_translate">Translate animation</string>
+    <string name="animationutils_test_set">Animation set</string>
+    <string name="animationutils_test_layout">Layout animation</string>
+    <string name="animationutils_test_gridlayout">Grid layout animation</string>
+    <string name="twolinelistitem_test_text1">text1</string>
+    <string name="twolinelistitem_test_text2">text2</string>
+    <string name="metadata_text">metadata text</string>
+    <string name="horizontal_text_1">horizontal 1</string>
+    <string name="horizontal_text_2">horizontal 2</string>
+    <string name="horizontal_text_3">horizontal 3</string>
+    <string name="vertical_text_1">vertical 1</string>
+    <string name="vertical_text_2">vertical 2</string>
+    <string name="vertical_text_3">vertical 3</string>
+    <string name="reference">here</string>
+    <string name="coerceIntegerToString">100</string>
+    <string name="coerceBooleanToString">true</string>
+    <string name="coerceColorToString">#fff</string>
+    <string name="coerceFloatToString">100.0</string>
+    <string name="coerceDimensionToString">100px</string>
+    <string name="coerceFractionToString">100<xliff:g id="percent">%</xliff:g></string>
+    <string name="formattedStringNone">Format[]</string>
+    <string name="formattedStringOne">Format[<xliff:g id="format">%d</xliff:g>]</string>
+    <string name="formattedStringTwo">Format[<xliff:g id="format">%3$d,%2$s</xliff:g>]</string>
+    <string name="checkboxpref_key">checkboxpref_key</string>
+   <string name="checkboxpref_title">title of preference</string>
+   <string name="checkboxpref_summary">summary of preference</string>
+   <string name="checkboxpref_summary_on">summary on of preference</string>
+   <string name="checkboxpref_summary_off">summary off of preference</string>
+   <string name="checkboxpref_depend">checkboxpref_depend</string>
+   <string name="checkboxpref_depend_title"> depend title of preference</string>
+   <string name="checkboxpref_depend_summary"> depend summary of preference</string>
+   <string name="edittextpref_key">edittextpref_key</string>
+   <string name="edittextpref_default_value">default value of preference</string>
+   <string name="edittextpref_title">title of edit text preference</string>
+   <string name="edittextpref_summary">summary of edit text preference</string>
+   <string name="edittextpref_dialog_title">dialog title of edit text preference</string>
+   <string name="edittextpref_text">text of  edit text preference</string>
+   <string name="listpref_key">listpref_key</string>
+   <string name="listpref_title">title of list preference</string>
+   <string name="listpref_summary">summary of list preference</string>
+   <string name="listpref_dialogtitle">dialog title of list preference</string>
+   <string name="easy">Easy</string>
+   <string name="medium">Medium</string>
+   <string name="hard">Hard</string>
+   <string name="footer_view">Footer view</string>
+   <string name="header_view">Header view</string>
+   <string name="dialogpref_title">title of dialog preference </string>
+   <string name="dialogpref_dialog_title">dialog title of dialog preference </string>
+   <string name="dialogpref_key">dialogpref_key</string>
+   <string name="dialogpref_default_value">default value of dialog preference</string>
+   <string name="dialogpref_summary">summary of dialog preference</string>
+   <string name="dialogpref_message">message of dialog preference</string>
+   <string name="dialogpref_sure">Sure</string>
+   <string name="dialogpref_cancel">Cancel</string>
+   <string name="pref_key">pref_key</string>
+   <string name="pref_title">title of preference</string>
+   <string name="pref_summary">summary of preference</string>
+   <string name="pref_depend_key">pref_depend_key</string>
+   <string name="pref_depend_title"> depend title of preference</string>
+   <string name="pref_depend_summary"> depend summary of preference</string>
+   <string name="android_intent_action_preference">android.intent.action.PREFERENCE</string>
+   <string name="def_pref_key">def_pref_key</string>
+   <string name="def_pref_title">default preference</string>
+   <string name="def_pref_summary">This is default preference of cts</string>
+   <string name="relative_view1">view 1</string>
+   <string name="relative_view2">view 2</string>
+   <string name="relative_view3">view 3</string>
+   <string name="relative_view4">view 4</string>
+   <string name="relative_view5">view 5</string>
+   <string name="relative_view6">view 6</string>
+   <string name="relative_view7">view 7</string>
+   <string name="relative_view8">view 8</string>
+   <string name="relative_view9">view 9</string>
+   <string name="relative_view10">view 10</string>
+   <string name="relative_view11">view 11</string>
+   <string name="relative_view12">view 12</string>
+   <string name="relative_view13">view 13</string>
+   <string name="country">Country:</string>
+   <string name="symbol">Symbol:</string>
+   <string name="country_warning">No such country registered</string>
+   <string name="version_cur">base</string>
+   <string name="version_old">base</string>
+   <string name="version_v3">base</string>
+   <string name="authenticator_label">Android CTS</string>
+   <string name="search_label">Android CTS</string>
+   <string name="tag1">tag 1</string>
+   <string name="tag2">tag 2</string>
+
+   <string name="button">Button</string>
+   <string name="holo_test">Holo Test</string>
+   <string name="holo_generator">Holo Generator</string>
+   <string name="holo_light_test">Holo Light Test</string>
+   <string name="holo_light_generator">Holo Light Generator</string>
+   <string name="reference_image">Reference Image: </string>
+   <string name="generated_image">Generated Image: </string>
+   <string name="themes_prompt">Select a Theme:</string>
+   <string name="sample_text">Sample text goes here. I wanted something creative and whimsical
+but then I just got bored...</string>
+    <string name="long_text">This is a really long string which exceeds the width of the view.
+New devices have a much larger screen which actually enables long strings to be displayed
+with no fading. I have made this string longer to fix this case. If you are correcting this
+text, I would love to see the kind of devices you guys now use! Guys, maybe some devices need longer string!
+I think so, so how about double this string, like copy and paste!
+This is a really long string which exceeds the width of the view.
+New devices have a much larger screen which actually enables long strings to be displayed
+with no fading. I have made this string longer to fix this case. If you are correcting this
+text, I would love to see the kind of devices you guys now use! Guys, maybe some devices need longer string!
+I think so, so how about double this string, like copy and paste! </string>
+    <string name="rectangle200">"M 0,0 l 200,0 l 0, 200 l -200, 0 z"</string>
+</resources>
diff --git a/tests/tests/content/res/values/styles.xml b/tests/tests/content/res/values/styles.xml
new file mode 100644
index 0000000..20c80f8
--- /dev/null
+++ b/tests/tests/content/res/values/styles.xml
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <style name="Whatever">
+        <item name="type1">true</item>
+        <item name="type2">false</item>
+        <item name="type3">#ff0000ff</item>
+        <item name="type4">#ff00ff00</item>
+        <item name="type5">0.75px</item>
+        <item name="type6">10px</item>
+        <item name="type7">18px</item>
+        <item name="type8">@drawable/pass</item>
+        <item name="type9">3.14</item>
+        <item name="type10">100%</item>
+        <item name="type11">365</item>
+        <item name="type12">86400</item>
+        <item name="type13">@string/hello_android</item>
+        <item name="type14">TypedArray Test!</item>
+        <item name="type15">@array/difficultyLevel</item>
+        <item name="type16">Typed Value!</item>
+    </style>
+
+    <style name="TextViewWithoutColorAndAppearance">
+        <item name="android:textSize">18sp</item>
+    </style>
+
+    <style name="TextViewWithColorButWithOutAppearance">
+        <item name="android:textColor">#ff0000ff</item>
+    </style>
+
+    <style name="TextViewWithColorAndAppearance">
+        <item name="android:textColor">#ff0000ff</item>
+        <item name="android:textAppearance">@style/TextAppearance.WithColor</item>
+    </style>
+
+    <style name="TextViewWithoutColorButWithAppearance">
+        <item name="android:textAppearance">@style/TextAppearance.WithColor</item>
+    </style>
+
+    <style name="TextAppearance" parent="android:TextAppearance">
+    </style>
+
+    <style name="TextAppearance.WithColor">
+        <item name="android:textColor">#ffff0000</item>
+    </style>
+
+    <style name="TextAppearance.All">
+        <item name="android:textColor">@drawable/black</item>
+        <item name="android:textSize">20px</item>
+        <item name="android:textStyle">bold</item>
+        <item name="android:textColorHint">@drawable/red</item>
+        <item name="android:textColorLink">@drawable/blue</item>
+        <item name="android:textColorHighlight">@drawable/yellow</item>
+    </style>
+
+    <style name="TextAppearance.Colors">
+        <item name="android:textColor">@drawable/black</item>
+        <item name="android:textColorHint">@drawable/blue</item>
+        <item name="android:textColorLink">@drawable/yellow</item>
+        <item name="android:textColorHighlight">@drawable/red</item>
+    </style>
+
+    <style name="TextAppearance.NotColors">
+        <item name="android:textSize">17px</item>
+        <item name="android:typeface">sans</item>
+        <item name="android:textStyle">normal</item>
+    </style>
+
+    <style name="TextAppearance.Style">
+        <item name="android:textStyle">normal</item>
+    </style>
+
+    <style name="TestEnum1">
+        <item name="testEnum">val1</item>
+    </style>
+
+    <style name="TestEnum2">
+        <item name="testEnum">val2</item>
+    </style>
+
+    <style name="TestEnum10">
+        <item name="testEnum">val10</item>
+    </style>
+
+    <style name="TestFlag1">
+        <item name="testFlags">bit1</item>
+    </style>
+
+    <style name="TestFlag2">
+        <item name="testFlags">bit2</item>
+    </style>
+
+    <style name="TestFlag31">
+        <item name="testFlags">bit31</item>
+    </style>
+
+    <style name="TestFlag1And2">
+        <item name="testFlags">bit1|bit2</item>
+    </style>
+
+    <style name="TestFlag1And2And31">
+        <item name="testFlags">bit1|bit2|bit31</item>
+    </style>
+
+    <style name="TestEnum1.EmptyInherit" />
+
+    <style name="Theme_AlertDialog">
+        <item name="android:textSize">18sp</item>
+    </style>
+
+    <style name="TestProgressBar">
+        <item name="android:indeterminateOnly">false</item>
+        <item name="android:progressDrawable">?android:drawable/progress_horizontal</item>
+        <item name="android:indeterminateDrawable">?android:drawable/progress_horizontal</item>
+        <item name="android:minHeight">20dip</item>
+        <item name="android:maxHeight">20dip</item>
+        <item name="android:focusable">true</item>
+    </style>
+
+    <style name="Test_Theme">
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:panelColorForeground">#ff000000</item>
+        <item name="android:panelColorBackground">#ffffffff</item>
+    </style>
+
+    <style name="Theme_OverrideOuter">
+        <item name="themeType">1</item>
+    </style>
+
+    <style name="Theme_OverrideInner">
+        <item name="themeType">2</item>
+        <item name="themeOverrideAttr">@style/Theme_OverrideAttr</item>
+    </style>
+
+    <style name="Theme_OverrideAttr">
+        <item name="themeType">3</item>
+    </style>
+    
+    <style name="Theme_ThemedDrawableTest">
+        <item name="themeBoolean">true</item>
+        <item name="themeColor">@android:color/black</item>
+        <item name="themeFloat">1.0</item>
+        <item name="themeAngle">45.0</item>
+        <item name="themeInteger">1</item>
+        <item name="themeDimension">1px</item>
+        <item name="themeDrawable">@drawable/icon_black</item>
+        <item name="themeBitmap">@drawable/icon_black</item>
+        <item name="themeNinePatch">@drawable/ninepatch_0</item>
+        <item name="themeGravity">48</item>
+        <item name="themeTileMode">2</item>
+    </style>
+
+    <style name="Theme_NoSwipeDismiss">
+        <item name="android:windowSwipeToDismiss">false</item>
+    </style>
+
+</resources>
diff --git a/tests/tests/content/res/xml/alias.xml b/tests/tests/content/res/xml/alias.xml
new file mode 100644
index 0000000..f88f3dc
--- /dev/null
+++ b/tests/tests/content/res/xml/alias.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * 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.
+ */
+-->
+
+<alias xmlns:android="http://schemas.android.com/apk/res/android">
+    <intent android:action="android.intent.action.MAIN"
+        android:targetPackage="com.android.cts.stub"
+        android:targetClass="android.app.cts.ChildActivity"
+        android:data="http://www.google.com/">
+    </intent>
+</alias>
+
diff --git a/tests/tests/content/res/xml/authenticator.xml b/tests/tests/content/res/xml/authenticator.xml
new file mode 100644
index 0000000..1e298b1
--- /dev/null
+++ b/tests/tests/content/res/xml/authenticator.xml
@@ -0,0 +1,28 @@
+<?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.
+ */
+-->
+
+<!-- The attributes in this XML file provide configuration information -->
+<!-- for the Account Manager. -->
+
+<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
+    android:accountType="android.content.cts.account.type"
+    android:icon="@drawable/ic_cts_selected"
+    android:smallIcon="@drawable/ic_cts_minitab_selected"
+    android:label="@string/authenticator_label"
+/>
\ No newline at end of file
diff --git a/tests/tests/content/res/xml/colors.xml b/tests/tests/content/res/xml/colors.xml
new file mode 100644
index 0000000..8c44a66
--- /dev/null
+++ b/tests/tests/content/res/xml/colors.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * 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.
+ */
+-->
+<resources>
+    <color name="testcolor1">#ff00ff00</color>
+    <color name="testcolor2">#ffff0000</color>
+    <color name="failColor">#ff0000ff</color>
+</resources>
+
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/content/res/xml/extra.xml
old mode 100644
new mode 100755
similarity index 65%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/content/res/xml/extra.xml
index 16e76c9..b3bffb4
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/content/res/xml/extra.xml
@@ -1,5 +1,6 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
@@ -12,15 +13,8 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-package android.os.cts;
-
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasTaggedPointer();
-}
+ -->
+<tag xmlns:android="http://schemas.android.com/apk/res/android" android:name="Bruce" android:value="Lee">
+    <extra android:name="google" android:value="android">
+    </extra>
+</tag>
diff --git a/tests/tests/content/res/xml/intentfilter.xml b/tests/tests/content/res/xml/intentfilter.xml
new file mode 100644
index 0000000..7ed3a53
--- /dev/null
+++ b/tests/tests/content/res/xml/intentfilter.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * 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.
+ */
+-->
+<intent-filter xmlns="http://schemas.android.com/apk/res/android">
+    <action name="testAction"/>
+    <cat name="testCategory" />
+    <type name="vnd.android.cursor.dir/person"/>
+    <scheme name="testScheme"/>
+    <auth host="testHost" port="80"/>
+    <path name="testPath" literal="test"/>
+    <path name="testPath" prefix="test"/>
+    <path name="testPath" sglob="test"/>
+</intent-filter>
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/content/res/xml/pm_test.xml
similarity index 70%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/content/res/xml/pm_test.xml
index 16e76c9..4db24cf 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/content/res/xml/pm_test.xml
@@ -1,5 +1,6 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
@@ -12,15 +13,7 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-package android.os.cts;
-
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasTaggedPointer();
-}
+ -->
+ <!-- This xml is just test for PackageManager Test -->
+<resources>
+</resources>
diff --git a/tests/tests/content/res/xml/syncadapter.xml b/tests/tests/content/res/xml/syncadapter.xml
new file mode 100644
index 0000000..1c0bb72
--- /dev/null
+++ b/tests/tests/content/res/xml/syncadapter.xml
@@ -0,0 +1,26 @@
+<?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.
+ */
+-->
+
+<!-- The attributes in this XML file provide configuration information -->
+<!-- for the SyncAdapter. -->
+
+<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
+    android:contentAuthority="android.content.cts.authority"
+    android:accountType="android.content.cts.account.type"
+/>
diff --git a/tests/tests/content/res/xml/test_color.xml b/tests/tests/content/res/xml/test_color.xml
new file mode 100644
index 0000000..97f7dec
--- /dev/null
+++ b/tests/tests/content/res/xml/test_color.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+        android:versionName="testNonResourcesString">
+    <color name="testcolor1">#ff00ff00</color>
+    <color name="testcolor2">#ffff0000</color>
+    <color name="failColor">#ff0000ff</color>
+</resources>
diff --git a/tests/src/android/content/cts/AvailableIntentsActivity.java b/tests/tests/content/src/android/content/cts/AvailableIntentsActivity.java
similarity index 96%
rename from tests/src/android/content/cts/AvailableIntentsActivity.java
rename to tests/tests/content/src/android/content/cts/AvailableIntentsActivity.java
index ac676de..773defc 100644
--- a/tests/src/android/content/cts/AvailableIntentsActivity.java
+++ b/tests/tests/content/src/android/content/cts/AvailableIntentsActivity.java
@@ -16,7 +16,7 @@
 
 package android.content.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 import android.app.Activity;
 import android.os.Bundle;
diff --git a/tests/tests/content/src/android/content/cts/BroadcastReceiverTest.java b/tests/tests/content/src/android/content/cts/BroadcastReceiverTest.java
index 2865f9e..526087b 100644
--- a/tests/tests/content/src/android/content/cts/BroadcastReceiverTest.java
+++ b/tests/tests/content/src/android/content/cts/BroadcastReceiverTest.java
@@ -18,8 +18,6 @@
 
 
 import android.app.Service;
-import android.app.cts.MockActivity;
-import android.app.cts.MockService;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
@@ -52,7 +50,7 @@
     private static final long START_SERVICE_TIMEOUT  = 3000;
 
     public BroadcastReceiverTest() {
-        super("com.android.cts.stub", MockActivity.class);
+        super("com.android.cts.content", MockActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/content/cts/ClipboardManagerListenerActivity.java b/tests/tests/content/src/android/content/cts/ClipboardManagerListenerActivity.java
similarity index 100%
rename from tests/src/android/content/cts/ClipboardManagerListenerActivity.java
rename to tests/tests/content/src/android/content/cts/ClipboardManagerListenerActivity.java
diff --git a/tests/tests/content/src/android/content/cts/ComponentNameTest.java b/tests/tests/content/src/android/content/cts/ComponentNameTest.java
index d14a95b..6277bd6 100644
--- a/tests/tests/content/src/android/content/cts/ComponentNameTest.java
+++ b/tests/tests/content/src/android/content/cts/ComponentNameTest.java
@@ -85,7 +85,7 @@
     }
 
     public void testFlattenToString() {
-        assertEquals("com.android.cts.stub/android.content.cts.ComponentNameTest",
+        assertEquals("com.android.cts.content/android.content.cts.ComponentNameTest",
                 getComponentName().flattenToString());
     }
 
@@ -121,7 +121,7 @@
 
     public void testGetPackageName() {
         final String actual = getComponentName().getPackageName();
-        assertEquals("com.android.cts.stub", actual);
+        assertEquals("com.android.cts.content", actual);
     }
 
     public void testUnflattenFromString() {
@@ -135,7 +135,7 @@
     public void testFlattenToShortString() {
         // Test normal
         String actual = getComponentName().flattenToShortString();
-        assertEquals("com.android.cts.stub/android.content.cts.ComponentNameTest", actual);
+        assertEquals("com.android.cts.content/android.content.cts.ComponentNameTest", actual);
 
         // Test long class name
         final ComponentName componentName = new ComponentName("com.android.view",
@@ -168,7 +168,7 @@
     public void testToShortString() {
         // Test normal string
         final String shortString = getComponentName().toShortString();
-        assertEquals("{com.android.cts.stub/android.content.cts.ComponentNameTest}", shortString);
+        assertEquals("{com.android.cts.content/android.content.cts.ComponentNameTest}", shortString);
     }
 
     public void testGetClassName() {
@@ -196,7 +196,7 @@
         ComponentName.writeToParcel(componentName, parcel);
         parcel.setDataPosition(0);
         assertFalse(0 == parcel.dataAvail());
-        assertEquals("com.android.cts.stub", parcel.readString());
+        assertEquals("com.android.cts.content", parcel.readString());
         assertEquals("android.content.cts.ComponentNameTest", parcel.readString());
 
         // Test null data
diff --git a/tests/tests/content/src/android/content/cts/ContentProviderTest.java b/tests/tests/content/src/android/content/cts/ContentProviderTest.java
index 5ced37c..0b4d9aa 100644
--- a/tests/tests/content/src/android/content/cts/ContentProviderTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentProviderTest.java
@@ -27,7 +27,7 @@
 import android.os.ParcelFileDescriptor;
 import android.test.AndroidTestCase;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -37,7 +37,7 @@
  * Test {@link ContentProvider}.
  */
 public class ContentProviderTest extends AndroidTestCase {
-    private static final String TEST_PACKAGE_NAME = "com.android.cts.stub";
+    private static final String TEST_PACKAGE_NAME = "com.android.cts.content";
     private static final String TEST_FILE_NAME = "testFile.tmp";
     private static final String TEST_DB_NAME = "test.db";
 
diff --git a/tests/tests/content/src/android/content/cts/ContentResolverTest.java b/tests/tests/content/src/android/content/cts/ContentResolverTest.java
index 47371cc..4176da3 100644
--- a/tests/tests/content/src/android/content/cts/ContentResolverTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentResolverTest.java
@@ -16,7 +16,7 @@
 
 package android.content.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 
 import android.accounts.Account;
@@ -75,7 +75,7 @@
     private static final int VALUE2 = 2;
     private static final int VALUE3 = 3;
 
-    private static final String TEST_PACKAGE_NAME = "com.android.cts.stub";
+    private static final String TEST_PACKAGE_NAME = "com.android.cts.content";
 
     private Context mContext;
     private ContentResolver mContentResolver;
diff --git a/tests/tests/content/src/android/content/cts/ContextTest.java b/tests/tests/content/src/android/content/cts/ContextTest.java
index 70abe1f..7c5dc50 100644
--- a/tests/tests/content/src/android/content/cts/ContextTest.java
+++ b/tests/tests/content/src/android/content/cts/ContextTest.java
@@ -16,7 +16,7 @@
 
 package android.content.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 import com.android.internal.util.XmlUtils;
 
 
diff --git a/tests/src/android/content/cts/ContextWrapperStubActivity.java b/tests/tests/content/src/android/content/cts/ContextWrapperCtsActivity.java
similarity index 90%
rename from tests/src/android/content/cts/ContextWrapperStubActivity.java
rename to tests/tests/content/src/android/content/cts/ContextWrapperCtsActivity.java
index 977cedc..9ff4df9 100644
--- a/tests/src/android/content/cts/ContextWrapperStubActivity.java
+++ b/tests/tests/content/src/android/content/cts/ContextWrapperCtsActivity.java
@@ -21,9 +21,9 @@
 import android.app.Activity;
 import android.os.Bundle;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
-public class ContextWrapperStubActivity extends Activity {
+public class ContextWrapperCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
index 59fae2f..e7b6ed7 100644
--- a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
@@ -16,7 +16,7 @@
 
 package android.content.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 
 import android.content.ActivityNotFoundException;
@@ -79,8 +79,8 @@
     private final static String MOCK_ACTION1 = ACTION_BROADCAST_TESTORDER + "1";
     private final static String MOCK_ACTION2 = ACTION_BROADCAST_TESTORDER + "2";
 
-    public static final String PERMISSION_GRANTED = "android.app.cts.permission.TEST_GRANTED";
-    public static final String PERMISSION_DENIED = "android.app.cts.permission.TEST_DENIED";
+    public static final String PERMISSION_GRANTED = "android.content.cts.permission.TEST_GRANTED";
+    public static final String PERMISSION_DENIED = "android.content.cts.permission.TEST_DENIED";
 
     private static final int BROADCAST_TIMEOUT = 10000;
 
@@ -402,7 +402,7 @@
     }
 
     public void testStartActivity() {
-        Intent intent = new Intent(mContext, ContextWrapperStubActivity.class);
+        Intent intent = new Intent(mContext, ContextWrapperCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         try {
             mContextWrapper.startActivity(intent);
@@ -474,7 +474,7 @@
     }
 
     public void testGetPackageName() {
-        assertEquals("com.android.cts.stub", mContextWrapper.getPackageName());
+        assertEquals("com.android.cts.content", mContextWrapper.getPackageName());
     }
 
     public void testGetCacheDir() {
diff --git a/tests/src/android/content/cts/DummyProvider.java b/tests/tests/content/src/android/content/cts/DummyProvider.java
similarity index 100%
rename from tests/src/android/content/cts/DummyProvider.java
rename to tests/tests/content/src/android/content/cts/DummyProvider.java
diff --git a/tests/src/android/content/cts/HighPriorityBroadcastReceiver.java b/tests/tests/content/src/android/content/cts/HighPriorityBroadcastReceiver.java
similarity index 100%
rename from tests/src/android/content/cts/HighPriorityBroadcastReceiver.java
rename to tests/tests/content/src/android/content/cts/HighPriorityBroadcastReceiver.java
diff --git a/tests/tests/content/src/android/content/cts/IntentFilterTest.java b/tests/tests/content/src/android/content/cts/IntentFilterTest.java
index d067b9e..d0e70f2 100644
--- a/tests/tests/content/src/android/content/cts/IntentFilterTest.java
+++ b/tests/tests/content/src/android/content/cts/IntentFilterTest.java
@@ -33,7 +33,6 @@
 import org.xmlpull.v1.XmlPullParserException;
 import org.xmlpull.v1.XmlSerializer;
 
-import android.app.cts.MockActivity;
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.Intent;
diff --git a/tests/tests/content/src/android/content/cts/IntentTest.java b/tests/tests/content/src/android/content/cts/IntentTest.java
index d7bf6f4..d4fac55 100644
--- a/tests/tests/content/src/android/content/cts/IntentTest.java
+++ b/tests/tests/content/src/android/content/cts/IntentTest.java
@@ -22,8 +22,6 @@
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
 
-import android.app.cts.MockActivity;
-import android.app.cts.MockReceiver;
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -730,18 +728,18 @@
         // Should only have one activity responding to narrow category
         final ComponentName target = intent.resolveActivity(mPm);
         assertEquals("com.android.cts.content", target.getPackageName());
-        assertEquals("android.app.cts.MockActivity", target.getClassName());
+        assertEquals("android.content.cts.MockActivity", target.getClassName());
     }
 
     public void testResolveActivityShortcutMatch() {
         final Intent intent = new Intent("com.android.cts.content.action.TEST_ACTION");
         intent.setComponent(
-                new ComponentName("com.android.cts.content", "android.app.cts.MockActivity2"));
+                new ComponentName("com.android.cts.content", "android.content.cts.MockActivity2"));
 
         // Multiple activities match, but we asked for explicit component
         final ComponentName target = intent.resolveActivity(mPm);
         assertEquals("com.android.cts.content", target.getPackageName());
-        assertEquals("android.app.cts.MockActivity2", target.getClassName());
+        assertEquals("android.content.cts.MockActivity2", target.getClassName());
     }
 
     public void testResolveActivityMultipleMatch() {
diff --git a/tests/tests/content/src/android/content/cts/Intent_ShortcutIconResourceTest.java b/tests/tests/content/src/android/content/cts/Intent_ShortcutIconResourceTest.java
index b38f3fc..062ef90 100644
--- a/tests/tests/content/src/android/content/cts/Intent_ShortcutIconResourceTest.java
+++ b/tests/tests/content/src/android/content/cts/Intent_ShortcutIconResourceTest.java
@@ -29,7 +29,7 @@
 
     ShortcutIconResource mShortcutIconResource;
     Context mContext;
-    final int resourceId = com.android.cts.stub.R.string.notify;
+    final int resourceId = com.android.cts.content.R.string.notify;
 
     @Override
     protected void setUp() throws Exception {
@@ -63,7 +63,7 @@
     public void testWriteToParcel() {
 
         mShortcutIconResource = ShortcutIconResource.fromContext(mContext,
-                com.android.cts.stub.R.string.notify);
+                com.android.cts.content.R.string.notify);
         assertNotNull(mShortcutIconResource);
         Parcel parce = Parcel.obtain();
         mShortcutIconResource.writeToParcel(parce, 1);
diff --git a/tests/src/android/content/cts/LowPriorityBroadcastReceiver.java b/tests/tests/content/src/android/content/cts/LowPriorityBroadcastReceiver.java
similarity index 100%
rename from tests/src/android/content/cts/LowPriorityBroadcastReceiver.java
rename to tests/tests/content/src/android/content/cts/LowPriorityBroadcastReceiver.java
diff --git a/tests/src/android/content/cts/MockAccountAuthenticator.java b/tests/tests/content/src/android/content/cts/MockAccountAuthenticator.java
similarity index 100%
rename from tests/src/android/content/cts/MockAccountAuthenticator.java
rename to tests/tests/content/src/android/content/cts/MockAccountAuthenticator.java
diff --git a/tests/src/android/content/cts/MockAccountService.java b/tests/tests/content/src/android/content/cts/MockAccountService.java
similarity index 100%
rename from tests/src/android/content/cts/MockAccountService.java
rename to tests/tests/content/src/android/content/cts/MockAccountService.java
diff --git a/tests/src/android/widget/cts/StubActivity.java b/tests/tests/content/src/android/content/cts/MockActivity.java
similarity index 75%
copy from tests/src/android/widget/cts/StubActivity.java
copy to tests/tests/content/src/android/content/cts/MockActivity.java
index fe4002c..19834df 100644
--- a/tests/src/android/widget/cts/StubActivity.java
+++ b/tests/tests/content/src/android/content/cts/MockActivity.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,13 +14,10 @@
  * limitations under the License.
  */
 
-package android.widget.cts;
+package android.content.cts;
 
 import android.app.Activity;
 
-/**
- * Stub activity for helping test. It's an empty activity.
- */
-public class StubActivity extends Activity {
+public class MockActivity extends Activity {
 
 }
diff --git a/tests/tests/content/src/android/content/cts/MockApplication.java b/tests/tests/content/src/android/content/cts/MockApplication.java
new file mode 100644
index 0000000..cca34d6
--- /dev/null
+++ b/tests/tests/content/src/android/content/cts/MockApplication.java
@@ -0,0 +1,59 @@
+/*
+ * 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.content.cts;
+
+import android.app.Application;
+import android.content.res.Configuration;
+
+
+public class MockApplication extends Application {
+
+    public boolean isOnCreateCalled;
+    public boolean isConstructorCalled;
+    public boolean isOnConfigurationChangedCalled;
+    public boolean isOnLowMemoryCalled;
+
+    public MockApplication() {
+        super();
+        isConstructorCalled = true;
+    }
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        isOnCreateCalled = true;
+    }
+
+    @Override
+    public void onTerminate() {
+        super.onTerminate();
+        // The documentation states that one cannot rely on this method being called. No need to
+        // test it here.
+    }
+
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        isOnConfigurationChangedCalled = true;
+    }
+
+    @Override
+    public void onLowMemory() {
+        super.onLowMemory();
+        isOnLowMemoryCalled = true;
+    }
+}
diff --git a/tests/src/android/content/cts/MockContentProvider.java b/tests/tests/content/src/android/content/cts/MockContentProvider.java
similarity index 100%
rename from tests/src/android/content/cts/MockContentProvider.java
rename to tests/tests/content/src/android/content/cts/MockContentProvider.java
diff --git a/tests/src/android/content/cts/MockContextWrapperService.java b/tests/tests/content/src/android/content/cts/MockContextWrapperService.java
similarity index 100%
rename from tests/src/android/content/cts/MockContextWrapperService.java
rename to tests/tests/content/src/android/content/cts/MockContextWrapperService.java
diff --git a/tests/src/android/content/cts/MockReceiver.java b/tests/tests/content/src/android/content/cts/MockReceiver.java
similarity index 100%
rename from tests/src/android/content/cts/MockReceiver.java
rename to tests/tests/content/src/android/content/cts/MockReceiver.java
diff --git a/tests/src/android/content/cts/MockReceiverAbort.java b/tests/tests/content/src/android/content/cts/MockReceiverAbort.java
similarity index 100%
rename from tests/src/android/content/cts/MockReceiverAbort.java
rename to tests/tests/content/src/android/content/cts/MockReceiverAbort.java
diff --git a/tests/src/android/content/cts/MockReceiverFirst.java b/tests/tests/content/src/android/content/cts/MockReceiverFirst.java
similarity index 100%
rename from tests/src/android/content/cts/MockReceiverFirst.java
rename to tests/tests/content/src/android/content/cts/MockReceiverFirst.java
diff --git a/tests/src/android/content/cts/MockRemoteContentProvider.java b/tests/tests/content/src/android/content/cts/MockRemoteContentProvider.java
similarity index 100%
rename from tests/src/android/content/cts/MockRemoteContentProvider.java
rename to tests/tests/content/src/android/content/cts/MockRemoteContentProvider.java
diff --git a/tests/src/android/content/cts/MockSRSProvider.java b/tests/tests/content/src/android/content/cts/MockSRSProvider.java
similarity index 100%
rename from tests/src/android/content/cts/MockSRSProvider.java
rename to tests/tests/content/src/android/content/cts/MockSRSProvider.java
diff --git a/tests/tests/content/src/android/content/cts/MockService.java b/tests/tests/content/src/android/content/cts/MockService.java
new file mode 100644
index 0000000..6726f8b
--- /dev/null
+++ b/tests/tests/content/src/android/content/cts/MockService.java
@@ -0,0 +1,52 @@
+/*
+ * 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.content.cts;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+
+public class MockService extends Service {
+    public static boolean result = false;
+    private final IBinder mBinder = new MockBinder();
+
+    public class MockBinder extends Binder {
+        MockService getService() {
+            return MockService.this;
+        }
+    }
+
+    /**
+     * set the result as true when service bind
+     */
+    @Override
+    public IBinder onBind(Intent intent) {
+        result = true;
+        return mBinder;
+    }
+
+    /**
+     * set the result as true when service start
+     */
+    @Override
+    public void onStart(Intent intent, int startId) {
+        super.onStart(intent, startId);
+        result = true;
+    }
+}
+
diff --git a/tests/src/android/content/cts/MockSyncAdapter.java b/tests/tests/content/src/android/content/cts/MockSyncAdapter.java
similarity index 100%
rename from tests/src/android/content/cts/MockSyncAdapter.java
rename to tests/tests/content/src/android/content/cts/MockSyncAdapter.java
diff --git a/tests/src/android/content/cts/MockSyncAdapterService.java b/tests/tests/content/src/android/content/cts/MockSyncAdapterService.java
similarity index 100%
rename from tests/src/android/content/cts/MockSyncAdapterService.java
rename to tests/tests/content/src/android/content/cts/MockSyncAdapterService.java
diff --git a/tests/tests/content/src/android/content/cts/MutableContextWrapperTest.java b/tests/tests/content/src/android/content/cts/MutableContextWrapperTest.java
index b81ca71..aaba30c 100644
--- a/tests/tests/content/src/android/content/cts/MutableContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/MutableContextWrapperTest.java
@@ -16,7 +16,6 @@
 
 package android.content.cts;
 
-import android.app.cts.MockActivity;
 import android.content.Context;
 import android.content.MutableContextWrapper;
 import android.test.AndroidTestCase;
diff --git a/tests/src/android/content/cts/ResultReceiver.java b/tests/tests/content/src/android/content/cts/ResultReceiver.java
similarity index 100%
rename from tests/src/android/content/cts/ResultReceiver.java
rename to tests/tests/content/src/android/content/cts/ResultReceiver.java
diff --git a/tests/tests/content/src/android/content/cts/SharedPreferencesTest.java b/tests/tests/content/src/android/content/cts/SharedPreferencesTest.java
index 2354926..c271483 100644
--- a/tests/tests/content/src/android/content/cts/SharedPreferencesTest.java
+++ b/tests/tests/content/src/android/content/cts/SharedPreferencesTest.java
@@ -54,8 +54,8 @@
 
         // Duplicated from ContextImpl.java.  Not ideal, but there wasn't a better
         // way to reach into Context{Wrapper,Impl} to ask where this file lives.
-        mPrefsFile = new File("/data/data/com.android.cts.stub/shared_prefs",
-                              "com.android.cts.stub_preferences.xml");
+        mPrefsFile = new File("/data/data/com.android.cts.content/shared_prefs",
+                              "com.android.cts.content_preferences.xml");
         mPrefsFile.delete();
     }
 
diff --git a/tests/tests/content/src/android/content/pm/cts/ActivityInfoTest.java b/tests/tests/content/src/android/content/pm/cts/ActivityInfoTest.java
index 6c1ae40..caabdb4 100644
--- a/tests/tests/content/src/android/content/pm/cts/ActivityInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/ActivityInfoTest.java
@@ -17,7 +17,7 @@
 package android.content.pm.cts;
 
 
-import android.app.cts.MockActivity;
+import android.content.cts.MockActivity;
 import android.content.ComponentName;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
diff --git a/tests/tests/content/src/android/content/pm/cts/ApplicationInfoTest.java b/tests/tests/content/src/android/content/pm/cts/ApplicationInfoTest.java
index 3055e57..1e9f5a2 100644
--- a/tests/tests/content/src/android/content/pm/cts/ApplicationInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/ApplicationInfoTest.java
@@ -16,7 +16,7 @@
 
 package android.content.pm.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 
 import android.content.pm.ApplicationInfo;
diff --git a/tests/tests/content/src/android/content/pm/cts/ApplicationInfo_DisplayNameComparatorTest.java b/tests/tests/content/src/android/content/pm/cts/ApplicationInfo_DisplayNameComparatorTest.java
index ebd75cc..211a2ca 100644
--- a/tests/tests/content/src/android/content/pm/cts/ApplicationInfo_DisplayNameComparatorTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/ApplicationInfo_DisplayNameComparatorTest.java
@@ -26,7 +26,7 @@
  * Test {@link DisplayNameComparator}.
  */
 public class ApplicationInfo_DisplayNameComparatorTest extends AndroidTestCase {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     DisplayNameComparator mDisplayNameComparator;
 
     @Override
diff --git a/tests/tests/content/src/android/content/pm/cts/ComponentInfoTest.java b/tests/tests/content/src/android/content/pm/cts/ComponentInfoTest.java
index 7850e1e..361bfe4 100644
--- a/tests/tests/content/src/android/content/pm/cts/ComponentInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/ComponentInfoTest.java
@@ -26,16 +26,15 @@
 import android.test.AndroidTestCase;
 import android.util.Printer;
 import android.util.StringBuilderPrinter;
-import android.widget.cts.WidgetTestUtils;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 
 /**
  * Test {@link ComponentInfo}.
  */
 public class ComponentInfoTest extends AndroidTestCase {
-    private final String PACKAGE_NAME = "com.android.cts.stub";
+    private final String PACKAGE_NAME = "com.android.cts.content";
     private ComponentInfo mComponentInfo;
 
     public void testConstructor() {
diff --git a/tests/tests/content/src/android/content/pm/cts/InstrumentationInfoTest.java b/tests/tests/content/src/android/content/pm/cts/InstrumentationInfoTest.java
index 4656949..5b7747d 100644
--- a/tests/tests/content/src/android/content/pm/cts/InstrumentationInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/InstrumentationInfoTest.java
@@ -25,7 +25,7 @@
 import android.test.AndroidTestCase;
 
 public class InstrumentationInfoTest extends AndroidTestCase {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     private static final String INSTRUMENTATION_NAME =
             "android.content.pm.cts.TestPmInstrumentation";
 
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageInfoTest.java b/tests/tests/content/src/android/content/pm/cts/PackageInfoTest.java
index cefe1a6..0540e0b 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageInfoTest.java
@@ -32,7 +32,7 @@
     private PackageManager mPackageManager;
     private PackageInfo mPackageInfo;
     private PackageInfo mPackageInfoCmp;
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
 
     @Override
     protected void setUp() throws Exception {
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageItemInfoTest.java b/tests/tests/content/src/android/content/pm/cts/PackageItemInfoTest.java
index d3372c6..53e69da 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageItemInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageItemInfoTest.java
@@ -16,7 +16,7 @@
 
 package android.content.pm.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 
 import android.content.ComponentName;
@@ -30,7 +30,7 @@
 import android.util.Printer;
 
 public class PackageItemInfoTest extends AndroidTestCase {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     private static final String ACTIVITY_NAME = "android.content.pm.cts.TestPmActivity";
     private static final String METADATA_NAME = "android.content.pm.cts.xmltest";
     private PackageManager mPackageManager;
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageItemInfo_DisplayNameComparatorTest.java b/tests/tests/content/src/android/content/pm/cts/PackageItemInfo_DisplayNameComparatorTest.java
index f332d6e..0cfd1dd 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageItemInfo_DisplayNameComparatorTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageItemInfo_DisplayNameComparatorTest.java
@@ -26,7 +26,7 @@
 import android.test.AndroidTestCase;
 
 public class PackageItemInfo_DisplayNameComparatorTest extends AndroidTestCase {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     private static final String ACTIVITY_NAME = "android.content.pm.cts.TestPmActivity";
     private static final String CMPACTIVITY_NAME = "android.content.pm.cts.TestPmCompare";
 
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java b/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
index d1e1252..aaab8c4 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
@@ -16,7 +16,7 @@
 
 package android.content.pm.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 
 import android.content.ComponentName;
@@ -44,7 +44,7 @@
  */
 public class PackageManagerTest extends AndroidTestCase {
     private PackageManager mPackageManager;
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     private static final String CONTENT_PKG_NAME = "com.android.cts.content";
     private static final String ACTIVITY_ACTION_NAME = "android.intent.action.PMTEST";
     private static final String MAIN_ACTION_NAME = "android.intent.action.MAIN";
@@ -395,7 +395,7 @@
 
     public void testOpPermission() {
         PermissionInfo permissionInfo = new PermissionInfo();
-        String permissionName = "com.android.cts.stub.permission.TEST_DYNAMIC.ADD";
+        String permissionName = "com.android.cts.content.permission.TEST_DYNAMIC.ADD";
         permissionInfo.name = permissionName;
         permissionInfo.labelRes = R.string.permlab_testDynamic;
         permissionInfo.nonLocalizedLabel = "Test Tree";
@@ -450,7 +450,7 @@
     public void testGetResources() throws NameNotFoundException {
         ComponentName componentName = new ComponentName(PACKAGE_NAME, ACTIVITY_NAME);
         int resourceId = R.xml.pm_test;
-        String xmlName = "com.android.cts.stub:xml/pm_test";
+        String xmlName = "com.android.cts.content:xml/pm_test";
         ApplicationInfo appInfo = mPackageManager.getApplicationInfo(PACKAGE_NAME, 0);
         assertNotNull(mPackageManager.getXml(PACKAGE_NAME, resourceId, appInfo));
         assertEquals(xmlName, mPackageManager.getResourcesForActivity(componentName)
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageStatsTest.java b/tests/tests/content/src/android/content/pm/cts/PackageStatsTest.java
index dca51e9..6425209 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageStatsTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageStatsTest.java
@@ -22,7 +22,7 @@
 import android.test.AndroidTestCase;
 
 public class PackageStatsTest extends AndroidTestCase {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
 
     public void testPackageStats() {
         // Set mock data to make sure the functionality of constructor
diff --git a/tests/tests/content/src/android/content/pm/cts/ProviderInfoTest.java b/tests/tests/content/src/android/content/pm/cts/ProviderInfoTest.java
index c585568..6256a69 100644
--- a/tests/tests/content/src/android/content/pm/cts/ProviderInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/ProviderInfoTest.java
@@ -28,7 +28,7 @@
 import java.util.List;
 
 public class ProviderInfoTest extends AndroidTestCase {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     private static final String PROVIDER_NAME = "android.content.cts.MockContentProvider";
 
     public void testProviderInfo() throws NameNotFoundException {
diff --git a/tests/tests/content/src/android/content/pm/cts/ResolveInfoTest.java b/tests/tests/content/src/android/content/pm/cts/ResolveInfoTest.java
index 3501e86..af3f161 100644
--- a/tests/tests/content/src/android/content/pm/cts/ResolveInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/ResolveInfoTest.java
@@ -26,7 +26,7 @@
 import android.util.Printer;
 
 public class ResolveInfoTest extends AndroidTestCase {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     private static final String MAIN_ACTION_NAME = "android.intent.action.MAIN";
     private static final String ACTIVITY_NAME = "android.content.pm.cts.TestPmActivity";
     private static final String SERVICE_NAME = "android.content.pm.cts.activity.PMTEST_SERVICE";
diff --git a/tests/tests/content/src/android/content/pm/cts/ServiceInfoTest.java b/tests/tests/content/src/android/content/pm/cts/ServiceInfoTest.java
index 8508c15..297ab69 100644
--- a/tests/tests/content/src/android/content/pm/cts/ServiceInfoTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/ServiceInfoTest.java
@@ -25,7 +25,7 @@
 import android.test.AndroidTestCase;
 
 public class ServiceInfoTest extends AndroidTestCase {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     private static final String SERVICE_NAME = "android.content.pm.cts.TestPmService";
 
     public void testServiceInfo() throws NameNotFoundException {
diff --git a/tests/tests/content/src/android/content/pm/cts/WidgetTestUtils.java b/tests/tests/content/src/android/content/pm/cts/WidgetTestUtils.java
new file mode 100644
index 0000000..6efd8b1
--- /dev/null
+++ b/tests/tests/content/src/android/content/pm/cts/WidgetTestUtils.java
@@ -0,0 +1,138 @@
+/*
+ * 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.content.pm.cts;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+/**
+ * The useful methods for widget test.
+ */
+public class WidgetTestUtils {
+    /**
+     * Assert that two bitmaps are equal.
+     *
+     * @param Bitmap b1 the first bitmap which needs to compare.
+     * @param Bitmap b2 the second bitmap which needs to compare.
+     */
+    public static void assertEquals(Bitmap b1, Bitmap b2) {
+        if (b1 == b2) {
+            return;
+        }
+
+        if (b1 == null || b2 == null) {
+            Assert.fail("the bitmaps are not equal");
+        }
+
+        // b1 and b2 are all not null.
+        if (b1.getWidth() != b2.getWidth() || b1.getHeight() != b2.getHeight()
+            || b1.getConfig() != b2.getConfig()) {
+            Assert.fail("the bitmaps are not equal");
+        }
+
+        int w = b1.getWidth();
+        int h = b1.getHeight();
+        int s = w * h;
+        int[] pixels1 = new int[s];
+        int[] pixels2 = new int[s];
+
+        b1.getPixels(pixels1, 0, w, 0, 0, w, h);
+        b2.getPixels(pixels2, 0, w, 0, 0, w, h);
+
+        for (int i = 0; i < s; i++) {
+            if (pixels1[i] != pixels2[i]) {
+                Assert.fail("the bitmaps are not equal");
+            }
+        }
+    }
+
+    /**
+     * Find beginning of the special element.
+     * @param parser XmlPullParser will be parsed.
+     * @param firstElementName the target element name.
+     *
+     * @throws XmlPullParserException if XML Pull Parser related faults occur.
+     * @throws IOException if I/O-related error occur when parsing.
+     */
+    public static final void beginDocument(XmlPullParser parser, String firstElementName)
+            throws XmlPullParserException, IOException {
+        Assert.assertNotNull(parser);
+        Assert.assertNotNull(firstElementName);
+
+        int type;
+        while ((type = parser.next()) != XmlPullParser.START_TAG
+                && type != XmlPullParser.END_DOCUMENT) {
+            ;
+        }
+
+        if (!parser.getName().equals(firstElementName)) {
+            throw new XmlPullParserException("Unexpected start tag: found " + parser.getName()
+                    + ", expected " + firstElementName);
+        }
+    }
+
+    /**
+     * Compare the expected pixels with actual, scaling for the target context density
+     *
+     * @throws AssertionFailedError
+     */
+    public static void assertScaledPixels(int expected, int actual, Context context) {
+        Assert.assertEquals(expected * context.getResources().getDisplayMetrics().density,
+                actual, 3);
+    }
+
+    /** Converts dips into pixels using the {@link Context}'s density. */
+    public static int convertDipToPixels(Context context, int dip) {
+      float density = context.getResources().getDisplayMetrics().density;
+      return Math.round(density * dip);
+    }
+
+    /**
+     * Retrieve a bitmap that can be used for comparison on any density
+     * @param resources
+     * @return the {@link Bitmap} or <code>null</code>
+     */
+    public static Bitmap getUnscaledBitmap(Resources resources, int resId) {
+        BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inScaled = false;
+        return BitmapFactory.decodeResource(resources, resId, options);
+    }
+
+    /**
+     * Retrieve a dithered bitmap that can be used for comparison on any density
+     * @param resources
+     * @param config the preferred config for the returning bitmap
+     * @return the {@link Bitmap} or <code>null</code>
+     */
+    public static Bitmap getUnscaledAndDitheredBitmap(Resources resources,
+            int resId, Bitmap.Config config) {
+        BitmapFactory.Options options = new BitmapFactory.Options();
+        options.inDither = true;
+        options.inScaled = false;
+        options.inPreferredConfig = config;
+        return BitmapFactory.decodeResource(resources, resId, options);
+    }
+}
diff --git a/tests/tests/content/src/android/content/res/cts/ArrayTest.java b/tests/tests/content/src/android/content/res/cts/ArrayTest.java
index 1b1fcdf..909fbf6 100644
--- a/tests/tests/content/src/android/content/res/cts/ArrayTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ArrayTest.java
@@ -20,7 +20,7 @@
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 public class ArrayTest extends AndroidTestCase {
     private Resources mResources;
diff --git a/tests/tests/content/src/android/content/res/cts/AssetManagerTest.java b/tests/tests/content/src/android/content/res/cts/AssetManagerTest.java
index cbf20ec..2870fee 100644
--- a/tests/tests/content/src/android/content/res/cts/AssetManagerTest.java
+++ b/tests/tests/content/src/android/content/res/cts/AssetManagerTest.java
@@ -30,7 +30,7 @@
 import android.test.AndroidTestCase;
 import android.util.TypedValue;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 import com.android.internal.util.XmlUtils;
 
 
diff --git a/tests/tests/content/src/android/content/res/cts/ColorStateListTest.java b/tests/tests/content/src/android/content/res/cts/ColorStateListTest.java
index cd1ac8b..88f5798 100644
--- a/tests/tests/content/src/android/content/res/cts/ColorStateListTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ColorStateListTest.java
@@ -27,7 +27,7 @@
 import android.os.Parcel;
 import android.test.AndroidTestCase;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 
 public class ColorStateListTest extends AndroidTestCase {
diff --git a/tests/tests/content/src/android/content/res/cts/ConfigTest.java b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
index bfc7887..0b94b6f 100644
--- a/tests/tests/content/src/android/content/res/cts/ConfigTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
@@ -31,7 +31,7 @@
 import android.util.DisplayMetrics;
 import android.util.Log;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 public class ConfigTest extends AndroidTestCase {
     enum Properties {
diff --git a/tests/tests/content/src/android/content/res/cts/FractionTest.java b/tests/tests/content/src/android/content/res/cts/FractionTest.java
index 9fa896c..2c3e797 100644
--- a/tests/tests/content/src/android/content/res/cts/FractionTest.java
+++ b/tests/tests/content/src/android/content/res/cts/FractionTest.java
@@ -20,7 +20,7 @@
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 import android.util.TypedValue;
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 public class FractionTest extends AndroidTestCase {
 
diff --git a/tests/tests/content/src/android/content/res/cts/PluralResourcesTest.java b/tests/tests/content/src/android/content/res/cts/PluralResourcesTest.java
index 074d10a..1fd204d 100644
--- a/tests/tests/content/src/android/content/res/cts/PluralResourcesTest.java
+++ b/tests/tests/content/src/android/content/res/cts/PluralResourcesTest.java
@@ -25,7 +25,7 @@
 import android.test.suitebuilder.annotation.SmallTest;
 import android.util.Log;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 public class PluralResourcesTest extends AndroidTestCase {
     public static boolean DEBUG = false;
diff --git a/tests/tests/content/src/android/content/res/cts/PrimitiveTest.java b/tests/tests/content/src/android/content/res/cts/PrimitiveTest.java
index c7da6d8..8eeb086 100644
--- a/tests/tests/content/src/android/content/res/cts/PrimitiveTest.java
+++ b/tests/tests/content/src/android/content/res/cts/PrimitiveTest.java
@@ -21,7 +21,7 @@
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 import android.util.TypedValue;
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 public class PrimitiveTest extends AndroidTestCase {
     private Resources mResources;
diff --git a/tests/tests/content/src/android/content/res/cts/RawResourceTest.java b/tests/tests/content/src/android/content/res/cts/RawResourceTest.java
index 9c8dae0..c92efc7 100644
--- a/tests/tests/content/src/android/content/res/cts/RawResourceTest.java
+++ b/tests/tests/content/src/android/content/res/cts/RawResourceTest.java
@@ -19,7 +19,7 @@
 import android.content.res.Resources;
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 import java.io.IOException;
 import java.io.InputStream;
diff --git a/tests/tests/content/src/android/content/res/cts/ResourceNameTest.java b/tests/tests/content/src/android/content/res/cts/ResourceNameTest.java
index eacf00d..a7cc03b 100644
--- a/tests/tests/content/src/android/content/res/cts/ResourceNameTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ResourceNameTest.java
@@ -20,7 +20,7 @@
 import android.test.AndroidTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 public class ResourceNameTest extends AndroidTestCase {
 
@@ -29,10 +29,10 @@
         final Resources res = mContext.getResources();
 
         final String fullName = res.getResourceName(R.configVarying.simple);
-        assertEquals("com.android.cts.stub:configVarying/simple", fullName);
+        assertEquals("com.android.cts.content:configVarying/simple", fullName);
 
         final String packageName = res.getResourcePackageName(R.configVarying.simple);
-        assertEquals("com.android.cts.stub", packageName);
+        assertEquals("com.android.cts.content", packageName);
 
         final String typeName = res.getResourceTypeName(R.configVarying.simple);
         assertEquals("configVarying", typeName);
@@ -45,16 +45,16 @@
     public void testGetResourceIdentifier() {
         final Resources res = mContext.getResources();
         int resid = res.getIdentifier(
-                "com.android.cts.stub:configVarying/simple",
+                "com.android.cts.content:configVarying/simple",
                 null, null);
         assertEquals(R.configVarying.simple, resid);
 
         resid = res.getIdentifier("configVarying/simple", null,
-                "com.android.cts.stub");
+                "com.android.cts.content");
         assertEquals(R.configVarying.simple, resid);
 
         resid = res.getIdentifier("simple", "configVarying",
-                "com.android.cts.stub");
+                "com.android.cts.content");
         assertEquals(R.configVarying.simple, resid);
     }
 }
diff --git a/tests/tests/content/src/android/content/res/cts/ResourcesTest.java b/tests/tests/content/src/android/content/res/cts/ResourcesTest.java
index 058076c..88caa6f 100644
--- a/tests/tests/content/src/android/content/res/cts/ResourcesTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ResourcesTest.java
@@ -16,7 +16,7 @@
 
 package android.content.res.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 import com.android.internal.util.XmlUtils;
 
 
@@ -49,9 +49,9 @@
     private static final String CONFIG_VARYING = "configVarying";
     private static final String SIMPLE = "simple";
     private static final String CONFIG_VARYING_SIMPLE = "configVarying/simple";
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+    private static final String PACKAGE_NAME = "com.android.cts.content";
     private static final String COM_ANDROID_CTS_STUB_IDENTIFIER =
-                "com.android.cts.stub:configVarying/simple";
+                "com.android.cts.content:configVarying/simple";
     private Resources mResources;
 
     @Override
@@ -320,7 +320,7 @@
             //expected
         }
 
-        mResources.getValue("com.android.cts.stub:raw/text", tv, false);
+        mResources.getValue("com.android.cts.content:raw/text", tv, false);
         assertNotNull(tv);
         assertEquals("res/raw/text.txt", tv.coerceToString());
     }
diff --git a/tests/tests/content/src/android/content/res/cts/Resources_ThemeTest.java b/tests/tests/content/src/android/content/res/cts/Resources_ThemeTest.java
index 4a4991f..349cb47 100644
--- a/tests/tests/content/src/android/content/res/cts/Resources_ThemeTest.java
+++ b/tests/tests/content/src/android/content/res/cts/Resources_ThemeTest.java
@@ -26,7 +26,7 @@
 import android.util.TypedValue;
 import android.util.Xml;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 
 
 public class Resources_ThemeTest extends AndroidTestCase {
diff --git a/tests/tests/content/src/android/content/res/cts/TypedArrayTest.java b/tests/tests/content/src/android/content/res/cts/TypedArrayTest.java
index c51405a..cc6c5ec 100644
--- a/tests/tests/content/src/android/content/res/cts/TypedArrayTest.java
+++ b/tests/tests/content/src/android/content/res/cts/TypedArrayTest.java
@@ -27,7 +27,7 @@
 import android.util.TypedValue;
 import android.view.ContextThemeWrapper;
 
-import com.android.cts.stub.R;
+import com.android.cts.content.R;
 import com.android.internal.util.XmlUtils;
 
 
diff --git a/tests/tests/hardware/Android.mk b/tests/tests/hardware/Android.mk
index dec0d5d..e5203e5 100644
--- a/tests/tests/hardware/Android.mk
+++ b/tests/tests/hardware/Android.mk
@@ -29,6 +29,7 @@
     src/android/hardware/cts/SensorTestCase.java \
     src/android/hardware/cts/SingleSensorTests.java \
     src/android/hardware/cts/SensorIntegrationTests.java \
+    src/android/hardware/cts/SensorBatchingTests.java \
     src/android/hardware/cts/SensorTest.java \
 
 LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraDeviceTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraDeviceTest.java
index 6fee8ce..9f50b43 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraDeviceTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraDeviceTest.java
@@ -48,7 +48,9 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
@@ -78,6 +80,14 @@
             CameraDevice.TEMPLATE_VIDEO_SNAPSHOT
     };
 
+    // Request templates that are unsupported by LEGACY mode.
+    private static Set<Integer> sLegacySkipTemplates = new HashSet<>();
+    static {
+        sLegacySkipTemplates.add(CameraDevice.TEMPLATE_VIDEO_SNAPSHOT);
+        sLegacySkipTemplates.add(CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG);
+        sLegacySkipTemplates.add(CameraDevice.TEMPLATE_MANUAL);
+    }
+
     @Override
     public void setContext(Context context) {
         super.setContext(context);
@@ -744,11 +754,14 @@
                         .onError(
                                 any(CameraDevice.class),
                                 anyInt());
-            }
-            finally {
+            } catch (Exception e) {
+                mCollector.addError(e);
+            } finally {
                 try {
                     closeSession();
-                } finally {
+                } catch (Exception e) {
+                    mCollector.addError(e);
+                }finally {
                     closeDevice(mCameraIds[i], mCameraMockListener);
                 }
             }
@@ -828,7 +841,7 @@
         }
         waitForSessionState(SESSION_ACTIVE, SESSION_READY_TIMEOUT_MS);
 
-        int expectedResultCount = len;
+        int expectedResultCount = requests.size();
         if (repeating) {
             expectedResultCount *= REPEATING_CAPTURE_EXPECTED_RESULT_COUNT;
         }
@@ -1294,7 +1307,7 @@
                         !mStaticInfo.isCapabilitySupported(CameraCharacteristics.
                                 REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) {
                     // OK
-                }  else if (template == CameraDevice.TEMPLATE_VIDEO_SNAPSHOT &&
+                } else if (sLegacySkipTemplates.contains(template) &&
                         mStaticInfo.isHardwareLevelLegacy()) {
                     // OK
                 } else {
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
index f81e2be..744f4ca 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
@@ -504,6 +504,10 @@
             waiverKeys.add(CaptureResult.NOISE_REDUCTION_MODE);
         }
 
+        if (!mStaticInfo.isManualLensShadingMapSupported()) {
+            waiverKeys.add(CaptureResult.SHADING_MODE);
+        }
+
         //Keys not required if manual sensor control is not supported
         if (!mStaticInfo.isCapabilitySupported(
                 CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) {
@@ -531,7 +535,6 @@
         waiverKeys.add(CaptureResult.LENS_APERTURE);
         waiverKeys.add(CaptureResult.LENS_FILTER_DENSITY);
         waiverKeys.add(CaptureResult.SENSOR_ROLLING_SHUTTER_SKEW);
-        waiverKeys.add(CaptureResult.SHADING_MODE);
         waiverKeys.add(CaptureResult.STATISTICS_LENS_SHADING_MAP_MODE);
         waiverKeys.add(CaptureResult.STATISTICS_SCENE_FLICKER);
         waiverKeys.add(CaptureResult.STATISTICS_HOT_PIXEL_MAP_MODE);
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
index 2ddff9f..a28eadd 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/ExtendedCameraCharacteristicsTest.java
@@ -65,7 +65,7 @@
     private static final int LEGACY = CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY;
     private static final int LIMITED = CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED;
     private static final int FULL = CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL;
-    private static final int OPT = -1;  // For keys that are optional on all hardware levels.
+    private static final int OPT = Integer.MAX_VALUE;  // For keys that are optional on all hardware levels.
 
     /*
      * Capabilities short hand
@@ -478,7 +478,7 @@
     private static int remapHardwareLevel(int level) {
         switch (level) {
             case OPT:
-                return -1;
+                return Integer.MAX_VALUE;
             case LEGACY:
                 return 0; // lowest
             case LIMITED:
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
index 83c3afb..e98a73c 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
@@ -584,7 +584,8 @@
             SimpleCaptureCallback resultListener = new SimpleCaptureCallback();
             SimpleImageReaderListener imageListener = new SimpleImageReaderListener();
             CaptureRequest.Builder videoSnapshotRequestBuilder =
-                    mCamera.createCaptureRequest(CameraDevice.TEMPLATE_VIDEO_SNAPSHOT);
+                    mCamera.createCaptureRequest((mStaticInfo.isHardwareLevelLegacy()) ?
+                            CameraDevice.TEMPLATE_RECORD : CameraDevice.TEMPLATE_VIDEO_SNAPSHOT);
 
             // prepare preview surface by using video size.
             updatePreviewSurfaceWithVideoSize(videoSz);
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
index f0d8293..1d28e6d 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
@@ -31,14 +31,16 @@
 import junit.framework.Assert;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
  * This class covers the {@link CameraCharacteristics} tests that are not
- * covered by {@link CaptureRequestTest} and {@link CameraCharacteristicsTest}
- * (auto-generated tests that only do the non-null checks).
+ * covered by {@link CaptureRequestTest} and {@link ExtendedCameraCharacteristicsTest}
  * </p>
  * <p>
  * Note that most of the tests in this class don't require camera open.
@@ -137,14 +139,79 @@
      * @return {@code true} if request keys' presence match expectation. Otherwise {@code false}
      */
     private boolean validateRequestKeysPresence(String capabilityName,
-            List<CaptureRequest.Key<?>> requestKeys, boolean expectedPresence) {
+            Collection<CaptureRequest.Key<?>> requestKeys, boolean expectedPresence) {
         boolean actualPresence = mStaticInfo.areRequestKeysAvailable(requestKeys);
         if (expectedPresence != actualPresence) {
             if (expectedPresence) {
                 for (CaptureRequest.Key<?> key : requestKeys) {
                     if (!mStaticInfo.areKeysAvailable(key)) {
                         mCollector.addMessage(String.format(
-                                "Camera %s list capability %s but doesn't contain key %s",
+                                "Camera %s list capability %s but doesn't contain request key %s",
+                                mCameraId, capabilityName, key.getName()));
+                    }
+                }
+            } else {
+                Log.w(TAG, String.format(
+                        "Camera %s doesn't list capability %s but contain all required keys",
+                        mCameraId, capabilityName));
+            }
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Check if result keys' presence match expectation.
+     *
+     * @param capabilityName The name string of capability being tested. Used for output messages.
+     * @param resultKeys The capture result keys to be checked
+     * @param expectedPresence Expected presence of {@code resultKeys}. {@code true} for expecting
+     *        all keys are available. Otherwise {@code false}
+     * @return {@code true} if result keys' presence match expectation. Otherwise {@code false}
+     */
+    private boolean validateResultKeysPresence(String capabilityName,
+            Collection<CaptureResult.Key<?>> resultKeys, boolean expectedPresence) {
+        boolean actualPresence = mStaticInfo.areResultKeysAvailable(resultKeys);
+        if (expectedPresence != actualPresence) {
+            if (expectedPresence) {
+                for (CaptureResult.Key<?> key : resultKeys) {
+                    if (!mStaticInfo.areKeysAvailable(key)) {
+                        mCollector.addMessage(String.format(
+                                "Camera %s list capability %s but doesn't contain result key %s",
+                                mCameraId, capabilityName, key.getName()));
+                    }
+                }
+            } else {
+                Log.w(TAG, String.format(
+                        "Camera %s doesn't list capability %s but contain all required keys",
+                        mCameraId, capabilityName));
+            }
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Check if characteristics keys' presence match expectation.
+     *
+     * @param capabilityName The name string of capability being tested. Used for output messages.
+     * @param characteristicsKeys The characteristics keys to be checked
+     * @param expectedPresence Expected presence of {@code characteristicsKeys}. {@code true} for
+     *        expecting all keys are available. Otherwise {@code false}
+     * @return {@code true} if characteristics keys' presence match expectation.
+     *         Otherwise {@code false}
+     */
+    private boolean validateCharacteristicsKeysPresence(String capabilityName,
+            Collection<CameraCharacteristics.Key<?>> characteristicsKeys,
+            boolean expectedPresence) {
+        boolean actualPresence = mStaticInfo.areCharacteristicsKeysAvailable(characteristicsKeys);
+        if (expectedPresence != actualPresence) {
+            if (expectedPresence) {
+                for (CameraCharacteristics.Key<?> key : characteristicsKeys) {
+                    if (!mStaticInfo.areKeysAvailable(key)) {
+                        mCollector.addMessage(String.format(
+                                "Camera %s list capability %s but doesn't contain" +
+                                "characteristics key %s",
                                 mCameraId, capabilityName, key.getName()));
                     }
                 }
@@ -160,8 +227,8 @@
 
     private void validateCapability(Integer capability, boolean isCapabilityAvailable) {
         List<CaptureRequest.Key<?>> requestKeys = new ArrayList<>();
-        /* Only test request keys in this test
-           Characteristics keys are tested in CameraCharacteristicsTest
+        /* For available capabilities, only check request keys in this test
+           Characteristics keys are tested in ExtendedCameraCharacteristicsTest
            Result keys are tested in CaptureResultTest */
         String capabilityName;
         switch (capability) {
@@ -239,38 +306,74 @@
                 requestKeys.add(CaptureRequest.BLACK_LEVEL_LOCK);
                 break;
             case REQUEST_AVAILABLE_CAPABILITIES_RAW:
-                capabilityName = "REQUEST_AVAILABLE_CAPABILITIES_RAW";
-                boolean rawOutputSupported = mStaticInfo.getRawOutputSizesChecked().length > 0;
-                if (isCapabilityAvailable) {
-                    mCollector.expectTrue(
-                            "REQUEST_AVAILABLE_CAPABILITIES_RAW should support RAW_SENSOR output",
-                            rawOutputSupported);
-                }
-                requestKeys.add(CaptureRequest.HOT_PIXEL_MODE);
-                requestKeys.add(CaptureRequest.STATISTICS_HOT_PIXEL_MAP_MODE);
-                break;
+                // RAW_CAPABILITY needs to check for not just capture request keys
+                validateRawCapability(isCapabilityAvailable);
+                return;
             default:
                 capabilityName = "Unknown";
                 Assert.fail(String.format("Unknown capability: %d", capability));
         }
+
         boolean matchExpectation =
                 validateRequestKeysPresence(capabilityName, requestKeys, isCapabilityAvailable);
-
         // In case of isCapabilityAvailable == true, error has been filed in
         // validateRequestKeysPresence
         if (!matchExpectation && !isCapabilityAvailable) {
-            if (capability == REQUEST_AVAILABLE_CAPABILITIES_RAW) {
-                // RAW capability needs to also check raw output capability
-                boolean rawOutputSupported = mStaticInfo.getRawOutputSizesChecked().length > 0;
-                if (rawOutputSupported) {
-                    mCollector.addMessage(String.format(
-                            "Camera %s doesn't list capability %s but contain all required keys" +
-                            " and RAW format output",
-                            mCameraId, capabilityName));
-                }
+            mCollector.addMessage(String.format(
+                    "Camera %s doesn't list capability %s but contain all required keys",
+                    mCameraId, capabilityName));
+        }
+    }
+
+    private void validateRawCapability(boolean isCapabilityAvailable) {
+        String capabilityName = "REQUEST_AVAILABLE_CAPABILITIES_RAW";
+
+        Set<CaptureRequest.Key<?>> requestKeys = new HashSet<>();
+        requestKeys.add(CaptureRequest.HOT_PIXEL_MODE);
+        requestKeys.add(CaptureRequest.STATISTICS_HOT_PIXEL_MAP_MODE);
+
+        Set<CameraCharacteristics.Key<?>> characteristicsKeys = new HashSet<>();
+        characteristicsKeys.add(HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES);
+        characteristicsKeys.add(SENSOR_BLACK_LEVEL_PATTERN);
+        characteristicsKeys.add(SENSOR_CALIBRATION_TRANSFORM1);
+        characteristicsKeys.add(SENSOR_CALIBRATION_TRANSFORM2);
+        characteristicsKeys.add(SENSOR_COLOR_TRANSFORM1);
+        characteristicsKeys.add(SENSOR_COLOR_TRANSFORM2);
+        characteristicsKeys.add(SENSOR_FORWARD_MATRIX1);
+        characteristicsKeys.add(SENSOR_FORWARD_MATRIX2);
+        characteristicsKeys.add(SENSOR_INFO_ACTIVE_ARRAY_SIZE);
+        characteristicsKeys.add(SENSOR_INFO_COLOR_FILTER_ARRANGEMENT);
+        characteristicsKeys.add(SENSOR_INFO_WHITE_LEVEL);
+        characteristicsKeys.add(SENSOR_REFERENCE_ILLUMINANT1);
+        characteristicsKeys.add(SENSOR_REFERENCE_ILLUMINANT2);
+        characteristicsKeys.add(STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES);
+
+        Set<CaptureResult.Key<?>> resultKeys = new HashSet<>();
+        resultKeys.add(CaptureResult.SENSOR_NEUTRAL_COLOR_POINT);
+        resultKeys.add(CaptureResult.SENSOR_GREEN_SPLIT);
+        resultKeys.add(CaptureResult.SENSOR_NOISE_PROFILE);
+
+        boolean rawOutputSupported = mStaticInfo.getRawOutputSizesChecked().length > 0;
+        boolean requestKeysPresent = mStaticInfo.areRequestKeysAvailable(requestKeys);
+        boolean characteristicsKeysPresent =
+                mStaticInfo.areCharacteristicsKeysAvailable(characteristicsKeys);
+        boolean resultKeysPresent = mStaticInfo.areResultKeysAvailable(resultKeys);
+        boolean expectCapabilityPresent = rawOutputSupported && requestKeysPresent &&
+                characteristicsKeysPresent && resultKeysPresent;
+
+        if (isCapabilityAvailable != expectCapabilityPresent) {
+            if (isCapabilityAvailable) {
+                mCollector.expectTrue(
+                        "REQUEST_AVAILABLE_CAPABILITIES_RAW should support RAW_SENSOR output",
+                        rawOutputSupported);
+                validateRequestKeysPresence(capabilityName, requestKeys, isCapabilityAvailable);
+                validateResultKeysPresence(capabilityName, resultKeys, isCapabilityAvailable);
+                validateCharacteristicsKeysPresence(capabilityName, characteristicsKeys,
+                        isCapabilityAvailable);
             } else {
                 mCollector.addMessage(String.format(
-                        "Camera %s doesn't list capability %s but contain all required keys",
+                        "Camera %s doesn't list capability %s but contain all required keys" +
+                        " and RAW format output",
                         mCameraId, capabilityName));
             }
         }
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
index 578d03e..6ae6fa7 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
@@ -630,10 +630,15 @@
             checkTrueForKey(key, " value must be 0 if only OFF mode is supported in "
                     + "availableFaceDetectionModes", count == 0);
         } else {
-            int maxFaceCountAtLeat = STATISTICS_INFO_MAX_FACE_COUNT_MIN_AT_LEAST;
-            checkTrueForKey(key, " value must be no less than " + maxFaceCountAtLeat + " if SIMPLE"
+            int maxFaceCountAtLeast = STATISTICS_INFO_MAX_FACE_COUNT_MIN_AT_LEAST;
+
+            // Legacy mode may support fewer than STATISTICS_INFO_MAX_FACE_COUNT_MIN_AT_LEAST faces.
+            if (isHardwareLevelLegacy()) {
+                maxFaceCountAtLeast = 1;
+            }
+            checkTrueForKey(key, " value must be no less than " + maxFaceCountAtLeast + " if SIMPLE"
                     + "or FULL is also supported in availableFaceDetectionModes",
-                    count >= maxFaceCountAtLeat);
+                    count >= maxFaceCountAtLeast);
         }
 
         return count;
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorBatchingTests.java b/tests/tests/hardware/src/android/hardware/cts/SensorBatchingTests.java
new file mode 100644
index 0000000..3d66b50
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorBatchingTests.java
@@ -0,0 +1,319 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.cts;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorManager;
+import android.hardware.cts.helpers.SensorCtsHelper;
+import android.hardware.cts.helpers.SensorStats;
+import android.hardware.cts.helpers.SensorTestInformation;
+import android.hardware.cts.helpers.sensoroperations.TestSensorFlushOperation;
+import android.hardware.cts.helpers.sensoroperations.TestSensorOperation;
+import android.hardware.cts.helpers.sensoroperations.VerifiableSensorOperation;
+import android.hardware.cts.helpers.sensorverification.ISensorVerification;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Set of tests to verify that sensors operate correctly when operating in batching mode.
+ * This class defines tests for continuous sensors when the device is awake.
+ * On-change and special sensors are tested separately inside CtsVerifier, and they are defined in:
+ * {@link com.android.cts.verifier.sensors.BatchingTestActivity}.
+ *
+ * Each test is expected to pass even if batching is not supported for a particular sensor. This is
+ * usually achieved by ensuring that {@link ISensorVerification}s fallback accordingly.
+ *
+ * <p>To execute these test cases, the following command can be used:</p>
+ * <pre>
+ * adb shell am instrument -e class android.hardware.cts.SensorBatchingTests \
+ *     -w com.android.cts.hardware/android.test.AndroidJUnitRunner
+ * </pre>
+ */
+public class SensorBatchingTests extends SensorTestCase {
+    private static final String TAG = "SensorBatchingTests";
+
+    private static final int BATCHING_10S = 10;
+    private static final int RATE_50HZ = 20000;
+    private static final int RATE_FASTEST = SensorManager.SENSOR_DELAY_FASTEST;
+
+    /**
+     * An arbitrary 'padding' time slot to wait for events after batching latency expires.
+     * This allows for the test to wait for event arrivals after batching was expected.
+     */
+    private static final int BATCHING_PADDING_TIME_S = 2;
+
+    public void testAccelerometer_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testAccelerometer_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testAccelerometer_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testAccelerometer_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testMagneticField_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testMagneticField_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testMagneticField_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testMagneticField_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_50HZ, BATCHING_10S);
+    }
+
+    @SuppressWarnings("deprecation")
+    public void testOrientation_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_ORIENTATION, RATE_FASTEST, BATCHING_10S);
+    }
+
+    @SuppressWarnings("deprecation")
+    public void testOrientation_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_ORIENTATION, RATE_50HZ, BATCHING_10S);
+    }
+
+    @SuppressWarnings("deprecation")
+    public void testOrientation_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_ORIENTATION, RATE_FASTEST, BATCHING_10S);
+    }
+
+    @SuppressWarnings("deprecation")
+    public void testOrientation_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_ORIENTATION, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGyroscope_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GYROSCOPE, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testGyroscope_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GYROSCOPE, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGyroscope_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GYROSCOPE, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_10S);
+    }
+
+    public void testGyroscope_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GYROSCOPE, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testPressure_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_PRESSURE, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testPressure_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_PRESSURE, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testPressure_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_PRESSURE, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_10S);
+    }
+
+    public void testPressure_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_PRESSURE, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGravity_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GRAVITY, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testGravity_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GRAVITY, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGravity_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GRAVITY, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_10S);
+    }
+
+    public void testGravity_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GRAVITY, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testRotationVector_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testRotationVector_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testRotationVector_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testRotationVector_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testMagneticFieldUncalibrated_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testMagneticFieldUncalibrated_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testMagneticFieldUncalibrated_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testMagneticFieldUncalibrated_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGameRotationVector_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testGameRotationVector_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGameRotationVector_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testGameRotationVector_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGyroscopeUncalibrated_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testGyroscopeUncalibrated_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGyroscopeUncalibrated_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testGyroscopeUncalibrated_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testLinearAcceleration_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testLinearAcceleration_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testLinearAcceleration_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testLinearAcceleration_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGeomagneticRotationVector_fastest_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testGeomagneticRotationVector_50hz_batching() throws Throwable {
+        runBatchingSensorTest(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, RATE_50HZ, BATCHING_10S);
+    }
+
+    public void testGeomagneticRotationVector_fastest_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, RATE_FASTEST, BATCHING_10S);
+    }
+
+    public void testGeomagneticRotationVector_50hz_flush() throws Throwable {
+        runFlushSensorTest(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, RATE_50HZ, BATCHING_10S);
+    }
+
+    private void runBatchingSensorTest(int sensorType, int rateUs, int maxBatchReportLatencySec)
+            throws Throwable {
+        Context context = getContext();
+        int maxBatchReportLatencyUs = (int) TimeUnit.SECONDS.toMicros(maxBatchReportLatencySec);
+        int testDurationSec = maxBatchReportLatencySec + BATCHING_PADDING_TIME_S;
+        TestSensorOperation operation = new TestSensorOperation(
+                context,
+                sensorType,
+                rateUs,
+                maxBatchReportLatencyUs,
+                testDurationSec,
+                TimeUnit.SECONDS);
+
+        boolean flushExpected = false;
+        executeTest(operation, sensorType, rateUs, maxBatchReportLatencyUs, flushExpected);
+    }
+
+    private void runFlushSensorTest(int sensorType, int rateUs, int maxBatchReportLatencySec)
+            throws Throwable {
+        Context context = getContext();
+        int maxBatchReportLatencyUs = (int) TimeUnit.SECONDS.toMicros(maxBatchReportLatencySec);
+        int flushDurationSec = maxBatchReportLatencySec / 2;
+        TestSensorFlushOperation operation = new TestSensorFlushOperation(
+                context,
+                sensorType,
+                rateUs,
+                maxBatchReportLatencyUs,
+                flushDurationSec,
+                TimeUnit.SECONDS);
+
+        boolean flushExpected = true;
+        executeTest(operation, sensorType, rateUs, maxBatchReportLatencyUs, flushExpected);
+    }
+
+    private void executeTest(
+            VerifiableSensorOperation operation,
+            int sensorType,
+            int rateUs,
+            int maxBatchReportLatencyUs,
+            boolean flushExpected) throws Throwable {
+        operation.addDefaultVerifications();
+        operation.setLogEvents(true);
+
+        try {
+            operation.execute();
+        } finally {
+            SensorStats.logStats(TAG, operation.getStats());
+
+            String sensorName = SensorTestInformation.getSanitizedSensorName(sensorType);
+            String sensorRate;
+            if (rateUs == SensorManager.SENSOR_DELAY_FASTEST) {
+                sensorRate = "fastest";
+            } else {
+                sensorRate = String.format("%.0fhz",
+                        SensorCtsHelper.getFrequency(rateUs, TimeUnit.MICROSECONDS));
+            }
+            String batching = maxBatchReportLatencyUs > 0 ? "_batching" : "";
+            String flush = flushExpected ? "_flush" : "";
+            String fileName = String.format("sensor_batching_%s_%s%s%s.txt",
+                    sensorName, sensorRate, batching, flush);
+            SensorStats.logStatsToFile(fileName, operation.getStats());
+        }
+    }
+}
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java b/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
index 1b923fc..c471b7a 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorIntegrationTests.java
@@ -15,6 +15,9 @@
  */
 package android.hardware.cts;
 
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
 import android.content.Context;
 import android.hardware.Sensor;
 import android.hardware.SensorManager;
@@ -24,11 +27,9 @@
 import android.hardware.cts.helpers.sensoroperations.RepeatingSensorOperation;
 import android.hardware.cts.helpers.sensoroperations.SequentialSensorOperation;
 import android.hardware.cts.helpers.sensoroperations.TestSensorOperation;
+import android.hardware.cts.helpers.sensoroperations.VerifiableSensorOperation;
 import android.hardware.cts.helpers.sensorverification.EventOrderingVerification;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
 import java.util.Random;
 
 /**
@@ -225,7 +226,7 @@
                 100 /* event count */);
         tester.addVerification(new EventOrderingVerification());
 
-        TestSensorOperation testee = new TestSensorOperation(
+        VerifiableSensorOperation testee = new TestSensorOperation(
                 context,
                 mSensorTypeTestee,
                 SensorManager.SENSOR_DELAY_FASTEST,
diff --git a/tests/tests/hardware/src/android/hardware/cts/SensorTest.java b/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
index 5607123..a4d4157 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SensorTest.java
@@ -518,8 +518,11 @@
         assertTrue(sensor.getResolution() >= 0);
         assertNotNull(sensor.getVendor());
         assertTrue(sensor.getVersion() > 0);
-        assertTrue(sensor.getFifoMaxEventCount() >= 0);
-        assertTrue(sensor.getFifoReservedEventCount() >= 0);
+        int fifoMaxEventCount = sensor.getFifoMaxEventCount();
+        int fifoReservedEventCount = sensor.getFifoReservedEventCount();
+        assertTrue(fifoMaxEventCount >= 0);
+        assertTrue(fifoReservedEventCount >= 0);
+        assertTrue(fifoReservedEventCount <= fifoMaxEventCount);
         if (sensor.getReportingMode() == Sensor.REPORTING_MODE_ONE_SHOT) {
             assertTrue("One shot sensors should have zero FIFO Size",
                     sensor.getFifoMaxEventCount() == 0);
diff --git a/tests/tests/hardware/src/android/hardware/cts/SingleSensorTests.java b/tests/tests/hardware/src/android/hardware/cts/SingleSensorTests.java
index cc7f71c..866e556 100644
--- a/tests/tests/hardware/src/android/hardware/cts/SingleSensorTests.java
+++ b/tests/tests/hardware/src/android/hardware/cts/SingleSensorTests.java
@@ -34,7 +34,7 @@
  * To execute these test cases, the following command can be used:
  * </p><pre>
  * adb shell am instrument -e class android.hardware.cts.SingleSensorTests \
- *     -w com.android.cts.hardware/android.test.InstrumentationCtsTestRunner
+ *     -w com.android.cts.hardware/android.test.AndroidJUnitRunner
  * </pre><p>
  * For each sensor that reports continuously, it takes a set of samples. The test suite verifies
  * that the event ordering, frequency, and jitter pass for the collected sensor events. It
@@ -86,9 +86,6 @@
 public class SingleSensorTests extends SensorTestCase {
     private static final String TAG = "SingleSensorTests";
 
-    private static final int BATCHING_OFF = 0;
-    private static final int BATCHING_5S = 5000000;
-
     private static final int RATE_200HZ = 5000;
     private static final int RATE_100HZ = 10000;
     private static final int RATE_50HZ = 20000;
@@ -98,17 +95,8 @@
     private static final int RATE_5HZ = 200000;
     private static final int RATE_1HZ = 1000000;
 
-    private static final String[] STAT_KEYS = {
-        SensorStats.FREQUENCY_KEY,
-        SensorStats.JITTER_95_PERCENTILE_KEY,
-        SensorStats.EVENT_OUT_OF_ORDER_COUNT_KEY,
-        SensorStats.MAGNITUDE_KEY,
-        SensorStats.MEAN_KEY,
-        SensorStats.STANDARD_DEVIATION_KEY,
-    };
-
     /**
-     * This test verifies that the sensor's properties complies with the required properites set in
+     * This test verifies that the sensor's properties complies with the required properties set in
      * the CDD.
      * <p>
      * It checks that the sampling rate advertised by the sensor under test matches that which is
@@ -138,513 +126,414 @@
     // TODO: Figure out if a better way to enumerate test cases programmatically exists that works
     // with CTS framework.
     public void testAccelerometer_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testAccelerometer_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_100HZ);
     }
 
     public void testAccelerometer_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_200HZ);
     }
 
     public void testAccelerometer_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_50HZ);
     }
 
     public void testAccelerometer_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_25HZ);
     }
 
     public void testAccelerometer_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_15HZ);
     }
 
     public void testAccelerometer_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_10HZ);
     }
 
     public void testAccelerometer_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_5HZ);
     }
 
     public void testAccelerometer_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testAccelerometer_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_5S);
-    }
-
-    public void testAccelerometer_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_ACCELEROMETER, RATE_1HZ);
     }
 
     public void testMagneticField_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testMagneticField_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_200HZ);
     }
 
     public void testMagneticField_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_100HZ);
     }
 
     public void testMagneticField_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_50HZ);
     }
 
     public void testMagneticField_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_25HZ);
     }
 
     public void testMagneticField_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_15HZ);
     }
 
     public void testMagneticField_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_10HZ);
     }
 
     public void testMagneticField_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_5HZ);
     }
 
     public void testMagneticField_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testMagneticField_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_5S);
-    }
-
-    public void testMagneticField_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD, RATE_1HZ);
     }
 
     @SuppressWarnings("deprecation")
     public void testOrientation_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     @SuppressWarnings("deprecation")
     public void testOrientation_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_200HZ);
     }
     @SuppressWarnings("deprecation")
     public void testOrientation_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_100HZ);
     }
 
     @SuppressWarnings("deprecation")
     public void testOrientation_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_50HZ);
     }
 
     @SuppressWarnings("deprecation")
     public void testOrientation_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_25HZ);
     }
 
     @SuppressWarnings("deprecation")
     public void testOrientation_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_15HZ);
     }
 
     @SuppressWarnings("deprecation")
     public void testOrientation_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_10HZ);
     }
 
     @SuppressWarnings("deprecation")
     public void testOrientation_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_5HZ);
     }
 
     @SuppressWarnings("deprecation")
     public void testOrientation_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_1HZ, BATCHING_OFF);
-    }
-
-    @SuppressWarnings("deprecation")
-    public void testOrientation_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_5S);
-    }
-
-    @SuppressWarnings("deprecation")
-    public void testOrientation_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_ORIENTATION, RATE_1HZ);
     }
 
     public void testGyroscope_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testGyroscope_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_200HZ);
     }
 
     public void testGyroscope_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_100HZ);
     }
 
     public void testGyroscope_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_50HZ);
     }
 
     public void testGyroscope_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_25HZ);
     }
 
     public void testGyroscope_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_15HZ);
     }
 
     public void testGyroscope_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_10HZ);
     }
 
     public void testGyroscope_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_5HZ);
     }
 
     public void testGyroscope_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testGyroscope_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_5S);
-    }
-
-    public void testGyroscope_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_GYROSCOPE, RATE_1HZ);
     }
 
     public void testPressure_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_PRESSURE, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testPressure_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_PRESSURE, RATE_200HZ);
     }
 
     public void testPressure_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_PRESSURE, RATE_100HZ);
     }
 
     public void testPressure_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_PRESSURE, RATE_50HZ);
     }
 
     public void testPressure_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_PRESSURE, RATE_25HZ);
     }
 
     public void testPressure_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_PRESSURE, RATE_15HZ);
     }
 
     public void testPressure_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_PRESSURE, RATE_10HZ);
     }
 
     public void testPressure_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_PRESSURE, RATE_5HZ);
     }
 
     public void testPressure_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testPressure_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_5S);
-    }
-
-    public void testPressure_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_PRESSURE, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_PRESSURE, RATE_1HZ);
     }
 
     public void testGravity_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GRAVITY, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testGravity_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GRAVITY, RATE_200HZ);
     }
 
     public void testGravity_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GRAVITY, RATE_100HZ);
     }
 
     public void testGravity_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GRAVITY, RATE_50HZ);
     }
 
     public void testGravity_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GRAVITY, RATE_25HZ);
     }
 
     public void testGravity_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GRAVITY, RATE_15HZ);
     }
 
     public void testGravity_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GRAVITY, RATE_10HZ);
     }
 
     public void testGravity_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GRAVITY, RATE_5HZ);
     }
 
     public void testGravity_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testGravity_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_5S);
-    }
-
-    public void testGravity_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_GRAVITY, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_GRAVITY, RATE_1HZ);
     }
 
     public void testRotationVector_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testRotationVector_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_200HZ);
     }
 
     public void testRotationVector_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_100HZ);
     }
 
     public void testRotationVector_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_50HZ);
     }
 
     public void testRotationVector_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_25HZ);
     }
 
     public void testRotationVector_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_15HZ);
     }
 
     public void testRotationVector_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_10HZ);
     }
 
     public void testRotationVector_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_5HZ);
     }
 
     public void testRotationVector_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testRotationVector_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST, BATCHING_5S);
-    }
-
-    public void testRotationVector_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_ROTATION_VECTOR, RATE_1HZ);
     }
 
     public void testMagneticFieldUncalibrated_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testMagneticFieldUncalibrated_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_200HZ);
     }
 
     public void testMagneticFieldUncalibrated_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_100HZ);
     }
 
     public void testMagneticFieldUncalibrated_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_50HZ);
     }
 
     public void testMagneticFieldUncalibrated_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_25HZ);
     }
 
     public void testMagneticFieldUncalibrated_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_15HZ);
     }
 
     public void testMagneticFieldUncalibrated_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_10HZ);
     }
 
     public void testMagneticFieldUncalibrated_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_5HZ);
     }
 
     public void testMagneticFieldUncalibrated_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testMagneticFieldUncalibrated_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_5S);
-    }
-
-    public void testMagneticFieldUncalibrated_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_MAGNETIC_FIELD_UNCALIBRATED, RATE_1HZ);
     }
 
     public void testGameRotationVector_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testGameRotationVector_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_200HZ);
     }
 
     public void testGameRotationVector_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_100HZ);
     }
 
     public void testGameRotationVector_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_50HZ);
     }
 
     public void testGameRotationVector_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_25HZ);
     }
 
     public void testGameRotationVector_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_15HZ);
     }
 
     public void testGameRotationVector_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_10HZ);
     }
 
     public void testGameRotationVector_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_5HZ);
     }
 
     public void testGameRotationVector_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testGameRotationVector_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_5S);
-    }
-
-    public void testGameRotationVector_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_GAME_ROTATION_VECTOR, RATE_1HZ);
     }
 
     public void testGyroscopeUncalibrated_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void testGyroscopeUncalibrated_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_200HZ);
     }
 
     public void testGyroscopeUncalibrated_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_100HZ);
     }
 
     public void testGyroscopeUncalibrated_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_50HZ);
     }
 
     public void testGyroscopeUncalibrated_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_25HZ);
     }
 
     public void testGyroscopeUncalibrated_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_15HZ);
     }
 
     public void testGyroscopeUncalibrated_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_10HZ);
     }
 
     public void testGyroscopeUncalibrated_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_5HZ);
     }
 
     public void testGyroscopeUncalibrated_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_1HZ, BATCHING_OFF);
-    }
-
-    public void testGyroscopeUncalibrated_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_5S);
-    }
-
-    public void testGyroscopeUncalibrated_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_50HZ, BATCHING_5S);
+        runSensorTest(Sensor.TYPE_GYROSCOPE_UNCALIBRATED, RATE_1HZ);
     }
 
     public void  testGeomagneticRotationVector_fastest() throws Throwable {
-        runSensorTest(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR, SensorManager.SENSOR_DELAY_FASTEST);
     }
 
     public void  testLinearAcceleration_200hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_200HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_200HZ);
     }
 
     public void  testLinearAcceleration_100hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_100HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_100HZ);
     }
 
     public void testLinearAcceleration_50hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_50HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_50HZ);
     }
 
     public void testLinearAcceleration_25hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_25HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_25HZ);
     }
 
     public void testLinearAcceleration_15hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_15HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_15HZ);
     }
 
     public void testLinearAcceleration_10hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_10HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_10HZ);
     }
 
     public void testLinearAcceleration_5hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_5HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_5HZ);
     }
 
     public void testLinearAcceleration_1hz() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_1HZ, BATCHING_OFF);
+        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_1HZ);
     }
 
-    public void testLinearAcceleration_fastest_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, SensorManager.SENSOR_DELAY_FASTEST,
-                BATCHING_5S);
-    }
-
-    public void testLinearAcceleration_50hz_batching() throws Throwable {
-        runSensorTest(Sensor.TYPE_LINEAR_ACCELERATION, RATE_50HZ, BATCHING_5S);
-    }
-
-    private void runSensorTest(int sensorType, int rateUs, int maxBatchReportLatencyUs)
+    private void runSensorTest(int sensorType, int rateUs)
             throws Throwable {
         TestSensorOperation op = new TestSensorOperation(this.getContext(), sensorType,
-                rateUs, maxBatchReportLatencyUs, 5, TimeUnit.SECONDS);
-        op.setDefaultVerifications();
+                rateUs, 0 /* maxBatchReportLatencyUs */, 5, TimeUnit.SECONDS);
+        op.addDefaultVerifications();
         op.setLogEvents(true);
         try {
             op.execute();
@@ -659,9 +548,7 @@
                 sensorRate = String.format("%.0fhz",
                         SensorCtsHelper.getFrequency(rateUs, TimeUnit.MICROSECONDS));
             }
-            String batching = maxBatchReportLatencyUs > 0 ? "_batching" : "";
-            String fileName = String.format("single_sensor_%s_%s%s.txt",
-                    sensorName, sensorRate, batching);
+            String fileName = String.format("single_sensor_%s_%s.txt", sensorName, sensorRate);
             SensorStats.logStatsToFile(fileName, op.getStats());
         }
     }
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 a45ad70..1c1ea1c 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/TestSensorManager.java
@@ -16,6 +16,8 @@
 
 package android.hardware.cts.helpers;
 
+import junit.framework.Assert;
+
 import android.content.Context;
 import android.hardware.Sensor;
 import android.hardware.SensorEventListener;
@@ -23,8 +25,6 @@
 import android.hardware.SensorManager;
 import android.util.Log;
 
-import junit.framework.Assert;
-
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -213,6 +213,29 @@
     }
 
     /**
+     * Registers a listener, waits for a specific duration, calls flush, and waits for flush to
+     * complete.
+     */
+    public void runSensorAndFlush(
+            TestSensorEventListener listener,
+            long duration,
+            TimeUnit timeUnit) {
+        if (mTestSensorEventListener != null) {
+            Log.w(LOG_TAG, "Listener already registered, returning.");
+            return;
+        }
+
+        try {
+            registerListener(listener);
+            SensorCtsHelper.sleep(duration, timeUnit);
+            startFlush();
+            listener.waitForFlushComplete();
+        } finally {
+            unregisterListener();
+        }
+    }
+
+    /**
      * Get the sensor under test.
      */
     public Sensor getSensor() {
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorFlushOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorFlushOperation.java
new file mode 100644
index 0000000..135d674
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorFlushOperation.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.cts.helpers.sensoroperations;
+
+import android.content.Context;
+import android.hardware.cts.helpers.TestSensorEventListener;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A {@link ISensorOperation} used to verify that sensor events and sensor values are correct.
+ * <p>
+ * Provides methods to set test expectations as well as providing a set of default expectations
+ * depending on sensor type.  When {{@link #execute()} is called, the sensor will collect the
+ * events, call flush, and then run all the tests.
+ * </p>
+ */
+public class TestSensorFlushOperation extends VerifiableSensorOperation {
+    private final Long mDuration;
+    private final TimeUnit mTimeUnit;
+
+    /**
+     * Create a {@link TestSensorOperation}.
+     *
+     * @param context the {@link Context}.
+     * @param sensorType the sensor type
+     * @param rateUs the rate that
+     * @param maxBatchReportLatencyUs the max batch report latency
+     * @param duration the duration to gather events before calling {@code SensorManager.flush()}
+     * @param timeUnit the time unit of the duration
+     */
+    public TestSensorFlushOperation(
+            Context context,
+            int sensorType,
+            int rateUs,
+            int maxBatchReportLatencyUs,
+            long duration,
+            TimeUnit timeUnit) {
+        super(context, sensorType, rateUs, maxBatchReportLatencyUs);
+        mDuration = duration;
+        mTimeUnit = timeUnit;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void doExecute(TestSensorEventListener listener) {
+        mSensorManager.runSensorAndFlush(listener, mDuration, mTimeUnit);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected VerifiableSensorOperation doClone() {
+        return new TestSensorFlushOperation(
+                mContext,
+                mSensorType,
+                mRateUs,
+                mMaxBatchReportLatencyUs,
+                mDuration,
+                mTimeUnit);
+    }
+}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
index b841eda..5982d24 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/TestSensorOperation.java
@@ -17,25 +17,8 @@
 package android.hardware.cts.helpers.sensoroperations;
 
 import android.content.Context;
-import android.hardware.Sensor;
-import android.hardware.cts.helpers.SensorCtsHelper;
-import android.hardware.cts.helpers.SensorStats;
-import android.hardware.cts.helpers.SensorTestInformation;
-import android.hardware.cts.helpers.TestSensorManager;
-import android.hardware.cts.helpers.ValidatingSensorEventListener;
-import android.hardware.cts.helpers.sensorverification.EventGapVerification;
-import android.hardware.cts.helpers.sensorverification.EventOrderingVerification;
-import android.hardware.cts.helpers.sensorverification.FrequencyVerification;
-import android.hardware.cts.helpers.sensorverification.ISensorVerification;
-import android.hardware.cts.helpers.sensorverification.JitterVerification;
-import android.hardware.cts.helpers.sensorverification.MagnitudeVerification;
-import android.hardware.cts.helpers.sensorverification.MeanVerification;
-import android.hardware.cts.helpers.sensorverification.StandardDeviationVerification;
+import android.hardware.cts.helpers.TestSensorEventListener;
 
-import junit.framework.Assert;
-
-import java.util.Collection;
-import java.util.HashSet;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -46,21 +29,11 @@
  * events and then run all the tests.
  * </p>
  */
-public class TestSensorOperation extends AbstractSensorOperation {
-    private final TestSensorManager mSensorManager;
-    private final Context mContext;
-    private final int mSensorType;
-    private final int mRateUs;
-    private final int mMaxBatchReportLatencyUs;
+public class TestSensorOperation extends VerifiableSensorOperation {
     private final Integer mEventCount;
     private final Long mDuration;
     private final TimeUnit mTimeUnit;
 
-    private final Collection<ISensorVerification> mVerifications =
-            new HashSet<ISensorVerification>();
-
-    private boolean mLogEvents = false;
-
     /**
      * Create a {@link TestSensorOperation}.
      *
@@ -95,109 +68,35 @@
      */
     private TestSensorOperation(Context context, int sensorType, int rateUs,
             int maxBatchReportLatencyUs, Integer eventCount, Long duration, TimeUnit timeUnit) {
-        mContext = context;
-        mSensorType = sensorType;
-        mRateUs = rateUs;
-        mMaxBatchReportLatencyUs = maxBatchReportLatencyUs;
+        super(context, sensorType, rateUs, maxBatchReportLatencyUs);
         mEventCount = eventCount;
         mDuration = duration;
         mTimeUnit = timeUnit;
-        mSensorManager = new TestSensorManager(mContext, mSensorType, mRateUs,
-                mMaxBatchReportLatencyUs);
     }
 
     /**
-     * Set whether to log events.
-     */
-    public void setLogEvents(boolean logEvents) {
-        mLogEvents = logEvents;
-    }
-
-    /**
-     * Set all of the default test expectations.
-     */
-    public void setDefaultVerifications() {
-        Sensor sensor = mSensorManager.getSensor();
-        addVerification(EventGapVerification.getDefault(sensor, mRateUs));
-        addVerification(EventOrderingVerification.getDefault(sensor));
-        addVerification(FrequencyVerification.getDefault(sensor, mRateUs));
-        addVerification(JitterVerification.getDefault(sensor, mRateUs));
-        addVerification(MagnitudeVerification.getDefault(sensor));
-        addVerification(MeanVerification.getDefault(sensor));
-        // Skip SigNumVerification since it has no default
-        addVerification(StandardDeviationVerification.getDefault(sensor));
-    }
-
-    public void addVerification(ISensorVerification verification) {
-        if (verification != null) {
-            mVerifications.add(verification);
-        }
-    }
-
-    /**
-     * Collect the specified number of events from the sensor and run all enabled verifications.
+     * {@inheritDoc}
      */
     @Override
-    public void execute() {
-        getStats().addValue("sensor_name", SensorTestInformation.getSensorName(mSensorType));
-
-        ValidatingSensorEventListener listener = new ValidatingSensorEventListener(mVerifications);
-        listener.setLogEvents(mLogEvents);
-
+    protected void doExecute(TestSensorEventListener listener) {
         if (mEventCount != null) {
             mSensorManager.runSensor(listener, mEventCount);
         } else {
             mSensorManager.runSensor(listener, mDuration, mTimeUnit);
         }
-
-        boolean failed = false;
-        StringBuilder sb = new StringBuilder();
-
-        for (ISensorVerification verification : mVerifications) {
-            failed |= evaluateResults(verification, sb);
-        }
-
-        if (failed) {
-            String msg = SensorCtsHelper.formatAssertionMessage(mSensorManager.getSensor(),
-                    "VerifySensorOperation", mRateUs, mMaxBatchReportLatencyUs, sb.toString());
-            getStats().addValue(SensorStats.ERROR, msg);
-            Assert.fail(msg);
-        }
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public TestSensorOperation clone() {
-        TestSensorOperation operation;
+    protected VerifiableSensorOperation doClone() {
         if (mEventCount != null) {
-            operation = new TestSensorOperation(mContext, mSensorType, mRateUs,
+            return new TestSensorOperation(mContext, mSensorType, mRateUs,
                     mMaxBatchReportLatencyUs, mEventCount);
         } else {
-            operation = new TestSensorOperation(mContext, mSensorType, mRateUs,
+            return new TestSensorOperation(mContext, mSensorType, mRateUs,
                     mMaxBatchReportLatencyUs, mDuration, mTimeUnit);
         }
-
-        for (ISensorVerification verification : mVerifications) {
-            operation.addVerification(verification.clone());
-        }
-        return operation;
-    }
-
-    /**
-     * Evaluate the results of a test, aggregate the stats, and build the error message.
-     */
-    private boolean evaluateResults(ISensorVerification verification, StringBuilder sb) {
-        try {
-            verification.verify(getStats());
-        } catch (AssertionError e) {
-            if (sb.length() > 0) {
-                sb.append(", ");
-            }
-            sb.append(e.getMessage());
-            return true;
-        }
-        return false;
     }
 }
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/VerifiableSensorOperation.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/VerifiableSensorOperation.java
new file mode 100644
index 0000000..d0a5673
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensoroperations/VerifiableSensorOperation.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.hardware.cts.helpers.sensoroperations;
+
+import junit.framework.Assert;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.cts.helpers.SensorCtsHelper;
+import android.hardware.cts.helpers.SensorStats;
+import android.hardware.cts.helpers.SensorTestInformation;
+import android.hardware.cts.helpers.TestSensorEventListener;
+import android.hardware.cts.helpers.TestSensorManager;
+import android.hardware.cts.helpers.ValidatingSensorEventListener;
+import android.hardware.cts.helpers.sensorverification.EventGapVerification;
+import android.hardware.cts.helpers.sensorverification.EventOrderingVerification;
+import android.hardware.cts.helpers.sensorverification.FrequencyVerification;
+import android.hardware.cts.helpers.sensorverification.ISensorVerification;
+import android.hardware.cts.helpers.sensorverification.JitterVerification;
+import android.hardware.cts.helpers.sensorverification.MagnitudeVerification;
+import android.hardware.cts.helpers.sensorverification.MeanVerification;
+import android.hardware.cts.helpers.sensorverification.StandardDeviationVerification;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * A {@link ISensorOperation} used to verify that sensor events and sensor values are correct.
+ * <p>
+ * Provides methods to set test expectations as well as providing a set of default expectations
+ * depending on sensor type.  When {{@link #execute()} is called, the sensor will collect the
+ * events and then run all the tests.
+ * </p>
+ */
+public abstract class VerifiableSensorOperation extends AbstractSensorOperation {
+    protected final TestSensorManager mSensorManager;
+    protected final Context mContext;
+    protected final int mSensorType;
+    protected final int mRateUs;
+    protected final int mMaxBatchReportLatencyUs;
+
+    private final Collection<ISensorVerification> mVerifications =
+            new HashSet<ISensorVerification>();
+
+    private boolean mLogEvents = false;
+
+    /**
+     * Create a {@link TestSensorOperation}.
+     *
+     * @param context the {@link Context}.
+     * @param sensorType the sensor type
+     * @param rateUs the rate that
+     * @param maxBatchReportLatencyUs the max batch report latency
+     */
+    public VerifiableSensorOperation(
+            Context context,
+            int sensorType,
+            int rateUs,
+            int maxBatchReportLatencyUs) {
+        mContext = context;
+        mSensorType = sensorType;
+        mRateUs = rateUs;
+        mMaxBatchReportLatencyUs = maxBatchReportLatencyUs;
+        mSensorManager = new TestSensorManager(mContext, mSensorType, mRateUs,
+                mMaxBatchReportLatencyUs);
+    }
+
+    /**
+     * Set whether to log events.
+     */
+    public void setLogEvents(boolean logEvents) {
+        mLogEvents = logEvents;
+    }
+
+    /**
+     * Set all of the default test expectations.
+     */
+    public void addDefaultVerifications() {
+        Sensor sensor = mSensorManager.getSensor();
+        addVerification(EventGapVerification.getDefault(sensor, mRateUs));
+        addVerification(EventOrderingVerification.getDefault(sensor));
+        addVerification(FrequencyVerification.getDefault(sensor, mRateUs));
+        addVerification(JitterVerification.getDefault(sensor, mRateUs));
+        addVerification(MagnitudeVerification.getDefault(sensor));
+        addVerification(MeanVerification.getDefault(sensor));
+        // Skip SigNumVerification since it has no default
+        addVerification(StandardDeviationVerification.getDefault(sensor));
+    }
+
+    public void addVerification(ISensorVerification verification) {
+        if (verification != null) {
+            mVerifications.add(verification);
+        }
+    }
+
+    /**
+     * Collect the specified number of events from the sensor and run all enabled verifications.
+     */
+    @Override
+    public void execute() {
+        getStats().addValue("sensor_name", SensorTestInformation.getSensorName(mSensorType));
+
+        ValidatingSensorEventListener listener = new ValidatingSensorEventListener(mVerifications);
+        listener.setLogEvents(mLogEvents);
+
+        doExecute(listener);
+
+        boolean failed = false;
+        StringBuilder sb = new StringBuilder();
+        for (ISensorVerification verification : mVerifications) {
+            failed |= evaluateResults(verification, sb);
+        }
+
+        if (failed) {
+            String msg = SensorCtsHelper.formatAssertionMessage(mSensorManager.getSensor(),
+                    "VerifySensorOperation", mRateUs, mMaxBatchReportLatencyUs, sb.toString());
+            getStats().addValue(SensorStats.ERROR, msg);
+            Assert.fail(msg);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public VerifiableSensorOperation clone() {
+        VerifiableSensorOperation operation = doClone();
+        for (ISensorVerification verification : mVerifications) {
+            operation.addVerification(verification.clone());
+        }
+        return operation;
+    }
+
+    /**
+     * Execute operations in a {@link TestSensorManager}.
+     */
+    protected abstract void doExecute(TestSensorEventListener listener);
+
+    /**
+     * Clone the subclass operation.
+     */
+    protected abstract VerifiableSensorOperation doClone();
+
+    /**
+     * Evaluate the results of a test, aggregate the stats, and build the error message.
+     */
+    private boolean evaluateResults(ISensorVerification verification, StringBuilder sb) {
+        try {
+            verification.verify(getStats());
+        } catch (AssertionError e) {
+            if (sb.length() > 0) {
+                sb.append(", ");
+            }
+            sb.append(e.getMessage());
+            return true;
+        }
+        return false;
+    }
+}
diff --git a/tests/tests/media/res/raw/camera_click.ogg b/tests/tests/media/res/raw/camera_click.ogg
new file mode 100644
index 0000000..b836e10
--- /dev/null
+++ b/tests/tests/media/res/raw/camera_click.ogg
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java b/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
index a3f1815..e6530ec 100644
--- a/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaCodecCapabilitiesTest.java
@@ -212,6 +212,10 @@
                 continue;
             }
 
+            if (!supportsMimeType(codecInfo, mimeType)) {
+                continue;
+            }
+
             CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mimeType);
             for (CodecProfileLevel profileLevel : capabilities.profileLevels) {
                 if (profileLevel.profile == profile
@@ -224,4 +228,14 @@
         return false;
     }
 
+    private static boolean supportsMimeType(MediaCodecInfo codecInfo, String mimeType) {
+        String[] supportedMimeTypes = codecInfo.getSupportedTypes();
+        for (String supportedMimeType : supportedMimeTypes) {
+            if (mimeType.equalsIgnoreCase(supportedMimeType)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
 }
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
index 7b6a136..10ec741 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
@@ -237,6 +237,98 @@
         }
     }
 
+    static class OutputListener {
+        int mSession;
+        AudioEffect mVc;
+        Visualizer mVis;
+        byte [] mVisData;
+        boolean mSoundDetected;
+        OutputListener(int session) {
+            mSession = session;
+            // creating a volume controller on output mix ensures that ro.audio.silent mutes
+            // audio after the effects and not before
+            mVc = new AudioEffect(
+                    AudioEffect.EFFECT_TYPE_NULL,
+                    UUID.fromString("119341a0-8469-11df-81f9-0002a5d5c51b"),
+                    0,
+                    session);
+            mVc.setEnabled(true);
+            mVis = new Visualizer(session);
+            int size = 256;
+            int[] range = Visualizer.getCaptureSizeRange();
+            if (size < range[0]) {
+                size = range[0];
+            }
+            if (size > range[1]) {
+                size = range[1];
+            }
+            assertTrue(mVis.setCaptureSize(size) == Visualizer.SUCCESS);
+
+            mVis.setDataCaptureListener(new Visualizer.OnDataCaptureListener() {
+                @Override
+                public void onWaveFormDataCapture(Visualizer visualizer,
+                        byte[] waveform, int samplingRate) {
+                    if (!mSoundDetected) {
+                        for (int i = 0; i < waveform.length; i++) {
+                            // 8 bit unsigned PCM, zero level is at 128, which is -128 when
+                            // seen as a signed byte
+                            if (waveform[i] != -128) {
+                                mSoundDetected = true;
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                @Override
+                public void onFftDataCapture(Visualizer visualizer, byte[] fft, int samplingRate) {
+                }
+            }, 10000 /* milliHertz */, true /* PCM */, false /* FFT */);
+            assertTrue(mVis.setEnabled(true) == Visualizer.SUCCESS);
+        }
+
+        void reset() {
+            mSoundDetected = false;
+        }
+
+        boolean heardSound() {
+            return mSoundDetected;
+        }
+
+        void release() {
+            mVis.release();
+            mVc.release();
+        }
+    }
+
+    public void testPlayAudioTwice() throws Exception {
+        final int resid = R.raw.camera_click;
+
+        MediaPlayer mp = MediaPlayer.create(mContext, resid);
+        try {
+            mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
+            mp.setWakeMode(mContext, PowerManager.PARTIAL_WAKE_LOCK);
+
+            OutputListener listener = new OutputListener(mp.getAudioSessionId());
+
+            Thread.sleep(SLEEP_TIME);
+            assertFalse("noise heard before test started", listener.heardSound());
+
+            mp.start();
+            Thread.sleep(SLEEP_TIME);
+            assertFalse("player was still playing after " + SLEEP_TIME + " ms", mp.isPlaying());
+            assertTrue("nothing heard while test ran", listener.heardSound());
+            listener.reset();
+            mp.seekTo(0);
+            mp.start();
+            Thread.sleep(SLEEP_TIME);
+            assertTrue("nothing heard when sound was replayed", listener.heardSound());
+            listener.release();
+        } finally {
+            mp.release();
+        }
+    }
+
     public void testPlayVideo() throws Exception {
         playVideoTest(R.raw.testvideo, 352, 288);
     }
diff --git a/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java b/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
index a4051c9..5e38842 100644
--- a/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
+++ b/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
@@ -390,6 +390,32 @@
         return yuv;
     }
 
+    /**
+     * Packs YUV420 frame by moving it to a smaller size buffer with stride and slice
+     * height equal to the original frame width and height.
+     */
+    private static byte[] PackYUV420(int width, int height,
+            int stride, int sliceHeight, byte[] src) {
+        byte[] dst = new byte[width * height * 3 / 2];
+        // Y copy.
+        for (int i = 0; i < height; i++) {
+            System.arraycopy(src, i * stride, dst, i * width, width);
+        }
+        // U and V copy.
+        int u_src_offset = stride * sliceHeight;
+        int v_src_offset = u_src_offset + u_src_offset / 4;
+        int u_dst_offset = width * height;
+        int v_dst_offset = u_dst_offset + u_dst_offset / 4;
+        for (int i = 0; i < height / 2; i++) {
+            System.arraycopy(src, u_src_offset + i * (stride / 2),
+                    dst, u_dst_offset + i * (width / 2), width / 2);
+            System.arraycopy(src, v_src_offset + i * (stride / 2),
+                    dst, v_dst_offset + i * (width / 2), width / 2);
+        }
+        return dst;
+    }
+
+
     private static void imageUpscale1To2(byte[] src, int srcByteOffset, int srcStride,
             byte[] dst, int dstByteOffset, int dstWidth, int dstHeight) {
         for (int i = 0; i < dstHeight/2 - 1; i++) {
@@ -624,6 +650,8 @@
                     }
                     Log.d(TAG, "Frame stride and slice height: " + frameStride +
                             " x " + frameSliceHeight);
+                    frameStride = Math.max(frameWidth, frameStride);
+                    frameSliceHeight = Math.max(frameHeight, frameSliceHeight);
                 }
                 result = decoder.dequeueOutputBuffer(bufferInfo, DEFAULT_DEQUEUE_TIMEOUT_US);
             }
@@ -645,12 +673,19 @@
                         byte[] frame = new byte[bufferInfo.size];
                         outputBuffers[outputBufIndex].position(bufferInfo.offset);
                         outputBuffers[outputBufIndex].get(frame, 0, bufferInfo.size);
-                        // Convert NV12 to YUV420 if necessary
+                        // Convert NV12 to YUV420 if necessary.
                         if (frameColorFormat != CodecCapabilities.COLOR_FormatYUV420Planar) {
                             frame = NV12ToYUV420(frameWidth, frameHeight,
                                     frameStride, frameSliceHeight, frame);
                         }
-                        yuv.write(frame);
+                        int writeLength = Math.min(frameWidth * frameHeight * 3 / 2, frame.length);
+                        // Pack frame if necessary.
+                        if (writeLength < frame.length &&
+                                (frameStride > frameWidth || frameSliceHeight > frameHeight)) {
+                            frame = PackYUV420(frameWidth, frameHeight,
+                                    frameStride, frameSliceHeight, frame);
+                        }
+                        yuv.write(frame, 0, writeLength);
                     }
                     outputFrameIndex++;
 
diff --git a/tests/tests/os/Android.mk b/tests/tests/os/Android.mk
index 0007a54..f0fb88a 100644
--- a/tests/tests/os/Android.mk
+++ b/tests/tests/os/Android.mk
@@ -23,17 +23,21 @@
 
 LOCAL_PROGUARD_ENABLED := disabled
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner guava
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner guava
+
+LOCAL_JNI_SHARED_LIBRARIES := libctsos_jni
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
-        src/android/os/cts/IParcelFileDescriptorPeer.aidl
+        src/android/os/cts/IParcelFileDescriptorPeer.aidl \
+        src/android/os/cts/IEmptyService.aidl \
+        src/android/os/cts/ISecondary.aidl
 
 LOCAL_PACKAGE_NAME := CtsOsTestCases
 
-LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
-
 # uncomment when b/13282254 is fixed
 #LOCAL_SDK_VERSION := current
 LOCAL_JAVA_LIBRARIES += android.test.runner
 
 include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/os/AndroidManifest.xml b/tests/tests/os/AndroidManifest.xml
index 155e772..0599c89 100644
--- a/tests/tests/os/AndroidManifest.xml
+++ b/tests/tests/os/AndroidManifest.xml
@@ -18,11 +18,52 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.cts.os">
 
+    <permission android:name="android.os.cts.permission.TEST_GRANTED"
+        android:protectionLevel="normal"
+            android:label="@string/permlab_testGranted"
+            android:description="@string/permdesc_testGranted">
+        <meta-data android:name="android.os.cts.string" android:value="foo" />
+        <meta-data android:name="android.os.cts.boolean" android:value="true" />
+        <meta-data android:name="android.os.cts.integer" android:value="100" />
+        <meta-data android:name="android.os.cts.color" android:value="#ff000000" />
+        <meta-data android:name="android.os.cts.float" android:value="100.1" />
+        <meta-data android:name="android.os.cts.reference" android:resource="@xml/metadata" />
+    </permission>
+
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
     <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.SEND_SMS" />
+    <uses-permission android:name="android.permission.RECEIVE_SMS" />
+    <uses-permission android:name="android.permission.READ_SMS"/>
+    <uses-permission android:name="android.permission.WRITE_SMS"/>
+    <uses-permission android:name="android.permission.CALL_PHONE" />
+    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
+    <uses-permission android:name="android.permission.DEVICE_POWER" />
+    <uses-permission android:name="android.app.cts.permission.TEST_GRANTED" />
 
     <application>
+        <activity android:name="android.app.os.LaunchpadActivity"
+                  android:configChanges="keyboardHidden|orientation|screenSize"
+                  android:multiprocess="true">
+        </activity>
+
+        <activity android:name="android.app.os.AliasActivityStub">
+            <meta-data android:name="android.app.alias"
+                android:resource="@xml/alias" />
+        </activity>
+
+        <activity android:name="android.os.cts.CountDownTimerTestStub"
+            android:label="CountDownTimerTestStub">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
         <service
             android:name="android.os.cts.ParcelFileDescriptorPeer$Red"
             android:process=":red"
@@ -31,11 +72,63 @@
             android:name="android.os.cts.ParcelFileDescriptorPeer$Blue"
             android:process=":blue"
             android:exported="true" />
+
+        <service android:name="android.os.cts.LocalService">
+            <intent-filter>
+                <action android:name="android.os.cts.activity.SERVICE_LOCAL" />
+            </intent-filter>
+            <meta-data android:name="android.os.cts.string" android:value="foo" />
+            <meta-data android:name="android.os.cts.boolean" android:value="true" />
+            <meta-data android:name="android.os.cts.integer" android:value="100" />
+            <meta-data android:name="android.os.cts.color" android:value="#ff000000" />
+            <meta-data android:name="android.os.cts.float" android:value="100.1" />
+            <meta-data android:name="android.os.cts.reference" android:resource="@xml/metadata" />
+        </service>
+
+        <service android:name="android.os.cts.LocalGrantedService"
+             android:permission="android.os.cts.permission.TEST_GRANTED">
+            <intent-filter>
+                <action android:name="android.os.cts.activity.SERVICE_LOCAL_GRANTED" />
+            </intent-filter>
+        </service>
+
+        <service android:name="android.os.cts.LocalDeniedService"
+               android:permission="android.os.cts.permission.TEST_DENIED">
+            <intent-filter>
+                <action android:name="android.os.cts.activity.SERVICE_LOCAL_DENIED" />
+            </intent-filter>
+        </service>
+
+
+        <service android:name="android.os.cts.EmptyService"
+            android:process=":remote">
+            <intent-filter>
+                <action
+                    android:name="android.os.cts.IEmptyService" />
+                <action
+                    android:name="android.os.REMOTESERVICE" />
+            </intent-filter>
+        </service>
+
+        <service android:name="android.os.cts.CtsRemoteService"
+            android:process=":remote">
+            <intent-filter>
+                <action
+                    android:name="android.os.cts.ISecondary" />
+                <action
+                    android:name="android.os.REMOTESERVICE" />
+            </intent-filter>
+        </service>
+
+        <service android:name="android.os.cts.MessengerService"
+                android:process=":messengerService">
+        </service>
+
         <uses-library android:name="android.test.runner" />
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="com.android.cts.stub"
+                     android:targetPackage="com.android.cts.os"
                      android:label="CTS tests of android.os">
         <meta-data android:name="listener"
             android:value="com.android.cts.runner.CtsTestRunListener" />
diff --git a/tests/tests/os/assets/otacerts.zip b/tests/tests/os/assets/otacerts.zip
new file mode 100644
index 0000000..937a128
--- /dev/null
+++ b/tests/tests/os/assets/otacerts.zip
Binary files differ
diff --git a/tests/tests/os/assets/otasigned.zip b/tests/tests/os/assets/otasigned.zip
new file mode 100644
index 0000000..a6bc53e
--- /dev/null
+++ b/tests/tests/os/assets/otasigned.zip
Binary files differ
diff --git a/tests/jni/Android.mk b/tests/tests/os/jni/Android.mk
similarity index 95%
rename from tests/jni/Android.mk
rename to tests/tests/os/jni/Android.mk
index a3e401e..a39b5d1 100644
--- a/tests/jni/Android.mk
+++ b/tests/tests/os/jni/Android.mk
@@ -16,13 +16,13 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_MODULE := libcts_jni
+LOCAL_MODULE := libctsos_jni
 
 # Don't include this package in any configuration by default.
 LOCAL_MODULE_TAGS := optional
 
 LOCAL_SRC_FILES := \
-		CtsJniOnLoad.cpp \
+		CtsOsJniOnLoad.cpp \
 		android_os_cts_CpuInstructions.cpp.arm \
 		android_os_cts_TaggedPointer.cpp \
 		android_os_cts_OSFeatures.cpp \
diff --git a/tests/jni/CtsJniOnLoad.cpp b/tests/tests/os/jni/CtsOsJniOnLoad.cpp
similarity index 100%
rename from tests/jni/CtsJniOnLoad.cpp
rename to tests/tests/os/jni/CtsOsJniOnLoad.cpp
diff --git a/tests/jni/android_os_cts_CpuFeatures.cpp b/tests/tests/os/jni/android_os_cts_CpuFeatures.cpp
similarity index 100%
rename from tests/jni/android_os_cts_CpuFeatures.cpp
rename to tests/tests/os/jni/android_os_cts_CpuFeatures.cpp
diff --git a/tests/jni/android_os_cts_CpuInstructions.cpp b/tests/tests/os/jni/android_os_cts_CpuInstructions.cpp
similarity index 100%
rename from tests/jni/android_os_cts_CpuInstructions.cpp
rename to tests/tests/os/jni/android_os_cts_CpuInstructions.cpp
diff --git a/tests/jni/android_os_cts_FileUtils.cpp b/tests/tests/os/jni/android_os_cts_FileUtils.cpp
similarity index 100%
rename from tests/jni/android_os_cts_FileUtils.cpp
rename to tests/tests/os/jni/android_os_cts_FileUtils.cpp
diff --git a/tests/jni/android_os_cts_OSFeatures.cpp b/tests/tests/os/jni/android_os_cts_OSFeatures.cpp
similarity index 100%
rename from tests/jni/android_os_cts_OSFeatures.cpp
rename to tests/tests/os/jni/android_os_cts_OSFeatures.cpp
diff --git a/tests/jni/android_os_cts_TaggedPointer.cpp b/tests/tests/os/jni/android_os_cts_TaggedPointer.cpp
similarity index 100%
rename from tests/jni/android_os_cts_TaggedPointer.cpp
rename to tests/tests/os/jni/android_os_cts_TaggedPointer.cpp
diff --git a/tests/tests/os/res/raw/test1.obb b/tests/tests/os/res/raw/test1.obb
new file mode 100644
index 0000000..33479aa
--- /dev/null
+++ b/tests/tests/os/res/raw/test1.obb
Binary files differ
diff --git a/tests/tests/os/res/raw/test1_nosig.obb b/tests/tests/os/res/raw/test1_nosig.obb
new file mode 100644
index 0000000..5c3573f
--- /dev/null
+++ b/tests/tests/os/res/raw/test1_nosig.obb
Binary files differ
diff --git a/tests/tests/os/res/raw/test1_wrongpackage.obb b/tests/tests/os/res/raw/test1_wrongpackage.obb
new file mode 100644
index 0000000..d0aafe1
--- /dev/null
+++ b/tests/tests/os/res/raw/test1_wrongpackage.obb
Binary files differ
diff --git a/tests/tests/os/res/values/strings.xml b/tests/tests/os/res/values/strings.xml
new file mode 100644
index 0000000..c167278
--- /dev/null
+++ b/tests/tests/os/res/values/strings.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="permlab_testGranted">Test Granted</string>
+    <string name="permdesc_testGranted">Used for running CTS tests, for testing operations
+        where we have the permission.</string>
+    <string name="permlab_testDynamic">Test Dynamic</string>
+    <string name="permdesc_testDynamic">Used for running CTS tests, for testing adding
+        dynamic permissions.</string>
+    <string name="permlab_testDenied">Test Denied</string>
+    <string name="permdesc_testDenied">Used for running CTS tests, for testing operations
+        where we do not have the permission.</string>
+    <string name="explain">1. click start. \n2. if above image shaked, then press pass button,
+         else press failed button.</string>
+    <string name="text_view_hello">Hello! Text view!</string>
+    <string name="text_view_hello_two_lines">Hello! \nText view!</string>
+    <string name="text_view_simple_hint">This is a hint.</string>
+    <string name="text_view_hint">This is a string for testing hint of textview.</string>
+    <string name="activity_forwarding">App/Forwarding</string>
+    <string name="forwarding">$$$</string>
+    <string name="go">Go</string>
+    <string name="back">Back</string>
+    <string name="forward_target">
+        Press back button and notice we don\'t see the previous activity.
+    </string>
+    <string name="edit_text">testing</string>
+    <string name="text">DialogTest</string>
+    <string name="text_country">Country</string>
+    <string name="text_name">Name</string>
+    <string name="hello_world">Hello, World!</string>
+    <string name="hello_android">Hello, Android!</string>
+    <string name="alert_dialog_username">Name:</string>
+    <string name="alert_dialog_password">Password:</string>
+    <string name="alert_dialog_positive">Positive</string>
+    <string name="alert_dialog_negative">Negative</string>
+    <string name="alert_dialog_neutral">Neutral</string>
+    <string name="notify">Notify </string>
+    <string name="tabs_1">testing</string>
+    <string name="table_layout_first">first</string>
+    <string name="table_layout_second">second</string>
+    <string name="table_layout_third">third</string>
+    <string name="table_layout_long">Very long to make the string out of the screen</string>
+    <string name="chronometer_text">Test Chronometer</string>
+    <string name="am">AM</string>
+    <string name="pm">PM</string>
+    <string name="viewgroup_test">ViewGroup test</string>
+    <string name="viewanimator_test">ViewAnimator test</string>
+    <string name="id_ok">OK</string>
+    <string name="id_cancel">Cancel</string>
+    <string name="context_test_string1">This is %s string.</string>
+    <string name="context_test_string2">This is test string.</string>
+    <string name="animationutils_test_instructions">Choose different animations</string>
+    <string name="animationutils_test_alpha">Alpha animation</string>
+    <string name="animationutils_test_scale">Scale animation</string>
+    <string name="animationutils_test_rotate">Rotate animation</string>
+    <string name="animationutils_test_translate">Translate animation</string>
+    <string name="animationutils_test_set">Animation set</string>
+    <string name="animationutils_test_layout">Layout animation</string>
+    <string name="animationutils_test_gridlayout">Grid layout animation</string>
+    <string name="twolinelistitem_test_text1">text1</string>
+    <string name="twolinelistitem_test_text2">text2</string>
+    <string name="metadata_text">metadata text</string>
+    <string name="horizontal_text_1">horizontal 1</string>
+    <string name="horizontal_text_2">horizontal 2</string>
+    <string name="horizontal_text_3">horizontal 3</string>
+    <string name="vertical_text_1">vertical 1</string>
+    <string name="vertical_text_2">vertical 2</string>
+    <string name="vertical_text_3">vertical 3</string>
+    <string name="reference">here</string>
+    <string name="coerceIntegerToString">100</string>
+    <string name="coerceBooleanToString">true</string>
+    <string name="coerceColorToString">#fff</string>
+    <string name="coerceFloatToString">100.0</string>
+    <string name="coerceDimensionToString">100px</string>
+    <string name="coerceFractionToString">100<xliff:g id="percent">%</xliff:g></string>
+    <string name="formattedStringNone">Format[]</string>
+    <string name="formattedStringOne">Format[<xliff:g id="format">%d</xliff:g>]</string>
+    <string name="formattedStringTwo">Format[<xliff:g id="format">%3$d,%2$s</xliff:g>]</string>
+    <string name="checkboxpref_key">checkboxpref_key</string>
+   <string name="checkboxpref_title">title of preference</string>
+   <string name="checkboxpref_summary">summary of preference</string>
+   <string name="checkboxpref_summary_on">summary on of preference</string>
+   <string name="checkboxpref_summary_off">summary off of preference</string>
+   <string name="checkboxpref_depend">checkboxpref_depend</string>
+   <string name="checkboxpref_depend_title"> depend title of preference</string>
+   <string name="checkboxpref_depend_summary"> depend summary of preference</string>
+   <string name="edittextpref_key">edittextpref_key</string>
+   <string name="edittextpref_default_value">default value of preference</string>
+   <string name="edittextpref_title">title of edit text preference</string>
+   <string name="edittextpref_summary">summary of edit text preference</string>
+   <string name="edittextpref_dialog_title">dialog title of edit text preference</string>
+   <string name="edittextpref_text">text of  edit text preference</string>
+   <string name="listpref_key">listpref_key</string>
+   <string name="listpref_title">title of list preference</string>
+   <string name="listpref_summary">summary of list preference</string>
+   <string name="listpref_dialogtitle">dialog title of list preference</string>
+   <string name="easy">Easy</string>
+   <string name="medium">Medium</string>
+   <string name="hard">Hard</string>
+   <string name="footer_view">Footer view</string>
+   <string name="header_view">Header view</string>
+   <string name="dialogpref_title">title of dialog preference </string>
+   <string name="dialogpref_dialog_title">dialog title of dialog preference </string>
+   <string name="dialogpref_key">dialogpref_key</string>
+   <string name="dialogpref_default_value">default value of dialog preference</string>
+   <string name="dialogpref_summary">summary of dialog preference</string>
+   <string name="dialogpref_message">message of dialog preference</string>
+   <string name="dialogpref_sure">Sure</string>
+   <string name="dialogpref_cancel">Cancel</string>
+   <string name="pref_key">pref_key</string>
+   <string name="pref_title">title of preference</string>
+   <string name="pref_summary">summary of preference</string>
+   <string name="pref_depend_key">pref_depend_key</string>
+   <string name="pref_depend_title"> depend title of preference</string>
+   <string name="pref_depend_summary"> depend summary of preference</string>
+   <string name="android_intent_action_preference">android.intent.action.PREFERENCE</string>
+   <string name="def_pref_key">def_pref_key</string>
+   <string name="def_pref_title">default preference</string>
+   <string name="def_pref_summary">This is default preference of cts</string>
+   <string name="relative_view1">view 1</string>
+   <string name="relative_view2">view 2</string>
+   <string name="relative_view3">view 3</string>
+   <string name="relative_view4">view 4</string>
+   <string name="relative_view5">view 5</string>
+   <string name="relative_view6">view 6</string>
+   <string name="relative_view7">view 7</string>
+   <string name="relative_view8">view 8</string>
+   <string name="relative_view9">view 9</string>
+   <string name="relative_view10">view 10</string>
+   <string name="relative_view11">view 11</string>
+   <string name="relative_view12">view 12</string>
+   <string name="relative_view13">view 13</string>
+   <string name="country">Country:</string>
+   <string name="symbol">Symbol:</string>
+   <string name="country_warning">No such country registered</string>
+   <string name="version_cur">base</string>
+   <string name="version_old">base</string>
+   <string name="version_v3">base</string>
+   <string name="authenticator_label">Android CTS</string>
+   <string name="search_label">Android CTS</string>
+   <string name="tag1">tag 1</string>
+   <string name="tag2">tag 2</string>
+
+   <string name="button">Button</string>
+   <string name="holo_test">Holo Test</string>
+   <string name="holo_generator">Holo Generator</string>
+   <string name="holo_light_test">Holo Light Test</string>
+   <string name="holo_light_generator">Holo Light Generator</string>
+   <string name="reference_image">Reference Image: </string>
+   <string name="generated_image">Generated Image: </string>
+   <string name="themes_prompt">Select a Theme:</string>
+   <string name="sample_text">Sample text goes here. I wanted something creative and whimsical
+but then I just got bored...</string>
+    <string name="long_text">This is a really long string which exceeds the width of the view.
+New devices have a much larger screen which actually enables long strings to be displayed
+with no fading. I have made this string longer to fix this case. If you are correcting this
+text, I would love to see the kind of devices you guys now use! Guys, maybe some devices need longer string!
+I think so, so how about double this string, like copy and paste!
+This is a really long string which exceeds the width of the view.
+New devices have a much larger screen which actually enables long strings to be displayed
+with no fading. I have made this string longer to fix this case. If you are correcting this
+text, I would love to see the kind of devices you guys now use! Guys, maybe some devices need longer string!
+I think so, so how about double this string, like copy and paste! </string>
+    <string name="rectangle200">"M 0,0 l 200,0 l 0, 200 l -200, 0 z"</string>
+</resources>
diff --git a/tests/tests/os/res/xml/alias.xml b/tests/tests/os/res/xml/alias.xml
new file mode 100644
index 0000000..f88f3dc
--- /dev/null
+++ b/tests/tests/os/res/xml/alias.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * 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.
+ */
+-->
+
+<alias xmlns:android="http://schemas.android.com/apk/res/android">
+    <intent android:action="android.intent.action.MAIN"
+        android:targetPackage="com.android.cts.stub"
+        android:targetClass="android.app.cts.ChildActivity"
+        android:data="http://www.google.com/">
+    </intent>
+</alias>
+
diff --git a/tests/tests/os/res/xml/metadata.xml b/tests/tests/os/res/xml/metadata.xml
new file mode 100644
index 0000000..336b931
--- /dev/null
+++ b/tests/tests/os/res/xml/metadata.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<thedata xmlns:android="http://schemas.android.com/apk/res/android"
+    rawText="some raw text"
+    rawColor="#ffffff00"
+    android:color="#f00"
+    android:text="@string/metadata_text"/>
diff --git a/tests/tests/os/src/android/os/cts/ActivityTestsBase.java b/tests/tests/os/src/android/os/cts/ActivityTestsBase.java
new file mode 100644
index 0000000..3f7d91d
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/ActivityTestsBase.java
@@ -0,0 +1,211 @@
+/*
+ * 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.os.cts;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+import android.test.AndroidTestCase;
+import android.test.PerformanceTestCase;
+
+public class ActivityTestsBase extends AndroidTestCase implements PerformanceTestCase,
+        LaunchpadActivity.CallingTest {
+    public static final String PERMISSION_GRANTED = "android.os.cts.permission.TEST_GRANTED";
+    public static final String PERMISSION_DENIED = "android.os.cts.permission.TEST_DENIED";
+
+    private static final int TIMEOUT_MS = 60 * 1000;
+
+    protected Intent mIntent;
+
+    private PerformanceTestCase.Intermediates mIntermediates;
+    private String mExpecting;
+
+    // Synchronization of activity result.
+    private boolean mFinished;
+    private int mResultCode = 0;
+    private Intent mData;
+    private RuntimeException mResultStack = null;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mIntent = new Intent(mContext, LaunchpadActivity.class);
+        mIntermediates = null;
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mIntermediates = null;
+        super.tearDown();
+    }
+
+    public boolean isPerformanceOnly() {
+        return false;
+    }
+
+    public void setInternalIterations(int count) {
+    }
+
+    public void startTiming(boolean realTime) {
+        if (mIntermediates != null) {
+            mIntermediates.startTiming(realTime);
+        }
+    }
+
+    public void addIntermediate(String name) {
+        if (mIntermediates != null) {
+            mIntermediates.addIntermediate(name);
+        }
+    }
+
+    public void addIntermediate(String name, long timeInNS) {
+        if (mIntermediates != null) {
+            mIntermediates.addIntermediate(name, timeInNS);
+        }
+    }
+
+    public void finishTiming(boolean realTime) {
+        if (mIntermediates != null) {
+            mIntermediates.finishTiming(realTime);
+        }
+    }
+
+    public void activityFinished(int resultCode, Intent data, RuntimeException where) {
+        finishWithResult(resultCode, data, where);
+    }
+
+    public Intent editIntent() {
+        return mIntent;
+    }
+
+    @Override
+    public Context getContext() {
+        return mContext;
+    }
+
+    public int startPerformance(Intermediates intermediates) {
+        mIntermediates = intermediates;
+        return 1;
+    }
+
+    public void finishGood() {
+        finishWithResult(Activity.RESULT_OK, null);
+    }
+
+    public void finishBad(String error) {
+        finishWithResult(Activity.RESULT_CANCELED, new Intent().setAction(error));
+    }
+
+    public void finishWithResult(int resultCode, Intent data) {
+        final RuntimeException where = new RuntimeException("Original error was here");
+        where.fillInStackTrace();
+        finishWithResult(resultCode, data, where);
+    }
+
+    public void finishWithResult(int resultCode, Intent data, RuntimeException where) {
+        synchronized (this) {
+            mResultCode = resultCode;
+            mData = data;
+            mResultStack = where;
+            mFinished = true;
+            notifyAll();
+        }
+    }
+
+    public int runLaunchpad(String action) {
+        startLaunchpadActivity(action);
+        return waitForResultOrThrow(TIMEOUT_MS);
+    }
+
+    private void startLaunchpadActivity(String action) {
+        LaunchpadActivity.setCallingTest(this);
+
+        synchronized (this) {
+            mIntent.setAction(action);
+            mFinished = false;
+            mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            mContext.startActivity(mIntent);
+        }
+    }
+
+    public int waitForResultOrThrow(int timeoutMs) {
+        return waitForResultOrThrow(timeoutMs, null);
+    }
+
+    public int waitForResultOrThrow(int timeoutMs, String expected) {
+        final int res = waitForResult(timeoutMs, expected);
+
+        if (res == Activity.RESULT_CANCELED) {
+            if (mResultStack != null) {
+                throw new RuntimeException(mData != null ? mData.toString() : "Unable to launch",
+                        mResultStack);
+            } else {
+                throw new RuntimeException(mData != null ? mData.toString() : "Unable to launch");
+            }
+        }
+        return res;
+    }
+
+    public int waitForResult(int timeoutMs, String expected) {
+        mExpecting = expected;
+
+        final long endTime = System.currentTimeMillis() + timeoutMs;
+
+        boolean timeout = false;
+        synchronized (this) {
+            while (!mFinished) {
+                final long delay = endTime - System.currentTimeMillis();
+                if (delay < 0) {
+                    timeout = true;
+                    break;
+                }
+
+                try {
+                    wait(delay);
+                } catch (final java.lang.InterruptedException e) {
+                    // do nothing
+                }
+            }
+        }
+
+        mFinished = false;
+
+        if (timeout) {
+            mResultCode = Activity.RESULT_CANCELED;
+            onTimeout();
+        }
+        return mResultCode;
+    }
+
+
+    public int getResultCode() {
+        return mResultCode;
+    }
+
+    public Intent getResultData() {
+        return mData;
+    }
+
+    public RuntimeException getResultStack() {
+        return mResultStack;
+    }
+
+    public void onTimeout() {
+        final String msg = mExpecting == null ? "Timeout" : "Timeout while expecting " + mExpecting;
+        finishWithResult(Activity.RESULT_CANCELED, new Intent().setAction(msg));
+    }
+}
diff --git a/tests/src/android/widget/cts/MockPopupWindowStubActivity.java b/tests/tests/os/src/android/os/cts/AliasActivityStub.java
similarity index 64%
copy from tests/src/android/widget/cts/MockPopupWindowStubActivity.java
copy to tests/tests/os/src/android/os/cts/AliasActivityStub.java
index 2ca81de..cff405e 100644
--- a/tests/src/android/widget/cts/MockPopupWindowStubActivity.java
+++ b/tests/tests/os/src/android/os/cts/AliasActivityStub.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 The Android Open Source Project
+ * 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.
@@ -13,23 +13,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package android.os.cts;
 
-package android.widget.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
+import android.app.AliasActivity;
 import android.os.Bundle;
-import android.widget.PopupWindow;
 
-/**
- * Stub activity for testing {@link PopupWindow}
- */
-public class MockPopupWindowStubActivity extends Activity {
+public class AliasActivityStub extends AliasActivity {
+
+    public static boolean isOnCreateCalled = false;
+    public static boolean isFinished = false;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.popupwindow);
+        isOnCreateCalled = true;
+    }
+
+    @Override
+    public void finish() {
+        super.finish();
+        isFinished = true;
     }
 }
-
diff --git a/tests/tests/os/src/android/os/cts/BinderTest.java b/tests/tests/os/src/android/os/cts/BinderTest.java
index 7a30169..435e247 100644
--- a/tests/tests/os/src/android/os/cts/BinderTest.java
+++ b/tests/tests/os/src/android/os/cts/BinderTest.java
@@ -20,8 +20,6 @@
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 
-import android.app.cts.ActivityTestsBase;
-import android.app.cts.LocalService;
 import android.content.ComponentName;
 import android.content.Intent;
 import android.content.ServiceConnection;
diff --git a/tests/tests/os/src/android/os/cts/ClearTop.java b/tests/tests/os/src/android/os/cts/ClearTop.java
new file mode 100644
index 0000000..278336c
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/ClearTop.java
@@ -0,0 +1,49 @@
+/*
+ * 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.os.cts;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+public class ClearTop extends Activity {
+    public static final String WAIT_CLEAR_TASK = "waitClearTask";
+    private static final String TAG = "ClearTop";
+    public ClearTop() {
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        final Intent intent = new Intent(getIntent()).setAction(LocalScreen.CLEAR_TASK).setClass(
+                this, LocalScreen.class);
+        startActivity(intent);
+    }
+
+    @Override
+    public void onNewIntent(Intent intent) {
+        Log.i(TAG, "onNewIntent");
+        if (LocalScreen.CLEAR_TASK.equals(intent.getAction())) {
+            setResult(RESULT_OK);
+        } else {
+            setResult(RESULT_CANCELED, new Intent().setAction("New intent received " + intent
+                    + ", expecting action " + TestedScreen.CLEAR_TASK));
+        }
+        finish();
+    }
+}
diff --git a/tests/src/android/os/cts/CountDownTimerTestStub.java b/tests/tests/os/src/android/os/cts/CountDownTimerTestStub.java
similarity index 100%
rename from tests/src/android/os/cts/CountDownTimerTestStub.java
rename to tests/tests/os/src/android/os/cts/CountDownTimerTestStub.java
diff --git a/tests/src/android/os/cts/CpuFeatures.java b/tests/tests/os/src/android/os/cts/CpuFeatures.java
similarity index 97%
rename from tests/src/android/os/cts/CpuFeatures.java
rename to tests/tests/os/src/android/os/cts/CpuFeatures.java
index fa6628b..553f264 100644
--- a/tests/src/android/os/cts/CpuFeatures.java
+++ b/tests/tests/os/src/android/os/cts/CpuFeatures.java
@@ -41,7 +41,7 @@
     public static final int HWCAP_IDIVT = (1 << 18);
 
     static {
-        System.loadLibrary("cts_jni");
+        System.loadLibrary("ctsos_jni");
     }
 
     public static native boolean isArmCpu();
diff --git a/tests/src/android/os/cts/CpuInstructions.java b/tests/tests/os/src/android/os/cts/CpuInstructions.java
similarity index 95%
rename from tests/src/android/os/cts/CpuInstructions.java
rename to tests/tests/os/src/android/os/cts/CpuInstructions.java
index e001ceb..45fb2f1 100644
--- a/tests/src/android/os/cts/CpuInstructions.java
+++ b/tests/tests/os/src/android/os/cts/CpuInstructions.java
@@ -19,7 +19,7 @@
 public class CpuInstructions {
 
     static {
-        System.loadLibrary("cts_jni");
+        System.loadLibrary("ctsos_jni");
     }
 
     public static native boolean canReadCntvct();
diff --git a/tests/tests/os/src/android/os/cts/CtsRemoteService.java b/tests/tests/os/src/android/os/cts/CtsRemoteService.java
new file mode 100644
index 0000000..daae49e
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/CtsRemoteService.java
@@ -0,0 +1,54 @@
+/*
+ * 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.os.cts;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.os.Process;
+
+public class CtsRemoteService extends Service{
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        android.util.Log.d("Process test stub", "CtsRemoteServiceProcessPid:" + Process.myPid());
+    }
+
+    private final ISecondary.Stub mSecondaryBinder = new ISecondary.Stub() {
+        public int getPid() {
+            return Process.myPid();
+        }
+
+        public long getElapsedCpuTime() {
+            return Process.getElapsedCpuTime();
+        }
+
+        public String getTimeZoneID() {
+            return java.util.TimeZone.getDefault().getID();
+        }
+    };
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        if (ISecondary.class.getName().equals(intent.getAction())) {
+            return mSecondaryBinder;
+        }
+        return null;
+    }
+
+}
diff --git a/tests/src/android/os/cts/EmptyService.java b/tests/tests/os/src/android/os/cts/EmptyService.java
similarity index 100%
rename from tests/src/android/os/cts/EmptyService.java
rename to tests/tests/os/src/android/os/cts/EmptyService.java
diff --git a/tests/src/android/os/cts/FileUtils.java b/tests/tests/os/src/android/os/cts/FileUtils.java
similarity index 98%
rename from tests/src/android/os/cts/FileUtils.java
rename to tests/tests/os/src/android/os/cts/FileUtils.java
index ea31c54..8600d8b 100644
--- a/tests/src/android/os/cts/FileUtils.java
+++ b/tests/tests/os/src/android/os/cts/FileUtils.java
@@ -54,7 +54,7 @@
     public static final int S_IXOTH = 00001;
 
     static {
-        System.loadLibrary("cts_jni");
+        System.loadLibrary("ctsos_jni");
     }
 
     public static class FileStatus {
diff --git a/tests/tests/os/src/android/os/cts/IBinderParcelable.java b/tests/tests/os/src/android/os/cts/IBinderParcelable.java
new file mode 100644
index 0000000..e48f58a
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/IBinderParcelable.java
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+package android.os.cts;
+
+import android.os.IBinder;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class IBinderParcelable implements Parcelable {
+    public IBinder binder;
+
+    public IBinderParcelable(IBinder source) {
+        binder = source;
+    }
+
+    public int describeContents() {
+        return 0;
+    }
+
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeStrongBinder(binder);
+    }
+
+    public static final Parcelable.Creator<IBinderParcelable>
+        CREATOR = new Parcelable.Creator<IBinderParcelable>() {
+
+        public IBinderParcelable createFromParcel(Parcel source) {
+            return new IBinderParcelable(source);
+        }
+
+        public IBinderParcelable[] newArray(int size) {
+            return new IBinderParcelable[size];
+        }
+    };
+
+    private IBinderParcelable(Parcel source) {
+        binder = source.readStrongBinder();
+    }
+}
diff --git a/tests/src/android/os/cts/IEmptyService.aidl b/tests/tests/os/src/android/os/cts/IEmptyService.aidl
similarity index 100%
rename from tests/src/android/os/cts/IEmptyService.aidl
rename to tests/tests/os/src/android/os/cts/IEmptyService.aidl
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/os/src/android/os/cts/ISecondary.aidl
similarity index 74%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/os/src/android/os/cts/ISecondary.aidl
index 16e76c9..2c60149 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/os/src/android/os/cts/ISecondary.aidl
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,11 +16,11 @@
 
 package android.os.cts;
 
-public class TaggedPointer {
+interface ISecondary {
 
-    static {
-        System.loadLibrary("cts_jni");
-    }
+    int getPid();
 
-    public static native boolean hasTaggedPointer();
+    long getElapsedCpuTime();
+
+    String getTimeZoneID();
 }
diff --git a/tests/tests/os/src/android/os/cts/LaunchpadActivity.java b/tests/tests/os/src/android/os/cts/LaunchpadActivity.java
new file mode 100644
index 0000000..e812908
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/LaunchpadActivity.java
@@ -0,0 +1,648 @@
+/*
+ * 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.os.cts;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.test.PerformanceTestCase;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+class MyBadParcelable implements Parcelable {
+    public MyBadParcelable() {
+    }
+
+    public void writeToParcel(Parcel out, int flags) {
+        out.writeString("I am bad");
+    }
+
+    public int describeContents() {
+        return 0;
+    }
+
+    public static final Parcelable.Creator<MyBadParcelable> CREATOR =
+        new Parcelable.Creator<MyBadParcelable>() {
+        public MyBadParcelable createFromParcel(Parcel in) {
+            return new MyBadParcelable(in);
+        }
+
+        public MyBadParcelable[] newArray(int size) {
+            return new MyBadParcelable[size];
+        }
+    };
+
+    public MyBadParcelable(Parcel in) {
+        in.readString();
+    }
+}
+
+public class LaunchpadActivity extends Activity {
+    public interface CallingTest extends PerformanceTestCase.Intermediates {
+        public void startTiming(boolean realTime);
+
+        public void addIntermediate(String name);
+
+        public void addIntermediate(String name, long timeInNS);
+
+        public void finishTiming(boolean realTime);
+
+        public void activityFinished(int resultCode, Intent data, RuntimeException where);
+    }
+
+    // Also used as the Binder interface descriptor string in these tests
+    public static final String LAUNCH = "android.app.cts.activity.LAUNCH";
+
+    public static final String FORWARD_RESULT = "android.app.cts.activity.FORWARD_RESULT";
+    public static final String RETURNED_RESULT = "android.app.cts.activity.RETURNED_RESULT";
+
+    public static final String BAD_PARCELABLE = "android.app.cts.activity.BAD_PARCELABLE";
+
+    public static final int LAUNCHED_RESULT = 1;
+    public static final int FORWARDED_RESULT = 2;
+
+    public static final String LIFECYCLE_BASIC = "android.app.cts.activity.LIFECYCLE_BASIC";
+    public static final String LIFECYCLE_SCREEN = "android.app.cts.activity.LIFECYCLE_SCREEN";
+    public static final String LIFECYCLE_DIALOG = "android.app.cts.activity.LIFECYCLE_DIALOG";
+
+    public static final String BROADCAST_REGISTERED = "android.app.cts.activity.BROADCAST_REGISTERED";
+    public static final String BROADCAST_LOCAL = "android.app.cts.activity.BROADCAST_LOCAL";
+    public static final String BROADCAST_REMOTE = "android.app.cts.activity.BROADCAST_REMOTE";
+    public static final String BROADCAST_ALL = "android.app.cts.activity.BROADCAST_ALL";
+    public static final String BROADCAST_REPEAT = "android.app.cts.activity.BROADCAST_REPEAT";
+    public static final String BROADCAST_MULTI = "android.app.cts.activity.BROADCAST_MULTI";
+    public static final String BROADCAST_ABORT = "android.app.cts.activity.BROADCAST_ABORT";
+
+    public static final String EXPANDLIST_SELECT = "EXPANDLIST_SELECT";
+    public static final String EXPANDLIST_VIEW = "EXPANDLIST_VIEW";
+    public static final String EXPANDLIST_CALLBACK = "EXPANDLIST_CALLBACK";
+
+    public static final String BROADCAST_STICKY1 = "android.app.cts.activity.BROADCAST_STICKY1";
+    public static final String BROADCAST_STICKY2 = "android.app.cts.activity.BROADCAST_STICKY2";
+
+    public static final String ALIAS_ACTIVITY = "android.app.cts.activity.ALIAS_ACTIVITY";
+
+    public static final String RECEIVER_REG = "receiver-reg";
+    public static final String RECEIVER_LOCAL = "receiver-local";
+    public static final String RECEIVER_REMOTE = "receiver-remote";
+    public static final String RECEIVER_ABORT = "receiver-abort";
+
+    public static final String DATA_1 = "one";
+    public static final String DATA_2 = "two";
+
+    public static final String ON_START = "onStart";
+    public static final String ON_RESTART = "onRestart";
+    public static final String ON_RESUME = "onResume";
+    public static final String ON_FREEZE = "onSaveInstanceState";
+    public static final String ON_PAUSE = "onPause";
+
+    // ON_STOP and ON_DESTROY are not tested because they may not be called.
+
+    public static final String DO_FINISH = "finish";
+    public static final String DO_LOCAL_SCREEN = "local-screen";
+    public static final String DO_LOCAL_DIALOG = "local-dialog";
+
+    private static final String TAG = "LaunchpadActivity";
+
+    private boolean mBadParcelable = false;
+
+    private boolean mStarted = false;
+
+    private int mResultCode = RESULT_CANCELED;
+    private Intent mData = new Intent().setAction("No result received");
+    private RuntimeException mResultStack = null;
+
+    /** Index into the {@link #mNextLifecycle} array. */
+    private int mNextLifecycle;
+
+    /** Current lifecycle expected to be followed. */
+    private String[] mExpectedLifecycle;
+
+    /** Other possible lifecycles. Never includes the current {@link #mExpectedLifecycle}. */
+    private List<String[]> mOtherPossibleLifecycles = new ArrayList<String[]>(2);
+
+    /** Map from lifecycle arrays to debugging log names. */
+    private Map<String[], String> mLifecycleNames = new HashMap<String[], String>(2);
+
+    private String[] mExpectedReceivers = null;
+    private int mNextReceiver;
+
+    private String[] mExpectedData = null;
+    private boolean[] mReceivedData = null;
+
+    boolean mReceiverRegistered = false;
+
+    private static CallingTest sCallingTest = null;
+
+    public static void setCallingTest(CallingTest ct) {
+        sCallingTest = ct;
+    }
+
+    public LaunchpadActivity() {
+    }
+
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        resetLifecycles();
+
+        // ON_STOP and ON_DESTROY are not tested because they may not be called.
+
+        final String action = getIntent().getAction();
+        if (LIFECYCLE_BASIC.equals(action)) {
+            addPossibleLifecycle(LIFECYCLE_BASIC, new String[] {
+                    ON_START, ON_RESUME, DO_FINISH, ON_PAUSE
+            });
+        } else if (LIFECYCLE_SCREEN.equals(action)) {
+            addPossibleLifecycle(LIFECYCLE_SCREEN + "_RESTART", new String[] {
+                    ON_START, ON_RESUME, DO_LOCAL_SCREEN, ON_PAUSE,
+                    ON_RESTART, ON_START, ON_RESUME, DO_FINISH, ON_PAUSE
+            });
+            addPossibleLifecycle(LIFECYCLE_SCREEN + "_RESUME", new String[] {
+                    ON_START, ON_RESUME, DO_LOCAL_SCREEN, ON_PAUSE,
+                    ON_RESUME, DO_FINISH, ON_PAUSE
+            });
+        } else if (LIFECYCLE_DIALOG.equals(action)) {
+            addPossibleLifecycle(LIFECYCLE_DIALOG + "_RESTART", new String[] {
+                    ON_START, ON_RESUME, DO_LOCAL_DIALOG, ON_PAUSE,
+                    ON_RESTART, ON_START, ON_RESUME, DO_FINISH, ON_PAUSE
+            });
+            addPossibleLifecycle(LIFECYCLE_DIALOG + "_RESUME", new String[] {
+                    ON_START, ON_RESUME, DO_LOCAL_DIALOG, ON_PAUSE,
+                    ON_RESUME, DO_FINISH, ON_PAUSE
+            });
+        }
+    }
+
+    private void resetLifecycles() {
+        mNextLifecycle = 0;
+        mExpectedLifecycle = null;
+        mOtherPossibleLifecycles.clear();
+        mLifecycleNames.clear();
+    }
+
+    /**
+     * Add a potential lifecycle that this activity may follow, since there
+     * are usually multiple valid lifecycles. For instance, sometimes onPause
+     * will lead to onResume rather than onStop when another activity is
+     * raised over the current one.
+     *
+     * @param debugName for the lifecycle shown in the logs
+     * @param lifecycle array containing tokens indicating the expected lifecycle
+     */
+    private void addPossibleLifecycle(String debugName, String[] lifecycle) {
+        mLifecycleNames.put(lifecycle, debugName);
+        if (mExpectedLifecycle == null) {
+            mExpectedLifecycle = lifecycle;
+        } else {
+            mOtherPossibleLifecycles.add(lifecycle);
+        }
+    }
+
+    /**
+     * Switch to the next possible lifecycle and return if switching was
+     * successful. Call this method when mExpectedLifecycle doesn't match
+     * the current lifecycle and you need to check another possible lifecycle.
+     *
+     * @return whether on not there was a lifecycle to switch to
+     */
+    private boolean switchToNextPossibleLifecycle() {
+        if (!mOtherPossibleLifecycles.isEmpty()) {
+            String[] newLifecycle = mOtherPossibleLifecycles.remove(0);
+            Log.w(TAG, "Switching expected lifecycles from "
+                    + mLifecycleNames.get(mExpectedLifecycle) + " to "
+                    + mLifecycleNames.get(newLifecycle));
+            mExpectedLifecycle = newLifecycle;
+            return true;
+        } else {
+            Log.w(TAG, "No more lifecycles after "
+                    + mLifecycleNames.get(mExpectedLifecycle));
+            mExpectedLifecycle = null;
+            return false;
+        }
+    }
+
+    @Override
+    protected void onStart() {
+        super.onStart();
+        checkLifecycle(ON_START);
+    }
+
+    @Override
+    protected void onRestart() {
+        super.onStart();
+        checkLifecycle(ON_RESTART);
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        checkLifecycle(ON_RESUME);
+
+        if (!mStarted) {
+            mStarted = true;
+
+            mHandler.postDelayed(mTimeout, 10 * 1000);
+
+            final String action = getIntent().getAction();
+
+            sCallingTest.startTiming(true);
+
+            if (LAUNCH.equals(action)) {
+                final Intent intent = getIntent();
+                intent.setFlags(0);
+                intent.setComponent((ComponentName) intent.getParcelableExtra("component"));
+                startActivityForResult(intent, LAUNCHED_RESULT);
+
+            } else if (FORWARD_RESULT.equals(action)) {
+                final Intent intent = getIntent();
+                intent.setFlags(0);
+                intent.setClass(this, LocalScreen.class);
+                startActivityForResult(intent, FORWARDED_RESULT);
+            } else if (BAD_PARCELABLE.equals(action)) {
+                mBadParcelable = true;
+                final Intent intent = getIntent();
+                intent.setFlags(0);
+                intent.setClass(this, LocalScreen.class);
+                startActivityForResult(intent, LAUNCHED_RESULT);
+            } else if (BROADCAST_REGISTERED.equals(action)) {
+                setExpectedReceivers(new String[] {
+                    RECEIVER_REG
+                });
+                registerMyReceiver(new IntentFilter(BROADCAST_REGISTERED));
+                sCallingTest.addIntermediate("after-register");
+                sendBroadcast(makeBroadcastIntent(BROADCAST_REGISTERED));
+            } else if (BROADCAST_LOCAL.equals(action)) {
+                setExpectedReceivers(new String[] {
+                    RECEIVER_LOCAL
+                });
+                sendBroadcast(makeBroadcastIntent(BROADCAST_LOCAL));
+            } else if (BROADCAST_REMOTE.equals(action)) {
+                setExpectedReceivers(new String[] {
+                    RECEIVER_REMOTE
+                });
+                sendBroadcast(makeBroadcastIntent(BROADCAST_REMOTE));
+            } else if (BROADCAST_ALL.equals(action)) {
+                setExpectedReceivers(new String[] {
+                        RECEIVER_REMOTE, RECEIVER_REG, RECEIVER_LOCAL
+                });
+                registerMyReceiver(new IntentFilter(BROADCAST_ALL));
+                sCallingTest.addIntermediate("after-register");
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_ALL), null);
+            } else if (BROADCAST_MULTI.equals(action)) {
+                setExpectedReceivers(new String[] {
+                        RECEIVER_REMOTE, RECEIVER_REG, RECEIVER_LOCAL, RECEIVER_REMOTE,
+                        RECEIVER_REG, RECEIVER_LOCAL, RECEIVER_REMOTE, RECEIVER_REG,
+                        RECEIVER_LOCAL, RECEIVER_LOCAL, RECEIVER_REMOTE, RECEIVER_LOCAL,
+                        RECEIVER_REMOTE, RECEIVER_REMOTE, RECEIVER_REG, RECEIVER_LOCAL,
+                        RECEIVER_REMOTE, RECEIVER_REG, RECEIVER_LOCAL, RECEIVER_REMOTE,
+                        RECEIVER_REG, RECEIVER_LOCAL, RECEIVER_REMOTE, RECEIVER_LOCAL,
+                        RECEIVER_REMOTE, RECEIVER_LOCAL
+                });
+                registerMyReceiver(new IntentFilter(BROADCAST_ALL));
+                sCallingTest.addIntermediate("after-register");
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_ALL), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_ALL), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_ALL), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_LOCAL), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_REMOTE), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_LOCAL), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_REMOTE), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_ALL), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_ALL), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_ALL), null);
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_REPEAT), null);
+            } else if (BROADCAST_ABORT.equals(action)) {
+                setExpectedReceivers(new String[] {
+                        RECEIVER_REMOTE, RECEIVER_ABORT
+                });
+                registerMyReceiver(new IntentFilter(BROADCAST_ABORT));
+                sCallingTest.addIntermediate("after-register");
+                sendOrderedBroadcast(makeBroadcastIntent(BROADCAST_ABORT), null);
+            } else if (BROADCAST_STICKY1.equals(action)) {
+                setExpectedReceivers(new String[] {
+                    RECEIVER_REG
+                });
+                setExpectedData(new String[] {
+                    DATA_1
+                });
+                registerMyReceiver(new IntentFilter(BROADCAST_STICKY1));
+                sCallingTest.addIntermediate("after-register");
+            } else if (BROADCAST_STICKY2.equals(action)) {
+                setExpectedReceivers(new String[] {
+                        RECEIVER_REG, RECEIVER_REG
+                });
+                setExpectedData(new String[] {
+                        DATA_1, DATA_2
+                });
+                final IntentFilter filter = new IntentFilter(BROADCAST_STICKY1);
+                filter.addAction(BROADCAST_STICKY2);
+                registerMyReceiver(filter);
+                sCallingTest.addIntermediate("after-register");
+            } else if (ALIAS_ACTIVITY.equals(action)) {
+                final Intent intent = getIntent();
+                intent.setFlags(0);
+                intent.setClass(this, AliasActivityStub.class);
+                startActivityForResult(intent, LAUNCHED_RESULT);
+            } else if (EXPANDLIST_SELECT.equals(action)) {
+                final Intent intent = getIntent();
+                intent.setFlags(0);
+                intent.setAction(action);
+                intent.setComponent((ComponentName) intent.getParcelableExtra("component"));
+                startActivityForResult(intent, LAUNCHED_RESULT);
+            } else if (EXPANDLIST_VIEW.equals(action)) {
+                final Intent intent = getIntent();
+                intent.setFlags(0);
+                intent.setAction(action);
+                intent.setComponent((ComponentName) intent.getParcelableExtra("component"));
+                startActivityForResult(intent, LAUNCHED_RESULT);
+            } else if (EXPANDLIST_CALLBACK.equals(action)) {
+                final Intent intent = getIntent();
+                intent.setFlags(0);
+                intent.setAction(action);
+                intent.setComponent((ComponentName) intent.getParcelableExtra("component"));
+                startActivityForResult(intent, LAUNCHED_RESULT);
+            }
+        }
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle icicle) {
+        super.onSaveInstanceState(icicle);
+        if (mBadParcelable) {
+            icicle.putParcelable("baddy", new MyBadParcelable());
+        }
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        checkLifecycle(ON_PAUSE);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        switch (requestCode) {
+            case LAUNCHED_RESULT:
+                sCallingTest.finishTiming(true);
+                finishWithResult(resultCode, data);
+                break;
+            case FORWARDED_RESULT:
+                sCallingTest.finishTiming(true);
+                if (RETURNED_RESULT.equals(data.getAction())) {
+                    finishWithResult(resultCode, data);
+                } else {
+                    finishWithResult(RESULT_CANCELED, new Intent().setAction("Bad data returned: "
+                            + data));
+                }
+                break;
+            default:
+                sCallingTest.finishTiming(true);
+                finishWithResult(RESULT_CANCELED, new Intent()
+                        .setAction("Unexpected request code: " + requestCode));
+                break;
+        }
+    }
+
+    private void checkLifecycle(String where) {
+        String action = getIntent().getAction();
+
+        if (mExpectedLifecycle == null) {
+            return;
+        }
+
+        if (mNextLifecycle >= mExpectedLifecycle.length) {
+            finishBad("Activity lifecycle for " + action + " incorrect: received " + where
+                    + " but don't expect any more calls");
+            mExpectedLifecycle = null;
+            return;
+        }
+
+        do {
+            if (mExpectedLifecycle[mNextLifecycle].equals(where)) {
+                Log.w(TAG, "Matched: " + where);
+                break;
+            } else {
+                Log.w(TAG, "Expected " + mExpectedLifecycle[mNextLifecycle] + " but got " + where);
+            }
+        } while (switchToNextPossibleLifecycle());
+
+        if (mExpectedLifecycle == null) {
+            finishBad("Activity lifecycle for " + action + " incorrect: received " + where
+                    + " at " + mNextLifecycle);
+            return;
+        }
+
+        mNextLifecycle++;
+
+        if (mNextLifecycle >= mExpectedLifecycle.length) {
+            finishGood();
+            return;
+        }
+
+        final String next = mExpectedLifecycle[mNextLifecycle];
+        if (next.equals(DO_FINISH)) {
+            mNextLifecycle++;
+            if (mNextLifecycle >= mExpectedLifecycle.length) {
+                setTestResult(RESULT_OK, null);
+            }
+            if (!isFinishing()) {
+                finish();
+            }
+        } else if (next.equals(DO_LOCAL_SCREEN)) {
+            mNextLifecycle++;
+            final Intent intent = new Intent(TestedScreen.WAIT_BEFORE_FINISH);
+            intent.setClass(this, LocalScreen.class);
+            startActivity(intent);
+        } else if (next.equals(DO_LOCAL_DIALOG)) {
+            mNextLifecycle++;
+            final Intent intent = new Intent(TestedScreen.WAIT_BEFORE_FINISH);
+            intent.setClass(this, LocalDialog.class);
+            startActivity(intent);
+        }
+    }
+
+    private void setExpectedReceivers(String[] receivers) {
+        mExpectedReceivers = receivers;
+        mNextReceiver = 0;
+    }
+
+    private void setExpectedData(String[] data) {
+        mExpectedData = data;
+        mReceivedData = new boolean[data.length];
+    }
+
+    @SuppressWarnings("deprecation")
+    private Intent makeBroadcastIntent(String action) {
+        final Intent intent = new Intent(action, null);
+        intent.putExtra("caller", mCallTarget);
+        return intent;
+    }
+
+    private void finishGood() {
+        finishWithResult(RESULT_OK, null);
+    }
+
+    private void finishBad(String error) {
+        finishWithResult(RESULT_CANCELED, new Intent().setAction(error));
+    }
+
+    private void finishWithResult(int resultCode, Intent data) {
+        setTestResult(resultCode, data);
+        finish();
+
+        // Member fields set by calling setTestResult above...
+        sCallingTest.activityFinished(mResultCode, mData, mResultStack);
+    }
+
+    private void setTestResult(int resultCode, Intent data) {
+        mHandler.removeCallbacks(mTimeout);
+        unregisterMyReceiver();
+        mResultCode = resultCode;
+        mData = data;
+        mResultStack = new RuntimeException("Original error was here");
+        mResultStack.fillInStackTrace();
+    }
+
+    private void registerMyReceiver(IntentFilter filter) {
+        mReceiverRegistered = true;
+        registerReceiver(mReceiver, filter);
+    }
+
+    private void unregisterMyReceiver() {
+        if (mReceiverRegistered) {
+            mReceiverRegistered = false;
+            unregisterReceiver(mReceiver);
+        }
+    }
+
+    private final Handler mHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+        }
+    };
+
+    static final int GOT_RECEIVE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
+    static final int ERROR_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 1;
+
+    private final Binder mCallTarget = new Binder() {
+        @Override
+        public boolean onTransact(int code, Parcel data, Parcel reply, int flags) {
+            data.setDataPosition(0);
+            data.enforceInterface(LaunchpadActivity.LAUNCH);
+            if (code == GOT_RECEIVE_TRANSACTION) {
+                final String name = data.readString();
+                gotReceive(name, null);
+                return true;
+            } else if (code == ERROR_TRANSACTION) {
+                finishBad(data.readString());
+                return true;
+            }
+            return false;
+        }
+    };
+
+    private final void gotReceive(String name, Intent intent) {
+        synchronized (this) {
+
+            sCallingTest.addIntermediate(mNextReceiver + "-" + name);
+
+            if (mExpectedData != null) {
+                final int n = mExpectedData.length;
+                int i;
+                boolean prev = false;
+                for (i = 0; i < n; i++) {
+                    if (mExpectedData[i].equals(intent.getStringExtra("test"))) {
+                        if (mReceivedData[i]) {
+                            prev = true;
+                            continue;
+                        }
+                        mReceivedData[i] = true;
+                        break;
+                    }
+                }
+                if (i >= n) {
+                    if (prev) {
+                        finishBad("Receive got data too many times: "
+                                + intent.getStringExtra("test"));
+                    } else {
+                        finishBad("Receive got unexpected data: " + intent.getStringExtra("test"));
+                    }
+                    return;
+                }
+            }
+
+            if (mNextReceiver >= mExpectedReceivers.length) {
+                finishBad("Got too many onReceiveIntent() calls!");
+            } else if (!mExpectedReceivers[mNextReceiver].equals(name)) {
+                finishBad("Receive out of order: got " + name + " but expected "
+                        + mExpectedReceivers[mNextReceiver] + " at " + mNextReceiver);
+            } else {
+                mNextReceiver++;
+                if (mNextReceiver == mExpectedReceivers.length) {
+                    mHandler.post(mUnregister);
+                }
+            }
+
+        }
+    }
+
+    private final Runnable mUnregister = new Runnable() {
+        public void run() {
+            if (mReceiverRegistered) {
+                sCallingTest.addIntermediate("before-unregister");
+                unregisterMyReceiver();
+            }
+            sCallingTest.finishTiming(true);
+            finishGood();
+        }
+    };
+
+    private final Runnable mTimeout = new Runnable() {
+        public void run() {
+            Log.i(TAG, "timeout");
+            String msg = "Timeout";
+            if (mExpectedReceivers != null && mNextReceiver < mExpectedReceivers.length) {
+                msg = msg + " waiting for " + mExpectedReceivers[mNextReceiver];
+            }
+            finishBad(msg);
+        }
+    };
+
+    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            gotReceive(RECEIVER_REG, intent);
+        }
+    };
+}
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/os/src/android/os/cts/LocalDialog.java
similarity index 75%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/os/src/android/os/cts/LocalDialog.java
index 16e76c9..6ccca57 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/os/src/android/os/cts/LocalDialog.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,11 +16,7 @@
 
 package android.os.cts;
 
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
+public class LocalDialog extends TestedScreen {
+    public LocalDialog() {
     }
-
-    public static native boolean hasTaggedPointer();
 }
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/os/src/android/os/cts/LocalScreen.java
similarity index 75%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/os/src/android/os/cts/LocalScreen.java
index 16e76c9..0a017c4 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/os/src/android/os/cts/LocalScreen.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 The Android Open Source Project
+ * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,11 +16,7 @@
 
 package android.os.cts;
 
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
+public class LocalScreen extends TestedScreen {
+    public LocalScreen() {
     }
-
-    public static native boolean hasTaggedPointer();
 }
diff --git a/tests/tests/os/src/android/os/cts/LocalService.java b/tests/tests/os/src/android/os/cts/LocalService.java
new file mode 100644
index 0000000..0353c23
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/LocalService.java
@@ -0,0 +1,117 @@
+/*
+ * 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.os.cts;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+import android.os.Parcel;
+import android.os.RemoteException;
+
+public class LocalService extends Service {
+    public static final String SERVICE_LOCAL =
+            "android.os.cts.activity.SERVICE_LOCAL";
+    public static final String SERVICE_LOCAL_GRANTED =
+            "android.os.cts.activity.SERVICE_LOCAL_GRANTED";
+    public static final String SERVICE_LOCAL_DENIED =
+            "android.os.cts.activity.SERVICE_LOCAL_DENIED";
+
+    public static final String REPORT_OBJ_NAME = "report";
+
+    public static final int STARTED_CODE = 1;
+    public static final int DESTROYED_CODE = 2;
+    public static final int SET_REPORTER_CODE = 3;
+    public static final int UNBIND_CODE = 4;
+    public static final int REBIND_CODE = 5;
+
+    private IBinder mReportObject;
+    private int mStartCount = 1;
+
+    private final IBinder mBinder = new Binder() {
+        @Override
+        protected boolean onTransact(int code, Parcel data, Parcel reply,
+                int flags) throws RemoteException {
+            if (code == SET_REPORTER_CODE) {
+                data.enforceInterface(SERVICE_LOCAL);
+                mReportObject = data.readStrongBinder();
+                return true;
+            } else {
+                return super.onTransact(code, data, reply, flags);
+            }
+        }
+    };
+
+
+    public LocalService() {
+    }
+
+    @Override
+    public void onStart(Intent intent, int startId) {
+        if (intent.getExtras() != null) {
+            IBinderParcelable parcelable
+                    = (IBinderParcelable) intent.getExtras().getParcelable(REPORT_OBJ_NAME);
+            mReportObject = parcelable.binder;
+            if (mReportObject != null) {
+                bindAction(STARTED_CODE);
+            }
+        }
+    }
+
+    @Override
+    public void onDestroy() {
+        if (mReportObject != null) {
+            bindAction(DESTROYED_CODE);
+        }
+    }
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return mBinder;
+    }
+
+    @Override
+    public boolean onUnbind(Intent intent) {
+        if (mReportObject != null) {
+            bindAction(UNBIND_CODE);
+        }
+        return true;
+    }
+
+    @Override
+    public void onRebind(Intent intent) {
+        if (mReportObject != null) {
+            bindAction(REBIND_CODE);
+        }
+    }
+
+    private void bindAction(final int bindCode) {
+        try {
+            Parcel data = Parcel.obtain();
+            data.writeInterfaceToken(SERVICE_LOCAL);
+            if (bindCode == STARTED_CODE) {
+                data.writeInt(mStartCount);
+                mStartCount++;
+            }
+            mReportObject.transact(
+                    bindCode, data, null, 0);
+            data.recycle();
+        } catch (RemoteException e) {
+            // fail
+        }
+    }
+}
diff --git a/tests/src/android/os/cts/MessengerService.java b/tests/tests/os/src/android/os/cts/MessengerService.java
similarity index 100%
rename from tests/src/android/os/cts/MessengerService.java
rename to tests/tests/os/src/android/os/cts/MessengerService.java
diff --git a/tests/src/android/os/cts/OSFeatures.java b/tests/tests/os/src/android/os/cts/OSFeatures.java
similarity index 95%
rename from tests/src/android/os/cts/OSFeatures.java
rename to tests/tests/os/src/android/os/cts/OSFeatures.java
index 59556db..9c4660c 100644
--- a/tests/src/android/os/cts/OSFeatures.java
+++ b/tests/tests/os/src/android/os/cts/OSFeatures.java
@@ -18,7 +18,7 @@
 
 public class OSFeatures {
     static {
-        System.loadLibrary("cts_jni");
+        System.loadLibrary("ctsos_jni");
     }
 
     public static native int getNoNewPrivs();
diff --git a/tests/tests/os/src/android/os/cts/ProcessTest.java b/tests/tests/os/src/android/os/cts/ProcessTest.java
index 90c2eb9..2ca0fd0 100644
--- a/tests/tests/os/src/android/os/cts/ProcessTest.java
+++ b/tests/tests/os/src/android/os/cts/ProcessTest.java
@@ -16,7 +16,6 @@
 
 package android.os.cts;
 
-import android.app.cts.ISecondary;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
diff --git a/tests/src/android/os/cts/ReadElf.java b/tests/tests/os/src/android/os/cts/ReadElf.java
similarity index 100%
rename from tests/src/android/os/cts/ReadElf.java
rename to tests/tests/os/src/android/os/cts/ReadElf.java
diff --git a/tests/tests/os/src/android/os/cts/RemoteCallbackListTest.java b/tests/tests/os/src/android/os/cts/RemoteCallbackListTest.java
index 4c3f3cf..e00fe89 100644
--- a/tests/tests/os/src/android/os/cts/RemoteCallbackListTest.java
+++ b/tests/tests/os/src/android/os/cts/RemoteCallbackListTest.java
@@ -17,7 +17,6 @@
 package android.os.cts;
 
 
-import android.app.cts.ISecondary;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/os/src/android/os/cts/TaggedPointer.java
similarity index 94%
rename from tests/src/android/os/cts/TaggedPointer.java
rename to tests/tests/os/src/android/os/cts/TaggedPointer.java
index 16e76c9..11c3eba 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/os/src/android/os/cts/TaggedPointer.java
@@ -19,7 +19,7 @@
 public class TaggedPointer {
 
     static {
-        System.loadLibrary("cts_jni");
+        System.loadLibrary("ctsos_jni");
     }
 
     public static native boolean hasTaggedPointer();
diff --git a/tests/tests/os/src/android/os/cts/TestThread.java b/tests/tests/os/src/android/os/cts/TestThread.java
new file mode 100644
index 0000000..1a28a20
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/TestThread.java
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+package android.os.cts;
+
+/**
+ * Thread class for executing a Runnable containing assertions in a separate thread.
+ * Uncaught exceptions in the Runnable are rethrown in the context of the the thread
+ * calling the <code>runTest()</code> method.
+ */
+public final class TestThread extends Thread {
+    private Throwable mThrowable;
+    private Runnable mTarget;
+
+    public TestThread(Runnable target) {
+        mTarget = target;
+    }
+
+    @Override
+    public final void run() {
+        try {
+            mTarget.run();
+        } catch (Throwable t) {
+            mThrowable = t;
+        }
+    }
+
+    /**
+     * Run the target Runnable object and wait until the test finish or throw
+     * out Exception if test fail.
+     *
+     * @param runTime
+     * @throws Throwable
+     */
+    public void runTest(long runTime) throws Throwable {
+        start();
+        joinAndCheck(runTime);
+    }
+
+    /**
+     * Get the Throwable object which is thrown when test running
+     * @return  The Throwable object
+     */
+    public Throwable getThrowable() {
+        return mThrowable;
+    }
+
+    /**
+     * Set the Throwable object which is thrown when test running
+     * @param t The Throwable object
+     */
+    public void setThrowable(Throwable t) {
+        mThrowable = t;
+    }
+
+    /**
+     * Wait for the test thread to complete and throw the stored exception if there is one.
+     *
+     * @param runTime The time to wait for the test thread to complete.
+     * @throws Throwable
+     */
+    public void joinAndCheck(long runTime) throws Throwable {
+        this.join(runTime);
+        if (this.isAlive()) {
+            this.interrupt();
+            this.join(runTime);
+            throw new Exception("Thread did not finish within allotted time.");
+        }
+        checkException();
+    }
+
+    /**
+     * Check whether there is an exception when running Runnable object.
+     * @throws Throwable
+     */
+    public void checkException() throws Throwable {
+        if (mThrowable != null) {
+            throw mThrowable;
+        }
+    }
+}
diff --git a/tests/tests/os/src/android/os/cts/TestedScreen.java b/tests/tests/os/src/android/os/cts/TestedScreen.java
new file mode 100644
index 0000000..49f3e70
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/TestedScreen.java
@@ -0,0 +1,119 @@
+/*
+ * 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.os.cts;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.Message;
+import android.os.MessageQueue;
+import android.os.SystemClock;
+import android.util.Log;
+
+public class TestedScreen extends Activity {
+    public static final String WAIT_BEFORE_FINISH = "TestedScreen.WAIT_BEFORE_FINISH";
+    public static final String DELIVER_RESULT = "TestedScreen.DELIVER_RESULT";
+    public static final String CLEAR_TASK = "TestedScreen.CLEAR_TASK";
+    private static final String TAG = "TestedScreen" ;
+    public TestedScreen() {
+    }
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        if (LaunchpadActivity.FORWARD_RESULT.equals(getIntent().getAction())) {
+            final Intent intent = new Intent(getIntent());
+            intent.setAction(DELIVER_RESULT);
+            intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
+            startActivity(intent);
+            finish();
+        } else if (DELIVER_RESULT.equals(getIntent().getAction())) {
+            setResult(RESULT_OK, new Intent().setAction(LaunchpadActivity.RETURNED_RESULT));
+            finish();
+        } else if (CLEAR_TASK.equals(getIntent().getAction())) {
+            if (!getIntent().getBooleanExtra(ClearTop.WAIT_CLEAR_TASK, false)) {
+                launchClearTask();
+            }
+        }
+    }
+
+    @Override
+    protected void onRestoreInstanceState(Bundle state) {
+        super.onRestoreInstanceState(state);
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        if (CLEAR_TASK.equals(getIntent().getAction())) {
+            if (getIntent().getBooleanExtra(ClearTop.WAIT_CLEAR_TASK, false)) {
+                Looper.myLooper();
+                Looper.myQueue().addIdleHandler(new Idler());
+            }
+        } else {
+            Looper.myLooper();
+            Looper.myQueue().addIdleHandler(new Idler());
+        }
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+    }
+
+    private void launchClearTask() {
+        final Intent intent = new Intent(getIntent()).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+                .setClass(this, ClearTop.class);
+        startActivity(intent);
+    }
+
+    private final Handler mHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            if (CLEAR_TASK.equals(getIntent().getAction())) {
+                launchClearTask();
+            } else {
+                setResult(RESULT_OK);
+                finish();
+            }
+        }
+    };
+
+    private class Idler implements MessageQueue.IdleHandler {
+        public final boolean queueIdle() {
+            Log.i(TAG, "idle");
+            if (WAIT_BEFORE_FINISH.equals(getIntent().getAction())) {
+                final Message m = Message.obtain();
+                mHandler.sendMessageAtTime(m, SystemClock.uptimeMillis() + 1000);
+            } else if (CLEAR_TASK.equals(getIntent().getAction())) {
+                final Message m = Message.obtain();
+                mHandler.sendMessageAtTime(m, SystemClock.uptimeMillis() + 1000);
+            } else {
+                setResult(RESULT_OK);
+                finish();
+            }
+            return false;
+        }
+    }
+}
diff --git a/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java b/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java
index 45c5e45..a4a5759 100644
--- a/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java
+++ b/tests/tests/os/src/android/os/storage/cts/StorageManagerTest.java
@@ -16,7 +16,7 @@
 
 package android.os.storage.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.os.R;
 
 import android.content.Context;
 import android.content.res.Resources;
diff --git a/tests/tests/permission/src/android/permission/cts/AppWidgetManagerPermissionTest.java b/tests/tests/permission/src/android/permission/cts/AppWidgetManagerPermissionTest.java
index 4223f08..1328f88 100644
--- a/tests/tests/permission/src/android/permission/cts/AppWidgetManagerPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/AppWidgetManagerPermissionTest.java
@@ -51,11 +51,11 @@
         }
 
         try {
-            mAppWidgetManager.bindAppWidgetId(1, new ComponentName(mContext, "foo"));
-            fail("Was able to call bindAppWidgetId");
+            final boolean bound = mAppWidgetManager.bindAppWidgetIdIfAllowed(1,
+                    new ComponentName(mContext, "foo"));
+            assertFalse("Was able to call bindAppWidgetId", bound);
         } catch (SecurityException e) {
             // expected
         }
     }
 }
-
diff --git a/tests/tests/print/src/android/print/cts/BasePrintTest.java b/tests/tests/print/src/android/print/cts/BasePrintTest.java
index a8e8a95..1493bc9 100644
--- a/tests/tests/print/src/android/print/cts/BasePrintTest.java
+++ b/tests/tests/print/src/android/print/cts/BasePrintTest.java
@@ -39,8 +39,10 @@
 import android.print.PrintDocumentAdapter.WriteResultCallback;
 import android.print.PrintManager;
 import android.print.PrinterId;
+import android.print.cts.services.FirstPrintService;
 import android.print.cts.services.PrintServiceCallbacks;
 import android.print.cts.services.PrinterDiscoverySessionCallbacks;
+import android.print.cts.services.SecondPrintService;
 import android.print.cts.services.StubbablePrinterDiscoverySession;
 import android.print.pdf.PrintedPdfDocument;
 import android.printservice.PrintJob;
@@ -68,7 +70,7 @@
  */
 public abstract class BasePrintTest extends UiAutomatorTestCase {
 
-    private static final long OPERATION_TIMEOUT = 10000;
+    private static final long OPERATION_TIMEOUT = 100000000;
 
     private static final String ARG_PRIVILEGED_OPS = "ARG_PRIVILEGED_OPS";
 
diff --git a/tests/tests/print/src/android/print/cts/PrintDocumentAdapterContractTest.java b/tests/tests/print/src/android/print/cts/PrintDocumentAdapterContractTest.java
index 64bc5d6..516db56 100644
--- a/tests/tests/print/src/android/print/cts/PrintDocumentAdapterContractTest.java
+++ b/tests/tests/print/src/android/print/cts/PrintDocumentAdapterContractTest.java
@@ -122,6 +122,9 @@
         // Wait for finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -229,6 +232,9 @@
         // Wait for finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -344,6 +350,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -510,6 +519,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -649,6 +661,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -765,6 +780,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -868,6 +886,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -967,6 +988,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -1055,6 +1079,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -1121,6 +1148,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -1197,6 +1227,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -1283,6 +1316,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -1348,6 +1384,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -1421,6 +1460,9 @@
         // Wait for a finish.
         waitForAdapterFinishCallbackCalled();
 
+        // Wait for the session to be destroyed to isolate tests.
+        waitForPrinterDiscoverySessionDestroyCallbackCalled();
+
         // Verify the expected calls.
         InOrder inOrder = inOrder(adapter);
 
@@ -1517,7 +1559,14 @@
                 }
                 return null;
             }
-        }, null, null, null, null, null);
+        }, null, null, null, null, new Answer<Void>() {
+                @Override
+                public Void answer(InvocationOnMock invocation) throws Throwable {
+                    // Take a note onDestroy was called.
+                    onPrinterDiscoverySessionDestroyCalled();
+                    return null;
+                }
+            });
         return createMockPrintServiceCallbacks(new Answer<PrinterDiscoverySessionCallbacks>() {
             @Override
             public PrinterDiscoverySessionCallbacks answer(InvocationOnMock invocation) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java b/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
index c237ede..dfcf1f5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
@@ -1332,6 +1332,9 @@
             lgamma(in.max32()));
     }
 
+    /* TODO Until -0 handling is corrected in bionic & associated drivers, we temporarily
+     * disable the verification of -0.  We do this with a custom verifier.  Once bionic
+     * is fixed, we can restore computeLgamma and remove verifyLgamma.
     static public void computeLgamma(TestLgamma.ArgumentsFloatIntFloat args, Target t) {
         t.setPrecision(16, 128, false);
         Target.Floaty in = t.new32(args.inX);
@@ -1340,13 +1343,33 @@
         LgammaResult resultMax = lgamma2(in.max32());
         args.out = t.new32(result.lgamma, resultMin.lgamma, resultMax.lgamma);
         args.outY = result.gammaSign;
+    }
+    */
+    static public String verifyLgamma(TestLgamma.ArgumentsFloatIntFloat args, Target t) {
+        t.setPrecision(16, 128, false);
+        Target.Floaty in = t.new32(args.inX);
+        LgammaResult result = lgamma2(in.mid32());
+        LgammaResult resultMin = lgamma2(in.min32());
+        LgammaResult resultMax = lgamma2(in.max32());
+        Target.Floaty expectedOut = t.new32(result.lgamma, resultMin.lgamma, resultMax.lgamma);
+        boolean isNegativeZero = args.inX == 0.f && 1.f / args.inX < 0.f;
         /* TODO The current implementation of bionic does not handle the -0.f case correctly.
-         * It should set the sign to -1 but sets it to 1.  We correct the verifier here
-         * until bionic is fixed.
+         * It should set the sign to -1 but sets it to 1.
          */
-        if (args.inX == 0.f && 1.f / args.inX < 0.f) {
-            args.outY = -1;
+        if (!expectedOut.couldBe(args.out) ||
+            (args.outY != result.gammaSign && !isNegativeZero)) {
+            StringBuilder message = new StringBuilder();
+            message.append(String.format("Input in %14.8g {%8x}:\n", args.inX, Float.floatToRawIntBits(args.inX)));
+            message.append("Expected out: ");
+            message.append(expectedOut.toString());
+            message.append("\n");
+            message.append(String.format("Actual   out: %14.8g {%8x}", args.out, Float.floatToRawIntBits(args.out)));
+            message.append(String.format("Expected outY: %d\n", result.gammaSign));
+            message.append(String.format("Actual   outY: %d\n", args.outY));
+            return message.toString();
         }
+
+        return null;
     }
 
     // TODO The relaxed ulf for the various log are taken from the old tests.
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestLgamma.java b/tests/tests/renderscript/src/android/renderscript/cts/TestLgamma.java
index 8ec06e7..113df19 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestLgamma.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestLgamma.java
@@ -278,7 +278,7 @@
     public class ArgumentsFloatIntFloat {
         public float inX;
         public int outY;
-        public Target.Floaty out;
+        public float out;
     }
 
     private void checkLgammaFloatIntFloat() {
@@ -315,42 +315,26 @@
                 // Extract the inputs.
                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
                 args.inX = arrayInX[i];
-                // Figure out what the outputs should have been.
+                // Extract the outputs.
+                args.outY = arrayOutY[i * 1 + j];
+                args.out = arrayOut[i * 1 + j];
+                // Ask the CoreMathVerifier to validate.
                 Target target = new Target(relaxed);
-                CoreMathVerifier.computeLgamma(args, target);
-                // Validate the outputs.
-                boolean valid = true;
-                if (args.outY != arrayOutY[i * 1 + j]) {
-                    valid = false;
-                }
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
-                    valid = false;
-                }
+                String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
+                boolean valid = errorMessage == null;
                 if (!valid) {
                     StringBuilder message = new StringBuilder();
                     message.append("Input inX: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             args.inX, Float.floatToRawIntBits(args.inX), args.inX));
                     message.append("\n");
-                    message.append("Expected output outY: ");
+                    message.append("Output outY: ");
                     message.append(String.format("%d", args.outY));
                     message.append("\n");
-                    message.append("Actual   output outY: ");
-                    message.append(String.format("%d", arrayOutY[i * 1 + j]));
-                    if (args.outY != arrayOutY[i * 1 + j]) {
-                        message.append(" FAIL");
-                    }
+                    message.append("Output out: ");
+                    message.append(Float.toString(args.out));
                     message.append("\n");
-                    message.append("Expected output out: ");
-                    message.append(args.out.toString());
-                    message.append("\n");
-                    message.append("Actual   output out: ");
-                    message.append(String.format("%14.8g {%8x} %15a",
-                            arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
-                        message.append(" FAIL");
-                    }
-                    message.append("\n");
+                    message.append(errorMessage);
                     assertTrue("Incorrect output for checkLgammaFloatIntFloat" +
                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
                 }
@@ -392,42 +376,26 @@
                 // Extract the inputs.
                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
                 args.inX = arrayInX[i * 2 + j];
-                // Figure out what the outputs should have been.
+                // Extract the outputs.
+                args.outY = arrayOutY[i * 2 + j];
+                args.out = arrayOut[i * 2 + j];
+                // Ask the CoreMathVerifier to validate.
                 Target target = new Target(relaxed);
-                CoreMathVerifier.computeLgamma(args, target);
-                // Validate the outputs.
-                boolean valid = true;
-                if (args.outY != arrayOutY[i * 2 + j]) {
-                    valid = false;
-                }
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
-                    valid = false;
-                }
+                String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
+                boolean valid = errorMessage == null;
                 if (!valid) {
                     StringBuilder message = new StringBuilder();
                     message.append("Input inX: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             args.inX, Float.floatToRawIntBits(args.inX), args.inX));
                     message.append("\n");
-                    message.append("Expected output outY: ");
+                    message.append("Output outY: ");
                     message.append(String.format("%d", args.outY));
                     message.append("\n");
-                    message.append("Actual   output outY: ");
-                    message.append(String.format("%d", arrayOutY[i * 2 + j]));
-                    if (args.outY != arrayOutY[i * 2 + j]) {
-                        message.append(" FAIL");
-                    }
+                    message.append("Output out: ");
+                    message.append(Float.toString(args.out));
                     message.append("\n");
-                    message.append("Expected output out: ");
-                    message.append(args.out.toString());
-                    message.append("\n");
-                    message.append("Actual   output out: ");
-                    message.append(String.format("%14.8g {%8x} %15a",
-                            arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
-                        message.append(" FAIL");
-                    }
-                    message.append("\n");
+                    message.append(errorMessage);
                     assertTrue("Incorrect output for checkLgammaFloat2Int2Float2" +
                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
                 }
@@ -469,42 +437,26 @@
                 // Extract the inputs.
                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
                 args.inX = arrayInX[i * 4 + j];
-                // Figure out what the outputs should have been.
+                // Extract the outputs.
+                args.outY = arrayOutY[i * 4 + j];
+                args.out = arrayOut[i * 4 + j];
+                // Ask the CoreMathVerifier to validate.
                 Target target = new Target(relaxed);
-                CoreMathVerifier.computeLgamma(args, target);
-                // Validate the outputs.
-                boolean valid = true;
-                if (args.outY != arrayOutY[i * 4 + j]) {
-                    valid = false;
-                }
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
-                    valid = false;
-                }
+                String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
+                boolean valid = errorMessage == null;
                 if (!valid) {
                     StringBuilder message = new StringBuilder();
                     message.append("Input inX: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             args.inX, Float.floatToRawIntBits(args.inX), args.inX));
                     message.append("\n");
-                    message.append("Expected output outY: ");
+                    message.append("Output outY: ");
                     message.append(String.format("%d", args.outY));
                     message.append("\n");
-                    message.append("Actual   output outY: ");
-                    message.append(String.format("%d", arrayOutY[i * 4 + j]));
-                    if (args.outY != arrayOutY[i * 4 + j]) {
-                        message.append(" FAIL");
-                    }
+                    message.append("Output out: ");
+                    message.append(Float.toString(args.out));
                     message.append("\n");
-                    message.append("Expected output out: ");
-                    message.append(args.out.toString());
-                    message.append("\n");
-                    message.append("Actual   output out: ");
-                    message.append(String.format("%14.8g {%8x} %15a",
-                            arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
-                        message.append(" FAIL");
-                    }
-                    message.append("\n");
+                    message.append(errorMessage);
                     assertTrue("Incorrect output for checkLgammaFloat3Int3Float3" +
                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
                 }
@@ -546,42 +498,26 @@
                 // Extract the inputs.
                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
                 args.inX = arrayInX[i * 4 + j];
-                // Figure out what the outputs should have been.
+                // Extract the outputs.
+                args.outY = arrayOutY[i * 4 + j];
+                args.out = arrayOut[i * 4 + j];
+                // Ask the CoreMathVerifier to validate.
                 Target target = new Target(relaxed);
-                CoreMathVerifier.computeLgamma(args, target);
-                // Validate the outputs.
-                boolean valid = true;
-                if (args.outY != arrayOutY[i * 4 + j]) {
-                    valid = false;
-                }
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
-                    valid = false;
-                }
+                String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
+                boolean valid = errorMessage == null;
                 if (!valid) {
                     StringBuilder message = new StringBuilder();
                     message.append("Input inX: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             args.inX, Float.floatToRawIntBits(args.inX), args.inX));
                     message.append("\n");
-                    message.append("Expected output outY: ");
+                    message.append("Output outY: ");
                     message.append(String.format("%d", args.outY));
                     message.append("\n");
-                    message.append("Actual   output outY: ");
-                    message.append(String.format("%d", arrayOutY[i * 4 + j]));
-                    if (args.outY != arrayOutY[i * 4 + j]) {
-                        message.append(" FAIL");
-                    }
+                    message.append("Output out: ");
+                    message.append(Float.toString(args.out));
                     message.append("\n");
-                    message.append("Expected output out: ");
-                    message.append(args.out.toString());
-                    message.append("\n");
-                    message.append("Actual   output out: ");
-                    message.append(String.format("%14.8g {%8x} %15a",
-                            arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
-                        message.append(" FAIL");
-                    }
-                    message.append("\n");
+                    message.append(errorMessage);
                     assertTrue("Incorrect output for checkLgammaFloat4Int4Float4" +
                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
                 }
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcos.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcos.java
index bda06c7..430cf59 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcos.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAcos(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAcos(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAcos(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAcos(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcosh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcosh.java
index 7e84c96..d4a840a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcosh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcosh.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAcosh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAcosh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAcosh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAcosh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcospi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcospi.java
index 75a29ae..187b787 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcospi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcospi.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAcospi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAcospi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAcospi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAcospi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsin.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsin.java
index 30bab7e..b9f61a6 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsin.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAsin(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAsin(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAsin(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAsin(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinh.java
index 8edf947..f8382a8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinh.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAsinh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAsinh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAsinh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAsinh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinpi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinpi.java
index 08eb07d..e0029b7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinpi.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAsinpi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAsinpi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAsinpi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAsinpi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan.java
index 316eb6d..26225c5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAtan(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAtan(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAtan(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAtan(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2.java
index 5ca8f05..c33523c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2.java
@@ -79,7 +79,7 @@
                 CoreMathVerifier.computeNativeAtan2(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -98,7 +98,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -148,7 +148,7 @@
                 CoreMathVerifier.computeNativeAtan2(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -167,7 +167,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -217,7 +217,7 @@
                 CoreMathVerifier.computeNativeAtan2(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -236,7 +236,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -286,7 +286,7 @@
                 CoreMathVerifier.computeNativeAtan2(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -305,7 +305,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2pi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2pi.java
index f05d924..dd62b78 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2pi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2pi.java
@@ -79,7 +79,7 @@
                 CoreMathVerifier.computeNativeAtan2pi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -98,7 +98,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -148,7 +148,7 @@
                 CoreMathVerifier.computeNativeAtan2pi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -167,7 +167,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -217,7 +217,7 @@
                 CoreMathVerifier.computeNativeAtan2pi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -236,7 +236,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -286,7 +286,7 @@
                 CoreMathVerifier.computeNativeAtan2pi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -305,7 +305,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanh.java
index 95f4704..6161483 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanh.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAtanh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAtanh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAtanh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAtanh(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanpi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanpi.java
index bd07ad8..1e88568 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanpi.java
@@ -72,7 +72,7 @@
                 CoreMathVerifier.computeNativeAtanpi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -87,7 +87,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -131,7 +131,7 @@
                 CoreMathVerifier.computeNativeAtanpi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -146,7 +146,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -190,7 +190,7 @@
                 CoreMathVerifier.computeNativeAtanpi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -205,7 +205,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -249,7 +249,7 @@
                 CoreMathVerifier.computeNativeAtanpi(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -264,7 +264,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSincos.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSincos.java
index c497ed0..380f2b4 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSincos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSincos.java
@@ -79,10 +79,10 @@
                 CoreMathVerifier.computeNativeSincos(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.outCosptr.couldBe(arrayOutCosptr[i * 1 + j])) {
+                if (!args.outCosptr.couldBe(arrayOutCosptr[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
-                if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -97,7 +97,7 @@
                     message.append("Actual   output outCosptr: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOutCosptr[i * 1 + j], Float.floatToRawIntBits(arrayOutCosptr[i * 1 + j]), arrayOutCosptr[i * 1 + j]));
-                    if (!args.outCosptr.couldBe(arrayOutCosptr[i * 1 + j])) {
+                    if (!args.outCosptr.couldBe(arrayOutCosptr[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -107,7 +107,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 1 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -157,10 +157,10 @@
                 CoreMathVerifier.computeNativeSincos(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.outCosptr.couldBe(arrayOutCosptr[i * 2 + j])) {
+                if (!args.outCosptr.couldBe(arrayOutCosptr[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
-                if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -175,7 +175,7 @@
                     message.append("Actual   output outCosptr: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOutCosptr[i * 2 + j], Float.floatToRawIntBits(arrayOutCosptr[i * 2 + j]), arrayOutCosptr[i * 2 + j]));
-                    if (!args.outCosptr.couldBe(arrayOutCosptr[i * 2 + j])) {
+                    if (!args.outCosptr.couldBe(arrayOutCosptr[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -185,7 +185,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 2 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -235,10 +235,10 @@
                 CoreMathVerifier.computeNativeSincos(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j])) {
+                if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -253,7 +253,7 @@
                     message.append("Actual   output outCosptr: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOutCosptr[i * 4 + j], Float.floatToRawIntBits(arrayOutCosptr[i * 4 + j]), arrayOutCosptr[i * 4 + j]));
-                    if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j])) {
+                    if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -263,7 +263,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -313,10 +313,10 @@
                 CoreMathVerifier.computeNativeSincos(args, target);
                 // Validate the outputs.
                 boolean valid = true;
-                if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j])) {
+                if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
-                if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                     valid = false;
                 }
                 if (!valid) {
@@ -331,7 +331,7 @@
                     message.append("Actual   output outCosptr: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOutCosptr[i * 4 + j], Float.floatToRawIntBits(arrayOutCosptr[i * 4 + j]), arrayOutCosptr[i * 4 + j]));
-                    if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j])) {
+                    if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
@@ -341,7 +341,7 @@
                     message.append("Actual   output out: ");
                     message.append(String.format("%14.8g {%8x} %15a",
                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
-                    if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+                    if (!args.out.couldBe(arrayOut[i * 4 + j], 0.0005)) {
                         message.append(" FAIL");
                     }
                     message.append("\n");
diff --git a/tests/tests/security/Android.mk b/tests/tests/security/Android.mk
index 032bec3..6a7833d 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -31,6 +31,22 @@
 
 LOCAL_SDK_VERSION := current
 
+intermediates.COMMON := $(call intermediates-dir-for,APPS,$(LOCAL_PACKAGE_NAME),,COMMON)
+
+sepolicy_asset_dir := $(intermediates.COMMON)/assets
+
+LOCAL_ASSET_DIR := $(sepolicy_asset_dir)
+
 include $(BUILD_CTS_PACKAGE)
 
+selinux_policy.xml := $(sepolicy_asset_dir)/selinux_policy.xml
+selinux_policy_parser := packages/experimental/SELinux/CTS/src/gen_SELinux_CTS.py
+general_sepolicy_policy.conf := $(call intermediates-dir-for,ETC,general_sepolicy.conf)/general_sepolicy.conf
+$(selinux_policy.xml): PRIVATE_POLICY_PARSER := $(selinux_policy_parser)
+$(selinux_policy.xml): $(general_sepolicy_policy.conf) $(selinux_policy_parser)
+	mkdir -p $(dir $@)
+	$(PRIVATE_POLICY_PARSER) $< $@ neverallow_only=t
+
+$(R_file_stamp): $(selinux_policy.xml)
+
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/security/assets/selinux_policy.xml b/tests/tests/security/assets/selinux_policy.xml
deleted file mode 100644
index f7e816a..0000000
--- a/tests/tests/security/assets/selinux_policy.xml
+++ /dev/null
@@ -1,1733 +0,0 @@
-<?xml version="1.0" ?>
-<SELinux_AVC_Rules>
-    <avc_rule name="1" type="neverallow">
-        <type type="source">shell</type>
-        <type type="source">nfc</type>
-        <type type="source">platform_app</type>
-        <type type="source">bluetooth</type>
-        <type type="source">radio</type>
-        <type type="source">isolated_app</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_app</type>
-        <type type="source">release_app</type>
-        <type type="source">shared_app</type>
-        <type type="target">kernel</type>
-        <obj_class name="security">
-            <permission>load_policy</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="2" type="neverallow">
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">runas</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">nfc</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">shared_app</type>
-        <type type="target">audio_data_file</type>
-        <type type="target">sysfs_nfc_power_writable</type>
-        <type type="target">ion_device</type>
-        <type type="target">debuggerd</type>
-        <type type="target">netd</type>
-        <type type="target">system_server_tmpfs</type>
-        <type type="target">lmkd</type>
-        <type type="target">uhid_device</type>
-        <type type="target">init_shell</type>
-        <type type="target">radio</type>
-        <type type="target">zygote_socket</type>
-        <type type="target">system_wpa_socket</type>
-        <type type="target">sockfs</type>
-        <type type="target">selinuxfs</type>
-        <type type="target">dumpstate_socket</type>
-        <type type="target">untrusted_app_devpts</type>
-        <type type="target">shell_prop</type>
-        <type type="target">property_socket</type>
-        <type type="target">runas</type>
-        <type type="target">debuggerd_exec</type>
-        <type type="target">mqueue</type>
-        <type type="target">shell_data_file</type>
-        <type type="target">drmserver_tmpfs</type>
-        <type type="target">debuggerd_tmpfs</type>
-        <type type="target">init</type>
-        <type type="target">netif</type>
-        <type type="target">device</type>
-        <type type="target">apk_tmp_file</type>
-        <type type="target">logd</type>
-        <type type="target">servicemanager</type>
-        <type type="target">gpsd_tmpfs</type>
-        <type type="target">bluetooth_socket</type>
-        <type type="target">adb_keys_file</type>
-        <type type="target">sdcardd_exec</type>
-        <type type="target">system_app_tmpfs</type>
-        <type type="target">mediaserver_exec</type>
-        <type type="target">ppp_exec</type>
-        <type type="target">media_rw_data_file</type>
-        <type type="target">clatd_exec</type>
-        <type type="target">ueventd</type>
-        <type type="target">labeledfs</type>
-        <type type="target">asec_image_file</type>
-        <type type="target">camera_device</type>
-        <type type="target">efs_file</type>
-        <type type="target">media_app</type>
-        <type type="target">tmpfs</type>
-        <type type="target">bluetooth_prop</type>
-        <type type="target">logdr_socket</type>
-        <type type="target">nfc</type>
-        <type type="target">zygote_tmpfs</type>
-        <type type="target">cache_backup_file</type>
-        <type type="target">drmserver_socket</type>
-        <type type="target">logd_exec</type>
-        <type type="target">nfc_tmpfs</type>
-        <type type="target">zygote</type>
-        <type type="target">hostapd</type>
-        <type type="target">tee_data_file</type>
-        <type type="target">lmkd_socket</type>
-        <type type="target">zoneinfo_data_file</type>
-        <type type="target">cgroup</type>
-        <type type="target">platform_app</type>
-        <type type="target">release_app</type>
-        <type type="target">qtaguid_device</type>
-        <type type="target">surfaceflinger_tmpfs</type>
-        <type type="target">shm</type>
-        <type type="target">hci_attach_tmpfs</type>
-        <type type="target">rild_exec</type>
-        <type type="target">kernel</type>
-        <type type="target">system_ndebug_socket</type>
-        <type type="target">hci_attach_dev</type>
-        <type type="target">cpuctl_device</type>
-        <type type="target">iio_device</type>
-        <type type="target">dhcp</type>
-        <type type="target">audio_device</type>
-        <type type="target">bootanim_exec</type>
-        <type type="target">tee</type>
-        <type type="target">wpa_exec</type>
-        <type type="target">bluetooth</type>
-        <type type="target">sysfs_lowmemorykiller</type>
-        <type type="target">mdnsd_exec</type>
-        <type type="target">console_device</type>
-        <type type="target">rild</type>
-        <type type="target">hw_random_device</type>
-        <type type="target">radio_prop</type>
-        <type type="target">wallpaper_file</type>
-        <type type="target">surfaceflinger_exec</type>
-        <type type="target">audio_prop</type>
-        <type type="target">port</type>
-        <type type="target">gps_device</type>
-        <type type="target">vcs_device</type>
-        <type type="target">alarm_device</type>
-        <type type="target">keystore_tmpfs</type>
-        <type type="target">logd_socket</type>
-        <type type="target">inputflinger_exec</type>
-        <type type="target">gpu_device</type>
-        <type type="target">unlabeled</type>
-        <type type="target">racoon_exec</type>
-        <type type="target">init_tmpfs</type>
-        <type type="target">binder_device</type>
-        <type type="target">servicemanager_tmpfs</type>
-        <type type="target">sysfs_wake_lock</type>
-        <type type="target">system_app</type>
-        <type type="target">vold_exec</type>
-        <type type="target">powerctl_prop</type>
-        <type type="target">proc</type>
-        <type type="target">tee_device</type>
-        <type type="target">su_exec</type>
-        <type type="target">usermodehelper</type>
-        <type type="target">ppp_device</type>
-        <type type="target">watchdog_device</type>
-        <type type="target">netd_tmpfs</type>
-        <type type="target">debugfs</type>
-        <type type="target">wpa_socket</type>
-        <type type="target">rpmsg_device</type>
-        <type type="target">anr_data_file</type>
-        <type type="target">lmkd_tmpfs</type>
-        <type type="target">mdnsd_tmpfs</type>
-        <type type="target">logd_tmpfs</type>
-        <type type="target">proc_bluetooth_writable</type>
-        <type type="target">dhcp_exec</type>
-        <type type="target">gpsd</type>
-        <type type="target">log_device</type>
-        <type type="target">mediaserver_tmpfs</type>
-        <type type="target">security_prop</type>
-        <type type="target">vold_tmpfs</type>
-        <type type="target">system_server</type>
-        <type type="target">runas_exec</type>
-        <type type="target">adbd_socket</type>
-        <type type="target">radio_data_file</type>
-        <type type="target">tee_exec</type>
-        <type type="target">backup_data_file</type>
-        <type type="target">full_device</type>
-        <type type="target">kmsg_device</type>
-        <type type="target">ram_device</type>
-        <type type="target">inotify</type>
-        <type type="target">loop_device</type>
-        <type type="target">mtd_device</type>
-        <type type="target">random_device</type>
-        <type type="target">apk_private_tmp_file</type>
-        <type type="target">installd_socket</type>
-        <type type="target">camera_data_file</type>
-        <type type="target">uncrypt</type>
-        <type type="target">asec_public_file</type>
-        <type type="target">mediaserver</type>
-        <type type="target">graphics_device</type>
-        <type type="target">dumpstate_tmpfs</type>
-        <type type="target">usb_device</type>
-        <type type="target">vold</type>
-        <type type="target">drm_data_file</type>
-        <type type="target">sdcard_external</type>
-        <type type="target">gps_control</type>
-        <type type="target">mdns_socket</type>
-        <type type="target">logd_debug</type>
-        <type type="target">rild_debug_socket</type>
-        <type type="target">mtp_tmpfs</type>
-        <type type="target">release_app_tmpfs</type>
-        <type type="target">root_block_device</type>
-        <type type="target">dnsmasq</type>
-        <type type="target">sdcard_internal</type>
-        <type type="target">dm_device</type>
-        <type type="target">download_file</type>
-        <type type="target">inputflinger_tmpfs</type>
-        <type type="target">netd_socket</type>
-        <type type="target">racoon_tmpfs</type>
-        <type type="target">sensors_device</type>
-        <type type="target">hostapd_exec</type>
-        <type type="target">watchdogd</type>
-        <type type="target">system_file</type>
-        <type type="target">pipefs</type>
-        <type type="target">fscklogs</type>
-        <type type="target">rild_prop</type>
-        <type type="target">hci_attach_exec</type>
-        <type type="target">gpsd_exec</type>
-        <type type="target">bootanim_tmpfs</type>
-        <type type="target">servicemanager_exec</type>
-        <type type="target">proc_net</type>
-        <type type="target">shell_exec</type>
-        <type type="target">null_device</type>
-        <type type="target">debug_prop</type>
-        <type type="target">serial_device</type>
-        <type type="target">bluetooth_tmpfs</type>
-        <type type="target">sysfs_writable</type>
-        <type type="target">devpts</type>
-        <type type="target">wpa_tmpfs</type>
-        <type type="target">racoon</type>
-        <type type="target">shell</type>
-        <type type="target">video_device</type>
-        <type type="target">racoon_socket</type>
-        <type type="target">usbaccessory_device</type>
-        <type type="target">dumpstate</type>
-        <type type="target">adbd</type>
-        <type type="target">bootanim</type>
-        <type type="target">owntty_device</type>
-        <type type="target">untrusted_app</type>
-        <type type="target">sysfs_bluetooth_writable</type>
-        <type type="target">mtp_device</type>
-        <type type="target">vold_prop</type>
-        <type type="target">ctl_default_prop</type>
-        <type type="target">vpn_data_file</type>
-        <type type="target">dnsmasq_exec</type>
-        <type type="target">socket_device</type>
-        <type type="target">keystore_data_file</type>
-        <type type="target">installd_tmpfs</type>
-        <type type="target">sysfs_devices_system_cpu</type>
-        <type type="target">drmserver_exec</type>
-        <type type="target">proc_security</type>
-        <type type="target">sysfs</type>
-        <type type="target">properties_device</type>
-        <type type="target">block_device</type>
-        <type type="target">gps_data_file</type>
-        <type type="target">mtp</type>
-        <type type="target">inputflinger</type>
-        <type type="target">surfaceflinger</type>
-        <type type="target">systemkeys_data_file</type>
-        <type type="target">cache_file</type>
-        <type type="target">dalvikcache_data_file</type>
-        <type type="target">mdnsd</type>
-        <type type="target">mdnsd_socket</type>
-        <type type="target">lmkd_exec</type>
-        <type type="target">netd_exec</type>
-        <type type="target">nfc_device</type>
-        <type type="target">kmem_device</type>
-        <type type="target">ashmem_device</type>
-        <type type="target">sdcardd</type>
-        <type type="target">hci_attach</type>
-        <type type="target">dnsproxyd_socket</type>
-        <type type="target">wifi_data_file</type>
-        <type type="target">gps_socket</type>
-        <type type="target">fuse_device</type>
-        <type type="target">dhcp_tmpfs</type>
-        <type type="target">mtp_exec</type>
-        <type type="target">nfc_data_file</type>
-        <type type="target">tee_tmpfs</type>
-        <type type="target">default_prop</type>
-        <type type="target">input_device</type>
-        <type type="target">dumpstate_exec</type>
-        <type type="target">drmserver</type>
-        <type type="target">logdw_socket</type>
-        <type type="target">uncrypt_tmpfs</type>
-        <type type="target">rild_tmpfs</type>
-        <type type="target">zygote_exec</type>
-        <type type="target">keystore</type>
-        <type type="target">radio_tmpfs</type>
-        <type type="target">clatd</type>
-        <type type="target">zero_device</type>
-        <type type="target">recovery</type>
-        <type type="target">ctl_dumpstate_prop</type>
-        <type type="target">adb_device</type>
-        <type type="target">ppp</type>
-        <type type="target">rild_socket</type>
-        <type type="target">ptmx_device</type>
-        <type type="target">apk_private_data_file</type>
-        <type type="target">tun_device</type>
-        <type type="target">uncrypt_exec</type>
-        <type type="target">media_data_file</type>
-        <type type="target">media_app_tmpfs</type>
-        <type type="target">untrusted_app_tmpfs</type>
-        <type type="target">ctl_rildaemon_prop</type>
-        <type type="target">healthd</type>
-        <type type="target">node</type>
-        <type type="target">isolated_app_tmpfs</type>
-        <type type="target">radio_device</type>
-        <type type="target">urandom_device</type>
-        <type type="target">tombstone_data_file</type>
-        <type type="target">shared_app_tmpfs</type>
-        <type type="target">security_file</type>
-        <type type="target">system_data_file</type>
-        <type type="target">qtaguid_proc</type>
-        <type type="target">tty_device</type>
-        <type type="target">sdcardd_tmpfs</type>
-        <type type="target">isolated_app</type>
-        <type type="target">ueventd_tmpfs</type>
-        <type type="target">installd_exec</type>
-        <type type="target">system_prop</type>
-        <type type="target">platform_app_tmpfs</type>
-        <type type="target">wpa</type>
-        <type type="target">rootfs</type>
-        <type type="target">app_data_file</type>
-        <type type="target">apk_data_file</type>
-        <type type="target">dhcp_data_file</type>
-        <type type="target">asec_apk_file</type>
-        <type type="target">platform_app_data_file</type>
-        <type type="target">keystore_exec</type>
-        <type type="target">bluetooth_data_file</type>
-        <type type="target">klog_device</type>
-        <type type="target">debuggerd_prop</type>
-        <type type="target">vold_socket</type>
-        <type type="target">bluetooth_efs_file</type>
-        <type type="target">installd</type>
-        <type type="target">shell_tmpfs</type>
-        <type type="target">shared_app</type>
-        <obj_class name="fifo_file">
-            <permission>relabelto</permission>
-        </obj_class>
-        <obj_class name="chr_file">
-            <permission>relabelto</permission>
-        </obj_class>
-        <obj_class name="file">
-            <permission>relabelto</permission>
-        </obj_class>
-        <obj_class name="sock_file">
-            <permission>relabelto</permission>
-        </obj_class>
-        <obj_class name="blk_file">
-            <permission>relabelto</permission>
-        </obj_class>
-        <obj_class name="lnk_file">
-            <permission>relabelto</permission>
-        </obj_class>
-        <obj_class name="dir">
-            <permission>relabelto</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="3" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">init</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">self</type>
-        <obj_class name="capability">
-            <permission>sys_ptrace</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="4" type="neverallow">
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">runas</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">self</type>
-        <obj_class name="capability">
-            <permission>sys_rawio</permission>
-            <permission>mknod</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="5" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">init</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">self</type>
-        <obj_class name="capability2">
-            <permission>mac_override</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="6" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">runas</type>
-        <type type="source">init</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">self</type>
-        <obj_class name="capability2">
-            <permission>mac_admin</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="7" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">kernel</type>
-        <obj_class name="security">
-            <permission>load_policy</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="8" type="neverallow">
-        <type type="source">vold</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">init</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">kernel</type>
-        <obj_class name="security">
-            <permission>setenforce</permission>
-            <permission>setcheckreqprot</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="9" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">init</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">system_server_tmpfs</type>
-        <type type="target">logdr_socket</type>
-        <type type="target">lmkd_socket</type>
-        <type type="target">system_wpa_socket</type>
-        <type type="target">ueventd_tmpfs</type>
-        <type type="target">dumpstate_socket</type>
-        <type type="target">wpa_tmpfs</type>
-        <type type="target">property_socket</type>
-        <type type="target">shell_data_file</type>
-        <type type="target">debuggerd_tmpfs</type>
-        <type type="target">bootanim_tmpfs</type>
-        <type type="target">apk_tmp_file</type>
-        <type type="target">gpsd_tmpfs</type>
-        <type type="target">bluetooth_socket</type>
-        <type type="target">adb_keys_file</type>
-        <type type="target">system_app_tmpfs</type>
-        <type type="target">media_rw_data_file</type>
-        <type type="target">shared_app_tmpfs</type>
-        <type type="target">backup_data_file</type>
-        <type type="target">zygote_socket</type>
-        <type type="target">tee_data_file</type>
-        <type type="target">cache_backup_file</type>
-        <type type="target">drmserver_socket</type>
-        <type type="target">system_ndebug_socket</type>
-        <type type="target">nfc_tmpfs</type>
-        <type type="target">zoneinfo_data_file</type>
-        <type type="target">radio_data_file</type>
-        <type type="target">surfaceflinger_tmpfs</type>
-        <type type="target">apk_private_tmp_file</type>
-        <type type="target">hci_attach_tmpfs</type>
-        <type type="target">rild_debug_socket</type>
-        <type type="target">wallpaper_file</type>
-        <type type="target">sdcardd_tmpfs</type>
-        <type type="target">keystore_tmpfs</type>
-        <type type="target">bluetooth_data_file</type>
-        <type type="target">init_tmpfs</type>
-        <type type="target">servicemanager_tmpfs</type>
-        <type type="target">efs_file</type>
-        <type type="target">installd_socket</type>
-        <type type="target">inputflinger_tmpfs</type>
-        <type type="target">netd_tmpfs</type>
-        <type type="target">wpa_socket</type>
-        <type type="target">anr_data_file</type>
-        <type type="target">lmkd_tmpfs</type>
-        <type type="target">mdnsd_tmpfs</type>
-        <type type="target">logd_tmpfs</type>
-        <type type="target">mediaserver_tmpfs</type>
-        <type type="target">vold_tmpfs</type>
-        <type type="target">dnsproxyd_socket</type>
-        <type type="target">adbd_socket</type>
-        <type type="target">camera_data_file</type>
-        <type type="target">asec_public_file</type>
-        <type type="target">dumpstate_tmpfs</type>
-        <type type="target">drm_data_file</type>
-        <type type="target">gps_control</type>
-        <type type="target">logd_debug</type>
-        <type type="target">mtp_tmpfs</type>
-        <type type="target">release_app_tmpfs</type>
-        <type type="target">download_file</type>
-        <type type="target">netd_socket</type>
-        <type type="target">racoon_tmpfs</type>
-        <type type="target">system_file</type>
-        <type type="target">asec_image_file</type>
-        <type type="target">tombstone_data_file</type>
-        <type type="target">racoon_socket</type>
-        <type type="target">logd_socket</type>
-        <type type="target">untrusted_app_tmpfs</type>
-        <type type="target">vpn_data_file</type>
-        <type type="target">keystore_data_file</type>
-        <type type="target">bluetooth_tmpfs</type>
-        <type type="target">drmserver_tmpfs</type>
-        <type type="target">gps_data_file</type>
-        <type type="target">systemkeys_data_file</type>
-        <type type="target">cache_file</type>
-        <type type="target">dalvikcache_data_file</type>
-        <type type="target">installd_tmpfs</type>
-        <type type="target">mdnsd_socket</type>
-        <type type="target">mdns_socket</type>
-        <type type="target">wifi_data_file</type>
-        <type type="target">gps_socket</type>
-        <type type="target">dhcp_tmpfs</type>
-        <type type="target">nfc_data_file</type>
-        <type type="target">tee_tmpfs</type>
-        <type type="target">zygote_tmpfs</type>
-        <type type="target">uncrypt_tmpfs</type>
-        <type type="target">rild_tmpfs</type>
-        <type type="target">isolated_app_tmpfs</type>
-        <type type="target">radio_tmpfs</type>
-        <type type="target">rild_socket</type>
-        <type type="target">media_data_file</type>
-        <type type="target">media_app_tmpfs</type>
-        <type type="target">audio_data_file</type>
-        <type type="target">unlabeled</type>
-        <type type="target">security_file</type>
-        <type type="target">system_data_file</type>
-        <type type="target">bluetooth_efs_file</type>
-        <type type="target">platform_app_tmpfs</type>
-        <type type="target">app_data_file</type>
-        <type type="target">dhcp_data_file</type>
-        <type type="target">asec_apk_file</type>
-        <type type="target">platform_app_data_file</type>
-        <type type="target">logdw_socket</type>
-        <type type="target">apk_private_data_file</type>
-        <type type="target">vold_socket</type>
-        <type type="target">apk_data_file</type>
-        <type type="target">shell_tmpfs</type>
-        <obj_class name="file">
-            <permission>entrypoint</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="10" type="neverallow">
-        <type type="source">vold</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">kmem_device</type>
-        <obj_class name="chr_file">
-            <permission>rename</permission>
-            <permission>lock</permission>
-            <permission>quotaon</permission>
-            <permission>execute_no_trans</permission>
-            <permission>open</permission>
-            <permission>append</permission>
-            <permission>create</permission>
-            <permission>write</permission>
-            <permission>relabelfrom</permission>
-            <permission>getattr</permission>
-            <permission>entrypoint</permission>
-            <permission>read</permission>
-            <permission>mounton</permission>
-            <permission>ioctl</permission>
-            <permission>link</permission>
-            <permission>unlink</permission>
-            <permission>swapon</permission>
-            <permission>execute</permission>
-            <permission>setattr</permission>
-            <permission>execmod</permission>
-            <permission>relabelto</permission>
-            <permission>audit_access</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="11" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">init</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">kmem_device</type>
-        <obj_class name="chr_file">
-            <permission>rename</permission>
-            <permission>execute</permission>
-            <permission>open</permission>
-            <permission>read</permission>
-            <permission>lock</permission>
-            <permission>audit_access</permission>
-            <permission>quotaon</permission>
-            <permission>getattr</permission>
-            <permission>execute_no_trans</permission>
-            <permission>mounton</permission>
-            <permission>write</permission>
-            <permission>relabelfrom</permission>
-            <permission>ioctl</permission>
-            <permission>link</permission>
-            <permission>entrypoint</permission>
-            <permission>swapon</permission>
-            <permission>execmod</permission>
-            <permission>append</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="12" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">usermodehelper</type>
-        <obj_class name="file">
-            <permission>write</permission>
-            <permission>append</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="13" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">proc_security</type>
-        <obj_class name="file">
-            <permission>write</permission>
-            <permission>append</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="14" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">init</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">init</type>
-        <obj_class name="process">
-            <permission>ptrace</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="15" type="neverallow">
-        <type type="source">kernel</type>
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">vold</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">recovery</type>
-        <type type="source">runas</type>
-        <type type="source">init</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">init</type>
-        <obj_class name="binder">
-            <permission>call</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="16" type="neverallow">
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">runas</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">zygote</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">block_device</type>
-        <obj_class name="blk_file">
-            <permission>read</permission>
-            <permission>write</permission>
-            <permission>open</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="17" type="neverallow">
-        <type type="source">sdcardd</type>
-        <type type="source">init_shell</type>
-        <type type="source">adbd</type>
-        <type type="source">debuggerd</type>
-        <type type="source">netd</type>
-        <type type="source">tee</type>
-        <type type="source">bluetooth</type>
-        <type type="source">lmkd</type>
-        <type type="source">surfaceflinger</type>
-        <type type="source">mdnsd</type>
-        <type type="source">radio</type>
-        <type type="source">hci_attach</type>
-        <type type="source">clatd</type>
-        <type type="source">watchdogd</type>
-        <type type="source">drmserver</type>
-        <type type="source">keystore</type>
-        <type type="source">runas</type>
-        <type type="source">servicemanager</type>
-        <type type="source">dhcp</type>
-        <type type="source">shell</type>
-        <type type="source">uncrypt</type>
-        <type type="source">untrusted_app</type>
-        <type type="source">ueventd</type>
-        <type type="source">gpsd</type>
-        <type type="source">isolated_app</type>
-        <type type="source">system_app</type>
-        <type type="source">media_app</type>
-        <type type="source">system_server</type>
-        <type type="source">wpa</type>
-        <type type="source">racoon</type>
-        <type type="source">dumpstate</type>
-        <type type="source">nfc</type>
-        <type type="source">shared_app</type>
-        <type type="source">hostapd</type>
-        <type type="source">platform_app</type>
-        <type type="source">mtp</type>
-        <type type="source">inputflinger</type>
-        <type type="source">logd</type>
-        <type type="source">rild</type>
-        <type type="source">dnsmasq</type>
-        <type type="source">healthd</type>
-        <type type="source">mediaserver</type>
-        <type type="source">bootanim</type>
-        <type type="source">ppp</type>
-        <type type="source">release_app</type>
-        <type type="source">installd</type>
-        <type type="target">sysfs_nfc_power_writable</type>
-        <type type="target">sysfs_lowmemorykiller</type>
-        <type type="target">selinuxfs</type>
-        <type type="target">untrusted_app_devpts</type>
-        <type type="target">tmpfs</type>
-        <type type="target">sysfs</type>
-        <type type="target">sockfs</type>
-        <type type="target">proc_net</type>
-        <type type="target">sysfs_wake_lock</type>
-        <type type="target">rootfs</type>
-        <type type="target">proc</type>
-        <type type="target">usermodehelper</type>
-        <type type="target">devpts</type>
-        <type type="target">debugfs</type>
-        <type type="target">qtaguid_proc</type>
-        <type type="target">sysfs_bluetooth_writable</type>
-        <type type="target">labeledfs</type>
-        <type type="target">device</type>
-        <type type="target">pipefs</type>
-        <type type="target">mqueue</type>
-        <type type="target">sysfs_devices_system_cpu</type>
-        <type type="target">sysfs_writable</type>
-        <type type="target">proc_security</type>
-        <type type="target">inotify</type>
-        <type type="target">proc_bluetooth_writable</type>
-        <type type="target">cgroup</type>
-        <type type="target">shm</type>
-        <obj_class name="filesystem">
-            <permission>relabelfrom</permission>
-            <permission>relabelto</permission>
-            <permission>mount</permission>
-            <permission>remount</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="18" type="neverallow">
-        <type type="source">logd</type>
-        <type type="target">ashmem_device</type>
-        <type type="target">fscklogs</type>
-        <type type="target">cpuctl_device</type>
-        <type type="target">iio_device</type>
-        <type type="target">audio_device</type>
-        <type type="target">root_block_device</type>
-        <type type="target">properties_device</type>
-        <type type="target">console_device</type>
-        <type type="target">dm_device</type>
-        <type type="target">hw_random_device</type>
-        <type type="target">sensors_device</type>
-        <type type="target">input_device</type>
-        <type type="target">full_device</type>
-        <type type="target">gps_device</type>
-        <type type="target">vcs_device</type>
-        <type type="target">alarm_device</type>
-        <type type="target">video_device</type>
-        <type type="target">gpu_device</type>
-        <type type="target">adb_device</type>
-        <type type="target">ion_device</type>
-        <type type="target">ptmx_device</type>
-        <type type="target">binder_device</type>
-        <type type="target">null_device</type>
-        <type type="target">tun_device</type>
-        <type type="target">mtp_device</type>
-        <type type="target">rpmsg_device</type>
-        <type type="target">fuse_device</type>
-        <type type="target">watchdog_device</type>
-        <type type="target">radio_device</type>
-        <type type="target">urandom_device</type>
-        <type type="target">usbaccessory_device</type>
-        <type type="target">kmsg_device</type>
-        <type type="target">serial_device</type>
-        <type type="target">camera_device</type>
-        <type type="target">log_device</type>
-        <type type="target">owntty_device</type>
-        <type type="target">device</type>
-        <type type="target">zero_device</type>
-        <type type="target">qtaguid_device</type>
-        <type type="target">tty_device</type>
-        <type type="target">socket_device</type>
-        <type type="target">block_device</type>
-        <type type="target">mtd_device</type>
-        <type type="target">random_device</type>
-        <type type="target">uhid_device</type>
-        <type type="target">tee_device</type>
-        <type type="target">loop_device</type>
-        <type type="target">klog_device</type>
-        <type type="target">ppp_device</type>
-        <type type="target">graphics_device</type>
-        <type type="target">nfc_device</type>
-        <type type="target">ram_device</type>
-        <type type="target">kmem_device</type>
-        <type type="target">hci_attach_dev</type>
-        <type type="target">usb_device</type>
-        <obj_class name="blk_file">
-            <permission>read</permission>
-            <permission>write</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="19" type="neverallow">
-        <type type="source">logd</type>
-        <type type="target">kernel</type>
-        <type type="target">sdcardd</type>
-        <type type="target">init_shell</type>
-        <type type="target">adbd</type>
-        <type type="target">vold</type>
-        <type type="target">debuggerd</type>
-        <type type="target">netd</type>
-        <type type="target">tee</type>
-        <type type="target">bluetooth</type>
-        <type type="target">lmkd</type>
-        <type type="target">surfaceflinger</type>
-        <type type="target">mdnsd</type>
-        <type type="target">radio</type>
-        <type type="target">hci_attach</type>
-        <type type="target">clatd</type>
-        <type type="target">watchdogd</type>
-        <type type="target">drmserver</type>
-        <type type="target">keystore</type>
-        <type type="target">recovery</type>
-        <type type="target">runas</type>
-        <type type="target">init</type>
-        <type type="target">servicemanager</type>
-        <type type="target">dhcp</type>
-        <type type="target">shell</type>
-        <type type="target">uncrypt</type>
-        <type type="target">untrusted_app</type>
-        <type type="target">ueventd</type>
-        <type type="target">gpsd</type>
-        <type type="target">isolated_app</type>
-        <type type="target">system_app</type>
-        <type type="target">media_app</type>
-        <type type="target">system_server</type>
-        <type type="target">wpa</type>
-        <type type="target">racoon</type>
-        <type type="target">dumpstate</type>
-        <type type="target">nfc</type>
-        <type type="target">shared_app</type>
-        <type type="target">hostapd</type>
-        <type type="target">platform_app</type>
-        <type type="target">mtp</type>
-        <type type="target">inputflinger</type>
-        <type type="target">logd</type>
-        <type type="target">zygote</type>
-        <type type="target">rild</type>
-        <type type="target">dnsmasq</type>
-        <type type="target">healthd</type>
-        <type type="target">mediaserver</type>
-        <type type="target">bootanim</type>
-        <type type="target">ppp</type>
-        <type type="target">release_app</type>
-        <type type="target">installd</type>
-        <obj_class name="process">
-            <permission>ptrace</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="20" type="neverallow">
-        <type type="source">logd</type>
-        <type type="target">system_file</type>
-        <obj_class name="fifo_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="chr_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="sock_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="blk_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="lnk_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="dir">
-            <permission>write</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="21" type="neverallow">
-        <type type="source">logd</type>
-        <type type="target">app_data_file</type>
-        <type type="target">system_data_file</type>
-        <obj_class name="fifo_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="chr_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="sock_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="blk_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="lnk_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="dir">
-            <permission>write</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="22" type="neverallow">
-        <type type="source">netd</type>
-        <type type="target">ashmem_device</type>
-        <type type="target">fscklogs</type>
-        <type type="target">cpuctl_device</type>
-        <type type="target">iio_device</type>
-        <type type="target">audio_device</type>
-        <type type="target">root_block_device</type>
-        <type type="target">properties_device</type>
-        <type type="target">console_device</type>
-        <type type="target">dm_device</type>
-        <type type="target">hw_random_device</type>
-        <type type="target">sensors_device</type>
-        <type type="target">input_device</type>
-        <type type="target">full_device</type>
-        <type type="target">gps_device</type>
-        <type type="target">vcs_device</type>
-        <type type="target">alarm_device</type>
-        <type type="target">video_device</type>
-        <type type="target">gpu_device</type>
-        <type type="target">adb_device</type>
-        <type type="target">ion_device</type>
-        <type type="target">ptmx_device</type>
-        <type type="target">binder_device</type>
-        <type type="target">null_device</type>
-        <type type="target">tun_device</type>
-        <type type="target">mtp_device</type>
-        <type type="target">rpmsg_device</type>
-        <type type="target">fuse_device</type>
-        <type type="target">watchdog_device</type>
-        <type type="target">radio_device</type>
-        <type type="target">urandom_device</type>
-        <type type="target">usbaccessory_device</type>
-        <type type="target">kmsg_device</type>
-        <type type="target">serial_device</type>
-        <type type="target">camera_device</type>
-        <type type="target">log_device</type>
-        <type type="target">owntty_device</type>
-        <type type="target">device</type>
-        <type type="target">zero_device</type>
-        <type type="target">qtaguid_device</type>
-        <type type="target">tty_device</type>
-        <type type="target">socket_device</type>
-        <type type="target">block_device</type>
-        <type type="target">mtd_device</type>
-        <type type="target">random_device</type>
-        <type type="target">uhid_device</type>
-        <type type="target">tee_device</type>
-        <type type="target">loop_device</type>
-        <type type="target">klog_device</type>
-        <type type="target">ppp_device</type>
-        <type type="target">graphics_device</type>
-        <type type="target">nfc_device</type>
-        <type type="target">ram_device</type>
-        <type type="target">kmem_device</type>
-        <type type="target">hci_attach_dev</type>
-        <type type="target">usb_device</type>
-        <obj_class name="blk_file">
-            <permission>read</permission>
-            <permission>write</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="23" type="neverallow">
-        <type type="source">netd</type>
-        <type type="target">kernel</type>
-        <obj_class name="security">
-            <permission>setenforce</permission>
-            <permission>setbool</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="24" type="neverallow">
-        <type type="source">netd</type>
-        <type type="target">kernel</type>
-        <obj_class name="security">
-            <permission>load_policy</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="25" type="neverallow">
-        <type type="source">netd</type>
-        <type type="target">kernel</type>
-        <type type="target">sdcardd</type>
-        <type type="target">init_shell</type>
-        <type type="target">adbd</type>
-        <type type="target">vold</type>
-        <type type="target">debuggerd</type>
-        <type type="target">netd</type>
-        <type type="target">tee</type>
-        <type type="target">bluetooth</type>
-        <type type="target">lmkd</type>
-        <type type="target">surfaceflinger</type>
-        <type type="target">mdnsd</type>
-        <type type="target">radio</type>
-        <type type="target">hci_attach</type>
-        <type type="target">clatd</type>
-        <type type="target">watchdogd</type>
-        <type type="target">drmserver</type>
-        <type type="target">keystore</type>
-        <type type="target">recovery</type>
-        <type type="target">runas</type>
-        <type type="target">init</type>
-        <type type="target">servicemanager</type>
-        <type type="target">dhcp</type>
-        <type type="target">shell</type>
-        <type type="target">uncrypt</type>
-        <type type="target">untrusted_app</type>
-        <type type="target">ueventd</type>
-        <type type="target">gpsd</type>
-        <type type="target">isolated_app</type>
-        <type type="target">system_app</type>
-        <type type="target">media_app</type>
-        <type type="target">system_server</type>
-        <type type="target">wpa</type>
-        <type type="target">racoon</type>
-        <type type="target">dumpstate</type>
-        <type type="target">nfc</type>
-        <type type="target">shared_app</type>
-        <type type="target">hostapd</type>
-        <type type="target">platform_app</type>
-        <type type="target">mtp</type>
-        <type type="target">inputflinger</type>
-        <type type="target">logd</type>
-        <type type="target">zygote</type>
-        <type type="target">rild</type>
-        <type type="target">dnsmasq</type>
-        <type type="target">healthd</type>
-        <type type="target">mediaserver</type>
-        <type type="target">bootanim</type>
-        <type type="target">ppp</type>
-        <type type="target">release_app</type>
-        <type type="target">installd</type>
-        <obj_class name="process">
-            <permission>ptrace</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="26" type="neverallow">
-        <type type="source">netd</type>
-        <type type="target">system_file</type>
-        <obj_class name="fifo_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="chr_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="sock_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="blk_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="lnk_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="dir">
-            <permission>write</permission>
-        </obj_class>
-    </avc_rule>
-    <avc_rule name="27" type="neverallow">
-        <type type="source">netd</type>
-        <type type="target">app_data_file</type>
-        <type type="target">system_data_file</type>
-        <obj_class name="fifo_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="chr_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="sock_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="blk_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="lnk_file">
-            <permission>write</permission>
-        </obj_class>
-        <obj_class name="dir">
-            <permission>write</permission>
-        </obj_class>
-    </avc_rule>
-</SELinux_AVC_Rules>
diff --git a/tests/tests/security/src/android/security/cts/SqliteJournalLeakTest.java b/tests/tests/security/src/android/security/cts/SqliteJournalLeakTest.java
deleted file mode 100644
index 109aa21..0000000
--- a/tests/tests/security/src/android/security/cts/SqliteJournalLeakTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.security.cts;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Environment;
-import android.test.AndroidTestCase;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.InputStreamReader;
-import java.io.IOException;
-
-
-public class SqliteJournalLeakTest extends AndroidTestCase {
-
-    private static final int REPEAT = 5;
-
-    private static final String[] DATABASES = {
-        "/com.android.bluetooth/databases/btopp.db",
-        "/com.android.browser/app_appcache/ApplicationCache.db",
-        "/com.android.browser/app_databases/Databases.db",
-        "/com.android.browser/app_geolocation/CachedGeoposition.db",
-        "/com.android.browser/app_geolocation/GeolocationPermissions.db",
-        "/com.android.browser/app_icons/WebpageIcons.db",
-        "/com.android.browser/databases/browser.db",
-        "/com.android.browser/databases/launcher.db",
-        "/com.android.browser/databases/webview.db",
-        "/com.android.browser/databases/webviewCache.db",
-        "/com.android.email/databases/EmailProvider.db",
-        "/com.android.email/databases/EmailProviderBody.db",
-        "/com.android.email/databases/webview.db",
-        "/com.android.email/databases/webviewCache.db",
-        "/com.android.providers.calendar/databases/calendar.db",
-        "/com.android.providers.contacts/databases/contacts2.db",
-        "/com.android.providers.downloads/databases/downloads.db",
-        "/com.android.providers.drm/databases/drm.db",
-        "/com.android.providers.media/databases/internal.db",
-        "/com.android.providers.settings/databases/settings.db",
-        "/com.android.providers.tasks/databases/tasks.db",
-        "/com.android.providers.telephony/optable.db",
-        "/com.android.providers.telephony/databases/mmssms.db",
-        "/com.android.providers.telephony/databases/nwk_info.db",
-        "/com.android.providers.telephony/databases/telephony.db",
-        "/com.android.providers.telephony/databases/tether_dun.db",
-        "/com.android.providers.userdictionary/databases/user_dict.db",
-        "/com.android.settings/databases/webview.db",
-        "/com.android.settings/databases/webviewCache.db",
-        "/com.android.vending/databases/billing4.db",
-        "/com.android.vending/databases/market_assets.db",
-        "/com.android.vending/databases/suggestions.db",
-        "/com.android.vending/databases/webview.db",
-        "/com.android.vending/databases/webviewCache.db"
-    };
-
-    /**
-     * This method triggers activities that should cause database writes.
-     * The goal of this is to try to make potentially short-lived journal
-     * files show up.
-     */
-    private void doActivity() {
-        Intent webIntent = new Intent(Intent.ACTION_VIEW);
-        webIntent.setData(Uri.parse("http:///localhost"));
-        webIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        getContext().startActivity(webIntent);
-        Intent dictIntent = new Intent("android.settings.USER_DICTIONARY_SETTINGS");
-        dictIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        getContext().startActivity(dictIntent);
-    }
-
-    private void checkDatabases(String suffix) {
-        String msg = " is world readable. Please set its permissions to 600"
-            + " by setting -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600 in external/sqlite/dist/"
-            + "Android.mk; see CVE-2011-3901.";
-        String base = Environment.getDataDirectory().getAbsolutePath();
-        for(int i=REPEAT; i > 0; i--) {
-            doActivity();
-            for (String name : DATABASES) {
-                name = base + "/data" + name + suffix;
-                File f = new File(name);
-                assertFalse(name + msg, f.canRead());
-            }
-        }
-    }
-
-    public void testJournal() {
-        checkDatabases("-journal");
-    }
-
-    public void testWal() {
-        checkDatabases("-wal");
-    }
-
-    public void testShm() {
-        checkDatabases("-shm");
-    }
-}
diff --git a/tests/tests/tv/Android.mk b/tests/tests/tv/Android.mk
index 2ffe166..795b473 100644
--- a/tests/tests/tv/Android.mk
+++ b/tests/tests/tv/Android.mk
@@ -28,8 +28,6 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
 
-LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
-
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 05f6f00..2430c8c 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
@@ -373,7 +373,7 @@
                 assertEquals(view, mOnUiThread.getWebView());
 
                 // Save the main page request; discard any other requests (e.g. for favicon.ico)
-                if (request.getUrl().toString().contains(mainPath)) {
+                if (request.getUrl().getPath().equals(mainPath)) {
                     assertNull(interceptRequest);
                     interceptRequest = request;
                 }
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewOnUiThread.java b/tests/tests/webkit/src/android/webkit/cts/WebViewOnUiThread.java
index 03059a1..9b2d803 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewOnUiThread.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewOnUiThread.java
@@ -732,6 +732,16 @@
         });
     }
 
+    public void saveWebArchive(final String basename, final boolean autoname,
+                               final ValueCallback<String> callback) {
+        runOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mWebView.saveWebArchive(basename, autoname, callback);
+            }
+        });
+    }
+
     public WebView createWebView() {
         return getValue(new ValueGetter<WebView>() {
             @Override
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 564df6e..1d8a02a 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -75,8 +75,12 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
 import java.util.Collections;
 import java.util.Date;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -84,6 +88,7 @@
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.FutureTask;
+import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import java.util.HashMap;
 import java.util.Map;
@@ -1290,6 +1295,94 @@
         assertEquals("about:blank", mOnUiThread.getUrl());
     }
 
+    private void deleteIfExists(File file) throws IOException {
+        if (file.exists()) {
+            file.delete();
+        }
+    }
+
+    private String readTextFile(File file, Charset encoding)
+            throws FileNotFoundException, IOException {
+        FileInputStream stream = new FileInputStream(file);
+        byte[] bytes = new byte[(int)file.length()];
+        stream.read(bytes);
+        stream.close();
+        return new String(bytes, encoding);
+    }
+
+    private void doSaveWebArchive(String baseName, boolean autoName, final String expectName)
+            throws Throwable {
+        final Semaphore saving = new Semaphore(0);
+        ValueCallback<String> callback = new ValueCallback<String>() {
+            @Override
+            public void onReceiveValue(String savedName) {
+                assertEquals(expectName, savedName);
+                saving.release();
+            }
+        };
+
+        mOnUiThread.saveWebArchive(baseName, autoName, callback);
+        assertTrue(saving.tryAcquire(TEST_TIMEOUT, TimeUnit.MILLISECONDS));
+    }
+
+    public void testSaveWebArchive() throws Throwable {
+        if (!NullWebViewUtils.isWebViewAvailable()) {
+            return;
+        }
+
+        final String testPage = "testSaveWebArchive test page";
+
+        File dir = getActivity().getFilesDir();
+        String dirStr = dir.toString();
+
+        File test = new File(dir, "test.mht");
+        deleteIfExists(test);
+        String testStr = test.getAbsolutePath();
+
+        File index = new File(dir, "index.mht");
+        deleteIfExists(index);
+        String indexStr = index.getAbsolutePath();
+
+        File index1 = new File(dir, "index-1.mht");
+        deleteIfExists(index1);
+        String index1Str = index1.getAbsolutePath();
+
+        mOnUiThread.loadDataAndWaitForCompletion(testPage, "text/html", "UTF-8");
+
+        try {
+            // Save test.mht
+            doSaveWebArchive(testStr, false, testStr);
+
+            // Check the contents of test.mht
+            String testMhtml = readTextFile(test, StandardCharsets.UTF_8);
+            assertTrue(testMhtml.contains(testPage));
+
+            // Save index.mht
+            doSaveWebArchive(dirStr + "/", true, indexStr);
+
+            // Check the contents of index.mht
+            String indexMhtml = readTextFile(index, StandardCharsets.UTF_8);
+            assertTrue(indexMhtml.contains(testPage));
+
+            // Save index-1.mht since index.mht already exists
+            doSaveWebArchive(dirStr + "/", true, index1Str);
+
+            // Check the contents of index-1.mht
+            String index1Mhtml = readTextFile(index1, StandardCharsets.UTF_8);
+            assertTrue(index1Mhtml.contains(testPage));
+
+            // Try a file in a bogus directory
+            doSaveWebArchive("/bogus/path/test.mht", false, null);
+
+            // Try a bogus directory
+            doSaveWebArchive("/bogus/path/", true, null);
+        } finally {
+            deleteIfExists(test);
+            deleteIfExists(index);
+            deleteIfExists(index1);
+        }
+    }
+
     private static class WaitForFindResultsListener extends FutureTask<Integer>
             implements WebView.FindListener {
         public WaitForFindResultsListener() {
diff --git a/tests/tests/widget/Android.mk b/tests/tests/widget/Android.mk
index f6be07d..505f82c 100644
--- a/tests/tests/widget/Android.mk
+++ b/tests/tests/widget/Android.mk
@@ -21,7 +21,7 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES += android-common ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES += android-common ctsdeviceutil ctstestrunner
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
@@ -29,6 +29,4 @@
 
 LOCAL_PACKAGE_NAME := CtsWidgetTestCases
 
-LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
-
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/widget/AndroidManifest.xml b/tests/tests/widget/AndroidManifest.xml
index 3c7fe5f..4b88c01 100644
--- a/tests/tests/widget/AndroidManifest.xml
+++ b/tests/tests/widget/AndroidManifest.xml
@@ -19,12 +19,335 @@
     package="com.android.cts.widget">
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
-    <application>
+    <application android:label="Android TestCase"
+            android:icon="@drawable/size_48x48"
+            android:maxRecents="1"
+            android:multiArch="true"
+            android:name="android.widget.cts.MockApplication"
+            android:supportsRtl="true">
+
         <uses-library android:name="android.test.runner" />
+
+        <activity android:name="android.widget.cts.TwoLineListItemCtsActivity"
+            android:label="TwoLineListItemCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ViewFlipperCtsActivity"
+            android:label="ViewFlipperCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.HorizontalScrollViewCtsActivity"
+            android:label="HorizontalScrollViewCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.SlidingDrawerCtsActivity"
+            android:label="SlidingDrawerCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.DigitalClockCtsActivity"
+            android:label="DigitalClockCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ImageViewCtsActivity"
+            android:label="ImageViewCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.SeekBarCtsActivity"
+            android:label="SeekBarCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ScrollViewCtsActivity"
+            android:label="ScrollViewCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.FrameLayoutCtsActivity"
+            android:label="FrameLayoutCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.LinearLayoutCtsActivity"
+            android:label="LinearLayoutCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.GridLayoutCtsActivity"
+            android:label="GridLayoutCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.LayoutDirectionCtsActivity"
+            android:label="LayoutDirectionCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ProgressBarCtsActivity"
+            android:label="ProgressBarCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ChronometerCtsActivity"
+            android:label="ChronometerCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.MediaControllerCtsActivity"
+            android:label="MediaControllerCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.RatingBarCtsActivity"
+            android:label="RatingBarCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.RemoteViewsCtsActivity"
+            android:label="RemoteViewsCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ExpandableListSimple"
+            android:label="ExpandableListSimple">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.CtsActivity"
+            android:label="CtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ExpandableListWithHeaders"
+            android:label="ExpandableListWithHeaders">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.GalleryCtsActivity"
+            android:label="GalleryCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.MockPopupWindowCtsActivity"
+            android:label="MockPopupWindowCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ListViewCtsActivity"
+            android:label="ListViewCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.TextViewCtsActivity"
+            android:label="TextViewCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.DialerFilterCtsActivity"
+            android:label="DialerFilterCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.MultiAutoCompleteTextViewCtsActivity"
+            android:label="MultiAutoCompleteTextView Test Activity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ViewGroupCtsActivity"
+            android:label="WidgetViewGroupCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.VideoViewCtsActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize">
+            android:label="VideoViewCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.AutoCompleteCtsActivity"
+            android:label="AutoCompleteCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ViewAnimatorCtsActivity" android:label="ViewAnimatorCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.GridViewCtsActivity"
+            android:label="GridViewCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.RelativeLayoutCtsActivity"
+            android:label="RelativeLayoutCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.FrameLayoutCtsActivity"
+            android:label="FrameLayoutCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.AdapterViewCtsActivity"
+            android:label="AdapterViewCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.CheckedTextViewCtsActivity"
+            android:label="CheckedTextViewCtsActivity"/>
+
+        <activity android:name="android.widget.cts.TableCtsActivity"
+            android:label="TableCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.TabHostCtsActivity"
+            android:label="TabHostCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.widget.cts.ZoomButtonCtsActivity"
+            android:label="ZoomButtonCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.ActivityGroup"
+            android:label="ActivityGroup" />
+
+        <activity android:name="android.widget.cts.MockURLSpanTestActivity"
+            android:label="MockURLSpanTestActivity"
+            android:launchMode="singleTask"
+            android:alwaysRetainTaskState="true"
+            android:configChanges="orientation|keyboardHidden">
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+                <data android:scheme="ctstest" />
+            </intent-filter>
+        </activity>
+
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="com.android.cts.stub"
+                     android:targetPackage="com.android.cts.widget"
                      android:label="CTS tests of android.widget">
         <meta-data android:name="listener"
             android:value="com.android.cts.runner.CtsTestRunListener" />
diff --git a/tests/src/android/widget/cts/ViewFlipperStubActivity.java b/tests/tests/widget/res/anim/anim_alpha.xml
similarity index 62%
copy from tests/src/android/widget/cts/ViewFlipperStubActivity.java
copy to tests/tests/widget/res/anim/anim_alpha.xml
index 2ac331e..b5794c3 100644
--- a/tests/src/android/widget/cts/ViewFlipperStubActivity.java
+++ b/tests/tests/widget/res/anim/anim_alpha.xml
@@ -1,4 +1,5 @@
-/*
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
  * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,21 +13,11 @@
  * 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.widget.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class ViewFlipperStubActivity extends Activity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        setContentView(R.layout.viewflipper_layout);
-    }
-}
+<alpha xmlns:android="http://schemas.android.com/apk/res/android"
+       android:interpolator="@android:anim/accelerate_interpolator"
+       android:fromAlpha="0.0"
+       android:toAlpha="1.0"
+       android:duration="500" />
 
diff --git a/tests/tests/widget/res/drawable/animated.gif b/tests/tests/widget/res/drawable/animated.gif
new file mode 100644
index 0000000..51baf15
--- /dev/null
+++ b/tests/tests/widget/res/drawable/animated.gif
Binary files differ
diff --git a/tests/tests/widget/res/drawable/faces.jpg b/tests/tests/widget/res/drawable/faces.jpg
new file mode 100644
index 0000000..0672022
--- /dev/null
+++ b/tests/tests/widget/res/drawable/faces.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/failed.jpg b/tests/tests/widget/res/drawable/failed.jpg
new file mode 100644
index 0000000..1bb9b52
--- /dev/null
+++ b/tests/tests/widget/res/drawable/failed.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/icon_black.jpg b/tests/tests/widget/res/drawable/icon_black.jpg
new file mode 100644
index 0000000..4c9062a
--- /dev/null
+++ b/tests/tests/widget/res/drawable/icon_black.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/icon_blue.jpg b/tests/tests/widget/res/drawable/icon_blue.jpg
new file mode 100644
index 0000000..9e6c1c8
--- /dev/null
+++ b/tests/tests/widget/res/drawable/icon_blue.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/icon_green.jpg b/tests/tests/widget/res/drawable/icon_green.jpg
new file mode 100644
index 0000000..55a78f2
--- /dev/null
+++ b/tests/tests/widget/res/drawable/icon_green.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/icon_red.jpg b/tests/tests/widget/res/drawable/icon_red.jpg
new file mode 100644
index 0000000..6bc9e1f
--- /dev/null
+++ b/tests/tests/widget/res/drawable/icon_red.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/icon_yellow.jpg b/tests/tests/widget/res/drawable/icon_yellow.jpg
new file mode 100644
index 0000000..e748059
--- /dev/null
+++ b/tests/tests/widget/res/drawable/icon_yellow.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/ninepatch_0.9.png b/tests/tests/widget/res/drawable/ninepatch_0.9.png
new file mode 100644
index 0000000..24019d8
--- /dev/null
+++ b/tests/tests/widget/res/drawable/ninepatch_0.9.png
Binary files differ
diff --git a/tests/tests/widget/res/drawable/ninepatch_1.9.png b/tests/tests/widget/res/drawable/ninepatch_1.9.png
new file mode 100644
index 0000000..c56b1db
--- /dev/null
+++ b/tests/tests/widget/res/drawable/ninepatch_1.9.png
Binary files differ
diff --git a/tests/tests/widget/res/drawable/pass.jpg b/tests/tests/widget/res/drawable/pass.jpg
new file mode 100644
index 0000000..2f4b083
--- /dev/null
+++ b/tests/tests/widget/res/drawable/pass.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/scenery.jpg b/tests/tests/widget/res/drawable/scenery.jpg
new file mode 100644
index 0000000..7a6145b
--- /dev/null
+++ b/tests/tests/widget/res/drawable/scenery.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/size_48x48.jpg b/tests/tests/widget/res/drawable/size_48x48.jpg
new file mode 100644
index 0000000..5c2291e
--- /dev/null
+++ b/tests/tests/widget/res/drawable/size_48x48.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/start.jpg b/tests/tests/widget/res/drawable/start.jpg
new file mode 100644
index 0000000..54e05e0
--- /dev/null
+++ b/tests/tests/widget/res/drawable/start.jpg
Binary files differ
diff --git a/tests/tests/widget/res/drawable/testimage.jpg b/tests/tests/widget/res/drawable/testimage.jpg
new file mode 100644
index 0000000..754df0c
--- /dev/null
+++ b/tests/tests/widget/res/drawable/testimage.jpg
Binary files differ
diff --git a/tests/tests/widget/res/layout/abslistview_layout.xml b/tests/tests/widget/res/layout/abslistview_layout.xml
new file mode 100644
index 0000000..a090ce3
--- /dev/null
+++ b/tests/tests/widget/res/layout/abslistview_layout.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<ViewGroup_Layout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/abslistview_root"
+    android:layout_width="25px"
+    android:layout_height="25px" >
+
+   <GridView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
+   <ListView>
+        <TextView
+            android:text="@string/table_layout_first"
+            android:padding="3dip" />
+        <TextView
+            android:text="@string/table_layout_second"
+            android:padding="3dip" />
+        <TextView
+            android:text="@string/table_layout_third"
+            android:padding="3dip" />
+    </ListView>
+</ViewGroup_Layout>
+
diff --git a/tests/tests/widget/res/layout/absolute_layout.xml b/tests/tests/widget/res/layout/absolute_layout.xml
new file mode 100644
index 0000000..6cec61b
--- /dev/null
+++ b/tests/tests/widget/res/layout/absolute_layout.xml
@@ -0,0 +1,39 @@
+<?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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <AbsoluteLayout
+        android:id="@+id/absolute_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_x="1dip"
+        android:layout_y="2dip">
+
+        <TextView
+            android:id="@+id/absolute_textview"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_x="10dip"
+            android:layout_y="20dip"
+            android:background="@drawable/red"
+            android:text="@string/hello_world"/>
+
+    </AbsoluteLayout>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/adapterview_layout.xml b/tests/tests/widget/res/layout/adapterview_layout.xml
new file mode 100644
index 0000000..e118500
--- /dev/null
+++ b/tests/tests/widget/res/layout/adapterview_layout.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/adapterview_tv"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
diff --git a/tests/tests/widget/res/layout/analogclock.xml b/tests/tests/widget/res/layout/analogclock.xml
new file mode 100644
index 0000000..7d862c3
--- /dev/null
+++ b/tests/tests/widget/res/layout/analogclock.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<AnalogClock android:id="@+id/clock"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="96dip"
+    android:layout_gravity="center_horizontal"
+    android:layout_height="wrap_content"/>
diff --git a/tests/tests/widget/res/layout/autocompletetextview_layout.xml b/tests/tests/widget/res/layout/autocompletetextview_layout.xml
new file mode 100644
index 0000000..7fd183c
--- /dev/null
+++ b/tests/tests/widget/res/layout/autocompletetextview_layout.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <TextView android:id="@+id/autocompletetv_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/notify" />
+
+    <AutoCompleteTextView android:id="@+id/autocompletetv_edit"
+        android:completionThreshold="1"
+        android:completionHint="@string/tabs_1"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/checkbox_layout.xml b/tests/tests/widget/res/layout/checkbox_layout.xml
new file mode 100644
index 0000000..a1f1718
--- /dev/null
+++ b/tests/tests/widget/res/layout/checkbox_layout.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+    <CheckBox android:id="@+id/check_box"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/hello_world" />
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/checkedtextview_layout.xml b/tests/tests/widget/res/layout/checkedtextview_layout.xml
new file mode 100644
index 0000000..d5b9c1f
--- /dev/null
+++ b/tests/tests/widget/res/layout/checkedtextview_layout.xml
@@ -0,0 +1,33 @@
+<?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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+    <ListView android:id="@+id/checkedtextview_listview"
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+    </ListView>
+
+    <CheckedTextView android:id="@+id/checkedtextview_test"
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+    </CheckedTextView>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/chronometer_stub_layout.xml b/tests/tests/widget/res/layout/chronometer_stub_layout.xml
new file mode 100644
index 0000000..487f2f8
--- /dev/null
+++ b/tests/tests/widget/res/layout/chronometer_stub_layout.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen"
+    android:layout_width="match_parent" android:layout_height="match_parent"
+    android:orientation="vertical">
+    <LinearLayout
+        android:id="@+id/chronometer_view_group"
+        android:layout_width="match_parent" android:layout_height="match_parent"
+        android:orientation="vertical">
+        <Chronometer
+            android:id="@+id/test_chronometer"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/chronometer_text"
+            />
+    </LinearLayout>
+</ScrollView>
+
diff --git a/tests/tests/widget/res/layout/cursoradapter_group0.xml b/tests/tests/widget/res/layout/cursoradapter_group0.xml
new file mode 100644
index 0000000..f640686
--- /dev/null
+++ b/tests/tests/widget/res/layout/cursoradapter_group0.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:id="@+id/cursorAdapter_group0">
+</ImageView>
diff --git a/tests/tests/widget/res/layout/cursoradapter_group1.xml b/tests/tests/widget/res/layout/cursoradapter_group1.xml
new file mode 100644
index 0000000..d1dfa3c
--- /dev/null
+++ b/tests/tests/widget/res/layout/cursoradapter_group1.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:id="@+id/cursorAdapter_group1">
+</ImageView>
diff --git a/tests/tests/widget/res/layout/cursoradapter_host.xml b/tests/tests/widget/res/layout/cursoradapter_host.xml
new file mode 100644
index 0000000..82ac72b
--- /dev/null
+++ b/tests/tests/widget/res/layout/cursoradapter_host.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:id="@+id/cursorAdapter_host">
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/cursoradapter_item0.xml b/tests/tests/widget/res/layout/cursoradapter_item0.xml
new file mode 100644
index 0000000..5ecd496
--- /dev/null
+++ b/tests/tests/widget/res/layout/cursoradapter_item0.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:id="@+id/cursorAdapter_item0">
+</TextView>
diff --git a/tests/tests/widget/res/layout/cursoradapter_item1.xml b/tests/tests/widget/res/layout/cursoradapter_item1.xml
new file mode 100644
index 0000000..44037b0
--- /dev/null
+++ b/tests/tests/widget/res/layout/cursoradapter_item1.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:id="@+id/cursorAdapter_item1">
+</TextView>
diff --git a/tests/tests/widget/res/layout/datepicker_layout.xml b/tests/tests/widget/res/layout/datepicker_layout.xml
new file mode 100644
index 0000000..925674c
--- /dev/null
+++ b/tests/tests/widget/res/layout/datepicker_layout.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+    <DatePicker
+        android:id="@+id/datePicker_dp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true" />
+
+</RelativeLayout>
diff --git a/tests/tests/widget/res/layout/dialerfilter_layout.xml b/tests/tests/widget/res/layout/dialerfilter_layout.xml
new file mode 100644
index 0000000..46edbd7
--- /dev/null
+++ b/tests/tests/widget/res/layout/dialerfilter_layout.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<DialerFilter android:id="@+id/dialer_filter"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <EditText android:id="@android:id/hint"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@android:drawable/editbox_background"/>
+
+    <EditText android:id="@android:id/primary"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@android:id/hint"/>
+
+</DialerFilter>
diff --git a/tests/tests/widget/res/layout/digitalclock_layout.xml b/tests/tests/widget/res/layout/digitalclock_layout.xml
new file mode 100644
index 0000000..d405af2
--- /dev/null
+++ b/tests/tests/widget/res/layout/digitalclock_layout.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<com.android.cts.widget.alarmclock.DigitalClock android:id="@+id/digitalClock"
+     xmlns:android="http://schemas.android.com/apk/res/android"
+     android:layout_width="wrap_content"
+     android:layout_height="208dip"
+     android:gravity="center">
+     <!-- Includes vertical padding so animated background doesn't
+          stretch much -->
+     <TextView android:id="@+id/timeDisplay"
+         android:layout_width="wrap_content"
+         android:layout_height="wrap_content"
+         android:textSize="64sp"
+         android:paddingRight="4dip"
+         android:paddingTop="48dip"
+         android:paddingBottom="48dip"/>
+     <LinearLayout android:id="@+id/am_pm"
+         android:layout_width="wrap_content"
+         android:layout_height="wrap_content"
+         android:orientation="vertical">
+         <TextView android:id="@+id/am"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:layout_marginTop="-7dp"
+             android:text="@string/am"
+             android:textSize="28sp"/>
+         <TextView android:id="@+id/pm"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:layout_marginTop="-4dp"
+             android:text="@string/pm"
+             android:textSize="28sp"/>
+     </LinearLayout>
+</com.android.cts.widget.alarmclock.DigitalClock>
diff --git a/tests/tests/widget/res/layout/digitalclock_simplelayout.xml b/tests/tests/widget/res/layout/digitalclock_simplelayout.xml
new file mode 100644
index 0000000..16f7b45
--- /dev/null
+++ b/tests/tests/widget/res/layout/digitalclock_simplelayout.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/digitalclock_root"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/edittext_layout.xml b/tests/tests/widget/res/layout/edittext_layout.xml
new file mode 100644
index 0000000..398d3be
--- /dev/null
+++ b/tests/tests/widget/res/layout/edittext_layout.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" >
+
+    <LinearLayout android:id="@+id/edit_text"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+
+        <EditText android:id="@+id/edittext1"
+            style="@android:style/Widget.EditText"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_marginTop="10dip"
+            android:scrollHorizontally="true"
+            android:capitalize="sentences"
+            android:autoText="false"
+            android:maxLines="3"
+            android:textColor="#FF0000"
+            android:text="@string/edit_text"
+        />
+    </LinearLayout>
+</ScrollView>
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/widget/res/layout/expandablelistview_layout.xml
similarity index 60%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/widget/res/layout/expandablelistview_layout.xml
index 16e76c9..3a3ebb7 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/widget/res/layout/expandablelistview_layout.xml
@@ -1,5 +1,6 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
@@ -12,15 +13,10 @@
  * 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.
- */
+ -->
+<ExpandableListView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/expandablelistview_test"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:drawSelectorOnTop="false" />
 
-package android.os.cts;
-
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasTaggedPointer();
-}
diff --git a/tests/tests/widget/res/layout/framelayout_layout.xml b/tests/tests/widget/res/layout/framelayout_layout.xml
new file mode 100644
index 0000000..78b7b47
--- /dev/null
+++ b/tests/tests/widget/res/layout/framelayout_layout.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:id="@+id/framelayout_container"
+                android:background="@drawable/red"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_gravity="bottom"
+                android:orientation="vertical">
+
+    <FrameLayout
+        android:layout_width="100dip"
+        android:layout_height="100dip"
+        android:background="@drawable/yellow"
+        android:id="@+id/framelayout">
+    </FrameLayout>
+
+    <FrameLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:background="@drawable/yellow"
+        android:id="@+id/framelayout_measureall">
+
+        <TextView android:id="@+id/framelayout_textview"
+            android:background="@drawable/blue"
+            android:layout_width="60dip"
+            android:layout_height="30dip"
+            android:text="@string/hello_world"/>
+
+        <Button android:id="@+id/framelayout_button"
+            android:layout_width="50dip"
+            android:layout_height="15dip"
+            android:text="@string/go"/>
+
+    </FrameLayout>
+
+    <FrameLayout
+        android:id="@+id/foreground_tint"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:foregroundTint="@android:color/white"
+        android:foregroundTintMode="src_over" />
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/gallery_test.xml b/tests/tests/widget/res/layout/gallery_test.xml
new file mode 100644
index 0000000..03f0e60
--- /dev/null
+++ b/tests/tests/widget/res/layout/gallery_test.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <android.widget.cts.MyGallery xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/gallery_test"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+    </android.widget.cts.MyGallery>
+
+</LinearLayout>
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/widget/res/layout/gridlayout_layout.xml
similarity index 63%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/widget/res/layout/gridlayout_layout.xml
index 16e76c9..54b3b2c 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/widget/res/layout/gridlayout_layout.xml
@@ -1,5 +1,6 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2012 The Android Open Source Project.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -12,15 +13,11 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-package android.os.cts;
-
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasTaggedPointer();
-}
+ -->
+<GridLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical"
+    >
+</GridLayout>
diff --git a/tests/tests/widget/res/layout/gridview_layout.xml b/tests/tests/widget/res/layout/gridview_layout.xml
new file mode 100644
index 0000000..c7774a3
--- /dev/null
+++ b/tests/tests/widget/res/layout/gridview_layout.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<GridView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/gridview"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+/>
+
diff --git a/tests/tests/widget/res/layout/horizontal_scrollview.xml b/tests/tests/widget/res/layout/horizontal_scrollview.xml
new file mode 100644
index 0000000..0f88ab3
--- /dev/null
+++ b/tests/tests/widget/res/layout/horizontal_scrollview.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<android.widget.cts.MyHorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/horizontal_scroll_view"
+    android:layout_width="100px"
+    android:layout_height="100px">
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="250px"
+        android:layout_height="wrap_content">
+
+        <Button
+            android:id="@+id/first_horizontal_child"
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_3"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_3"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_3"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_3"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:id="@+id/last_horizontal_child"
+            android:layout_width="250px"
+            android:layout_height="100px"
+            android:text="@string/vertical_text_3"/>
+    </LinearLayout>
+
+</android.widget.cts.MyHorizontalScrollView>
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/widget/res/layout/imagebutton_test.xml
similarity index 63%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/widget/res/layout/imagebutton_test.xml
index 16e76c9..7d4b691 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/widget/res/layout/imagebutton_test.xml
@@ -1,5 +1,6 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
@@ -12,15 +13,11 @@
  * 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.
- */
+ -->
+<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/imagebutton"
+    android:layout_width="96px"
+    android:layout_height="76px"
+    android:soundEffectsEnabled="false"
+/>
 
-package android.os.cts;
-
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasTaggedPointer();
-}
diff --git a/tests/tests/widget/res/layout/imageswitcher_test.xml b/tests/tests/widget/res/layout/imageswitcher_test.xml
new file mode 100644
index 0000000..496b2ba
--- /dev/null
+++ b/tests/tests/widget/res/layout/imageswitcher_test.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+ -->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ImageSwitcher android:id="@+id/switcher"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_alignParentTop="true"
+        android:layout_alignParentLeft="true"
+    />
+</RelativeLayout>
+
diff --git a/tests/tests/widget/res/layout/imageview_layout.xml b/tests/tests/widget/res/layout/imageview_layout.xml
new file mode 100644
index 0000000..e56a9c9
--- /dev/null
+++ b/tests/tests/widget/res/layout/imageview_layout.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * 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.
+ */
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ImageView
+        android:id="@+id/imageview"
+        android:layout_width="320px"
+        android:layout_height="240px"/>
+
+    <ImageView
+        android:id="@+id/image_tint"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:tint="@android:color/white"
+        android:tintMode="src_over" />
+
+</LinearLayout>
+
diff --git a/tests/tests/widget/res/layout/layoutdirection_layout.xml b/tests/tests/widget/res/layout/layoutdirection_layout.xml
new file mode 100644
index 0000000..e506dc1
--- /dev/null
+++ b/tests/tests/widget/res/layout/layoutdirection_layout.xml
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2012 The Android Open Source Project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:orientation="vertical">
+
+    <LinearLayout android:id="@+id/layout_linearlayout_ltr"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="ltr">
+
+        <LinearLayout android:id="@+id/layout_linearlayout_ltr_child_1"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="ltr" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_ltr_child_2"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="rtl" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_ltr_child_3"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="inherit" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_ltr_child_4"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="locale" />
+
+    </LinearLayout>
+
+    <LinearLayout android:id="@+id/layout_linearlayout_rtl"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="rtl">
+
+        <LinearLayout android:id="@+id/layout_linearlayout_rtl_child_1"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="ltr" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_rtl_child_2"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="rtl" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_rtl_child_3"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="inherit" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_rtl_child_4"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="locale" />
+
+    </LinearLayout>
+
+    <LinearLayout android:id="@+id/layout_linearlayout_locale"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="locale">
+
+        <LinearLayout android:id="@+id/layout_linearlayout_locale_child_1"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="ltr" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_locale_child_2"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="rtl" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_locale_child_3"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="inherit" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_locale_child_4"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="locale" />
+
+    </LinearLayout>
+
+    <LinearLayout android:id="@+id/layout_linearlayout_inherit"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:layoutDirection="inherit">
+
+        <LinearLayout android:id="@+id/layout_linearlayout_inherit_child_1"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="ltr" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_inherit_child_2"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="rtl" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_inherit_child_3"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="inherit" />
+
+        <LinearLayout android:id="@+id/layout_linearlayout_inherit_child_4"
+                      android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layoutDirection="locale" />
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/linearlayout_layout.xml b/tests/tests/widget/res/layout/linearlayout_layout.xml
new file mode 100644
index 0000000..c70937d
--- /dev/null
+++ b/tests/tests/widget/res/layout/linearlayout_layout.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+    <LinearLayout android:id="@+id/horizontal"
+        android:orientation="horizontal"
+        android:layout_width="wrap_content"
+        android:layout_height="100dip"
+        android:background="#FF909090">
+
+        <TextView android:id="@+id/gravity_top"
+            android:background="#FF00FF00"
+            android:layout_width="wrap_content"
+            android:layout_height="50dip"
+            android:layout_gravity="top"
+            android:text="@string/horizontal_text_1"/>
+
+        <TextView android:id="@+id/gravity_center_vertical"
+            android:background="#FF00FF00"
+            android:layout_width="wrap_content"
+            android:layout_height="50dip"
+            android:layout_gravity="center_vertical"
+            android:text="@string/horizontal_text_2"/>
+
+        <TextView android:id="@+id/gravity_bottom"
+            android:background="#FF00FF00"
+            android:layout_width="wrap_content"
+            android:layout_height="50dip"
+            android:layout_gravity="bottom"
+            android:text="@string/horizontal_text_3"/>
+    </LinearLayout>
+
+    <LinearLayout android:id="@+id/vertical"
+        android:orientation="vertical"
+        android:layout_width="100dip"
+        android:layout_height="wrap_content"
+        android:background="#FFFF0909">
+
+        <TextView android:id="@+id/gravity_left"
+            android:background="#FF00FF00"
+            android:layout_width="wrap_content"
+            android:layout_height="20dip"
+            android:layout_gravity="left"
+            android:text="@string/vertical_text_1"/>
+
+        <TextView android:id="@+id/gravity_center_horizontal"
+            android:background="#FF0000FF"
+            android:layout_width="wrap_content"
+            android:layout_height="20dip"
+            android:layout_gravity="center_horizontal"
+            android:text="@string/vertical_text_2"/>
+
+        <TextView android:id="@+id/gravity_right"
+            android:background="#FF00FF00"
+            android:layout_width="wrap_content"
+            android:layout_height="20dip"
+            android:layout_gravity="right"
+            android:text="@string/vertical_text_3"/>
+    </LinearLayout>
+
+    <LinearLayout android:id="@+id/weightsum"
+        android:orientation="horizontal"
+        android:weightSum="1.0"
+        android:baselineAligned="false"
+        android:layout_width="100dip"
+        android:layout_height="100dip"
+        android:background="#FF909090">
+
+        <TextView android:id="@+id/weight_0_2"
+            android:background="#FF0000FF"
+            android:layout_width="0dip"
+            android:layout_height="wrap_content"
+            android:layout_weight="0.2"
+            android:text="@string/horizontal_text_1"/>
+
+        <TextView android:id="@+id/weight_0_5"
+            android:background="#FFF00F0F"
+            android:layout_width="0dip"
+            android:layout_height="wrap_content"
+            android:layout_weight="0.5"
+            android:text="@string/horizontal_text_2"/>
+
+        <TextView android:id="@+id/weight_0_3"
+            android:background="#FF0000FF"
+            android:layout_width="0dip"
+            android:layout_height="wrap_content"
+            android:layout_weight="0.3"
+            android:text="@string/horizontal_text_3"/>
+    </LinearLayout>
+
+    <LinearLayout android:id="@+id/baseline_aligned_child_index"
+        android:orientation="vertical"
+        android:baselineAlignedChildIndex="1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:background="#FFFF0909">
+
+        <TextView android:id="@+id/textview1"
+            android:background="#FF00FF00"
+            android:layout_width="wrap_content"
+            android:layout_height="20dip"
+            android:layout_gravity="left"
+            android:text="@string/vertical_text_1"/>
+
+        <TextView android:id="@+id/textview2"
+            android:background="#FF0000FF"
+            android:layout_width="wrap_content"
+            android:layout_height="20dip"
+            android:layout_gravity="center_horizontal"
+            android:text="@string/vertical_text_2"/>
+
+        <TextView android:id="@+id/textview3"
+            android:background="#FF00FF00"
+            android:layout_width="wrap_content"
+            android:layout_height="20dip"
+            android:layout_gravity="right"
+            android:text="@string/vertical_text_3"/>
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/listview_layout.xml b/tests/tests/widget/res/layout/listview_layout.xml
new file mode 100644
index 0000000..ee8b6de
--- /dev/null
+++ b/tests/tests/widget/res/layout/listview_layout.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <TextView android:id="@+id/headerview1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/header_view" />
+
+    <TextView android:id="@+id/headerview2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/header_view" />
+
+    <ListView android:id="@+id/listview_default"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
+
+    <TextView android:id="@+id/footerview1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/footer_view" />
+
+    <TextView android:id="@+id/footerview2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/footer_view" />
+</LinearLayout>
+
diff --git a/tests/src/android/widget/cts/ViewFlipperStubActivity.java b/tests/tests/widget/res/layout/mediacontroller_layout.xml
similarity index 60%
copy from tests/src/android/widget/cts/ViewFlipperStubActivity.java
copy to tests/tests/widget/res/layout/mediacontroller_layout.xml
index 2ac331e..871adf4 100644
--- a/tests/src/android/widget/cts/ViewFlipperStubActivity.java
+++ b/tests/tests/widget/res/layout/mediacontroller_layout.xml
@@ -1,4 +1,5 @@
-/*
+<?xml version="1.0" encoding="utf-8"?>
+<!--
  * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,21 +13,16 @@
  * 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.
- */
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
 
-package android.widget.cts;
+    <VideoView
+        android:id="@+id/mediacontroller_videoview"
+        android:layout_width="320px"
+        android:layout_height="240px"/>
 
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class ViewFlipperStubActivity extends Activity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        setContentView(R.layout.viewflipper_layout);
-    }
-}
+</LinearLayout>
 
diff --git a/tests/tests/widget/res/layout/multi_auto_complete_text_view_layout.xml b/tests/tests/widget/res/layout/multi_auto_complete_text_view_layout.xml
new file mode 100644
index 0000000..50109c8
--- /dev/null
+++ b/tests/tests/widget/res/layout/multi_auto_complete_text_view_layout.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/text_country" />
+
+    <MultiAutoCompleteTextView android:id="@+id/country_edit"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/text_name" />
+
+    <MultiAutoCompleteTextView android:id="@+id/name_edit"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
+
+</LinearLayout>
+
diff --git a/tests/tests/widget/res/layout/popupwindow.xml b/tests/tests/widget/res/layout/popupwindow.xml
new file mode 100644
index 0000000..e6b0aed
--- /dev/null
+++ b/tests/tests/widget/res/layout/popupwindow.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+    <TextView android:id="@+id/anchor_upper"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/text_view_hint"
+        android:layout_weight="1"/>
+
+    <LinearLayout android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1">
+
+        <TextView android:id="@+id/anchor_middle_left"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:text="@string/text_view_hint"
+            android:layout_weight="1"/>
+
+        <TextView android:id="@+id/anchor_middle_right"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:text="@string/text_view_hint"
+            android:layout_weight="1"/>
+
+    </LinearLayout>
+
+    <TextView android:id="@+id/anchor_lower"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/text_view_hint"
+        android:layout_weight="1"/>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/progressbar_layout.xml b/tests/tests/widget/res/layout/progressbar_layout.xml
new file mode 100644
index 0000000..a1786b8
--- /dev/null
+++ b/tests/tests/widget/res/layout/progressbar_layout.xml
@@ -0,0 +1,41 @@
+<?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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ProgressBar
+        android:id="@+id/progress_tint"
+        android:progressTint="@android:color/white"
+        android:progressTintMode="src_over"
+        android:progressBackgroundTint="@android:color/white"
+        android:progressBackgroundTintMode="src_over"
+        android:secondaryProgressTint="@android:color/white"
+        android:secondaryProgressTintMode="src_over"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        style="@android:style/Widget.ProgressBar.Horizontal" />
+
+    <ProgressBar
+        android:id="@+id/indeterminate_tint"
+        android:indeterminateTint="@android:color/white"
+        android:indeterminateTintMode="src_over"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        style="@android:style/Widget.ProgressBar.Large" />
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/radiogroup_1.xml b/tests/tests/widget/res/layout/radiogroup_1.xml
new file mode 100644
index 0000000..1e9db83
--- /dev/null
+++ b/tests/tests/widget/res/layout/radiogroup_1.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:layout_weight="0.5"
+    android:layout_gravity="bottom"
+    android:layout_margin="5px">
+</RadioGroup>
+
diff --git a/tests/tests/widget/res/layout/ratingbar_layout.xml b/tests/tests/widget/res/layout/ratingbar_layout.xml
new file mode 100644
index 0000000..acc7fa8
--- /dev/null
+++ b/tests/tests/widget/res/layout/ratingbar_layout.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:orientation="vertical">
+
+    <RatingBar android:id="@+id/ratingbar_constructor"
+        android:isIndicator="false"
+        android:numStars="50"
+        android:rating="1.2"
+        android:stepSize="0.2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"/>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/relative_layout.xml b/tests/tests/widget/res/layout/relative_layout.xml
new file mode 100644
index 0000000..db4b2e8
--- /dev/null
+++ b/tests/tests/widget/res/layout/relative_layout.xml
@@ -0,0 +1,258 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <RelativeLayout
+        android:id="@+id/relative_sublayout_attrs"
+        android:background="@drawable/blue"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <!-- view1, centered within its parent. -->
+        <TextView
+            android:id="@+id/relative_view1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerInParent="true"
+            android:text="@string/relative_view1"/>
+
+        <!-- view2, below view1 and has same left position with view1. -->
+        <TextView
+            android:id="@+id/relative_view2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/relative_view1"
+            android:layout_alignLeft="@id/relative_view1"
+            android:text="@string/relative_view2"/>
+
+        <!-- view3, has same top position with view1 and same bottom position with view2,
+             and on the right of view1. -->
+        <TextView
+            android:id="@+id/relative_view3"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignTop="@id/relative_view1"
+            android:layout_alignBottom="@id/relative_view2"
+            android:layout_toRightOf="@id/relative_view1"
+            android:text="@string/relative_view3"/>
+
+        <!-- view4, has same right position with view3 and above view3. -->
+        <TextView
+            android:id="@+id/relative_view4"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignRight="@id/relative_view3"
+            android:layout_above="@id/relative_view3"
+            android:text="@string/relative_view4"/>
+
+        <!-- view5 goes on the left-bottom -->
+        <TextView
+            android:id="@+id/relative_view5"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="true"
+            android:layout_alignParentLeft="true"
+            android:text="@string/relative_view5"/>
+
+        <!-- view6 goes on the top-right -->
+        <TextView
+            android:id="@+id/relative_view6"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignParentTop="true"
+            android:layout_alignParentRight="true"
+            android:text="@string/relative_view6"/>
+
+        <!-- view7, has same baseline with view6 and centered horizontally within its parent. -->
+        <TextView
+            android:id="@+id/relative_view7"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignBaseline="@id/relative_view6"
+            android:layout_centerHorizontal="true"
+            android:text="@string/relative_view7"/>
+
+        <!-- view8, centered vertically within its parent and on the left of view1. -->
+        <TextView
+            android:id="@+id/relative_view8"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_toLeftOf="@id/relative_view1"
+            android:layout_centerVertical="true"
+            android:text="@string/relative_view8"/>
+
+        <!-- view9, has same top and bottom position with view3 and same left position
+             with its parent. -->
+        <TextView
+            android:id="@+id/relative_view9"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_alignLeft="@id/gravity_bottom"
+            android:layout_alignTop="@id/relative_view3"
+            android:layout_alignBottom="@id/relative_view3"
+            android:layout_alignWithParentIfMissing="true"
+            android:text="@string/relative_view9"/>
+
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/relative_sublayout_gravity"
+        android:background="@drawable/yellow"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <!-- view10 -->
+        <TextView
+            android:id="@+id/relative_view10"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/relative_view10"/>
+
+        <!-- view11 -->
+        <TextView
+            android:id="@+id/relative_view11"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/relative_view10"
+            android:text="@string/relative_view11"/>
+    </RelativeLayout>
+
+    <RelativeLayout
+        android:id="@+id/relative_sublayout_ignore_gravity"
+        android:background="@drawable/red"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:ignoreGravity="@+id/relative_view12"
+        android:gravity="right">
+
+        <!-- view12 -->
+        <TextView
+            android:id="@id/relative_view12"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/relative_view12"/>
+
+        <!-- view13 -->
+        <TextView
+            android:id="@+id/relative_view13"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/relative_view13"/>
+    </RelativeLayout>
+
+    <Spinner
+        android:id="@+id/spinner1"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:prompt="@string/text_view_hello"/>
+
+    <RelativeLayout
+            android:id="@+id/relative_sublayout_attrs_2"
+            android:background="@drawable/blue"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
+
+        <!-- view21, centered within its parent. -->
+        <TextView
+                android:id="@+id/relative_view21"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerInParent="true"
+                android:text="@string/relative_view1"/>
+
+        <!-- view22, below view1 and has same start position with view21. -->
+        <TextView
+                android:id="@+id/relative_view22"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_below="@id/relative_view21"
+                android:layout_alignStart="@id/relative_view21"
+                android:text="@string/relative_view2"/>
+
+        <!-- view23, has same top position with view21 and same bottom position with view22,
+             and on the end of view1. -->
+        <TextView
+                android:id="@+id/relative_view23"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignTop="@id/relative_view21"
+                android:layout_alignBottom="@id/relative_view22"
+                android:layout_toEndOf="@id/relative_view21"
+                android:text="@string/relative_view3"/>
+
+        <!-- view24, has same end position with view23 and above view23. -->
+        <TextView
+                android:id="@+id/relative_view24"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignEnd="@id/relative_view23"
+                android:layout_above="@id/relative_view23"
+                android:text="@string/relative_view4"/>
+
+        <!-- view25 goes on the start-bottom -->
+        <TextView
+                android:id="@+id/relative_view25"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentBottom="true"
+                android:layout_alignParentStart="true"
+                android:text="@string/relative_view5"/>
+
+        <!-- view26 goes on the top-end -->
+        <TextView
+                android:id="@+id/relative_view26"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentTop="true"
+                android:layout_alignParentEnd="true"
+                android:text="@string/relative_view6"/>
+
+        <!-- view27, has same baseline with view26 and centered horizontally within its parent. -->
+        <TextView
+                android:id="@+id/relative_view27"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignBaseline="@id/relative_view26"
+                android:layout_centerHorizontal="true"
+                android:text="@string/relative_view7"/>
+
+        <!-- view28, centered vertically within its parent and on the start of view21. -->
+        <TextView
+                android:id="@+id/relative_view28"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_toStartOf="@id/relative_view21"
+                android:layout_centerVertical="true"
+                android:text="@string/relative_view8"/>
+
+        <!-- view29, has same top and bottom position with view23 and same start position
+             with its parent. -->
+        <TextView
+                android:id="@+id/relative_view29"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignStart="@id/gravity_bottom"
+                android:layout_alignTop="@id/relative_view23"
+                android:layout_alignBottom="@id/relative_view23"
+                android:layout_alignWithParentIfMissing="true"
+                android:text="@string/relative_view9"/>
+
+    </RelativeLayout>
+
+</RelativeLayout>
diff --git a/tests/tests/widget/res/layout/remote_view_test_bad_1.xml b/tests/tests/widget/res/layout/remote_view_test_bad_1.xml
new file mode 100644
index 0000000..a65a5ec
--- /dev/null
+++ b/tests/tests/widget/res/layout/remote_view_test_bad_1.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/linear"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <EditText android:id="@+id/edit"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/remote_view_test_bad_2.xml b/tests/tests/widget/res/layout/remote_view_test_bad_2.xml
new file mode 100644
index 0000000..92623d8
--- /dev/null
+++ b/tests/tests/widget/res/layout/remote_view_test_bad_2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/linear"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <WebView android:id="@+id/web"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/remote_view_test_good.xml b/tests/tests/widget/res/layout/remote_view_test_good.xml
new file mode 100644
index 0000000..3df9d62
--- /dev/null
+++ b/tests/tests/widget/res/layout/remote_view_test_good.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/linear"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <TextView android:id="@+id/text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <ImageView android:id="@+id/image"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <FrameLayout android:id="@+id/frame"
+        android:layout_width="10dip"
+        android:layout_height="10dip" />
+
+    <RelativeLayout android:id="@+id/relative"
+        android:layout_width="10dip"
+        android:layout_height="10dip" />
+
+    <AbsoluteLayout android:id="@+id/absolute"
+        android:layout_width="10dip"
+        android:layout_height="10dip" />
+
+    <ProgressBar android:id="@+id/progress"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <ImageButton android:id="@+id/image_button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <Button android:id="@+id/button"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/remoteviews_good.xml b/tests/tests/widget/res/layout/remoteviews_good.xml
new file mode 100644
index 0000000..8fdbc64
--- /dev/null
+++ b/tests/tests/widget/res/layout/remoteviews_good.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/remoteViews_good"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout android:id="@+id/remoteView_linear"
+        android:layout_width="10dip"
+        android:layout_height="10dip" />
+
+    <TextView android:id="@+id/remoteView_text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <ImageView android:id="@+id/remoteView_image"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <FrameLayout android:id="@+id/remoteView_frame"
+        android:layout_width="10dip"
+        android:layout_height="10dip" />
+
+    <RelativeLayout android:id="@+id/remoteView_relative"
+        android:layout_width="10dip"
+        android:layout_height="10dip" />
+
+    <AbsoluteLayout android:id="@+id/remoteView_absolute"
+        android:layout_width="10dip"
+        android:layout_height="10dip" />
+
+    <ProgressBar android:id="@+id/remoteView_progress"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        style="?android:attr/progressBarStyleHorizontal" />
+
+    <Chronometer android:id="@+id/remoteView_chronometer"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/remoteviews_host.xml b/tests/tests/widget/res/layout/remoteviews_host.xml
new file mode 100644
index 0000000..ace5903
--- /dev/null
+++ b/tests/tests/widget/res/layout/remoteviews_host.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:id="@+id/remoteView_host">
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/scrollview_layout.xml b/tests/tests/widget/res/layout/scrollview_layout.xml
new file mode 100644
index 0000000..3c9a474
--- /dev/null
+++ b/tests/tests/widget/res/layout/scrollview_layout.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<android.widget.cts.MyScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/scroll_view"
+    android:layout_width="100dip"
+    android:layout_height="100dip">
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="250dip"
+        android:layout_height="wrap_content">
+
+        <Button
+            android:id="@+id/first_child"
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_3"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_3"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_3"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_3"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_1"/>
+
+        <Button
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_2"/>
+
+        <Button
+            android:id="@+id/last_child"
+            android:layout_width="250dip"
+            android:layout_height="100dip"
+            android:text="@string/vertical_text_3"/>
+    </LinearLayout>
+
+</android.widget.cts.MyScrollView>
diff --git a/tests/tests/widget/res/layout/seekbar_layout.xml b/tests/tests/widget/res/layout/seekbar_layout.xml
new file mode 100644
index 0000000..5c311fd
--- /dev/null
+++ b/tests/tests/widget/res/layout/seekbar_layout.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+     <SeekBar android:id="@+id/seekBar"
+         android:layout_width="match_parent"
+         android:layout_height="wrap_content"
+         android:max="100"
+         android:progress="50"
+         android:secondaryProgress="75" />
+
+    <SeekBar
+        android:id="@+id/thumb_tint"
+        android:thumbTint="@android:color/white"
+        android:thumbTintMode="src_over"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/simple_dropdown_item_1line.xml b/tests/tests/widget/res/layout/simple_dropdown_item_1line.xml
new file mode 100644
index 0000000..9a044b1
--- /dev/null
+++ b/tests/tests/widget/res/layout/simple_dropdown_item_1line.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/text1"
+    style="?android:attr/dropDownItemStyle"
+    android:textAppearance="?android:attr/textAppearanceLargeInverse"
+    android:singleLine="true"
+    android:layout_width="match_parent"
+    android:layout_height="?android:attr/listPreferredItemHeight" />
diff --git a/tests/tests/widget/res/layout/simple_spinner_item.xml b/tests/tests/widget/res/layout/simple_spinner_item.xml
new file mode 100644
index 0000000..d52922a
--- /dev/null
+++ b/tests/tests/widget/res/layout/simple_spinner_item.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@android:id/text1"
+    style="?android:attr/spinnerItemStyle"
+    android:singleLine="true"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content" />
diff --git a/tests/tests/widget/res/layout/sliding_drawer_layout.xml b/tests/tests/widget/res/layout/sliding_drawer_layout.xml
new file mode 100644
index 0000000..3f84d46
--- /dev/null
+++ b/tests/tests/widget/res/layout/sliding_drawer_layout.xml
@@ -0,0 +1,45 @@
+<?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.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <SlidingDrawer
+        android:id="@+id/drawer"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:animateOnClick="false"
+
+        android:handle="@+id/handle"
+        android:content="@+id/content">
+
+        <ImageView
+            android:id="@id/handle"
+            android:background="#FF00FF00"
+            android:layout_width="88dip"
+            android:layout_height="44dip" />
+
+        <TextView
+            android:id="@id/content"
+            android:background="#FF0000FF"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:text="@string/hello_world" />
+
+    </SlidingDrawer>
+
+</RelativeLayout>
diff --git a/tests/tests/widget/res/layout/tabhost_layout.xml b/tests/tests/widget/res/layout/tabhost_layout.xml
new file mode 100644
index 0000000..1bae57a
--- /dev/null
+++ b/tests/tests/widget/res/layout/tabhost_layout.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@android:id/tabhost"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content">
+
+    <TabWidget android:id="@android:id/tabs"
+        android:layout_width="match_parent"
+        android:layout_height="68dip"
+        android:paddingLeft="1dip"
+        android:paddingRight="1dip"
+        android:paddingTop="4dip"
+    />
+
+    <FrameLayout android:id="@android:id/tabcontent"
+        android:layout_width="match_parent"
+        android:layout_height="0dip"
+        android:layout_weight="1">
+
+        <TextView android:id="@+id/tabhost_textview"
+            android:password="true"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/hello_world"/>
+
+        <ListView android:id="@+id/tabhost_listview"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"/>
+    </FrameLayout>
+</TabHost>
diff --git a/tests/tests/widget/res/layout/table_layout_1.xml b/tests/tests/widget/res/layout/table_layout_1.xml
new file mode 100644
index 0000000..0896cd2
--- /dev/null
+++ b/tests/tests/widget/res/layout/table_layout_1.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/table1"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:collapseColumns="0"
+    android:stretchColumns="2">
+
+    <TableRow>
+        <TextView
+            android:text="@string/table_layout_first"
+            android:padding="3dip" />
+        <TextView
+            android:text="@string/table_layout_second"
+            android:padding="3dip" />
+        <TextView
+            android:text="@string/table_layout_third"
+            android:padding="3dip" />
+    </TableRow>
+</TableLayout>
+
diff --git a/tests/tests/widget/res/layout/table_layout_2.xml b/tests/tests/widget/res/layout/table_layout_2.xml
new file mode 100644
index 0000000..84750fc
--- /dev/null
+++ b/tests/tests/widget/res/layout/table_layout_2.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/table2"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:shrinkColumns="1">
+
+    <TableRow>
+        <TextView
+            android:layout_column="1"
+            android:text="@string/table_layout_long"
+            android:padding="3dip" />
+        <TextView
+            android:layout_span="2"
+            android:text="@string/table_layout_second"
+            android:padding="3dip" />
+        <TextView
+            android:text="@string/table_layout_third"
+            android:padding="3dip" />
+    </TableRow>
+</TableLayout>
+
diff --git a/tests/tests/widget/res/layout/textview_autolink.xml b/tests/tests/widget/res/layout/textview_autolink.xml
new file mode 100644
index 0000000..53d89f3
--- /dev/null
+++ b/tests/tests/widget/res/layout/textview_autolink.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+    <TextView android:id="@+id/autolink_default"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"/>
+
+    <TextView android:id="@+id/autolink_web"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="web"/>
+
+    <TextView android:id="@+id/autolink_email"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="email"/>
+
+    <TextView android:id="@+id/autolink_phone"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="phone"/>
+
+    <TextView android:id="@+id/autolink_all"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="all"/>
+
+    <TextView android:id="@+id/autolink_compound1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="web|email"/>
+
+    <TextView android:id="@+id/autolink_compound2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="web|phone"/>
+
+    <TextView android:id="@+id/autolink_compound3"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="email|phone"/>
+
+    <TextView android:id="@+id/autolink_compound4"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:autoLink="phone|all"/>
+
+</FrameLayout>
diff --git a/tests/tests/widget/res/layout/textview_ellipsize.xml b/tests/tests/widget/res/layout/textview_ellipsize.xml
new file mode 100644
index 0000000..0fc5779
--- /dev/null
+++ b/tests/tests/widget/res/layout/textview_ellipsize.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+    <TextView android:id="@+id/ellipsize_default"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
+
+    <TextView android:id="@+id/ellipsize_none"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:ellipsize="none"/>
+
+    <TextView android:id="@+id/ellipsize_start"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:ellipsize="start"/>
+
+    <TextView android:id="@+id/ellipsize_middle"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:ellipsize="middle"/>
+
+    <TextView android:id="@+id/ellipsize_end"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:ellipsize="end"/>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/textview_gravity.xml b/tests/tests/widget/res/layout/textview_gravity.xml
new file mode 100644
index 0000000..a4a7592
--- /dev/null
+++ b/tests/tests/widget/res/layout/textview_gravity.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+    <TextView android:id="@+id/gravity_default"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
+
+    <TextView android:id="@+id/gravity_bottom"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="bottom"/>
+
+    <TextView android:id="@+id/gravity_right"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="right"/>
+
+    <TextView android:id="@+id/gravity_fill"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="fill"/>
+
+    <TextView android:id="@+id/gravity_center"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"/>
+
+    <TextView android:id="@+id/gravity_center_vertical_right"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center_vertical|right"/>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/textview_hint_linksclickable_freezestext.xml b/tests/tests/widget/res/layout/textview_hint_linksclickable_freezestext.xml
new file mode 100644
index 0000000..a22e429
--- /dev/null
+++ b/tests/tests/widget/res/layout/textview_hint_linksclickable_freezestext.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+    <TextView android:id="@+id/hint_linksClickable_freezesText_default"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
+
+    <TextView android:id="@+id/hint_blank"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint=""/>
+
+    <TextView android:id="@+id/hint_string"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/text_view_simple_hint"/>
+
+    <TextView android:id="@+id/hint_resid"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:hint="@string/text_view_hint"/>
+
+    <TextView android:id="@+id/linksClickable_true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:linksClickable="true"/>
+
+    <TextView android:id="@+id/linksClickable_false"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:linksClickable="false"/>
+
+    <TextView android:id="@+id/freezesText_true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:freezesText="true"/>
+
+    <TextView android:id="@+id/freezesText_false"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:freezesText="false"/>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/textview_layout.xml b/tests/tests/widget/res/layout/textview_layout.xml
new file mode 100644
index 0000000..c2cd159
--- /dev/null
+++ b/tests/tests/widget/res/layout/textview_layout.xml
@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/layout_textviewtest">
+
+    <ScrollView android:layout_width="match_parent"
+            android:layout_height="match_parent">
+
+        <LinearLayout android:orientation="vertical"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+            <TextView android:id="@+id/textview_textAttr"
+                    android:text="@string/text_view_hello"
+                    android:textColor="@drawable/black"
+                    android:textColorHighlight="@drawable/yellow"
+                    android:textColorHint="@drawable/red"
+                    android:textColorLink="@drawable/blue"
+                    android:textScaleX="1.2"
+                    android:typeface="normal"
+                    android:textSize="20px"
+                    android:textStyle="normal"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"/>
+
+            <TextView android:id="@+id/textview_password"
+                    android:password="true"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"/>
+
+            <TextView android:id="@+id/textview_singleLine"
+                    android:singleLine="true"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"/>
+
+            <TextView android:id="@+id/textview_text"
+                    android:text="@string/text_view_hello"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"/>
+
+            <TextView android:id="@+id/textview_text_two_lines"
+                    android:text="@string/text_view_hello_two_lines"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"/>
+
+            <android.widget.cts.MockTextView
+                    android:id="@+id/mock_textview_left"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:requiresFadingEdge="horizontal"
+                    android:singleLine="true"
+                    android:text="@string/long_text"
+                    android:gravity="left"
+                    />
+
+            <android.widget.cts.MockTextView
+                    android:id="@+id/mock_textview_right"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:requiresFadingEdge="horizontal"
+                    android:singleLine="true"
+                    android:text="@string/long_text"
+                    android:gravity="right"
+                    />
+
+            <android.widget.cts.MockTextView
+                    android:id="@+id/mock_textview_center"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:requiresFadingEdge="horizontal"
+                    android:singleLine="true"
+                    android:text="@string/long_text"
+                    android:gravity="center"
+                    />
+        </LinearLayout>
+
+    </ScrollView>
+
+    <TextView android:id="@+id/textview_ltr"
+              android:layout_height="wrap_content"
+              android:layout_width="wrap_content"/>
+
+    <TextView android:id="@+id/textview_rtl"
+              android:layout_height="wrap_content"
+              android:layout_width="wrap_content"/>
+
+    <TextView android:id="@+id/textview_drawable_1_1"
+              android:layout_height="wrap_content"
+              android:layout_width="wrap_content"
+              android:drawableLeft="@drawable/icon_blue"
+              android:drawableRight="@drawable/icon_red"
+              android:drawableTop="@drawable/icon_green"
+              android:drawableBottom="@drawable/icon_yellow"
+            />
+
+    <TextView android:id="@+id/textview_drawable_1_2"
+              android:layout_height="wrap_content"
+              android:layout_width="wrap_content"
+              android:drawableLeft="@drawable/icon_blue"
+              android:drawableRight="@drawable/icon_red"
+              android:drawableTop="@drawable/icon_green"
+              android:drawableBottom="@drawable/icon_yellow"
+              android:layoutDirection="rtl"
+            />
+
+    <TextView android:id="@+id/textview_drawable_2_1"
+              android:layout_height="wrap_content"
+              android:layout_width="wrap_content"
+              android:drawableStart="@drawable/icon_blue"
+              android:drawableEnd="@drawable/icon_red"
+              android:drawableTop="@drawable/icon_green"
+              android:drawableBottom="@drawable/icon_yellow"
+            />
+
+    <TextView android:id="@+id/textview_drawable_2_2"
+              android:layout_height="wrap_content"
+              android:layout_width="wrap_content"
+              android:drawableStart="@drawable/icon_blue"
+              android:drawableEnd="@drawable/icon_red"
+              android:drawableTop="@drawable/icon_green"
+              android:drawableBottom="@drawable/icon_yellow"
+              android:layoutDirection="rtl"
+            />
+
+    <TextView android:id="@+id/textview_drawable_3_1"
+              android:layout_height="wrap_content"
+              android:layout_width="wrap_content"
+              android:drawableLeft="@drawable/icon_black"
+              android:drawableRight="@drawable/icon_black"
+              android:drawableStart="@drawable/icon_blue"
+              android:drawableEnd="@drawable/icon_red"
+              android:drawableTop="@drawable/icon_green"
+              android:drawableBottom="@drawable/icon_yellow"
+            />
+
+    <TextView android:id="@+id/textview_drawable_3_2"
+              android:layout_height="wrap_content"
+              android:layout_width="wrap_content"
+              android:drawableLeft="@drawable/icon_black"
+              android:drawableRight="@drawable/icon_black"
+              android:drawableStart="@drawable/icon_blue"
+              android:drawableEnd="@drawable/icon_red"
+              android:drawableTop="@drawable/icon_green"
+              android:drawableBottom="@drawable/icon_yellow"
+              android:layoutDirection="rtl"
+            />
+
+
+    <LinearLayout android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="match_parent"
+                  android:layoutDirection="ltr">
+
+        <TextView android:id="@+id/textview_drawable_4_1"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:drawableStart="@drawable/icon_blue"
+                  android:drawableEnd="@drawable/icon_red"
+                  android:drawableTop="@drawable/icon_green"
+                  android:drawableBottom="@drawable/icon_yellow"
+                />
+
+        <TextView android:id="@+id/textview_drawable_5_1"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:drawableLeft="@drawable/icon_black"
+                  android:drawableRight="@drawable/icon_black"
+                  android:drawableStart="@drawable/icon_blue"
+                  android:drawableEnd="@drawable/icon_red"
+                  android:drawableTop="@drawable/icon_green"
+                  android:drawableBottom="@drawable/icon_yellow"
+                />
+
+    </LinearLayout>
+
+    <LinearLayout android:orientation="vertical"
+                  android:layout_width="match_parent"
+                  android:layout_height="match_parent"
+                  android:layoutDirection="rtl">
+
+        <TextView android:id="@+id/textview_drawable_4_2"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:drawableStart="@drawable/icon_blue"
+                  android:drawableEnd="@drawable/icon_red"
+                  android:drawableTop="@drawable/icon_green"
+                  android:drawableBottom="@drawable/icon_yellow"
+                />
+
+        <TextView android:id="@+id/textview_drawable_5_2"
+                  android:layout_height="wrap_content"
+                  android:layout_width="wrap_content"
+                  android:drawableLeft="@drawable/icon_black"
+                  android:drawableRight="@drawable/icon_black"
+                  android:drawableStart="@drawable/icon_blue"
+                  android:drawableEnd="@drawable/icon_red"
+                  android:drawableTop="@drawable/icon_green"
+                  android:drawableBottom="@drawable/icon_yellow"
+                />
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/textview_selectallonfocus.xml b/tests/tests/widget/res/layout/textview_selectallonfocus.xml
new file mode 100644
index 0000000..b1c3682
--- /dev/null
+++ b/tests/tests/widget/res/layout/textview_selectallonfocus.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+    <TextView android:id="@+id/selectAllOnFocus_default"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:focusable="true"/>
+
+    <TextView android:id="@+id/selectAllOnFocus_true"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:selectAllOnFocus="true"
+        android:focusable="true"/>
+
+    <TextView android:id="@+id/selectAllOnFocus_false"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:selectAllOnFocus="false"
+        android:focusable="true"/>
+
+        <TextView android:id="@+id/selectAllOnFocus_dummy"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:focusable="true"/>
+
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/timepicker.xml b/tests/tests/widget/res/layout/timepicker.xml
new file mode 100644
index 0000000..352f69b
--- /dev/null
+++ b/tests/tests/widget/res/layout/timepicker.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TimePicker xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"/>
diff --git a/tests/tests/widget/res/layout/togglebutton_layout.xml b/tests/tests/widget/res/layout/togglebutton_layout.xml
new file mode 100644
index 0000000..a6c08e1
--- /dev/null
+++ b/tests/tests/widget/res/layout/togglebutton_layout.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <ToggleButton android:id="@+id/toggle1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+
+        <ToggleButton android:id="@+id/toggle2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+
+        <ToggleButton android:id="@+id/button_tint"
+            android:buttonTint="@android:color/white"
+            android:buttonTintMode="src_over"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" />
+
+    </LinearLayout>
+
+</ScrollView>
diff --git a/tests/tests/widget/res/layout/twolinelistitem.xml b/tests/tests/widget/res/layout/twolinelistitem.xml
new file mode 100644
index 0000000..ec256c1
--- /dev/null
+++ b/tests/tests/widget/res/layout/twolinelistitem.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:id="@+id/twoLineListItem">
+
+    <TextView android:id="@android:id/text1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/twolinelistitem_test_text1"/>
+
+    <TextView android:id="@android:id/text2"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/twolinelistitem_test_text2"/>
+
+</TwoLineListItem>
diff --git a/tests/tests/widget/res/layout/urlspan_layout.xml b/tests/tests/widget/res/layout/urlspan_layout.xml
new file mode 100644
index 0000000..2ca95ac
--- /dev/null
+++ b/tests/tests/widget/res/layout/urlspan_layout.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+    <TextView android:id="@+id/url"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingLeft="4dip"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:text="@string/text_view_hello"/>
+
+</LinearLayout>
diff --git a/tests/src/android/widget/cts/ListViewStubActivity.java b/tests/tests/widget/res/layout/videoview_layout.xml
similarity index 61%
copy from tests/src/android/widget/cts/ListViewStubActivity.java
copy to tests/tests/widget/res/layout/videoview_layout.xml
index 77c3e5e..9b042cb 100644
--- a/tests/src/android/widget/cts/ListViewStubActivity.java
+++ b/tests/tests/widget/res/layout/videoview_layout.xml
@@ -1,4 +1,5 @@
-/*
+<?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");
@@ -12,19 +13,14 @@
  * 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.
- */
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
 
-package android.widget.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class ListViewStubActivity extends Activity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.listview_layout);
-    }
-}
+    <VideoView
+        android:id="@+id/videoview"
+        android:layout_width="160px"
+        android:layout_height="120px"/>
+</LinearLayout>
diff --git a/tests/tests/widget/res/layout/viewanimator_layout.xml b/tests/tests/widget/res/layout/viewanimator_layout.xml
new file mode 100644
index 0000000..96b2483
--- /dev/null
+++ b/tests/tests/widget/res/layout/viewanimator_layout.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<!-- Demonstrates using a relative layout to create a form -->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:focusable="true"
+    android:background="@drawable/blue">
+
+    <TextView android:id="@+id/label"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:layout_alignParentLeft="true"
+        android:text="@string/viewanimator_test"/>
+
+    <EditText android:id="@+id/entry"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@android:drawable/editbox_background"
+        android:layout_below="@id/label"/>
+
+    <Button android:id="@+id/cancel"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@id/entry"
+        android:layout_alignParentRight="true"
+        android:layout_marginLeft="10px"
+        android:text="@string/id_cancel" />
+
+    <Button android:id="@+id/ok"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_toLeftOf="@id/cancel"
+        android:layout_alignTop="@id/cancel"
+        android:text="@string/id_ok" />
+
+</RelativeLayout>
+
diff --git a/tests/tests/widget/res/layout/viewflipper_layout.xml b/tests/tests/widget/res/layout/viewflipper_layout.xml
new file mode 100644
index 0000000..6480379
--- /dev/null
+++ b/tests/tests/widget/res/layout/viewflipper_layout.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:orientation="vertical"
+        android:padding="10dip"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+    <ViewFlipper android:id="@+id/viewflipper_test"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:flipInterval="1000"
+                android:layout_marginBottom="20dip" >
+                <TextView android:id="@+id/viewflipper_textview1"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:gravity="center_horizontal"
+                        android:textSize="26sp"
+                        android:visibility="gone"
+                        android:text="@string/hello_world"/>
+                <TextView android:id="@+id/viewflipper_textview2"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:gravity="center_horizontal"
+                        android:textSize="26sp"
+                        android:visibility="gone"
+                        android:text="@string/hello_android"/>
+    </ViewFlipper>
+</LinearLayout>
+
diff --git a/tests/tests/widget/res/layout/viewgrouptest_stub.xml b/tests/tests/widget/res/layout/viewgrouptest_stub.xml
new file mode 100644
index 0000000..ee59126
--- /dev/null
+++ b/tests/tests/widget/res/layout/viewgrouptest_stub.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+ -->
+
+<android.widget.cts.MockLinearLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:id="@+id/mocklinearlayout">
+
+    <!-- view1 goes on top -->
+    <TextView
+        android:id="@+id/viewgrouptest_stub"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+    />
+
+</android.widget.cts.MockLinearLayout>
+
diff --git a/tests/tests/widget/res/layout/viewswitcher_layout.xml b/tests/tests/widget/res/layout/viewswitcher_layout.xml
new file mode 100644
index 0000000..933dc32
--- /dev/null
+++ b/tests/tests/widget/res/layout/viewswitcher_layout.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ViewSwitcher android:id="@+id/viewswitcher_test"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+</LinearLayout>
+
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/widget/res/layout/zoombutton_layout.xml
similarity index 64%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/widget/res/layout/zoombutton_layout.xml
index 16e76c9..1b1e0b2 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/widget/res/layout/zoombutton_layout.xml
@@ -1,5 +1,6 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
@@ -12,15 +13,10 @@
  * 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.
- */
+ -->
+<ZoomButton xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/zoombutton_test"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+/>
 
-package android.os.cts;
-
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasTaggedPointer();
-}
diff --git a/tests/tests/widget/res/raw/scenery.jpg b/tests/tests/widget/res/raw/scenery.jpg
new file mode 100644
index 0000000..7d1f5e1
--- /dev/null
+++ b/tests/tests/widget/res/raw/scenery.jpg
Binary files differ
diff --git a/tests/tests/widget/res/raw/testimage.jpg b/tests/tests/widget/res/raw/testimage.jpg
new file mode 100644
index 0000000..d3dae03
--- /dev/null
+++ b/tests/tests/widget/res/raw/testimage.jpg
Binary files differ
diff --git a/tests/tests/widget/res/raw/testvideo.3gp b/tests/tests/widget/res/raw/testvideo.3gp
new file mode 100644
index 0000000..1503272
--- /dev/null
+++ b/tests/tests/widget/res/raw/testvideo.3gp
Binary files differ
diff --git a/tests/tests/widget/res/values/arrays.xml b/tests/tests/widget/res/values/arrays.xml
new file mode 100644
index 0000000..71e0133
--- /dev/null
+++ b/tests/tests/widget/res/values/arrays.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<resources>
+    <item type="integer" name="reference" format="integer">101</item>
+
+      <string-array name="strings">
+        <item>zero</item>
+        <item>1</item>
+        <item>@string/reference</item>
+    </string-array>
+
+    <integer-array name="integers">
+        <item>0</item>
+        <item>1</item>
+        <item>@integer/reference</item>
+    </integer-array>
+
+    <array name="difficultyLevel">
+        <item>Easy</item>
+        <item>Medium</item>
+        <item>Hard</item>
+    </array>
+
+    <string-array name="string">
+        <item>Test String 1</item>
+        <item>Test String 2</item>
+        <item>Test String 3</item>
+    </string-array>
+
+    <integer-array name="table_row_layout">
+        <item>1</item>
+        <item>2</item>
+        <item>3</item>
+        <item>4</item>
+        <item>5</item>
+        <item>6</item>
+        <item>7</item>
+        <item>8</item>
+        <item>9</item>
+        <item>10</item>
+    </integer-array>
+</resources>
diff --git a/tests/tests/widget/res/values/attrs.xml b/tests/tests/widget/res/values/attrs.xml
new file mode 100644
index 0000000..4c3d9db
--- /dev/null
+++ b/tests/tests/widget/res/values/attrs.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+
+<resources>
+    <declare-styleable name="Style1">
+        <attr name="Type1" format="integer">
+            <enum name="type" value="28" />
+            <enum name="data" value="0xff00ff00" />
+            <enum name="asset_cookie" value="0" />
+            <enum name="resource_id" value="0" />
+            <enum name="changing_config" value="0" />
+        </attr>
+        <attr name="Type2" format="integer">
+            <enum name="type" value="28" />
+            <enum name="data" value="0xff0000ff" />
+            <enum name="asset_cookie" value="0" />
+            <enum name="resource_id" value="0" />
+            <enum name="changing_config" value="0" />
+        </attr>
+    </declare-styleable>
+    <attr name="type1" format="boolean"/>
+    <attr name="type2" format="boolean"/>
+    <attr name="type3" format="color"/>
+    <attr name="type4" format="reference|color"/>
+    <attr name="type5" format="dimension"/>
+    <attr name="type6" format="dimension"/>
+    <attr name="type7" format="dimension"/>
+    <attr name="type8" format="reference"/>
+    <attr name="type9" format="float"/>
+    <attr name="type10" format="fraction"/>
+    <attr name="type11" format="integer"/>
+    <attr name="type12" format="integer"/>
+    <attr name="type13" format="reference|string"/>
+    <attr name="type14" format="string"/>
+    <attr name="type15" format="reference"/>
+    <attr name="type16" format="string"/>
+    <declare-styleable name="style1">
+        <attr name="type1"/>
+        <attr name="type2"/>
+        <attr name="type3"/>
+        <attr name="type4"/>
+        <attr name="type5"/>
+        <attr name="type6"/>
+        <attr name="type7"/>
+        <attr name="type8"/>
+        <attr name="type9"/>
+        <attr name="type10"/>
+        <attr name="type11"/>
+        <attr name="type12"/>
+        <attr name="type13"/>
+        <attr name="type14"/>
+        <attr name="type15"/>
+        <attr name="type16"/>
+    </declare-styleable>
+    <attr name="testEnum">
+        <enum name="val1" value="1" />
+        <enum name="val2" value="2" />
+        <enum name="val10" value="10" />
+    </attr>
+    <attr name="testFlags">
+        <flag name="bit1" value="0x1" />
+        <flag name="bit2" value="0x2" />
+        <flag name="bit31" value="0x40000000" />
+    </attr>
+    <attr name="testString" format="string" />
+    <declare-styleable name="EnumStyle">
+        <attr name="testEnum" />
+    </declare-styleable>
+    <declare-styleable name="FlagStyle">
+        <attr name="testFlags" />
+    </declare-styleable>
+    <declare-styleable name="TestConfig">
+        <attr name="testString" />
+    </declare-styleable>
+    <!-- Size of text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp).
+         Supported values include the following:<p/>
+    <ul>
+        <li><b>px</b> Pixels</li>
+        <li><b>sp</b> Scaled pixels (scaled to relative pixel size on screen). See {@link android.util.DisplayMetrics} for more information.</li>
+        <li><b>pt</b> Points</li>
+        <li><b>dip</b> Device independent pixels. See {@link android.util.DisplayMetrics} for more information.</li>
+    </ul>
+    -->
+    <attr name="textSize" format="dimension" />
+    <attr name="typeface">
+        <enum name="normal" value="0" />
+        <enum name="sans" value="1" />
+        <enum name="serif" value="2" />
+        <enum name="monospace" value="3" />
+    </attr>
+    <!-- Default text typeface style. -->
+    <attr name="textStyle">
+        <flag name="normal" value="0" />
+        <flag name="bold" value="1" />
+        <flag name="italic" value="2" />
+    </attr>
+    <!-- Color of text (usually same as colorForeground). -->
+    <attr name="textColor" format="reference|color" />
+    <!-- Color of highlighted text. -->
+    <attr name="textColorHighlight" format="reference|color" />
+    <!-- Color of hint text (displayed when the field is empty). -->
+    <attr name="textColorHint" format="reference|color" />
+    <!-- Color of link text (URLs). -->
+    <attr name="textColorLink" format="reference|color" />
+    <declare-styleable name="TextAppearance">
+        <attr name="textColor"/>
+        <attr name="textSize"/>
+        <attr name="textStyle"/>
+        <attr name="typeface"/>
+        <attr name="textColorHighlight"/>
+        <attr name="textColorHint"/>
+        <attr name="textColorLink"/>
+    </declare-styleable>
+    <!-- Integer used to uniquely identify theme overrides. -->
+    <attr name="themeType" format="integer"/>
+    <!-- Theme reference used to override parent theme. -->
+    <attr name="themeOverrideAttr" format="reference"/>
+
+    <!-- Drawable theming attributes -->
+    <attr name="themeBoolean" />
+    <attr name="themeColor" />
+    <attr name="themeFloat" />
+    <attr name="themeInteger" />
+    <attr name="themeDimension" />
+    <attr name="themeDrawable" />
+    <attr name="themeBitmap" />
+    <attr name="themeNinePatch" />
+    <attr name="themeGravity" />
+    <attr name="themeTileMode" />
+    <attr name="themeAngle" />
+</resources>
diff --git a/tests/src/android/widget/cts/ViewFlipperStubActivity.java b/tests/tests/widget/res/values/colors.xml
similarity index 60%
copy from tests/src/android/widget/cts/ViewFlipperStubActivity.java
copy to tests/tests/widget/res/values/colors.xml
index 2ac331e..f3cc325 100644
--- a/tests/src/android/widget/cts/ViewFlipperStubActivity.java
+++ b/tests/tests/widget/res/values/colors.xml
@@ -1,4 +1,5 @@
-/*
+<?xml version="1.0" encoding="utf-8"?>
+<!--
  * Copyright (C) 2008 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,21 +13,14 @@
  * 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.widget.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class ViewFlipperStubActivity extends Activity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        setContentView(R.layout.viewflipper_layout);
-    }
-}
-
+<resources>
+    <drawable name="red">#7f00</drawable>
+    <drawable name="blue">#770000ff</drawable>
+    <drawable name="black">#77ffffff</drawable>
+    <drawable name="yellow">#77ffff00</drawable>
+    <color name="testcolor1">#ff00ff00</color>
+    <color name="testcolor2">#ffff0000</color>
+    <color name="failColor">#ff0000ff</color>
+</resources>
diff --git a/tests/tests/widget/res/values/strings.xml b/tests/tests/widget/res/values/strings.xml
new file mode 100644
index 0000000..c167278
--- /dev/null
+++ b/tests/tests/widget/res/values/strings.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="permlab_testGranted">Test Granted</string>
+    <string name="permdesc_testGranted">Used for running CTS tests, for testing operations
+        where we have the permission.</string>
+    <string name="permlab_testDynamic">Test Dynamic</string>
+    <string name="permdesc_testDynamic">Used for running CTS tests, for testing adding
+        dynamic permissions.</string>
+    <string name="permlab_testDenied">Test Denied</string>
+    <string name="permdesc_testDenied">Used for running CTS tests, for testing operations
+        where we do not have the permission.</string>
+    <string name="explain">1. click start. \n2. if above image shaked, then press pass button,
+         else press failed button.</string>
+    <string name="text_view_hello">Hello! Text view!</string>
+    <string name="text_view_hello_two_lines">Hello! \nText view!</string>
+    <string name="text_view_simple_hint">This is a hint.</string>
+    <string name="text_view_hint">This is a string for testing hint of textview.</string>
+    <string name="activity_forwarding">App/Forwarding</string>
+    <string name="forwarding">$$$</string>
+    <string name="go">Go</string>
+    <string name="back">Back</string>
+    <string name="forward_target">
+        Press back button and notice we don\'t see the previous activity.
+    </string>
+    <string name="edit_text">testing</string>
+    <string name="text">DialogTest</string>
+    <string name="text_country">Country</string>
+    <string name="text_name">Name</string>
+    <string name="hello_world">Hello, World!</string>
+    <string name="hello_android">Hello, Android!</string>
+    <string name="alert_dialog_username">Name:</string>
+    <string name="alert_dialog_password">Password:</string>
+    <string name="alert_dialog_positive">Positive</string>
+    <string name="alert_dialog_negative">Negative</string>
+    <string name="alert_dialog_neutral">Neutral</string>
+    <string name="notify">Notify </string>
+    <string name="tabs_1">testing</string>
+    <string name="table_layout_first">first</string>
+    <string name="table_layout_second">second</string>
+    <string name="table_layout_third">third</string>
+    <string name="table_layout_long">Very long to make the string out of the screen</string>
+    <string name="chronometer_text">Test Chronometer</string>
+    <string name="am">AM</string>
+    <string name="pm">PM</string>
+    <string name="viewgroup_test">ViewGroup test</string>
+    <string name="viewanimator_test">ViewAnimator test</string>
+    <string name="id_ok">OK</string>
+    <string name="id_cancel">Cancel</string>
+    <string name="context_test_string1">This is %s string.</string>
+    <string name="context_test_string2">This is test string.</string>
+    <string name="animationutils_test_instructions">Choose different animations</string>
+    <string name="animationutils_test_alpha">Alpha animation</string>
+    <string name="animationutils_test_scale">Scale animation</string>
+    <string name="animationutils_test_rotate">Rotate animation</string>
+    <string name="animationutils_test_translate">Translate animation</string>
+    <string name="animationutils_test_set">Animation set</string>
+    <string name="animationutils_test_layout">Layout animation</string>
+    <string name="animationutils_test_gridlayout">Grid layout animation</string>
+    <string name="twolinelistitem_test_text1">text1</string>
+    <string name="twolinelistitem_test_text2">text2</string>
+    <string name="metadata_text">metadata text</string>
+    <string name="horizontal_text_1">horizontal 1</string>
+    <string name="horizontal_text_2">horizontal 2</string>
+    <string name="horizontal_text_3">horizontal 3</string>
+    <string name="vertical_text_1">vertical 1</string>
+    <string name="vertical_text_2">vertical 2</string>
+    <string name="vertical_text_3">vertical 3</string>
+    <string name="reference">here</string>
+    <string name="coerceIntegerToString">100</string>
+    <string name="coerceBooleanToString">true</string>
+    <string name="coerceColorToString">#fff</string>
+    <string name="coerceFloatToString">100.0</string>
+    <string name="coerceDimensionToString">100px</string>
+    <string name="coerceFractionToString">100<xliff:g id="percent">%</xliff:g></string>
+    <string name="formattedStringNone">Format[]</string>
+    <string name="formattedStringOne">Format[<xliff:g id="format">%d</xliff:g>]</string>
+    <string name="formattedStringTwo">Format[<xliff:g id="format">%3$d,%2$s</xliff:g>]</string>
+    <string name="checkboxpref_key">checkboxpref_key</string>
+   <string name="checkboxpref_title">title of preference</string>
+   <string name="checkboxpref_summary">summary of preference</string>
+   <string name="checkboxpref_summary_on">summary on of preference</string>
+   <string name="checkboxpref_summary_off">summary off of preference</string>
+   <string name="checkboxpref_depend">checkboxpref_depend</string>
+   <string name="checkboxpref_depend_title"> depend title of preference</string>
+   <string name="checkboxpref_depend_summary"> depend summary of preference</string>
+   <string name="edittextpref_key">edittextpref_key</string>
+   <string name="edittextpref_default_value">default value of preference</string>
+   <string name="edittextpref_title">title of edit text preference</string>
+   <string name="edittextpref_summary">summary of edit text preference</string>
+   <string name="edittextpref_dialog_title">dialog title of edit text preference</string>
+   <string name="edittextpref_text">text of  edit text preference</string>
+   <string name="listpref_key">listpref_key</string>
+   <string name="listpref_title">title of list preference</string>
+   <string name="listpref_summary">summary of list preference</string>
+   <string name="listpref_dialogtitle">dialog title of list preference</string>
+   <string name="easy">Easy</string>
+   <string name="medium">Medium</string>
+   <string name="hard">Hard</string>
+   <string name="footer_view">Footer view</string>
+   <string name="header_view">Header view</string>
+   <string name="dialogpref_title">title of dialog preference </string>
+   <string name="dialogpref_dialog_title">dialog title of dialog preference </string>
+   <string name="dialogpref_key">dialogpref_key</string>
+   <string name="dialogpref_default_value">default value of dialog preference</string>
+   <string name="dialogpref_summary">summary of dialog preference</string>
+   <string name="dialogpref_message">message of dialog preference</string>
+   <string name="dialogpref_sure">Sure</string>
+   <string name="dialogpref_cancel">Cancel</string>
+   <string name="pref_key">pref_key</string>
+   <string name="pref_title">title of preference</string>
+   <string name="pref_summary">summary of preference</string>
+   <string name="pref_depend_key">pref_depend_key</string>
+   <string name="pref_depend_title"> depend title of preference</string>
+   <string name="pref_depend_summary"> depend summary of preference</string>
+   <string name="android_intent_action_preference">android.intent.action.PREFERENCE</string>
+   <string name="def_pref_key">def_pref_key</string>
+   <string name="def_pref_title">default preference</string>
+   <string name="def_pref_summary">This is default preference of cts</string>
+   <string name="relative_view1">view 1</string>
+   <string name="relative_view2">view 2</string>
+   <string name="relative_view3">view 3</string>
+   <string name="relative_view4">view 4</string>
+   <string name="relative_view5">view 5</string>
+   <string name="relative_view6">view 6</string>
+   <string name="relative_view7">view 7</string>
+   <string name="relative_view8">view 8</string>
+   <string name="relative_view9">view 9</string>
+   <string name="relative_view10">view 10</string>
+   <string name="relative_view11">view 11</string>
+   <string name="relative_view12">view 12</string>
+   <string name="relative_view13">view 13</string>
+   <string name="country">Country:</string>
+   <string name="symbol">Symbol:</string>
+   <string name="country_warning">No such country registered</string>
+   <string name="version_cur">base</string>
+   <string name="version_old">base</string>
+   <string name="version_v3">base</string>
+   <string name="authenticator_label">Android CTS</string>
+   <string name="search_label">Android CTS</string>
+   <string name="tag1">tag 1</string>
+   <string name="tag2">tag 2</string>
+
+   <string name="button">Button</string>
+   <string name="holo_test">Holo Test</string>
+   <string name="holo_generator">Holo Generator</string>
+   <string name="holo_light_test">Holo Light Test</string>
+   <string name="holo_light_generator">Holo Light Generator</string>
+   <string name="reference_image">Reference Image: </string>
+   <string name="generated_image">Generated Image: </string>
+   <string name="themes_prompt">Select a Theme:</string>
+   <string name="sample_text">Sample text goes here. I wanted something creative and whimsical
+but then I just got bored...</string>
+    <string name="long_text">This is a really long string which exceeds the width of the view.
+New devices have a much larger screen which actually enables long strings to be displayed
+with no fading. I have made this string longer to fix this case. If you are correcting this
+text, I would love to see the kind of devices you guys now use! Guys, maybe some devices need longer string!
+I think so, so how about double this string, like copy and paste!
+This is a really long string which exceeds the width of the view.
+New devices have a much larger screen which actually enables long strings to be displayed
+with no fading. I have made this string longer to fix this case. If you are correcting this
+text, I would love to see the kind of devices you guys now use! Guys, maybe some devices need longer string!
+I think so, so how about double this string, like copy and paste! </string>
+    <string name="rectangle200">"M 0,0 l 200,0 l 0, 200 l -200, 0 z"</string>
+</resources>
diff --git a/tests/tests/widget/res/values/styles.xml b/tests/tests/widget/res/values/styles.xml
new file mode 100644
index 0000000..81925cc
--- /dev/null
+++ b/tests/tests/widget/res/values/styles.xml
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <style name="Whatever">
+        <item name="type1">true</item>
+        <item name="type2">false</item>
+        <item name="type3">#ff0000ff</item>
+        <item name="type4">#ff00ff00</item>
+        <item name="type5">0.75px</item>
+        <item name="type6">10px</item>
+        <item name="type7">18px</item>
+        <item name="type8">@drawable/pass</item>
+        <item name="type9">3.14</item>
+        <item name="type10">100%</item>
+        <item name="type11">365</item>
+        <item name="type12">86400</item>
+        <item name="type13">@string/hello_android</item>
+        <item name="type14">TypedArray Test!</item>
+        <item name="type15">@array/difficultyLevel</item>
+        <item name="type16">Typed Value!</item>
+    </style>
+
+    <style name="TextViewWithoutColorAndAppearance">
+        <item name="android:textSize">18sp</item>
+    </style>
+
+    <style name="TextViewWithColorButWithOutAppearance">
+        <item name="android:textColor">#ff0000ff</item>
+    </style>
+
+    <style name="TextViewWithColorAndAppearance">
+        <item name="android:textColor">#ff0000ff</item>
+        <item name="android:textAppearance">@style/TextAppearance.WithColor</item>
+    </style>
+
+    <style name="TextViewWithoutColorButWithAppearance">
+        <item name="android:textAppearance">@style/TextAppearance.WithColor</item>
+    </style>
+
+    <style name="TextAppearance" parent="android:TextAppearance">
+    </style>
+
+    <style name="TextAppearance.WithColor">
+        <item name="android:textColor">#ffff0000</item>
+    </style>
+
+    <style name="TextAppearance.All">
+        <item name="android:textColor">@drawable/black</item>
+        <item name="android:textSize">20px</item>
+        <item name="android:textStyle">bold</item>
+        <item name="android:textColorHint">@drawable/red</item>
+        <item name="android:textColorLink">@drawable/blue</item>
+        <item name="android:textColorHighlight">@drawable/yellow</item>
+    </style>
+
+    <style name="TextAppearance.Colors">
+        <item name="android:textColor">@drawable/black</item>
+        <item name="android:textColorHint">@drawable/blue</item>
+        <item name="android:textColorLink">@drawable/yellow</item>
+        <item name="android:textColorHighlight">@drawable/red</item>
+    </style>
+
+    <style name="TextAppearance.NotColors">
+        <item name="android:textSize">17px</item>
+        <item name="android:typeface">sans</item>
+        <item name="android:textStyle">normal</item>
+    </style>
+
+    <style name="TextAppearance.Style">
+        <item name="android:textStyle">normal</item>
+    </style>
+
+    <style name="TestEnum1">
+        <item name="testEnum">val1</item>
+    </style>
+
+    <style name="TestEnum2">
+        <item name="testEnum">val2</item>
+    </style>
+
+    <style name="TestEnum10">
+        <item name="testEnum">val10</item>
+    </style>
+
+    <style name="TestFlag1">
+        <item name="testFlags">bit1</item>
+    </style>
+
+    <style name="TestFlag2">
+        <item name="testFlags">bit2</item>
+    </style>
+
+    <style name="TestFlag31">
+        <item name="testFlags">bit31</item>
+    </style>
+
+    <style name="TestFlag1And2">
+        <item name="testFlags">bit1|bit2</item>
+    </style>
+
+    <style name="TestFlag1And2And31">
+        <item name="testFlags">bit1|bit2|bit31</item>
+    </style>
+
+    <style name="TestEnum1.EmptyInherit" />
+
+    <style name="Theme_AlertDialog">
+        <item name="android:textSize">18sp</item>
+    </style>
+
+    <style name="TestProgressBar">
+        <item name="android:indeterminateOnly">false</item>
+        <item name="android:progressDrawable">?android:drawable/progress_horizontal</item>
+        <item name="android:indeterminateDrawable">?android:drawable/progress_horizontal</item>
+        <item name="android:minHeight">20dip</item>
+        <item name="android:maxHeight">20dip</item>
+        <item name="android:focusable">true</item>
+    </style>
+
+    <style name="Test_Theme">
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:panelColorForeground">#ff000000</item>
+        <item name="android:panelColorBackground">#ffffffff</item>
+    </style>
+
+    <style name="Theme_OverrideOuter">
+        <item name="themeType">1</item>
+    </style>
+
+    <style name="Theme_OverrideInner">
+        <item name="themeType">2</item>
+        <item name="themeOverrideAttr">@style/Theme_OverrideAttr</item>
+    </style>
+
+    <style name="Theme_OverrideAttr">
+        <item name="themeType">3</item>
+    </style>
+
+    <style name="Theme_ThemedDrawableTest">
+        <item name="themeBoolean">true</item>
+        <item name="themeColor">@android:color/black</item>
+        <item name="themeFloat">1.0</item>
+        <item name="themeAngle">45.0</item>
+        <item name="themeInteger">1</item>
+        <item name="themeDimension">1px</item>
+        <item name="themeDrawable">@drawable/icon_black</item>
+        <item name="themeBitmap">@drawable/icon_black</item>
+        <item name="themeNinePatch">@drawable/ninepatch_0</item>
+        <item name="themeGravity">48</item>
+        <item name="themeTileMode">2</item>
+    </style>
+
+    <style name="Theme_NoSwipeDismiss">
+        <item name="android:windowSwipeToDismiss">false</item>
+    </style>
+
+</resources>
diff --git a/tests/tests/widget/res/xml/base_attributes.xml b/tests/tests/widget/res/xml/base_attributes.xml
new file mode 100644
index 0000000..adb44de
--- /dev/null
+++ b/tests/tests/widget/res/xml/base_attributes.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+ -->
+<alias xmlns:android="http://schemas.android.com/apk/res/android">
+    <base_attr_pixel>
+        <Attributes xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="400px"
+            android:layout_height="600px"/>
+    </base_attr_pixel>
+    <base_attr_fillwrap>
+        <Attributes xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"/>
+    </base_attr_fillwrap>
+    <base_attr_noheight>
+        <Attributes xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="600px"/>
+    </base_attr_noheight>
+</alias>
diff --git a/tests/src/android/os/cts/TaggedPointer.java b/tests/tests/widget/res/xml/input_extras.xml
similarity index 64%
copy from tests/src/android/os/cts/TaggedPointer.java
copy to tests/tests/widget/res/xml/input_extras.xml
index 16e76c9..ce5eb5e 100644
--- a/tests/src/android/os/cts/TaggedPointer.java
+++ b/tests/tests/widget/res/xml/input_extras.xml
@@ -1,5 +1,6 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
@@ -12,15 +13,9 @@
  * 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.
- */
+-->
+<input-extras xmlns:android="http://schemas.android.com/apk/res/android">
+    <extra android:name="google" android:value="android"/>
+    <extra android:name="test" android:value="cts"/>
+</input-extras>
 
-package android.os.cts;
-
-public class TaggedPointer {
-
-    static {
-        System.loadLibrary("cts_jni");
-    }
-
-    public static native boolean hasTaggedPointer();
-}
diff --git a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
index 7dcae28..b6a96fb 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
@@ -52,7 +52,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-public class AbsListViewTest extends ActivityInstrumentationTestCase2<ListViewStubActivity> {
+public class AbsListViewTest extends ActivityInstrumentationTestCase2<ListViewCtsActivity> {
     private final String[] mShortList = new String[] {
         "This", "is", "short", "!",
     };
@@ -72,7 +72,7 @@
     private static final float DELTA = 0.001f;
 
     public AbsListViewTest() {
-        super("com.android.cts.stub", ListViewStubActivity.class);
+        super("com.android.cts.widget", ListViewCtsActivity.class);
     }
 
 
diff --git a/tests/tests/widget/src/android/widget/cts/AbsListView_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/AbsListView_LayoutParamsTest.java
index 655b5ee..413bc2a 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsListView_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsListView_LayoutParamsTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/tests/widget/src/android/widget/cts/AbsSeekBarTest.java b/tests/tests/widget/src/android/widget/cts/AbsSeekBarTest.java
index 58230e5..419a1c8 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsSeekBarTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsSeekBarTest.java
@@ -21,7 +21,7 @@
 import android.graphics.PorterDuff;
 import android.test.UiThreadTest;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -40,9 +40,9 @@
 /**
  * Test {@link AbsSeekBar}.
  */
-public class AbsSeekBarTest extends ActivityInstrumentationTestCase2<ProgressBarStubActivity> {
+public class AbsSeekBarTest extends ActivityInstrumentationTestCase2<ProgressBarCtsActivity> {
     public AbsSeekBarTest() {
-        super("com.android.cts.stub", ProgressBarStubActivity.class);
+        super("com.android.cts.widget", ProgressBarCtsActivity.class);
     }
 
     private Activity mActivity;
diff --git a/tests/tests/widget/src/android/widget/cts/AbsSpinnerTest.java b/tests/tests/widget/src/android/widget/cts/AbsSpinnerTest.java
index fc37a64..70b37e6 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsSpinnerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsSpinnerTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -39,11 +39,11 @@
 import android.widget.Spinner;
 import android.widget.SpinnerAdapter;
 
-public class AbsSpinnerTest extends ActivityInstrumentationTestCase2<RelativeLayoutStubActivity> {
+public class AbsSpinnerTest extends ActivityInstrumentationTestCase2<RelativeLayoutCtsActivity> {
     private Context mContext;
 
     public AbsSpinnerTest() {
-        super("com.android.cts.stub", RelativeLayoutStubActivity.class);
+        super("com.android.cts.widget", RelativeLayoutCtsActivity.class);
     }
 
     @Override
@@ -78,7 +78,7 @@
     public void testSetSelectionIntBoolean() {
         AbsSpinner absSpinner = (AbsSpinner) getActivity().findViewById(R.id.spinner1);
         ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext,
-                com.android.cts.stub.R.array.string, android.R.layout.simple_spinner_item);
+                com.android.cts.widget.R.array.string, android.R.layout.simple_spinner_item);
         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
         absSpinner.setAdapter(adapter);
         assertEquals(0, absSpinner.getSelectedItemPosition());
@@ -101,7 +101,7 @@
     public void testSetSelectionInt() {
         AbsSpinner absSpinner = (AbsSpinner) getActivity().findViewById(R.id.spinner1);
         ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext,
-                com.android.cts.stub.R.array.string, android.R.layout.simple_spinner_item);
+                com.android.cts.widget.R.array.string, android.R.layout.simple_spinner_item);
         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
         absSpinner.setAdapter(adapter);
         assertEquals(0, absSpinner.getSelectedItemPosition());
@@ -123,7 +123,7 @@
     public void testAccessAdapter() {
         AbsSpinner absSpinner = (AbsSpinner) getActivity().findViewById(R.id.spinner1);
         ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext,
-                com.android.cts.stub.R.array.string, android.R.layout.simple_spinner_item);
+                com.android.cts.widget.R.array.string, android.R.layout.simple_spinner_item);
         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
 
         absSpinner.setAdapter(adapter);
@@ -158,7 +158,7 @@
         AbsSpinner absSpinner = (AbsSpinner) getActivity().findViewById(R.id.spinner1);
 
         ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource(mContext,
-                com.android.cts.stub.R.array.string, android.R.layout.simple_spinner_item);
+                com.android.cts.widget.R.array.string, android.R.layout.simple_spinner_item);
 
         absSpinner.setAdapter(adapter1);
         assertEquals(adapter1.getCount(), absSpinner.getCount());
@@ -233,7 +233,7 @@
     public void testOnSaveAndRestoreInstanceState() {
         AbsSpinner absSpinner = (AbsSpinner) getActivity().findViewById(R.id.spinner1);
         ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext,
-                com.android.cts.stub.R.array.string, android.R.layout.simple_spinner_item);
+                com.android.cts.widget.R.array.string, android.R.layout.simple_spinner_item);
         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
         absSpinner.setAdapter(adapter);
         assertEquals(0, absSpinner.getSelectedItemPosition());
diff --git a/tests/tests/widget/src/android/widget/cts/AbsoluteLayoutTest.java b/tests/tests/widget/src/android/widget/cts/AbsoluteLayoutTest.java
index 8d2b6cd..053f42b 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsoluteLayoutTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsoluteLayoutTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -34,7 +34,7 @@
 import java.io.IOException;
 
 @SuppressWarnings("deprecation")
-public class AbsoluteLayoutTest extends ActivityInstrumentationTestCase2<StubActivity> {
+public class AbsoluteLayoutTest extends ActivityInstrumentationTestCase2<CtsActivity> {
     private static final int DEFAULT_X      = 5;
     private static final int DEFAULT_Y      = 10;
     private static final int DEFAULT_WIDTH  = 20;
@@ -45,7 +45,7 @@
     private LayoutParams mAbsoluteLayoutParams;
 
     public AbsoluteLayoutTest() {
-        super("com.android.cts.stub", StubActivity.class);
+        super("com.android.cts.widget", CtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/AbsoluteLayout_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/AbsoluteLayout_LayoutParamsTest.java
index 63be7d4..685f2d3 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsoluteLayout_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsoluteLayout_LayoutParamsTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/src/android/widget/cts/AdapterViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/AdapterViewCtsActivity.java
similarity index 94%
rename from tests/src/android/widget/cts/AdapterViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/AdapterViewCtsActivity.java
index edcf13d..956ff9a 100644
--- a/tests/src/android/widget/cts/AdapterViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/AdapterViewCtsActivity.java
@@ -25,12 +25,12 @@
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for AdapterView test.
  */
-public class AdapterViewStubActivity extends Activity {
+public class AdapterViewCtsActivity extends Activity {
     private ListView mView;
 
     /**
diff --git a/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java b/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
index b91ca73..81a1a4b 100644
--- a/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
@@ -38,10 +38,10 @@
 import android.widget.AdapterView.OnItemLongClickListener;
 import android.widget.AdapterView.OnItemSelectedListener;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
-public class AdapterViewTest extends ActivityInstrumentationTestCase2<AdapterViewStubActivity> {
+public class AdapterViewTest extends ActivityInstrumentationTestCase2<AdapterViewCtsActivity> {
 
     private final static int INVALID_ID = -1;
 
@@ -54,7 +54,7 @@
     private AdapterView<ListAdapter> mAdapterView;
 
     public AdapterViewTest() {
-        super("com.android.cts.stub", AdapterViewStubActivity.class);
+        super("com.android.cts.widget", AdapterViewCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/AnalogClockTest.java b/tests/tests/widget/src/android/widget/cts/AnalogClockTest.java
index f3b02b0..b360fd1 100644
--- a/tests/tests/widget/src/android/widget/cts/AnalogClockTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AnalogClockTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -27,12 +27,12 @@
 import android.util.Xml;
 import android.widget.AnalogClock;
 
-public class AnalogClockTest extends ActivityInstrumentationTestCase2<FrameLayoutStubActivity> {
+public class AnalogClockTest extends ActivityInstrumentationTestCase2<FrameLayoutCtsActivity> {
     private AttributeSet mAttrSet;
     private Activity mActivity;
 
     public AnalogClockTest() {
-        super("com.android.cts.stub", FrameLayoutStubActivity.class);
+        super("com.android.cts.widget", FrameLayoutCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java b/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
index 101b271..3b00754 100644
--- a/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ArrayAdapterTest.java
@@ -26,7 +26,7 @@
 import android.widget.Filter;
 import android.widget.TextView;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 public class ArrayAdapterTest extends AndroidTestCase {
diff --git a/tests/src/android/widget/cts/AutoCompleteStubActivity.java b/tests/tests/widget/src/android/widget/cts/AutoCompleteCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/AutoCompleteStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/AutoCompleteCtsActivity.java
index a23b6eb..3d68f3e 100644
--- a/tests/src/android/widget/cts/AutoCompleteStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/AutoCompleteCtsActivity.java
@@ -19,12 +19,12 @@
 import android.app.Activity;
 import android.os.Bundle;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for AutoCompleteTextView test.
  */
-public class AutoCompleteStubActivity extends Activity {
+public class AutoCompleteCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java b/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
index 373c03b..f3a58bc 100644
--- a/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -45,13 +45,13 @@
 import java.io.IOException;
 
 public class AutoCompleteTextViewTest extends
-        ActivityInstrumentationTestCase2<AutoCompleteStubActivity> {
+        ActivityInstrumentationTestCase2<AutoCompleteCtsActivity> {
 
     /**
      * Instantiates a new text view test.
      */
     public AutoCompleteTextViewTest() {
-        super("com.android.cts.stub", AutoCompleteStubActivity.class);
+        super("com.android.cts.widget", AutoCompleteCtsActivity.class);
     }
 
     /** The m activity. */
diff --git a/tests/tests/widget/src/android/widget/cts/ButtonTest.java b/tests/tests/widget/src/android/widget/cts/ButtonTest.java
index 98b3318..47d7108 100644
--- a/tests/tests/widget/src/android/widget/cts/ButtonTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ButtonTest.java
@@ -24,7 +24,7 @@
 import android.util.Xml;
 import android.widget.Button;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 public class ButtonTest extends AndroidTestCase {
diff --git a/tests/tests/widget/src/android/widget/cts/CheckBoxTest.java b/tests/tests/widget/src/android/widget/cts/CheckBoxTest.java
index 55960f9..21e463f 100644
--- a/tests/tests/widget/src/android/widget/cts/CheckBoxTest.java
+++ b/tests/tests/widget/src/android/widget/cts/CheckBoxTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/src/android/widget/cts/CheckedTextViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/CheckedTextViewCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/CheckedTextViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/CheckedTextViewCtsActivity.java
index 1c8d63e..a0ed498 100644
--- a/tests/src/android/widget/cts/CheckedTextViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/CheckedTextViewCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for CheckedTextView test.
  */
-public class CheckedTextViewStubActivity extends Activity {
+public class CheckedTextViewCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/CheckedTextViewTest.java b/tests/tests/widget/src/android/widget/cts/CheckedTextViewTest.java
index 6aa44c1..c5d3bd1 100644
--- a/tests/tests/widget/src/android/widget/cts/CheckedTextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/CheckedTextViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -38,13 +38,13 @@
 import java.util.Arrays;
 
 public class CheckedTextViewTest extends
-        ActivityInstrumentationTestCase2<CheckedTextViewStubActivity> {
+        ActivityInstrumentationTestCase2<CheckedTextViewCtsActivity> {
     private Resources mResources;
     private Activity mActivity;
     private Instrumentation mInstrumentation;
 
     public CheckedTextViewTest() {
-        super("com.android.cts.stub", CheckedTextViewStubActivity.class);
+        super("com.android.cts.widget", CheckedTextViewCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/ChronometerStubActivity.java b/tests/tests/widget/src/android/widget/cts/ChronometerCtsActivity.java
similarity index 92%
rename from tests/src/android/widget/cts/ChronometerStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ChronometerCtsActivity.java
index f72a427..3a7833d 100644
--- a/tests/src/android/widget/cts/ChronometerStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ChronometerCtsActivity.java
@@ -16,13 +16,13 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import android.app.Activity;
 import android.os.Bundle;
 import android.view.ViewGroup;
 import android.widget.Chronometer;
 
-public class ChronometerStubActivity extends Activity {
+public class ChronometerCtsActivity extends Activity {
 
     private Chronometer chronometer;
 
diff --git a/tests/tests/widget/src/android/widget/cts/ChronometerTest.java b/tests/tests/widget/src/android/widget/cts/ChronometerTest.java
index 7fbb58a..992577c 100644
--- a/tests/tests/widget/src/android/widget/cts/ChronometerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ChronometerTest.java
@@ -25,10 +25,10 @@
 /**
  * Test {@link Chronometer}.
  */
-public class ChronometerTest extends ActivityInstrumentationTestCase2<ChronometerStubActivity> {
-    private ChronometerStubActivity mActivity;
+public class ChronometerTest extends ActivityInstrumentationTestCase2<ChronometerCtsActivity> {
+    private ChronometerCtsActivity mActivity;
     public ChronometerTest() {
-        super("com.android.cts.stub", ChronometerStubActivity.class);
+        super("com.android.cts.widget", ChronometerCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/CompoundButtonTest.java b/tests/tests/widget/src/android/widget/cts/CompoundButtonTest.java
index 6674ef6..bf5382a 100644
--- a/tests/tests/widget/src/android/widget/cts/CompoundButtonTest.java
+++ b/tests/tests/widget/src/android/widget/cts/CompoundButtonTest.java
@@ -22,7 +22,7 @@
 import android.graphics.PorterDuff;
 import android.view.LayoutInflater;
 import android.widget.ToggleButton;
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/src/android/widget/cts/StubActivity.java b/tests/tests/widget/src/android/widget/cts/CtsActivity.java
similarity index 93%
rename from tests/src/android/widget/cts/StubActivity.java
rename to tests/tests/widget/src/android/widget/cts/CtsActivity.java
index fe4002c..e099694 100644
--- a/tests/src/android/widget/cts/StubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/CtsActivity.java
@@ -21,6 +21,6 @@
 /**
  * Stub activity for helping test. It's an empty activity.
  */
-public class StubActivity extends Activity {
+public class CtsActivity extends Activity {
 
 }
diff --git a/tests/tests/widget/src/android/widget/cts/CursorAdapterTest.java b/tests/tests/widget/src/android/widget/cts/CursorAdapterTest.java
index 963c392..6ff22b0 100644
--- a/tests/tests/widget/src/android/widget/cts/CursorAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/CursorAdapterTest.java
@@ -25,7 +25,6 @@
 import android.database.DataSetObserver;
 import android.database.sqlite.SQLiteDatabase;
 import android.os.Looper;
-import android.os.cts.TestThread;
 import android.test.AndroidTestCase;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -35,7 +34,7 @@
 import android.widget.FilterQueryProvider;
 import android.widget.TextView;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 /**
diff --git a/tests/tests/widget/src/android/widget/cts/CursorTreeAdapterTest.java b/tests/tests/widget/src/android/widget/cts/CursorTreeAdapterTest.java
index 1d26777..011a031 100644
--- a/tests/tests/widget/src/android/widget/cts/CursorTreeAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/CursorTreeAdapterTest.java
@@ -31,7 +31,7 @@
 import android.widget.FilterQueryProvider;
 import android.widget.TextView;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 /**
diff --git a/tests/tests/widget/src/android/widget/cts/DatePickerTest.java b/tests/tests/widget/src/android/widget/cts/DatePickerTest.java
index ad9da7c..aa727b7 100644
--- a/tests/tests/widget/src/android/widget/cts/DatePickerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/DatePickerTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import com.android.internal.util.XmlUtils;
 
 
diff --git a/tests/src/android/widget/cts/DialerFilterStubActivity.java b/tests/tests/widget/src/android/widget/cts/DialerFilterCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/DialerFilterStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/DialerFilterCtsActivity.java
index b67803a..572d3fb 100644
--- a/tests/src/android/widget/cts/DialerFilterStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/DialerFilterCtsActivity.java
@@ -18,12 +18,12 @@
 
 import android.app.Activity;
 import android.os.Bundle;
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for DialerFilter test.
  */
-public class DialerFilterStubActivity extends Activity {
+public class DialerFilterCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java b/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java
index 1c5c7ff..9b7fb56 100644
--- a/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -39,13 +39,13 @@
 import android.widget.EditText;
 import android.widget.RelativeLayout;
 
-public class DialerFilterTest extends ActivityInstrumentationTestCase2<DialerFilterStubActivity> {
+public class DialerFilterTest extends ActivityInstrumentationTestCase2<DialerFilterCtsActivity> {
     private Activity mActivity;
     private Instrumentation mInstrumentation;
     private DialerFilter mDialerFilter;
 
     public DialerFilterTest() {
-        super("com.android.cts.stub", DialerFilterStubActivity.class);
+        super("com.android.cts.widget", DialerFilterCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/DigitalClockStubActivity.java b/tests/tests/widget/src/android/widget/cts/DigitalClockCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/DigitalClockStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/DigitalClockCtsActivity.java
index 2351bc2..68cb3f0 100644
--- a/tests/src/android/widget/cts/DigitalClockStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/DigitalClockCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for TextView test.
  */
-public class DigitalClockStubActivity extends Activity {
+public class DigitalClockCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/DigitalClockTest.java b/tests/tests/widget/src/android/widget/cts/DigitalClockTest.java
index 4184cdd..26caef0 100644
--- a/tests/tests/widget/src/android/widget/cts/DigitalClockTest.java
+++ b/tests/tests/widget/src/android/widget/cts/DigitalClockTest.java
@@ -30,19 +30,19 @@
 import android.widget.DigitalClock;
 import android.widget.LinearLayout;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import com.android.internal.util.XmlUtils;
 
 
 /**
  * Test {@link DigitalClock}.
  */
-public class DigitalClockTest extends ActivityInstrumentationTestCase<DigitalClockStubActivity> {
+public class DigitalClockTest extends ActivityInstrumentationTestCase<DigitalClockCtsActivity> {
     private Activity mActivity;
     private Context mContext;
 
     public DigitalClockTest() {
-        super("com.android.cts.stub", DigitalClockStubActivity.class);
+        super("com.android.cts.widget", DigitalClockCtsActivity.class);
     }
 
     @Override
@@ -113,7 +113,7 @@
     private AttributeSet getAttributeSet(int resourceId) {
         XmlResourceParser parser = mActivity.getResources().getXml(resourceId);
         try {
-            XmlUtils.beginDocument(parser, "com.android.cts.stub.alarmclock.DigitalClock");
+            XmlUtils.beginDocument(parser, "com.android.cts.widget.alarmclock.DigitalClock");
         } catch (XmlPullParserException e) {
             fail("unexpected XmlPullParserException.");
         } catch (IOException e) {
diff --git a/tests/tests/widget/src/android/widget/cts/EditTextTest.java b/tests/tests/widget/src/android/widget/cts/EditTextTest.java
index ee10900..7a71a58 100644
--- a/tests/tests/widget/src/android/widget/cts/EditTextTest.java
+++ b/tests/tests/widget/src/android/widget/cts/EditTextTest.java
@@ -28,7 +28,7 @@
 import android.widget.EditText;
 import android.widget.TextView.BufferType;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 public class EditTextTest extends AndroidTestCase {
diff --git a/tests/src/android/widget/cts/ExpandableListSimple.java b/tests/tests/widget/src/android/widget/cts/ExpandableListSimple.java
similarity index 100%
rename from tests/src/android/widget/cts/ExpandableListSimple.java
rename to tests/tests/widget/src/android/widget/cts/ExpandableListSimple.java
diff --git a/tests/tests/widget/src/android/widget/cts/ExpandableListViewTest.java b/tests/tests/widget/src/android/widget/cts/ExpandableListViewTest.java
index 67dcb30..ac48ed8 100644
--- a/tests/tests/widget/src/android/widget/cts/ExpandableListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ExpandableListViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/src/android/widget/cts/ExpandableListWithHeaders.java b/tests/tests/widget/src/android/widget/cts/ExpandableListWithHeaders.java
similarity index 100%
rename from tests/src/android/widget/cts/ExpandableListWithHeaders.java
rename to tests/tests/widget/src/android/widget/cts/ExpandableListWithHeaders.java
diff --git a/tests/tests/widget/src/android/widget/cts/FilterTest.java b/tests/tests/widget/src/android/widget/cts/FilterTest.java
index 394f861..3441431 100644
--- a/tests/tests/widget/src/android/widget/cts/FilterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/FilterTest.java
@@ -22,13 +22,13 @@
 import android.widget.Filter;
 import android.widget.Filter.FilterListener;
 
-public class FilterTest extends ActivityInstrumentationTestCase2<StubActivity> {
+public class FilterTest extends ActivityInstrumentationTestCase2<CtsActivity> {
     private static final long TIME_OUT = 10000;
     private static final String TEST_CONSTRAINT = "filter test";
     private MockFilter mMockFilter;
 
     public FilterTest() {
-        super("com.android.cts.stub", StubActivity.class);
+        super("com.android.cts.widget", CtsActivity.class);
     }
 
     public void testConstructor() {
diff --git a/tests/src/android/widget/cts/FrameLayoutStubActivity.java b/tests/tests/widget/src/android/widget/cts/FrameLayoutCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/FrameLayoutStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/FrameLayoutCtsActivity.java
index 76482da..c638313 100644
--- a/tests/src/android/widget/cts/FrameLayoutStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/FrameLayoutCtsActivity.java
@@ -18,12 +18,12 @@
 
 import android.app.Activity;
 import android.os.Bundle;
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for frame layout test.
  */
-public class FrameLayoutStubActivity extends Activity {
+public class FrameLayoutCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/FrameLayoutTest.java b/tests/tests/widget/src/android/widget/cts/FrameLayoutTest.java
index b1a0d44..dcab088 100644
--- a/tests/tests/widget/src/android/widget/cts/FrameLayoutTest.java
+++ b/tests/tests/widget/src/android/widget/cts/FrameLayoutTest.java
@@ -22,7 +22,7 @@
 import android.graphics.ColorFilter;
 import android.graphics.PorterDuff;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
@@ -49,13 +49,13 @@
 
 import java.io.IOException;
 
-public class FrameLayoutTest extends ActivityInstrumentationTestCase2<FrameLayoutStubActivity> {
+public class FrameLayoutTest extends ActivityInstrumentationTestCase2<FrameLayoutCtsActivity> {
     private Activity mActivity;
     private Instrumentation mInstrumentation;
     private FrameLayout mFrameLayout;
 
     public FrameLayoutTest() {
-        super("com.android.cts.stub", FrameLayoutStubActivity.class);
+        super("com.android.cts.widget", FrameLayoutCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/FrameLayout_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/FrameLayout_LayoutParamsTest.java
index 89529a2..d8f1296 100644
--- a/tests/tests/widget/src/android/widget/cts/FrameLayout_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/FrameLayout_LayoutParamsTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/src/android/widget/cts/GalleryStubActivity.java b/tests/tests/widget/src/android/widget/cts/GalleryCtsActivity.java
similarity index 96%
rename from tests/src/android/widget/cts/GalleryStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/GalleryCtsActivity.java
index 8e0dd93..8d32717 100644
--- a/tests/src/android/widget/cts/GalleryStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/GalleryCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.content.Context;
@@ -30,7 +30,7 @@
 /**
  * A minimal application for {@link Gallery} test.
  */
-public class GalleryStubActivity extends Activity {
+public class GalleryCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/GalleryTest.java b/tests/tests/widget/src/android/widget/cts/GalleryTest.java
index 0aacda4..d42c375 100644
--- a/tests/tests/widget/src/android/widget/cts/GalleryTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GalleryTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import com.android.internal.view.menu.ContextMenuBuilder;
 
 
@@ -53,7 +53,7 @@
 /**
  * Test {@link Gallery}.
  */
-public class GalleryTest extends ActivityInstrumentationTestCase2<GalleryStubActivity>  {
+public class GalleryTest extends ActivityInstrumentationTestCase2<GalleryCtsActivity>  {
     private Gallery mGallery;
     private Activity mActivity;
     private Instrumentation mInstrumentation;
@@ -61,7 +61,7 @@
     private final static float DELTA = 0.01f;
 
     public GalleryTest() {
-        super("com.android.cts.stub", GalleryStubActivity.class);
+        super("com.android.cts.widget", GalleryCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/Gallery_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/Gallery_LayoutParamsTest.java
index af031e4..de90ed3 100644
--- a/tests/tests/widget/src/android/widget/cts/Gallery_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/Gallery_LayoutParamsTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParserException;
diff --git a/tests/src/android/widget/cts/GridLayoutStubActivity.java b/tests/tests/widget/src/android/widget/cts/GridLayoutCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/GridLayoutStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/GridLayoutCtsActivity.java
index 3fa0f28..3277ee8 100644
--- a/tests/src/android/widget/cts/GridLayoutStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/GridLayoutCtsActivity.java
@@ -18,12 +18,12 @@
 
 import android.app.Activity;
 import android.os.Bundle;
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for {@link android.widget.GridLayout} test.
  */
-public class GridLayoutStubActivity extends Activity {
+public class GridLayoutCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/GridLayoutTest.java b/tests/tests/widget/src/android/widget/cts/GridLayoutTest.java
index 638fe96..d701623 100644
--- a/tests/tests/widget/src/android/widget/cts/GridLayoutTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GridLayoutTest.java
@@ -27,7 +27,7 @@
 import android.widget.Button;
 import android.widget.GridLayout;
 import android.widget.TextView;
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import org.xmlpull.v1.XmlPullParser;
 
 import static android.view.ViewGroup.LAYOUT_MODE_OPTICAL_BOUNDS;
@@ -36,7 +36,7 @@
 /**
  * Test {@link android.widget.GridLayout}.
  */
-public class GridLayoutTest extends ActivityInstrumentationTestCase<GridLayoutStubActivity> {
+public class GridLayoutTest extends ActivityInstrumentationTestCase<GridLayoutCtsActivity> {
 
     // The size of the off-screen test container in which we we will testing layout.
     public static final int MAX_X = 2000;
@@ -117,7 +117,7 @@
     private Context mContext;
 
     public GridLayoutTest() {
-        super("com.android.cts.stub", GridLayoutStubActivity.class);
+        super("com.android.cts.widget", GridLayoutCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/GridViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/GridViewCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/GridViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/GridViewCtsActivity.java
index f58b7df..7a1182d 100644
--- a/tests/src/android/widget/cts/GridViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/GridViewCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for {@link GridView} test.
  */
-public class GridViewStubActivity extends Activity {
+public class GridViewCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/GridViewTest.java b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
index bd42e35..042986c 100644
--- a/tests/tests/widget/src/android/widget/cts/GridViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/GridViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -51,13 +51,13 @@
 /**
  * Test {@link GridView}.
  */
-public class GridViewTest extends ActivityInstrumentationTestCase<GridViewStubActivity> {
+public class GridViewTest extends ActivityInstrumentationTestCase<GridViewCtsActivity> {
     private GridView mGridView;
     private Activity mActivity;
     private Instrumentation mInstrumentation;
 
     public GridViewTest() {
-        super("com.android.cts.stub", GridViewStubActivity.class);
+        super("com.android.cts.widget", GridViewCtsActivity.class);
     }
 
     private GridView findGridViewById(int id) {
diff --git a/tests/src/android/widget/cts/HorizontalScrollViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewCtsActivity.java
similarity index 89%
rename from tests/src/android/widget/cts/HorizontalScrollViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/HorizontalScrollViewCtsActivity.java
index 8dd6911..312111a 100644
--- a/tests/src/android/widget/cts/HorizontalScrollViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewCtsActivity.java
@@ -16,12 +16,12 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
 
-public class HorizontalScrollViewStubActivity extends Activity {
+public class HorizontalScrollViewCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java b/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
index 5d75006..2862865 100644
--- a/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -42,7 +42,7 @@
  * Test {@link HorizontalScrollView}.
  */
 public class HorizontalScrollViewTest
-        extends ActivityInstrumentationTestCase2<HorizontalScrollViewStubActivity> {
+        extends ActivityInstrumentationTestCase2<HorizontalScrollViewCtsActivity> {
     private static final int ITEM_WIDTH  = 250;
     private static final int ITEM_HEIGHT = 100;
     private static final int ITEM_COUNT  = 15;
@@ -53,7 +53,7 @@
     private Activity mActivity;
 
     public HorizontalScrollViewTest() {
-        super("com.android.cts.stub", HorizontalScrollViewStubActivity.class);
+        super("com.android.cts.widget", HorizontalScrollViewCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/ImageButtonTest.java b/tests/tests/widget/src/android/widget/cts/ImageButtonTest.java
index a71ec9d..374c9c2 100644
--- a/tests/tests/widget/src/android/widget/cts/ImageButtonTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ImageButtonTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/tests/widget/src/android/widget/cts/ImageSwitcherTest.java b/tests/tests/widget/src/android/widget/cts/ImageSwitcherTest.java
index 49bf3c6..c0e606c 100644
--- a/tests/tests/widget/src/android/widget/cts/ImageSwitcherTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ImageSwitcherTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/src/android/widget/cts/ImageViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/ImageViewCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/ImageViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ImageViewCtsActivity.java
index 7b93168..295f3da 100644
--- a/tests/src/android/widget/cts/ImageViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ImageViewCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for {@link ImageView} test.
  */
-public class ImageViewStubActivity extends Activity {
+public class ImageViewCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/ImageViewTest.java b/tests/tests/widget/src/android/widget/cts/ImageViewTest.java
index 84276f9..7b0b65a 100644
--- a/tests/tests/widget/src/android/widget/cts/ImageViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ImageViewTest.java
@@ -47,18 +47,18 @@
 import android.widget.ImageView;
 import android.widget.ImageView.ScaleType;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 /**
  * Test {@link ImageView}.
  */
-public class ImageViewTest extends ActivityInstrumentationTestCase<ImageViewStubActivity> {
+public class ImageViewTest extends ActivityInstrumentationTestCase<ImageViewCtsActivity> {
     private ImageView mImageView;
     private Activity mActivity;
 
     public ImageViewTest() {
-        super("com.android.cts.stub", ImageViewStubActivity.class);
+        super("com.android.cts.widget", ImageViewCtsActivity.class);
     }
 
     /**
diff --git a/tests/src/android/widget/cts/LayoutDirectionStubActivity.java b/tests/tests/widget/src/android/widget/cts/LayoutDirectionCtsActivity.java
similarity index 90%
rename from tests/src/android/widget/cts/LayoutDirectionStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/LayoutDirectionCtsActivity.java
index 66f24f7..093f554 100644
--- a/tests/src/android/widget/cts/LayoutDirectionStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/LayoutDirectionCtsActivity.java
@@ -18,12 +18,12 @@
 
 import android.app.Activity;
 import android.os.Bundle;
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for layout direction test.
  */
-public class LayoutDirectionStubActivity extends Activity {
+public class LayoutDirectionCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/LayoutDirectionTest.java b/tests/tests/widget/src/android/widget/cts/LayoutDirectionTest.java
index 5c8be24..c393e95 100644
--- a/tests/tests/widget/src/android/widget/cts/LayoutDirectionTest.java
+++ b/tests/tests/widget/src/android/widget/cts/LayoutDirectionTest.java
@@ -20,17 +20,17 @@
 import android.test.UiThreadTest;
 import android.view.ViewGroup;
 import android.widget.*;
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import static android.view.View.LAYOUT_DIRECTION_LTR;
 import static android.view.View.LAYOUT_DIRECTION_RTL;
 import static android.view.View.LAYOUT_DIRECTION_INHERIT;
 import static android.view.View.LAYOUT_DIRECTION_LOCALE;
 
-public class LayoutDirectionTest extends ActivityInstrumentationTestCase2<LayoutDirectionStubActivity> {
+public class LayoutDirectionTest extends ActivityInstrumentationTestCase2<LayoutDirectionCtsActivity> {
 
     public LayoutDirectionTest() {
-        super(LayoutDirectionStubActivity.class);
+        super(LayoutDirectionCtsActivity.class);
     }
 
     private void checkDefaultDirectionForOneLayoutWithCode(ViewGroup vg) {
diff --git a/tests/src/android/widget/cts/LinearLayoutStubActivity.java b/tests/tests/widget/src/android/widget/cts/LinearLayoutCtsActivity.java
similarity index 90%
rename from tests/src/android/widget/cts/LinearLayoutStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/LinearLayoutCtsActivity.java
index 8f4c5da..0cb5bc0 100644
--- a/tests/src/android/widget/cts/LinearLayoutStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/LinearLayoutCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for {@link LinearLayout} test.
  */
-public class LinearLayoutStubActivity extends Activity {
+public class LinearLayoutCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/LinearLayoutTest.java b/tests/tests/widget/src/android/widget/cts/LinearLayoutTest.java
index 4465533..5815f9a 100644
--- a/tests/tests/widget/src/android/widget/cts/LinearLayoutTest.java
+++ b/tests/tests/widget/src/android/widget/cts/LinearLayoutTest.java
@@ -31,17 +31,17 @@
 import android.widget.ListView;
 import android.widget.TextView;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * Test {@link LinearLayout}.
  */
-public class LinearLayoutTest extends ActivityInstrumentationTestCase<LinearLayoutStubActivity> {
+public class LinearLayoutTest extends ActivityInstrumentationTestCase<LinearLayoutCtsActivity> {
     private Context mContext;
     private Activity mActivity;
 
     public LinearLayoutTest() {
-        super("com.android.cts.stub", LinearLayoutStubActivity.class);
+        super("com.android.cts.widget", LinearLayoutCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/LinearLayout_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/LinearLayout_LayoutParamsTest.java
index 72f3ff6..8ecca6f 100644
--- a/tests/tests/widget/src/android/widget/cts/LinearLayout_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/LinearLayout_LayoutParamsTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import com.android.internal.util.XmlUtils;
 
 
diff --git a/tests/src/android/widget/cts/ListViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/ListViewCtsActivity.java
similarity index 90%
rename from tests/src/android/widget/cts/ListViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ListViewCtsActivity.java
index 77c3e5e..186e47b 100644
--- a/tests/src/android/widget/cts/ListViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ListViewCtsActivity.java
@@ -16,12 +16,12 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
 
-public class ListViewStubActivity extends Activity {
+public class ListViewCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/ListViewTest.java b/tests/tests/widget/src/android/widget/cts/ListViewTest.java
index 7af8c2e..5f0967a 100644
--- a/tests/tests/widget/src/android/widget/cts/ListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ListViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import com.google.android.collect.Lists;
 
 import org.xmlpull.v1.XmlPullParser;
@@ -51,7 +51,7 @@
 
 import junit.framework.Assert;
 
-public class ListViewTest extends ActivityInstrumentationTestCase2<ListViewStubActivity> {
+public class ListViewTest extends ActivityInstrumentationTestCase2<ListViewCtsActivity> {
     private final String[] mCountryList = new String[] {
         "Argentina", "Australia", "China", "France", "Germany", "Italy", "Japan", "United States"
     };
@@ -69,7 +69,7 @@
     private ArrayAdapter<String> mAdapter_empty;
 
     public ListViewTest() {
-        super("com.android.cts.stub", ListViewStubActivity.class);
+        super("com.android.cts.widget", ListViewCtsActivity.class);
     }
 
     protected void setUp() throws Exception {
diff --git a/tests/src/android/widget/cts/MediaControllerStubActivity.java b/tests/tests/widget/src/android/widget/cts/MediaControllerCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/MediaControllerStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/MediaControllerCtsActivity.java
index 0e353be..5dfcc59 100644
--- a/tests/src/android/widget/cts/MediaControllerStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/MediaControllerCtsActivity.java
@@ -20,12 +20,12 @@
 import android.os.Bundle;
 import android.widget.MediaController;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for {@link MediaController} test.
  */
-public class MediaControllerStubActivity extends Activity {
+public class MediaControllerCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/MediaControllerTest.java b/tests/tests/widget/src/android/widget/cts/MediaControllerTest.java
index 5ae692b..a12dba6 100644
--- a/tests/tests/widget/src/android/widget/cts/MediaControllerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/MediaControllerTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -43,14 +43,14 @@
  * Test {@link MediaController}.
  */
 public class MediaControllerTest extends
-        ActivityInstrumentationTestCase2<MediaControllerStubActivity> {
+        ActivityInstrumentationTestCase2<MediaControllerCtsActivity> {
     private MediaController mMediaController;
     private Activity mActivity;
     private Instrumentation mInstrumentation;
     private static final long DEFAULT_TIMEOUT = 3000;
 
     public MediaControllerTest() {
-        super("com.android.cts.stub", MediaControllerStubActivity.class);
+        super("com.android.cts.widget", MediaControllerCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/MockApplication.java b/tests/tests/widget/src/android/widget/cts/MockApplication.java
new file mode 100644
index 0000000..827599d
--- /dev/null
+++ b/tests/tests/widget/src/android/widget/cts/MockApplication.java
@@ -0,0 +1,59 @@
+/*
+ * 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.widget.cts;
+
+import android.app.Application;
+import android.content.res.Configuration;
+
+
+public class MockApplication extends Application {
+
+    public boolean isOnCreateCalled;
+    public boolean isConstructorCalled;
+    public boolean isOnConfigurationChangedCalled;
+    public boolean isOnLowMemoryCalled;
+
+    public MockApplication() {
+        super();
+        isConstructorCalled = true;
+    }
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        isOnCreateCalled = true;
+    }
+
+    @Override
+    public void onTerminate() {
+        super.onTerminate();
+        // The documentation states that one cannot rely on this method being called. No need to
+        // test it here.
+    }
+
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        isOnConfigurationChangedCalled = true;
+    }
+
+    @Override
+    public void onLowMemory() {
+        super.onLowMemory();
+        isOnLowMemoryCalled = true;
+    }
+}
diff --git a/tests/src/android/widget/cts/MockLinearLayout.java b/tests/tests/widget/src/android/widget/cts/MockLinearLayout.java
similarity index 100%
rename from tests/src/android/widget/cts/MockLinearLayout.java
rename to tests/tests/widget/src/android/widget/cts/MockLinearLayout.java
diff --git a/tests/src/android/widget/cts/MockPopupWindowStubActivity.java b/tests/tests/widget/src/android/widget/cts/MockPopupWindowCtsActivity.java
similarity index 90%
rename from tests/src/android/widget/cts/MockPopupWindowStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/MockPopupWindowCtsActivity.java
index 2ca81de..a68286a 100644
--- a/tests/src/android/widget/cts/MockPopupWindowStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/MockPopupWindowCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -25,7 +25,7 @@
 /**
  * Stub activity for testing {@link PopupWindow}
  */
-public class MockPopupWindowStubActivity extends Activity {
+public class MockPopupWindowCtsActivity extends Activity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/src/android/widget/cts/MockTextView.java b/tests/tests/widget/src/android/widget/cts/MockTextView.java
similarity index 100%
rename from tests/src/android/widget/cts/MockTextView.java
rename to tests/tests/widget/src/android/widget/cts/MockTextView.java
diff --git a/tests/src/android/widget/cts/ListViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/MockURLSpanTestActivity.java
similarity index 80%
copy from tests/src/android/widget/cts/ListViewStubActivity.java
copy to tests/tests/widget/src/android/widget/cts/MockURLSpanTestActivity.java
index 77c3e5e..ab4940c 100644
--- a/tests/src/android/widget/cts/ListViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/MockURLSpanTestActivity.java
@@ -16,15 +16,18 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
 
-public class ListViewStubActivity extends Activity {
+/**
+ * A Mock application for {@link URLSpan} test.
+ */
+public class MockURLSpanTestActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.listview_layout);
+        setContentView(R.layout.urlspan_layout);
     }
 }
diff --git a/tests/src/android/widget/cts/MultiAutoCompleteTextViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/MultiAutoCompleteTextViewCtsActivity.java
similarity index 89%
rename from tests/src/android/widget/cts/MultiAutoCompleteTextViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/MultiAutoCompleteTextViewCtsActivity.java
index fa973a6..1379150 100644
--- a/tests/src/android/widget/cts/MultiAutoCompleteTextViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/MultiAutoCompleteTextViewCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for MultiAutoCompleteTextView test.
  */
-public class MultiAutoCompleteTextViewStubActivity extends Activity {
+public class MultiAutoCompleteTextViewCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/MultiAutoCompleteTextViewTest.java b/tests/tests/widget/src/android/widget/cts/MultiAutoCompleteTextViewTest.java
index b37b4ef..75f9242 100644
--- a/tests/tests/widget/src/android/widget/cts/MultiAutoCompleteTextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/MultiAutoCompleteTextViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -38,13 +38,13 @@
 import android.widget.MultiAutoCompleteTextView.Tokenizer;
 
 public class MultiAutoCompleteTextViewTest extends ActivityInstrumentationTestCase2
-        <MultiAutoCompleteTextViewStubActivity> {
+        <MultiAutoCompleteTextViewCtsActivity> {
     private MultiAutoCompleteTextView mMultiAutoCompleteTextView_country;
     private MultiAutoCompleteTextView mMultiAutoCompleteTextView_name;
     private Activity mActivity;
 
     public MultiAutoCompleteTextViewTest() {
-        super("com.android.cts.stub", MultiAutoCompleteTextViewStubActivity.class);
+        super("com.android.cts.widget", MultiAutoCompleteTextViewCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/MyGallery.java b/tests/tests/widget/src/android/widget/cts/MyGallery.java
similarity index 100%
rename from tests/src/android/widget/cts/MyGallery.java
rename to tests/tests/widget/src/android/widget/cts/MyGallery.java
diff --git a/tests/src/android/widget/cts/MyHorizontalScrollView.java b/tests/tests/widget/src/android/widget/cts/MyHorizontalScrollView.java
similarity index 100%
rename from tests/src/android/widget/cts/MyHorizontalScrollView.java
rename to tests/tests/widget/src/android/widget/cts/MyHorizontalScrollView.java
diff --git a/tests/src/android/widget/cts/MyScrollView.java b/tests/tests/widget/src/android/widget/cts/MyScrollView.java
similarity index 100%
rename from tests/src/android/widget/cts/MyScrollView.java
rename to tests/tests/widget/src/android/widget/cts/MyScrollView.java
diff --git a/tests/tests/widget/src/android/widget/cts/NullWebViewUtils.java b/tests/tests/widget/src/android/widget/cts/NullWebViewUtils.java
new file mode 100644
index 0000000..d7a73fa
--- /dev/null
+++ b/tests/tests/widget/src/android/widget/cts/NullWebViewUtils.java
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ * 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.widget.cts;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+
+/**
+ * Utilities to enable the android.webkit.* CTS tests (and others that rely on a functioning
+ * android.webkit.WebView implementation) to determine whether a functioning WebView is present
+ * on the device or not.
+ *
+ * Test cases that require android.webkit.* classes should wrap their first usage of WebView in a
+ * try catch block, and pass any exception that is thrown to
+ * NullWebViewUtils.determineIfWebViewAvailable. The return value of
+ * NullWebViewUtils.isWebViewAvailable will then determine if the test should expect to be able to
+ * use a WebView.
+ */
+public class NullWebViewUtils {
+
+    private static boolean sWebViewUnavailable;
+
+    /**
+     * @param context Current Activity context, used to query the PackageManager.
+     * @param t       An exception thrown by trying to invoke android.webkit.* APIs.
+     */
+    public static void determineIfWebViewAvailable(Context context, Throwable t) {
+        sWebViewUnavailable = !hasWebViewFeature(context) && checkCauseWasUnsupportedOperation(t);
+    }
+
+    /**
+     * After calling determineIfWebViewAvailable, this returns whether a WebView is available on the
+     * device and wheter the test can rely on it.
+     * @return True iff. PackageManager determined that there is no WebView on the device and the
+     *         exception thrown from android.webkit.* was UnsupportedOperationException.
+     */
+    public static boolean isWebViewAvailable() {
+        return !sWebViewUnavailable;
+    }
+
+    private static boolean hasWebViewFeature(Context context) {
+        // Query the system property that determins if there is a functional WebView on the device.
+        PackageManager pm = context.getPackageManager();
+        return pm.hasSystemFeature(PackageManager.FEATURE_WEBVIEW);
+    }
+
+    private static boolean checkCauseWasUnsupportedOperation(Throwable t) {
+        if (t == null) return false;
+        while (t.getCause() != null) {
+            t = t.getCause();
+        }
+        return t instanceof UnsupportedOperationException;
+    }
+
+    /**
+     * Some CTS tests (by design) first use android.webkit.* from a background thread. This helper
+     * allows the test to catch the UnsupportedOperationException from that background thread, and
+     * then query the result from the test main thread.
+     */
+    public static class NullWebViewFromThreadExceptionHandler
+            implements Thread.UncaughtExceptionHandler {
+        private Throwable mPendingException;
+
+        @Override
+        public void uncaughtException(Thread t, Throwable e) {
+            mPendingException = e;
+        }
+
+        public boolean isWebViewAvailable(Context context) {
+            return hasWebViewFeature(context) ||
+                    !checkCauseWasUnsupportedOperation(mPendingException);
+        }
+    }
+}
\ No newline at end of file
diff --git a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
index 997c2e9..9c4c3a3 100644
--- a/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/PopupWindowTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -41,7 +41,7 @@
 import android.widget.PopupWindow.OnDismissListener;
 
 public class PopupWindowTest extends
-        ActivityInstrumentationTestCase2<MockPopupWindowStubActivity> {
+        ActivityInstrumentationTestCase2<MockPopupWindowCtsActivity> {
     private Instrumentation mInstrumentation;
     private Activity mActivity;
     /** The popup window. */
@@ -51,7 +51,7 @@
      * Instantiates a new popup window test.
      */
     public PopupWindowTest() {
-        super("com.android.cts.stub", MockPopupWindowStubActivity.class);
+        super("com.android.cts.widget", MockPopupWindowCtsActivity.class);
     }
 
     /*
diff --git a/tests/src/android/widget/cts/ProgressBarStubActivity.java b/tests/tests/widget/src/android/widget/cts/ProgressBarCtsActivity.java
similarity index 93%
rename from tests/src/android/widget/cts/ProgressBarStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ProgressBarCtsActivity.java
index 57cfa1a..8298d5f 100644
--- a/tests/src/android/widget/cts/ProgressBarStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ProgressBarCtsActivity.java
@@ -23,7 +23,7 @@
  * An application for ProgressBar test
  *
  */
-public class ProgressBarStubActivity extends Activity {
+public class ProgressBarCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/ProgressBarTest.java b/tests/tests/widget/src/android/widget/cts/ProgressBarTest.java
index 80681d0..e57d298 100644
--- a/tests/tests/widget/src/android/widget/cts/ProgressBarTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ProgressBarTest.java
@@ -21,7 +21,7 @@
 import android.graphics.PorterDuff;
 import android.view.LayoutInflater;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.content.Context;
diff --git a/tests/tests/widget/src/android/widget/cts/RadioButtonTest.java b/tests/tests/widget/src/android/widget/cts/RadioButtonTest.java
index 79a51c8..c6ee1b7 100644
--- a/tests/tests/widget/src/android/widget/cts/RadioButtonTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RadioButtonTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.content.Context;
diff --git a/tests/tests/widget/src/android/widget/cts/RadioGroupTest.java b/tests/tests/widget/src/android/widget/cts/RadioGroupTest.java
index f7baab7..ee912fc 100644
--- a/tests/tests/widget/src/android/widget/cts/RadioGroupTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RadioGroupTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
diff --git a/tests/tests/widget/src/android/widget/cts/RadioGroup_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/RadioGroup_LayoutParamsTest.java
index 23155c7..4b1aa5b 100644
--- a/tests/tests/widget/src/android/widget/cts/RadioGroup_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RadioGroup_LayoutParamsTest.java
@@ -113,8 +113,8 @@
         } catch (NullPointerException e) {
         }
 
-        mLayoutParams = new LayoutParams(getContext(), 
-                getAttributeSet(com.android.cts.stub.R.layout.radiogroup_1));
+        mLayoutParams = new LayoutParams(getContext(),
+                getAttributeSet(com.android.cts.widget.R.layout.radiogroup_1));
         assertNotNull(mLayoutParams);
         assertEquals(0.5, mLayoutParams.weight, 0);
         assertEquals(Gravity.BOTTOM, mLayoutParams.gravity);
@@ -130,8 +130,8 @@
         assertEquals(RadioGroup.LayoutParams.WRAP_CONTENT, mLayoutParams.height);
 
         try {
-            new RadioGroup.LayoutParams(null, 
-                    getAttributeSet(com.android.cts.stub.R.layout.radiogroup_1));
+            new RadioGroup.LayoutParams(null,
+                    getAttributeSet(com.android.cts.widget.R.layout.radiogroup_1));
             fail("The constructor should throw NullPointerException when param Context is null.");
         } catch (NullPointerException e) {
         }
@@ -143,7 +143,7 @@
         assertEquals(LayoutParams.WRAP_CONTENT, layoutParams.width);
         assertEquals(LayoutParams.WRAP_CONTENT, layoutParams.height);
 
-        AttributeSet attrs = getAttributeSet(com.android.cts.stub.R.layout.radiogroup_1);
+        AttributeSet attrs = getAttributeSet(com.android.cts.widget.R.layout.radiogroup_1);
         TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.ViewGroup_MarginLayout);
         layoutParams.setBaseAttributes(a,
                 R.styleable.ViewGroup_MarginLayout_layout_width,
diff --git a/tests/src/android/widget/cts/RatingBarStubActivity.java b/tests/tests/widget/src/android/widget/cts/RatingBarCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/RatingBarStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/RatingBarCtsActivity.java
index 9635252..7d4e232 100644
--- a/tests/src/android/widget/cts/RatingBarStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/RatingBarCtsActivity.java
@@ -19,13 +19,13 @@
 import android.app.Activity;
 import android.os.Bundle;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * An application for ProgressBar test
  *
  */
-public class RatingBarStubActivity extends Activity {
+public class RatingBarCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/RatingBarTest.java b/tests/tests/widget/src/android/widget/cts/RatingBarTest.java
index fe0e647..1bb42e8 100644
--- a/tests/tests/widget/src/android/widget/cts/RatingBarTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RatingBarTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.content.Context;
@@ -28,12 +28,12 @@
 /**
  * Test {@link RatingBar}.
  */
-public class RatingBarTest extends ActivityInstrumentationTestCase2<RatingBarStubActivity> {
+public class RatingBarTest extends ActivityInstrumentationTestCase2<RatingBarCtsActivity> {
     private Context mContext;
-    private RatingBarStubActivity mActivity;
+    private RatingBarCtsActivity mActivity;
 
     public RatingBarTest() {
-        super("com.android.cts.stub", RatingBarStubActivity.class);
+        super("com.android.cts.widget", RatingBarCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/RelativeLayoutStubActivity.java b/tests/tests/widget/src/android/widget/cts/RelativeLayoutCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/RelativeLayoutStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/RelativeLayoutCtsActivity.java
index d4bd474..df83f54 100644
--- a/tests/src/android/widget/cts/RelativeLayoutStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/RelativeLayoutCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for RelativeLayout test.
  */
-public class RelativeLayoutStubActivity extends Activity {
+public class RelativeLayoutCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/RelativeLayoutTest.java b/tests/tests/widget/src/android/widget/cts/RelativeLayoutTest.java
index 9d15160..b5ce5c9 100644
--- a/tests/tests/widget/src/android/widget/cts/RelativeLayoutTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RelativeLayoutTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import com.android.internal.util.XmlUtils;
 
 
@@ -43,11 +43,11 @@
  * Test {@link RelativeLayout}.
  */
 public class RelativeLayoutTest extends
-        ActivityInstrumentationTestCase2<RelativeLayoutStubActivity> {
+        ActivityInstrumentationTestCase2<RelativeLayoutCtsActivity> {
     private Activity mActivity;
 
     public RelativeLayoutTest() {
-        super("com.android.cts.stub", RelativeLayoutStubActivity.class);
+        super("com.android.cts.widget", RelativeLayoutCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/RelativeLayout_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/RelativeLayout_LayoutParamsTest.java
index 04682cb..a3bd95c 100644
--- a/tests/tests/widget/src/android/widget/cts/RelativeLayout_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RelativeLayout_LayoutParamsTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.test.ActivityInstrumentationTestCase2;
@@ -29,10 +29,10 @@
  * Test {@link RelativeLayout.LayoutParams}.
  */
 public class RelativeLayout_LayoutParamsTest extends
-        ActivityInstrumentationTestCase2<RelativeLayoutStubActivity> {
+        ActivityInstrumentationTestCase2<RelativeLayoutCtsActivity> {
 
     public RelativeLayout_LayoutParamsTest() {
-        super("com.android.cts.stub", RelativeLayoutStubActivity.class);
+        super("com.android.cts.widget", RelativeLayoutCtsActivity.class);
     }
 
     public void testConstructor() {
@@ -53,7 +53,7 @@
 
         // Test RelativeLayout.Params which generated from the xml file.
         int rules[];
-        RelativeLayoutStubActivity activity = getActivity();
+        RelativeLayoutCtsActivity activity = getActivity();
 
         // test attributes used in RelativeLayout.
         RelativeLayout relativeLayout = (RelativeLayout) activity.findViewById(
@@ -160,7 +160,7 @@
 
         // Test RelativeLayout.Params which generated from the xml file.
         int rules[];
-        RelativeLayoutStubActivity activity = getActivity();
+        RelativeLayoutCtsActivity activity = getActivity();
 
         // test attributes used in RelativeLayout.
         RelativeLayout relativeLayout = (RelativeLayout) activity.findViewById(
diff --git a/tests/tests/widget/src/android/widget/cts/RemoteViewsActivityTest.java b/tests/tests/widget/src/android/widget/cts/RemoteViewsActivityTest.java
index b3c0915..a03edce 100644
--- a/tests/tests/widget/src/android/widget/cts/RemoteViewsActivityTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RemoteViewsActivityTest.java
@@ -23,18 +23,17 @@
 import android.view.InflateException;
 import android.view.View;
 import android.view.ViewGroup;
-import android.webkit.cts.NullWebViewUtils;
 import android.widget.RemoteViews;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 public class RemoteViewsActivityTest
-        extends ActivityInstrumentationTestCase2<RemoteViewsStubActivity> {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+        extends ActivityInstrumentationTestCase2<RemoteViewsCtsActivity> {
+    private static final String PACKAGE_NAME = "com.android.cts.widget";
     private Activity mActivity;
 
     public RemoteViewsActivityTest() {
-        super(PACKAGE_NAME, RemoteViewsStubActivity.class);
+        super(PACKAGE_NAME, RemoteViewsCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/RemoteViewsStubActivity.java b/tests/tests/widget/src/android/widget/cts/RemoteViewsCtsActivity.java
similarity index 88%
rename from tests/src/android/widget/cts/RemoteViewsStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/RemoteViewsCtsActivity.java
index f16ae13..6826eb3 100644
--- a/tests/src/android/widget/cts/RemoteViewsStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/RemoteViewsCtsActivity.java
@@ -16,17 +16,16 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
-import android.webkit.cts.NullWebViewUtils;
 import android.widget.RemoteViews;
 
 /**
  * Stub activity for testing {@link RemoteViews}
  */
-public class RemoteViewsStubActivity extends Activity {
+public class RemoteViewsCtsActivity extends Activity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         try {
diff --git a/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java b/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
index 891bdf7..8d1cddf 100644
--- a/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/RemoteViewsTest.java
@@ -16,7 +16,8 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import android.test.UiThreadTest;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -31,7 +32,6 @@
 import android.net.Uri;
 import android.os.Parcel;
 import android.test.ActivityInstrumentationTestCase2;
-import android.text.style.cts.MockURLSpanTestActivity;
 import android.view.View;
 import android.widget.AbsoluteLayout;
 import android.widget.Chronometer;
@@ -56,8 +56,8 @@
 /**
  * Test {@link RemoteViews}.
  */
-public class RemoteViewsTest extends ActivityInstrumentationTestCase2<RemoteViewsStubActivity> {
-    private static final String PACKAGE_NAME = "com.android.cts.stub";
+public class RemoteViewsTest extends ActivityInstrumentationTestCase2<RemoteViewsCtsActivity> {
+    private static final String PACKAGE_NAME = "com.android.cts.widget";
 
     private static final int INVALD_ID = -1;
 
@@ -70,15 +70,20 @@
     private Activity mActivity;
 
     public RemoteViewsTest() {
-        super(PACKAGE_NAME, RemoteViewsStubActivity.class);
+        super(PACKAGE_NAME, RemoteViewsCtsActivity.class);
     }
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         mActivity = getActivity();
-        mRemoteViews = new RemoteViews(PACKAGE_NAME, R.layout.remoteviews_good);
-        mResult = mRemoteViews.apply(mActivity, null);
+        getInstrumentation().runOnMainSync(new Runnable() {
+            @Override
+            public void run() {
+                mRemoteViews = new RemoteViews(PACKAGE_NAME, R.layout.remoteviews_good);
+                mResult = mRemoteViews.apply(mActivity, null);
+            }
+        });
     }
 
     public void testConstructor() {
@@ -308,6 +313,7 @@
         mRemoteViews.describeContents();
     }
 
+    @UiThreadTest
     public void testWriteToParcel() {
         mRemoteViews.setTextViewText(R.id.remoteView_text, "This is content");
         mRemoteViews.setViewVisibility(R.id.remoteView_frame, View.GONE);
diff --git a/tests/tests/widget/src/android/widget/cts/ResourceCursorAdapterTest.java b/tests/tests/widget/src/android/widget/cts/ResourceCursorAdapterTest.java
index d91094c..ed9d09c 100644
--- a/tests/tests/widget/src/android/widget/cts/ResourceCursorAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ResourceCursorAdapterTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.content.Context;
diff --git a/tests/tests/widget/src/android/widget/cts/ResourceCursorTreeAdapterTest.java b/tests/tests/widget/src/android/widget/cts/ResourceCursorTreeAdapterTest.java
index 4a5a9c9..4f137a0 100644
--- a/tests/tests/widget/src/android/widget/cts/ResourceCursorTreeAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ResourceCursorTreeAdapterTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.content.Context;
diff --git a/tests/src/android/widget/cts/ScrollViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/ScrollViewCtsActivity.java
similarity index 90%
rename from tests/src/android/widget/cts/ScrollViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ScrollViewCtsActivity.java
index 4daeb9f..8965610 100644
--- a/tests/src/android/widget/cts/ScrollViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ScrollViewCtsActivity.java
@@ -16,12 +16,12 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
 
-public class ScrollViewStubActivity extends Activity {
+public class ScrollViewCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/ScrollViewTest.java b/tests/tests/widget/src/android/widget/cts/ScrollViewTest.java
index e297744..a8fb224 100644
--- a/tests/tests/widget/src/android/widget/cts/ScrollViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ScrollViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -41,7 +41,7 @@
 /**
  * Test {@link ScrollView}.
  */
-public class ScrollViewTest extends ActivityInstrumentationTestCase2<ScrollViewStubActivity> {
+public class ScrollViewTest extends ActivityInstrumentationTestCase2<ScrollViewCtsActivity> {
     // view dpi constants. Must match those defined in scroll_view layout
     private static final int ITEM_WIDTH_DPI  = 250;
     private static final int ITEM_HEIGHT_DPI = 100;
@@ -61,7 +61,7 @@
     private Activity mActivity;
 
     public ScrollViewTest() {
-        super("com.android.cts.stub", ScrollViewStubActivity.class);
+        super("com.android.cts.widget", ScrollViewCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/SeekBarStubActivity.java b/tests/tests/widget/src/android/widget/cts/SeekBarCtsActivity.java
similarity index 93%
rename from tests/src/android/widget/cts/SeekBarStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/SeekBarCtsActivity.java
index 81d3d41..e7842c2 100644
--- a/tests/src/android/widget/cts/SeekBarStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/SeekBarCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -26,7 +26,7 @@
 /**
  * Stub activity for testing {@link SeekBar}
  */
-public class SeekBarStubActivity extends Activity {
+public class SeekBarCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/SeekBarTest.java b/tests/tests/widget/src/android/widget/cts/SeekBarTest.java
index 266583f..54bbedf 100644
--- a/tests/tests/widget/src/android/widget/cts/SeekBarTest.java
+++ b/tests/tests/widget/src/android/widget/cts/SeekBarTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -30,7 +30,7 @@
 /**
  * Test {@link SeekBar}.
  */
-public class SeekBarTest extends ActivityInstrumentationTestCase2<SeekBarStubActivity> {
+public class SeekBarTest extends ActivityInstrumentationTestCase2<SeekBarCtsActivity> {
     private SeekBar mSeekBar;
 
     private Activity mActivity;
@@ -38,7 +38,7 @@
     private Instrumentation mInstrumentation;
 
     public SeekBarTest() {
-        super("com.android.cts.stub", SeekBarStubActivity.class);
+        super("com.android.cts.widget", SeekBarCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/SimpleAdapterTest.java b/tests/tests/widget/src/android/widget/cts/SimpleAdapterTest.java
index 8b35a2f..86a4bca 100644
--- a/tests/tests/widget/src/android/widget/cts/SimpleAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/SimpleAdapterTest.java
@@ -89,7 +89,7 @@
         mContext = getInstrumentation().getTargetContext();
         mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         mAdapterHost = (LinearLayout) mInflater.inflate(
-                com.android.cts.stub.R.layout.cursoradapter_host, null);
+                com.android.cts.widget.R.layout.cursoradapter_host, null);
 
         // new the SimpleAdapter instance
         mSimpleAdapter = new SimpleAdapter(mContext,
@@ -280,9 +280,9 @@
         // String represents resId
         ImageView view = new ImageView(mContext);
         assertNull(view.getDrawable());
-        mSimpleAdapter.setViewImage(view, String.valueOf(com.android.cts.stub.R.drawable.scenery));
+        mSimpleAdapter.setViewImage(view, String.valueOf(com.android.cts.widget.R.drawable.scenery));
         BitmapDrawable d = (BitmapDrawable) mContext.getResources().getDrawable(
-                com.android.cts.stub.R.drawable.scenery);
+                com.android.cts.widget.R.drawable.scenery);
         WidgetTestUtils.assertEquals(d.getBitmap(),
                 ((BitmapDrawable) view.getDrawable()).getBitmap());
 
@@ -305,9 +305,9 @@
         // resId
         view = new ImageView(mContext);
         assertNull(view.getDrawable());
-        mSimpleAdapter.setViewImage(view, com.android.cts.stub.R.drawable.scenery);
+        mSimpleAdapter.setViewImage(view, com.android.cts.widget.R.drawable.scenery);
         d = (BitmapDrawable) mContext.getResources()
-                .getDrawable(com.android.cts.stub.R.drawable.scenery);
+                .getDrawable(com.android.cts.widget.R.drawable.scenery);
         WidgetTestUtils.assertEquals(d.getBitmap(),
                 ((BitmapDrawable) view.getDrawable()).getBitmap());
 
@@ -322,11 +322,11 @@
         assertNull(view.getDrawable());
         try {
             mSimpleAdapter.setViewImage(view, SimpleCursorAdapterTest.createTestImage(mContext,
-                    "testimage", com.android.cts.stub.R.raw.testimage));
+                    "testimage", com.android.cts.widget.R.raw.testimage));
             assertNotNull(view.getDrawable());
             Bitmap actualBitmap = ((BitmapDrawable) view.getDrawable()).getBitmap();
             Bitmap testBitmap = WidgetTestUtils.getUnscaledAndDitheredBitmap(mContext.getResources(),
-                    com.android.cts.stub.R.raw.testimage, actualBitmap.getConfig());
+                    com.android.cts.widget.R.raw.testimage, actualBitmap.getConfig());
             WidgetTestUtils.assertEquals(testBitmap, actualBitmap);
         } finally {
             SimpleCursorAdapterTest.destroyTestImage(mContext,"testimage");
diff --git a/tests/tests/widget/src/android/widget/cts/SimpleCursorAdapterTest.java b/tests/tests/widget/src/android/widget/cts/SimpleCursorAdapterTest.java
index 59660e0..2d73a03 100644
--- a/tests/tests/widget/src/android/widget/cts/SimpleCursorAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/SimpleCursorAdapterTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.content.Context;
@@ -175,7 +175,7 @@
 
     public void testSetViewImage() {
         // resId
-        int sceneryImgResId = com.android.cts.stub.R.drawable.scenery;
+        int sceneryImgResId = com.android.cts.widget.R.drawable.scenery;
         ImageView view = new ImageView(mContext);
         assertNull(view.getDrawable());
         mSimpleCursorAdapter.setViewImage(view, String.valueOf(sceneryImgResId));
@@ -206,7 +206,7 @@
         view = new ImageView(mContext);
         assertNull(view.getDrawable());
         try {
-            int testimgRawId = com.android.cts.stub.R.raw.testimage;
+            int testimgRawId = com.android.cts.widget.R.raw.testimage;
             mSimpleCursorAdapter.setViewImage(view,
                     createTestImage(mContext, SAMPLE_IMAGE_NAME, testimgRawId));
             assertNotNull(view.getDrawable());
@@ -307,7 +307,7 @@
         LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(
                 Context.LAYOUT_INFLATER_SERVICE);
         ViewGroup viewGroup = (ViewGroup) layoutInflater.inflate(
-                com.android.cts.stub.R.layout.cursoradapter_host, null);
+                com.android.cts.widget.R.layout.cursoradapter_host, null);
         View result = mSimpleCursorAdapter.newView(mContext, null, viewGroup);
         assertNotNull(result);
         assertEquals(R.id.cursorAdapter_item0, result.getId());
@@ -321,7 +321,7 @@
         LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(
                 Context.LAYOUT_INFLATER_SERVICE);
         ViewGroup viewGroup = (ViewGroup) layoutInflater.inflate(
-                com.android.cts.stub.R.layout.cursoradapter_host, null);
+                com.android.cts.widget.R.layout.cursoradapter_host, null);
         View result = mSimpleCursorAdapter.newDropDownView(null, null, viewGroup);
         assertNotNull(result);
         assertEquals(R.id.cursorAdapter_item0, result.getId());
diff --git a/tests/tests/widget/src/android/widget/cts/SimpleCursorTreeAdapterTest.java b/tests/tests/widget/src/android/widget/cts/SimpleCursorTreeAdapterTest.java
index bf9e358..9085b55 100644
--- a/tests/tests/widget/src/android/widget/cts/SimpleCursorTreeAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/SimpleCursorTreeAdapterTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.content.Context;
@@ -130,9 +130,9 @@
         ImageView view = new ImageView(mContext);
         assertNull(view.getDrawable());
         mSimpleCursorTreeAdapter.setViewImage(view,
-                String.valueOf(com.android.cts.stub.R.drawable.scenery));
+                String.valueOf(com.android.cts.widget.R.drawable.scenery));
         BitmapDrawable d = (BitmapDrawable) mContext.getResources().getDrawable(
-                com.android.cts.stub.R.drawable.scenery);
+                com.android.cts.widget.R.drawable.scenery);
         WidgetTestUtils.assertEquals(d.getBitmap(),
                 ((BitmapDrawable) view.getDrawable()).getBitmap());
 
@@ -158,10 +158,10 @@
         try {
             mSimpleCursorTreeAdapter.setViewImage(view,
                     SimpleCursorAdapterTest.createTestImage(mContext, SAMPLE_IMAGE_NAME,
-                            com.android.cts.stub.R.raw.testimage));
+                            com.android.cts.widget.R.raw.testimage));
             Bitmap actualBitmap = ((BitmapDrawable) view.getDrawable()).getBitmap();
             Bitmap test = WidgetTestUtils.getUnscaledAndDitheredBitmap(mContext.getResources(),
-                    com.android.cts.stub.R.raw.testimage, actualBitmap.getConfig());
+                    com.android.cts.widget.R.raw.testimage, actualBitmap.getConfig());
             WidgetTestUtils.assertEquals(test, actualBitmap);
         } finally {
             SimpleCursorAdapterTest.destroyTestImage(mContext, SAMPLE_IMAGE_NAME);
diff --git a/tests/tests/widget/src/android/widget/cts/SimpleExpandableListAdapterTest.java b/tests/tests/widget/src/android/widget/cts/SimpleExpandableListAdapterTest.java
index 7c4fe23..a7bfc31 100644
--- a/tests/tests/widget/src/android/widget/cts/SimpleExpandableListAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/SimpleExpandableListAdapterTest.java
@@ -98,7 +98,7 @@
 
         mAdapterHost = (LinearLayout) ((LayoutInflater) mContext
                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
-                com.android.cts.stub.R.layout.cursoradapter_host, null);
+                com.android.cts.widget.R.layout.cursoradapter_host, null);
     }
 
     public void testConstructor() {
diff --git a/tests/src/android/widget/cts/SlidingDrawerStubActivity.java b/tests/tests/widget/src/android/widget/cts/SlidingDrawerCtsActivity.java
similarity index 90%
rename from tests/src/android/widget/cts/SlidingDrawerStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/SlidingDrawerCtsActivity.java
index d19b9b1..8b55e63 100644
--- a/tests/src/android/widget/cts/SlidingDrawerStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/SlidingDrawerCtsActivity.java
@@ -16,12 +16,12 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
 
-public class SlidingDrawerStubActivity extends Activity {
+public class SlidingDrawerCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/SlidingDrawerTest.java b/tests/tests/widget/src/android/widget/cts/SlidingDrawerTest.java
index 60666ae..c4aaca1 100644
--- a/tests/tests/widget/src/android/widget/cts/SlidingDrawerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/SlidingDrawerTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -44,14 +44,14 @@
  * Test {@link SlidingDrawer}.
  */
 public class SlidingDrawerTest
-        extends ActivityInstrumentationTestCase2<SlidingDrawerStubActivity> {
+        extends ActivityInstrumentationTestCase2<SlidingDrawerCtsActivity> {
 
     private static final long TEST_TIMEOUT = 5000L;
     private Activity mActivity;
     private Object mLock;
 
     public SlidingDrawerTest() {
-        super("com.android.cts.stub", SlidingDrawerStubActivity.class);
+        super("com.android.cts.widget", SlidingDrawerCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/SpinnerTest.java b/tests/tests/widget/src/android/widget/cts/SpinnerTest.java
index 8ffd90b..7a2de0c 100644
--- a/tests/tests/widget/src/android/widget/cts/SpinnerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/SpinnerTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.AlertDialog;
@@ -31,11 +31,11 @@
 /**
  * Test {@link Spinner}.
  */
-public class SpinnerTest extends ActivityInstrumentationTestCase2<RelativeLayoutStubActivity> {
+public class SpinnerTest extends ActivityInstrumentationTestCase2<RelativeLayoutCtsActivity> {
     private Context mTargetContext;
 
     public SpinnerTest() {
-        super("com.android.cts.stub", RelativeLayoutStubActivity.class);
+        super("com.android.cts.widget", RelativeLayoutCtsActivity.class);
     }
 
     @Override
@@ -63,7 +63,7 @@
 
         spinner = (Spinner) getActivity().findViewById(R.id.spinner1);
         ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mTargetContext,
-                com.android.cts.stub.R.array.string, android.R.layout.simple_spinner_item);
+                com.android.cts.widget.R.array.string, android.R.layout.simple_spinner_item);
         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
         spinner.setAdapter(adapter);
         assertTrue(spinner.getBaseline() > 0);
diff --git a/tests/src/android/widget/cts/TabHostStubActivity.java b/tests/tests/widget/src/android/widget/cts/TabHostCtsActivity.java
similarity index 94%
rename from tests/src/android/widget/cts/TabHostStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/TabHostCtsActivity.java
index 78e0894..9703dd7 100644
--- a/tests/src/android/widget/cts/TabHostStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/TabHostCtsActivity.java
@@ -22,13 +22,13 @@
 import android.widget.TabHost;
 import android.widget.TextView;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for TabHost test.
  * It contains an initial tab whose tag is INITIAL_TAB_TAG and label is INITIAL_TAB_LABEL.
  */
-public class TabHostStubActivity extends TabActivity {
+public class TabHostCtsActivity extends TabActivity {
     public static final String INITIAL_TAB_TAG = "initial tag";
     public static final String INITIAL_TAB_LABEL = "initial label";
     public static final String INITIAL_VIEW_TEXT = "initial view text";
diff --git a/tests/tests/widget/src/android/widget/cts/TabHostTest.java b/tests/tests/widget/src/android/widget/cts/TabHostTest.java
index 07334ad..3af8d9c 100644
--- a/tests/tests/widget/src/android/widget/cts/TabHostTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TabHostTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -34,15 +34,15 @@
 /**
  * Test {@link TabHost}.
  */
-public class TabHostTest extends ActivityInstrumentationTestCase2<TabHostStubActivity> {
+public class TabHostTest extends ActivityInstrumentationTestCase2<TabHostCtsActivity> {
     private static final String TAG_TAB1 = "tab 1";
     private static final String TAG_TAB2 = "tab 2";
     private static final int TAB_HOST_ID = android.R.id.tabhost;
 
-    private TabHostStubActivity mActivity;
+    private TabHostCtsActivity mActivity;
 
     public TabHostTest() {
-        super("com.android.cts.stub", TabHostStubActivity.class);
+        super("com.android.cts.widget", TabHostCtsActivity.class);
     }
 
     @Override
@@ -71,7 +71,7 @@
      * 2. no exception occurs when doing normal operation after setup().
      */
     public void testSetup1() throws Throwable {
-        final Activity activity = launchActivity("com.android.cts.stub", StubActivity.class, null);
+        final Activity activity = launchActivity("com.android.cts.widget", CtsActivity.class, null);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -102,7 +102,7 @@
      * 2. no exception occurs when uses TabSpec.setContent(android.content.Intent) after setup().
      */
     public void testSetup2() throws Throwable {
-        final ActivityGroup activity = launchActivity("com.android.cts.stub",
+        final ActivityGroup activity = launchActivity("com.android.cts.widget",
                 ActivityGroup.class, null);
 
 
@@ -120,7 +120,7 @@
                 TabSpec tabSpec = tabHost.newTabSpec(TAG_TAB1);
                 tabSpec.setIndicator(TAG_TAB1);
                 Intent intent = new Intent(Intent.ACTION_VIEW, null,
-                        mActivity, StubActivity.class);
+                        mActivity, CtsActivity.class);
                 tabSpec.setContent(intent);
                 tabHost.addTab(tabSpec);
                 tabHost.setCurrentTab(0);
@@ -249,7 +249,7 @@
     public void testGetCurrentView() {
         TabHost tabHost = mActivity.getTabHost();
         TextView textView = (TextView) tabHost.getCurrentView();
-        assertEquals(TabHostStubActivity.INITIAL_VIEW_TEXT, textView.getText().toString());
+        assertEquals(TabHostCtsActivity.INITIAL_VIEW_TEXT, textView.getText().toString());
 
         TabSpec tabSpec = tabHost.newTabSpec(TAG_TAB2);
         tabSpec.setIndicator(TAG_TAB2);
@@ -272,7 +272,7 @@
         tabHost.setCurrentTabByTag(TAG_TAB2);
         assertEquals(1, tabHost.getCurrentTab());
 
-        tabHost.setCurrentTabByTag(TabHostStubActivity.INITIAL_TAB_TAG);
+        tabHost.setCurrentTabByTag(TabHostCtsActivity.INITIAL_TAB_TAG);
         assertEquals(0, tabHost.getCurrentTab());
 
         // exceptional value
@@ -294,7 +294,7 @@
         assertTrue(tabHost.getTabContentView().getChildAt(1) instanceof ListView);
         TextView child2 = (TextView) tabHost.getTabContentView().getChildAt(2);
         tabHost.setCurrentTab(0);
-        assertEquals(TabHostStubActivity.INITIAL_VIEW_TEXT, child2.getText().toString());
+        assertEquals(TabHostCtsActivity.INITIAL_VIEW_TEXT, child2.getText().toString());
 
         TabSpec tabSpec = tabHost.newTabSpec(TAG_TAB2);
         tabSpec.setIndicator(TAG_TAB2);
@@ -310,7 +310,7 @@
         assertTrue(tabHost.getTabContentView().getChildAt(1) instanceof ListView);
         child2 = (TextView) tabHost.getTabContentView().getChildAt(2);
         tabHost.setCurrentTab(0);
-        assertEquals(TabHostStubActivity.INITIAL_VIEW_TEXT, child2.getText().toString());
+        assertEquals(TabHostCtsActivity.INITIAL_VIEW_TEXT, child2.getText().toString());
     }
 
     @UiThreadTest
@@ -357,7 +357,7 @@
     @UiThreadTest
     public void testGetCurrentTabTag() {
         TabHost tabHost = mActivity.getTabHost();
-        assertEquals(TabHostStubActivity.INITIAL_TAB_TAG, tabHost.getCurrentTabTag());
+        assertEquals(TabHostCtsActivity.INITIAL_TAB_TAG, tabHost.getCurrentTabTag());
 
         TabSpec tabSpec = tabHost.newTabSpec(TAG_TAB2);
         tabSpec.setIndicator(TAG_TAB2);
diff --git a/tests/tests/widget/src/android/widget/cts/TabHost_TabSpecTest.java b/tests/tests/widget/src/android/widget/cts/TabHost_TabSpecTest.java
index 470a666..1363491 100644
--- a/tests/tests/widget/src/android/widget/cts/TabHost_TabSpecTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TabHost_TabSpecTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -29,7 +29,6 @@
 import android.net.Uri;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
-import android.text.style.cts.MockURLSpanTestActivity;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.ListView;
@@ -40,14 +39,14 @@
 /**
  * Test {@link TabSpec}.
  */
-public class TabHost_TabSpecTest extends ActivityInstrumentationTestCase2<TabHostStubActivity> {
+public class TabHost_TabSpecTest extends ActivityInstrumentationTestCase2<TabHostCtsActivity> {
     private static final String TAG_TAB2 = "tab 2";
 
     private TabHost mTabHost;
-    private TabHostStubActivity mActivity;
+    private TabHostCtsActivity mActivity;
 
     public TabHost_TabSpecTest() {
-        super("com.android.cts.stub", TabHostStubActivity.class);
+        super("com.android.cts.widget", TabHostCtsActivity.class);
     }
 
     @Override
@@ -138,7 +137,7 @@
         TabSpec tabSpec2 = mTabHost.newTabSpec("tab spec 2");
         tabSpec2.setIndicator("tab 2");
         // TabContentFactory to create a TextView as the content of the tab.
-        tabSpec2.setContent(com.android.cts.stub.R.id.tabhost_textview);
+        tabSpec2.setContent(com.android.cts.widget.R.id.tabhost_textview);
         mTabHost.addTab(tabSpec2);
         mTabHost.setCurrentTab(1);
         TextView currentView = (TextView) mTabHost.getCurrentView();
@@ -148,7 +147,7 @@
         TabSpec tabSpec3 = mTabHost.newTabSpec("tab spec 3");
         tabSpec3.setIndicator("tab 3");
         // TabContentFactory to create a ListView as the content of the tab.
-        tabSpec3.setContent(com.android.cts.stub.R.id.tabhost_listview);
+        tabSpec3.setContent(com.android.cts.widget.R.id.tabhost_listview);
         mTabHost.addTab(tabSpec3);
         mTabHost.setCurrentTab(2);
         assertTrue(mTabHost.getCurrentView() instanceof ListView);
diff --git a/tests/tests/widget/src/android/widget/cts/TabWidgetTest.java b/tests/tests/widget/src/android/widget/cts/TabWidgetTest.java
index b5c46c5..1f2e66c 100644
--- a/tests/tests/widget/src/android/widget/cts/TabWidgetTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TabWidgetTest.java
@@ -32,11 +32,11 @@
 /**
  * Test {@link TabWidget}.
  */
-public class TabWidgetTest extends ActivityInstrumentationTestCase2<TabHostStubActivity> {
+public class TabWidgetTest extends ActivityInstrumentationTestCase2<TabHostCtsActivity> {
     private Activity mActivity;
 
     public TabWidgetTest() {
-        super("com.android.cts.stub", TabHostStubActivity.class);
+        super("com.android.cts.widget", TabHostCtsActivity.class);
     }
 
     @Override
@@ -79,7 +79,7 @@
 
     @UiThreadTest
     public void testSetCurrentTab() {
-        TabHostStubActivity activity = getActivity();
+        TabHostCtsActivity activity = getActivity();
         TabWidget tabWidget = activity.getTabWidget();
         tabWidget.addView(new TextView(mActivity));
 
@@ -97,7 +97,7 @@
 
     @UiThreadTest
     public void testFocusCurrentTab() {
-        TabHostStubActivity activity = getActivity();
+        TabHostCtsActivity activity = getActivity();
         TabWidget tabWidget = activity.getTabWidget();
         tabWidget.addView(new TextView(mActivity));
 
diff --git a/tests/src/android/widget/cts/TableStubActivity.java b/tests/tests/widget/src/android/widget/cts/TableCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/TableStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/TableCtsActivity.java
index 0edc513..f76caed 100644
--- a/tests/src/android/widget/cts/TableStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/TableCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for TableLayout test.
  */
-public class TableStubActivity extends Activity {
+public class TableCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/TableLayoutTest.java b/tests/tests/widget/src/android/widget/cts/TableLayoutTest.java
index ea84071..c8211f6 100644
--- a/tests/tests/widget/src/android/widget/cts/TableLayoutTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TableLayoutTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.content.Context;
@@ -39,11 +39,11 @@
 /**
  * Test {@link TableLayout}.
  */
-public class TableLayoutTest extends ActivityInstrumentationTestCase2<TableStubActivity> {
+public class TableLayoutTest extends ActivityInstrumentationTestCase2<TableCtsActivity> {
     private Context mContext;
 
     public TableLayoutTest() {
-        super("com.android.cts.stub", TableStubActivity.class);
+        super("com.android.cts.widget", TableCtsActivity.class);
     }
 
     @Override
@@ -58,15 +58,15 @@
 
         new TableLayout(mContext, null);
 
-        TableStubActivity activity = getActivity();
-        activity.setContentView(com.android.cts.stub.R.layout.table_layout_1);
+        TableCtsActivity activity = getActivity();
+        activity.setContentView(com.android.cts.widget.R.layout.table_layout_1);
         TableLayout tableLayout = (TableLayout) activity
-                .findViewById(com.android.cts.stub.R.id.table1);
+                .findViewById(com.android.cts.widget.R.id.table1);
         assertTrue(tableLayout.isColumnCollapsed(0));
         assertTrue(tableLayout.isColumnStretchable(2));
 
-        activity.setContentView(com.android.cts.stub.R.layout.table_layout_2);
-        tableLayout = (TableLayout) activity.findViewById(com.android.cts.stub.R.id.table2);
+        activity.setContentView(com.android.cts.widget.R.layout.table_layout_2);
+        tableLayout = (TableLayout) activity.findViewById(com.android.cts.widget.R.id.table2);
         assertTrue(tableLayout.isColumnShrinkable(1));
     }
 
@@ -203,15 +203,15 @@
     }
 
     public void testColumnStretchableEffect() {
-        final TableStubActivity activity = getActivity();
+        final TableCtsActivity activity = getActivity();
         getInstrumentation().runOnMainSync(new Runnable() {
             public void run() {
-                activity.setContentView(com.android.cts.stub.R.layout.table_layout_1);
+                activity.setContentView(com.android.cts.widget.R.layout.table_layout_1);
             }
         });
         getInstrumentation().waitForIdleSync();
         final TableLayout tableLayout =
-                (TableLayout) activity.findViewById(com.android.cts.stub.R.id.table1);
+                (TableLayout) activity.findViewById(com.android.cts.widget.R.id.table1);
 
         // Preparation: remove Collapsed mark for column 0.
         getInstrumentation().runOnMainSync(new Runnable() {
@@ -554,7 +554,7 @@
     public void testGenerateLayoutParams1() {
         TableLayout tableLayout = new TableLayout(mContext);
 
-        TableStubActivity activity = getActivity();
+        TableCtsActivity activity = getActivity();
         XmlResourceParser parser = activity.getResources().getLayout(R.layout.table_layout_1);
         AttributeSet attr = Xml.asAttributeSet(parser);
 
diff --git a/tests/tests/widget/src/android/widget/cts/TableLayout_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/TableLayout_LayoutParamsTest.java
index d63979a..20a9937 100644
--- a/tests/tests/widget/src/android/widget/cts/TableLayout_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TableLayout_LayoutParamsTest.java
@@ -139,7 +139,7 @@
         AttributeSet attrs = null;
         try {
             parser = mTargetContext.getResources()
-                    .getXml(com.android.cts.stub.R.xml.base_attributes);
+                    .getXml(com.android.cts.widget.R.xml.base_attributes);
 
             int type;
             while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
diff --git a/tests/tests/widget/src/android/widget/cts/TableRowTest.java b/tests/tests/widget/src/android/widget/cts/TableRowTest.java
index 9ab4d13..6012f59 100644
--- a/tests/tests/widget/src/android/widget/cts/TableRowTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TableRowTest.java
@@ -33,18 +33,18 @@
 import android.widget.TableRow;
 import android.widget.TextView;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 /**
  * Test {@link TableRow}.
  */
-public class TableRowTest extends ActivityInstrumentationTestCase2<TableStubActivity> {
+public class TableRowTest extends ActivityInstrumentationTestCase2<TableCtsActivity> {
     Context mContext;
     Context mTargetContext;
 
     public TableRowTest() {
-        super("com.android.cts.stub", TableStubActivity.class);
+        super("com.android.cts.widget", TableCtsActivity.class);
     }
 
     @Override
@@ -82,10 +82,10 @@
 
     @UiThreadTest
     public void testGetVirtualChildAt() {
-        TableStubActivity activity = getActivity();
-        activity.setContentView(com.android.cts.stub.R.layout.table_layout_1);
+        TableCtsActivity activity = getActivity();
+        activity.setContentView(com.android.cts.widget.R.layout.table_layout_1);
         TableLayout tableLayout = (TableLayout) activity
-                .findViewById(com.android.cts.stub.R.id.table1);
+                .findViewById(com.android.cts.widget.R.id.table1);
 
         TableRow tableRow = (TableRow) tableLayout.getChildAt(0);
         Resources resources = activity.getResources();
@@ -96,8 +96,8 @@
         assertEquals(resources.getString(R.string.table_layout_third),
                 ((TextView) tableRow.getVirtualChildAt(2)).getText().toString());
 
-        activity.setContentView(com.android.cts.stub.R.layout.table_layout_2);
-        tableLayout = (TableLayout) activity.findViewById(com.android.cts.stub.R.id.table2);
+        activity.setContentView(com.android.cts.widget.R.layout.table_layout_2);
+        tableLayout = (TableLayout) activity.findViewById(com.android.cts.widget.R.id.table2);
 
         tableRow = (TableRow) tableLayout.getChildAt(0);
         assertNull(tableRow.getVirtualChildAt(0));
@@ -113,16 +113,16 @@
 
     @UiThreadTest
     public void testGetVirtualChildCount() {
-        TableStubActivity activity = getActivity();
-        activity.setContentView(com.android.cts.stub.R.layout.table_layout_1);
+        TableCtsActivity activity = getActivity();
+        activity.setContentView(com.android.cts.widget.R.layout.table_layout_1);
         TableLayout tableLayout = (TableLayout) activity
-                .findViewById(com.android.cts.stub.R.id.table1);
+                .findViewById(com.android.cts.widget.R.id.table1);
 
         TableRow tableRow = (TableRow) tableLayout.getChildAt(0);
         assertEquals(3, tableRow.getVirtualChildCount());
 
-        activity.setContentView(com.android.cts.stub.R.layout.table_layout_2);
-        tableLayout = (TableLayout) activity.findViewById(com.android.cts.stub.R.id.table2);
+        activity.setContentView(com.android.cts.widget.R.layout.table_layout_2);
+        tableLayout = (TableLayout) activity.findViewById(com.android.cts.widget.R.id.table2);
 
         tableRow = (TableRow) tableLayout.getChildAt(0);
         assertEquals(5, tableRow.getVirtualChildCount());
diff --git a/tests/tests/widget/src/android/widget/cts/TableRow_LayoutParamsTest.java b/tests/tests/widget/src/android/widget/cts/TableRow_LayoutParamsTest.java
index 1d6793f..cf2603f 100644
--- a/tests/tests/widget/src/android/widget/cts/TableRow_LayoutParamsTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TableRow_LayoutParamsTest.java
@@ -39,11 +39,11 @@
  * Test {@link TableRow.LayoutParams}.
  */
 public class TableRow_LayoutParamsTest
-        extends ActivityInstrumentationTestCase2<TableStubActivity> {
+        extends ActivityInstrumentationTestCase2<TableCtsActivity> {
     Context mTargetContext;
 
     public TableRow_LayoutParamsTest() {
-        super("com.android.cts.stub", TableStubActivity.class);
+        super("com.android.cts.widget", TableCtsActivity.class);
     }
 
     @Override
@@ -91,9 +91,9 @@
         assertEquals(0, layoutParams.column);
         assertEquals(0, layoutParams.span);
 
-        TableStubActivity activity = getActivity();
-        activity.setContentView(com.android.cts.stub.R.layout.table_layout_2);
-        int idTable = com.android.cts.stub.R.id.table2;
+        TableCtsActivity activity = getActivity();
+        activity.setContentView(com.android.cts.widget.R.layout.table_layout_2);
+        int idTable = com.android.cts.widget.R.id.table2;
         TableLayout tableLayout = (TableLayout) activity.findViewById(idTable);
         View vVitural1 = ((TableRow) tableLayout.getChildAt(0)).getVirtualChildAt(1);
         layoutParams = (TableRow.LayoutParams) vVitural1.getLayoutParams();
@@ -186,7 +186,7 @@
         AttributeSet attrs = null;
         try {
             parser = mTargetContext.getResources()
-                    .getXml(com.android.cts.stub.R.xml.base_attributes);
+                    .getXml(com.android.cts.widget.R.xml.base_attributes);
 
             int type;
             while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
diff --git a/tests/tests/widget/src/android/widget/cts/TestThread.java b/tests/tests/widget/src/android/widget/cts/TestThread.java
new file mode 100644
index 0000000..78295b9
--- /dev/null
+++ b/tests/tests/widget/src/android/widget/cts/TestThread.java
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+package android.widget.cts;
+
+/**
+ * Thread class for executing a Runnable containing assertions in a separate thread.
+ * Uncaught exceptions in the Runnable are rethrown in the context of the the thread
+ * calling the <code>runTest()</code> method.
+ */
+public final class TestThread extends Thread {
+    private Throwable mThrowable;
+    private Runnable mTarget;
+
+    public TestThread(Runnable target) {
+        mTarget = target;
+    }
+
+    @Override
+    public final void run() {
+        try {
+            mTarget.run();
+        } catch (Throwable t) {
+            mThrowable = t;
+        }
+    }
+
+    /**
+     * Run the target Runnable object and wait until the test finish or throw
+     * out Exception if test fail.
+     *
+     * @param runTime
+     * @throws Throwable
+     */
+    public void runTest(long runTime) throws Throwable {
+        start();
+        joinAndCheck(runTime);
+    }
+
+    /**
+     * Get the Throwable object which is thrown when test running
+     * @return  The Throwable object
+     */
+    public Throwable getThrowable() {
+        return mThrowable;
+    }
+
+    /**
+     * Set the Throwable object which is thrown when test running
+     * @param t The Throwable object
+     */
+    public void setThrowable(Throwable t) {
+        mThrowable = t;
+    }
+
+    /**
+     * Wait for the test thread to complete and throw the stored exception if there is one.
+     *
+     * @param runTime The time to wait for the test thread to complete.
+     * @throws Throwable
+     */
+    public void joinAndCheck(long runTime) throws Throwable {
+        this.join(runTime);
+        if (this.isAlive()) {
+            this.interrupt();
+            this.join(runTime);
+            throw new Exception("Thread did not finish within allotted time.");
+        }
+        checkException();
+    }
+
+    /**
+     * Check whether there is an exception when running Runnable object.
+     * @throws Throwable
+     */
+    public void checkException() throws Throwable {
+        if (mThrowable != null) {
+            throw mThrowable;
+        }
+    }
+}
diff --git a/tests/src/android/widget/cts/TextViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/TextViewCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/TextViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/TextViewCtsActivity.java
index 956e264..888f215 100644
--- a/tests/src/android/widget/cts/TextViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for TextView test.
  */
-public class TextViewStubActivity extends Activity {
+public class TextViewCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index 53cdcb6..c5d9985 100644
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 import com.android.internal.util.FastMath;
 
 import org.xmlpull.v1.XmlPullParserException;
@@ -69,7 +69,6 @@
 import android.text.method.TimeKeyListener;
 import android.text.method.TransformationMethod;
 import android.text.style.URLSpan;
-import android.text.style.cts.MockURLSpanTestActivity;
 import android.text.util.Linkify;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
@@ -98,7 +97,7 @@
 /**
  * Test {@link TextView}.
  */
-public class TextViewTest extends ActivityInstrumentationTestCase2<TextViewStubActivity> {
+public class TextViewTest extends ActivityInstrumentationTestCase2<TextViewCtsActivity> {
 
     private TextView mTextView;
     private Activity mActivity;
@@ -112,7 +111,7 @@
     private CharSequence mTransformedText;
 
     public TextViewTest() {
-        super("com.android.cts.stub", TextViewStubActivity.class);
+        super("com.android.cts.widget", TextViewCtsActivity.class);
     }
 
     @Override
@@ -3294,7 +3293,7 @@
 
     @UiThreadTest
     public void testResetTextAlignment() {
-        TextViewStubActivity activity = getActivity();
+        TextViewCtsActivity activity = getActivity();
 
         LinearLayout ll = (LinearLayout) activity.findViewById(R.id.layout_textviewtest);
         TextView tv = (TextView) activity.findViewById(R.id.textview_rtl);
@@ -3320,7 +3319,7 @@
         final int RIGHT = 2;
         final int BOTTOM = 3;
 
-        TextViewStubActivity activity = getActivity();
+        TextViewCtsActivity activity = getActivity();
 
         // Case 1.1: left / right drawable defined in default LTR mode
         TextView tv = (TextView) activity.findViewById(R.id.textview_drawable_1_1);
@@ -3464,7 +3463,7 @@
         final int RIGHT = 2;
         final int BOTTOM = 3;
 
-        TextViewStubActivity activity = getActivity();
+        TextViewCtsActivity activity = getActivity();
 
         // Case 1.1: left / right drawable defined in default LTR mode
         TextView tv = (TextView) activity.findViewById(R.id.textview_drawable_1_1);
diff --git a/tests/tests/widget/src/android/widget/cts/TimePickerTest.java b/tests/tests/widget/src/android/widget/cts/TimePickerTest.java
index 2ab01a3..fcf787a 100644
--- a/tests/tests/widget/src/android/widget/cts/TimePickerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TimePickerTest.java
@@ -29,7 +29,7 @@
 /**
  * Test {@link TimePicker}.
  */
-public class TimePickerTest extends ActivityInstrumentationTestCase2<StubActivity> {
+public class TimePickerTest extends ActivityInstrumentationTestCase2<CtsActivity> {
     private TimePicker mTimePicker;
 
     private Activity mActivity;
@@ -39,7 +39,7 @@
     private Instrumentation mInstrumentation;
 
     public TimePickerTest() {
-        super("com.android.cts.stub", StubActivity.class);
+        super("com.android.cts.widget", CtsActivity.class);
     }
 
     @Override
@@ -52,7 +52,7 @@
 
     public void testConstructors() {
         AttributeSet attrs =
-            mContext.getResources().getLayout(com.android.cts.stub.R.layout.timepicker);
+            mContext.getResources().getLayout(com.android.cts.widget.R.layout.timepicker);
         assertNotNull(attrs);
 
         new TimePicker(mContext);
diff --git a/tests/tests/widget/src/android/widget/cts/ToastTest.java b/tests/tests/widget/src/android/widget/cts/ToastTest.java
index 9c7846b..055b874 100644
--- a/tests/tests/widget/src/android/widget/cts/ToastTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ToastTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -33,7 +33,7 @@
 import android.widget.ImageView;
 import android.widget.Toast;
 
-public class ToastTest extends ActivityInstrumentationTestCase2<StubActivity> {
+public class ToastTest extends ActivityInstrumentationTestCase2<CtsActivity> {
     private static final String TEST_TOAST_TEXT = "test toast";
     private static final long TIME_FOR_UI_OPERATION  = 1000L;
     private static final long TIME_OUT = 5000L;
@@ -44,7 +44,7 @@
     private ViewTreeObserver.OnGlobalLayoutListener mLayoutListener;
 
     public ToastTest() {
-        super("com.android.cts.stub", StubActivity.class);
+        super("com.android.cts.widget", CtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/widget/src/android/widget/cts/ToggleButtonTest.java b/tests/tests/widget/src/android/widget/cts/ToggleButtonTest.java
index ca1c94f..d5b74c3 100644
--- a/tests/tests/widget/src/android/widget/cts/ToggleButtonTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ToggleButtonTest.java
@@ -26,7 +26,7 @@
 import android.util.Xml;
 import android.widget.ToggleButton;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 /**
diff --git a/tests/src/android/widget/cts/TwoLineListItemStubActivity.java b/tests/tests/widget/src/android/widget/cts/TwoLineListItemCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/TwoLineListItemStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/TwoLineListItemCtsActivity.java
index 380cefb..bd2c36d 100644
--- a/tests/src/android/widget/cts/TwoLineListItemStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/TwoLineListItemCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -25,7 +25,7 @@
 /**
  * Stub activity for testing {@link TwoLineListItem}
  */
-public class TwoLineListItemStubActivity extends Activity {
+public class TwoLineListItemCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/TwoLineListItemTest.java b/tests/tests/widget/src/android/widget/cts/TwoLineListItemTest.java
index 5ef5961..0d5807f 100644
--- a/tests/tests/widget/src/android/widget/cts/TwoLineListItemTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TwoLineListItemTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import android.app.Activity;
@@ -32,11 +32,11 @@
  * Test {@link TwoLineListItem}.
  */
 public class TwoLineListItemTest extends
-        ActivityInstrumentationTestCase<TwoLineListItemStubActivity> {
+        ActivityInstrumentationTestCase<TwoLineListItemCtsActivity> {
     private Activity mActivity;
 
     public TwoLineListItemTest() {
-        super("com.android.cts.stub", TwoLineListItemStubActivity.class);
+        super("com.android.cts.widget", TwoLineListItemCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/VideoViewStubActivity.java b/tests/tests/widget/src/android/widget/cts/VideoViewCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/VideoViewStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/VideoViewCtsActivity.java
index 73c7756..ad0d6eb 100644
--- a/tests/src/android/widget/cts/VideoViewStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/VideoViewCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -25,7 +25,7 @@
 /**
  * A minimal application for {@link VideoView} test.
  */
-public class VideoViewStubActivity extends Activity {
+public class VideoViewCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/VideoViewTest.java b/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
index c8d9fc7..79b10df 100644
--- a/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.app.Instrumentation;
@@ -41,7 +41,7 @@
 /**
  * Test {@link VideoView}.
  */
-public class VideoViewTest extends ActivityInstrumentationTestCase2<VideoViewStubActivity> {
+public class VideoViewTest extends ActivityInstrumentationTestCase2<VideoViewCtsActivity> {
     /** Debug TAG. **/
     private static final String TAG = "VideoViewTest";
     /** The maximum time to wait for an operation. */
@@ -127,7 +127,7 @@
      * Instantiates a new video view test.
      */
     public VideoViewTest() {
-        super("com.android.cts.stub", VideoViewStubActivity.class);
+        super("com.android.cts.widget", VideoViewCtsActivity.class);
     }
 
     /**
diff --git a/tests/src/android/widget/cts/ViewAnimatorStubActivity.java b/tests/tests/widget/src/android/widget/cts/ViewAnimatorCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/ViewAnimatorStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ViewAnimatorCtsActivity.java
index 634f531..21deef7 100644
--- a/tests/src/android/widget/cts/ViewAnimatorStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ViewAnimatorCtsActivity.java
@@ -18,12 +18,12 @@
 
 import android.app.Activity;
 import android.os.Bundle;
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 /**
  * A minimal application for ViewAnimator test.
  */
-public class ViewAnimatorStubActivity extends Activity {
+public class ViewAnimatorCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/ViewAnimatorTest.java b/tests/tests/widget/src/android/widget/cts/ViewAnimatorTest.java
index 72f5559..024e3ee 100644
--- a/tests/tests/widget/src/android/widget/cts/ViewAnimatorTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ViewAnimatorTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -36,14 +36,14 @@
 import android.widget.ViewAnimator;
 
 public class ViewAnimatorTest extends
-        ActivityInstrumentationTestCase2<ViewAnimatorStubActivity> {
+        ActivityInstrumentationTestCase2<ViewAnimatorCtsActivity> {
     private ViewAnimator mViewAnimator;
     private Activity mActivity;
     private Instrumentation mInstrumentation;
     private AttributeSet mAttributeSet;
 
     public ViewAnimatorTest() {
-        super("com.android.cts.stub", ViewAnimatorStubActivity.class);
+        super("com.android.cts.widget", ViewAnimatorCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/ViewFlipperStubActivity.java b/tests/tests/widget/src/android/widget/cts/ViewFlipperCtsActivity.java
similarity index 90%
rename from tests/src/android/widget/cts/ViewFlipperStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ViewFlipperCtsActivity.java
index 2ac331e..7f13f6c 100644
--- a/tests/src/android/widget/cts/ViewFlipperStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ViewFlipperCtsActivity.java
@@ -16,12 +16,12 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
 
-public class ViewFlipperStubActivity extends Activity {
+public class ViewFlipperCtsActivity extends Activity {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
diff --git a/tests/tests/widget/src/android/widget/cts/ViewFlipperTest.java b/tests/tests/widget/src/android/widget/cts/ViewFlipperTest.java
index f223466..ac06def 100644
--- a/tests/tests/widget/src/android/widget/cts/ViewFlipperTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ViewFlipperTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -32,11 +32,11 @@
 /**
  * Test {@link ViewFlipper}.
  */
-public class ViewFlipperTest extends ActivityInstrumentationTestCase<ViewFlipperStubActivity> {
+public class ViewFlipperTest extends ActivityInstrumentationTestCase<ViewFlipperCtsActivity> {
     private Activity mActivity;
 
     public ViewFlipperTest() {
-        super("com.android.cts.stub", ViewFlipperStubActivity.class);
+        super("com.android.cts.widget", ViewFlipperCtsActivity.class);
     }
 
     protected void setUp() throws Exception {
diff --git a/tests/src/android/widget/cts/ViewGroupStubActivity.java b/tests/tests/widget/src/android/widget/cts/ViewGroupCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/ViewGroupStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ViewGroupCtsActivity.java
index 346c067..378395e 100644
--- a/tests/src/android/widget/cts/ViewGroupStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ViewGroupCtsActivity.java
@@ -22,7 +22,7 @@
 import android.os.Handler;
 import android.widget.TextView;
 
-public class ViewGroupStubActivity extends Activity {
+public class ViewGroupCtsActivity extends Activity {
 
     public static final String ACTION_INVALIDATE_CHILD = "invalidateChild";
 
@@ -35,8 +35,8 @@
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(com.android.cts.stub.R.layout.viewgrouptest_stub);
-        TextView textView = (TextView)findViewById(com.android.cts.stub.R.id.viewgrouptest_stub);
+        setContentView(com.android.cts.widget.R.layout.viewgrouptest_stub);
+        TextView textView = (TextView)findViewById(com.android.cts.widget.R.id.viewgrouptest_stub);
         textView.setText("test");
     }
 
@@ -49,7 +49,7 @@
             mHandler.postDelayed(new Runnable() {
                 public void run() {
                     MockLinearLayout mll =
-                        (MockLinearLayout) findViewById(com.android.cts.stub.R.id.
+                        (MockLinearLayout) findViewById(com.android.cts.widget.R.id.
                                                                         mocklinearlayout);
                     if (!mll.mIsInvalidateChildInParentCalled) {
                         fail();
diff --git a/tests/tests/widget/src/android/widget/cts/ViewSwitcherTest.java b/tests/tests/widget/src/android/widget/cts/ViewSwitcherTest.java
index b7bac6c..ce18267 100644
--- a/tests/tests/widget/src/android/widget/cts/ViewSwitcherTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ViewSwitcherTest.java
@@ -28,7 +28,7 @@
 import android.widget.ViewSwitcher;
 import android.widget.ViewSwitcher.ViewFactory;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 /**
diff --git a/tests/src/android/widget/cts/WidgetTestUtils.java b/tests/tests/widget/src/android/widget/cts/WidgetTestUtils.java
similarity index 100%
rename from tests/src/android/widget/cts/WidgetTestUtils.java
rename to tests/tests/widget/src/android/widget/cts/WidgetTestUtils.java
diff --git a/tests/src/android/widget/cts/ZoomButtonStubActivity.java b/tests/tests/widget/src/android/widget/cts/ZoomButtonCtsActivity.java
similarity index 91%
rename from tests/src/android/widget/cts/ZoomButtonStubActivity.java
rename to tests/tests/widget/src/android/widget/cts/ZoomButtonCtsActivity.java
index a49df7a..e371b3f 100644
--- a/tests/src/android/widget/cts/ZoomButtonStubActivity.java
+++ b/tests/tests/widget/src/android/widget/cts/ZoomButtonCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -24,7 +24,7 @@
 /**
  * A minimal application for {@link ZoomButton} test.
  */
-public class ZoomButtonStubActivity extends Activity {
+public class ZoomButtonCtsActivity extends Activity {
     /**
      * Called with the activity is first created.
      */
diff --git a/tests/tests/widget/src/android/widget/cts/ZoomButtonTest.java b/tests/tests/widget/src/android/widget/cts/ZoomButtonTest.java
index 94c2669..47bcfed 100644
--- a/tests/tests/widget/src/android/widget/cts/ZoomButtonTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ZoomButtonTest.java
@@ -16,7 +16,7 @@
 
 package android.widget.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.widget.R;
 
 
 import org.xmlpull.v1.XmlPullParser;
@@ -32,12 +32,12 @@
 import android.widget.ListView;
 import android.widget.ZoomButton;
 
-public class ZoomButtonTest extends ActivityInstrumentationTestCase2<ZoomButtonStubActivity> {
+public class ZoomButtonTest extends ActivityInstrumentationTestCase2<ZoomButtonCtsActivity> {
     private ZoomButton mZoomButton;
     private Activity mActivity;
 
     public ZoomButtonTest() {
-        super("com.android.cts.stub", ZoomButtonStubActivity.class);
+        super("com.android.cts.widget", ZoomButtonCtsActivity.class);
     }
 
     @Override
diff --git a/tests/src/android/widget/cts/util/ExpandableListScenario.java b/tests/tests/widget/src/android/widget/cts/util/ExpandableListScenario.java
similarity index 100%
rename from tests/src/android/widget/cts/util/ExpandableListScenario.java
rename to tests/tests/widget/src/android/widget/cts/util/ExpandableListScenario.java
diff --git a/tests/src/android/widget/cts/util/ListItemFactory.java b/tests/tests/widget/src/android/widget/cts/util/ListItemFactory.java
similarity index 100%
rename from tests/src/android/widget/cts/util/ListItemFactory.java
rename to tests/tests/widget/src/android/widget/cts/util/ListItemFactory.java
diff --git a/tests/src/android/widget/cts/util/ListScenario.java b/tests/tests/widget/src/android/widget/cts/util/ListScenario.java
similarity index 100%
rename from tests/src/android/widget/cts/util/ListScenario.java
rename to tests/tests/widget/src/android/widget/cts/util/ListScenario.java
diff --git a/tests/src/android/widget/cts/util/ListUtil.java b/tests/tests/widget/src/android/widget/cts/util/ListUtil.java
similarity index 100%
rename from tests/src/android/widget/cts/util/ListUtil.java
rename to tests/tests/widget/src/android/widget/cts/util/ListUtil.java
diff --git a/tests/webgl/src/android/webgl/WebGLActivity.java b/tests/webgl/src/android/webgl/WebGLActivity.java
index ae1032b..ebba905 100644
--- a/tests/webgl/src/android/webgl/WebGLActivity.java
+++ b/tests/webgl/src/android/webgl/WebGLActivity.java
@@ -24,6 +24,7 @@
 import android.webgl.cts.R;
 import android.webkit.WebView;
 import android.webkit.JavascriptInterface;
+import android.webkit.WebViewClient;
 import android.widget.Toast;
 import java.lang.Override;
 import java.io.InputStream;
@@ -54,6 +55,12 @@
         mWebView.getSettings().setJavaScriptEnabled(true);
         mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
         mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
+        mWebView.setWebViewClient(new WebViewClient() {
+            @Override
+            public boolean shouldOverrideUrlLoading(WebView webView, String url) {
+                return false;
+            }
+        });
 
         mWebView.addJavascriptInterface(new Object() {
             @JavascriptInterface
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index aa5bbf1..f9228d7 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -169,15 +169,153 @@
       plan.ExcludeTests(package, test_list)
     self.__WritePlan(plan, 'CTS-stable')
 
-    # CTS Flaky plan - inversion of CTS Stable
+    # CTS Flaky plan - list of tests known to be flaky in lab environment
     plan = tools.TestPlan(packages)
     plan.Exclude('.*')
     plan.Include(r'com\.android\.cts\.browserbench')
     for package, test_list in flaky_tests.iteritems():
-      plan.Include(package)
+      plan.Include(package+'$')
       plan.IncludeTests(package, test_list)
     self.__WritePlan(plan, 'CTS-flaky')
 
+    small_tests = BuildAospSmallSizeTestList()
+    medium_tests = BuildAospMediumSizeTestList()
+
+    # CTS - sub plan for public, small size tests
+    plan = tools.TestPlan(packages)
+    plan.Exclude('.*')
+    for package, test_list in small_tests.iteritems():
+      plan.Include(package+'$')
+    for package, test_list in flaky_tests.iteritems():
+      plan.ExcludeTests(package, test_list)
+    self.__WritePlan(plan, 'CTS-kitkat-small')
+
+    # CTS - sub plan for public, medium size tests
+    plan = tools.TestPlan(packages)
+    plan.Exclude('.*')
+    for package, test_list in medium_tests.iteritems():
+      plan.Include(package+'$')
+    for package, test_list in flaky_tests.iteritems():
+      plan.ExcludeTests(package, test_list)
+    self.__WritePlan(plan, 'CTS-kitkat-medium')
+
+    # CTS - sub plan for hardware tests which is public, large
+    plan = tools.TestPlan(packages)
+    plan.Exclude('.*')
+    plan.Include(r'android\.hardware$')
+    for package, test_list in flaky_tests.iteritems():
+      plan.ExcludeTests(package, test_list)
+    self.__WritePlan(plan, 'CTS-hardware')
+
+    # CTS - sub plan for media tests which is public, large
+    plan = tools.TestPlan(packages)
+    plan.Exclude('.*')
+    plan.Include(r'android\.media$')
+    for package, test_list in flaky_tests.iteritems():
+      plan.ExcludeTests(package, test_list)
+    self.__WritePlan(plan, 'CTS-media')
+
+    # CTS - sub plan for mediastress tests which is public, large
+    plan = tools.TestPlan(packages)
+    plan.Exclude('.*')
+    plan.Include(r'android\.mediastress$')
+    for package, test_list in flaky_tests.iteritems():
+      plan.ExcludeTests(package, test_list)
+    self.__WritePlan(plan, 'CTS-mediastress')
+
+    #CTS - sub plan for new test packages added for staging
+    plan = tools.TestPlan(packages)
+    for package, test_list in small_tests.iteritems():
+      plan.Exclude(package+'$')
+    for package, test_list in medium_tests.iteritems():
+      plan.Exclude(package+'$')
+    plan.Exclude(r'android\.hardware$')
+    plan.Exclude(r'android\.media$')
+    plan.Exclude(r'android\.mediastress$')
+    for package, test_list in flaky_tests.iteritems():
+      plan.ExcludeTests(package, test_list)
+    self.__WritePlan(plan, 'CTS-staging')
+
+def BuildAospMediumSizeTestList():
+  """ Construct a defaultdic that lists package names of medium tests
+      already published to aosp. """
+  return {
+      'android.app' : [],
+      'android.core.tests.libcore.package.libcore' : [],
+      'android.core.tests.libcore.package.org' : [],
+      'android.core.vm-tests-tf' : [],
+      'android.dpi' : [],
+      'android.host.security' : [],
+      'android.net' : [],
+      'android.os' : [],
+      'android.security' : [],
+      'android.telephony' : [],
+      'android.webkit' : [],
+      'android.widget' : [],
+      'com.android.cts.browserbench' : []}
+
+def BuildAospSmallSizeTestList():
+  """ Construct a defaultdict that lists packages names of small tests
+      already published to aosp. """
+  return {
+      'android.aadb' : [],
+      'android.acceleration' : [],
+      'android.accessibility' : [],
+      'android.accessibilityservice' : [],
+      'android.accounts' : [],
+      'android.admin' : [],
+      'android.animation' : [],
+      'android.bionic' : [],
+      'android.bluetooth' : [],
+      'android.calendarcommon' : [],
+      'android.content' : [],
+      'android.core.tests.libcore.package.com' : [],
+      'android.core.tests.libcore.package.conscrypt' : [],
+      'android.core.tests.libcore.package.dalvik' : [],
+      'android.core.tests.libcore.package.sun' : [],
+      'android.core.tests.libcore.package.tests' : [],
+      'android.database' : [],
+      'android.dreams' : [],
+      'android.drm' : [],
+      'android.effect' : [],
+      'android.gesture' : [],
+      'android.graphics' : [],
+      'android.graphics2' : [],
+      'android.jni' : [],
+      'android.keystore' : [],
+      'android.location' : [],
+      'android.nativemedia.sl' : [],
+      'android.nativemedia.xa' : [],
+      'android.nativeopengl' : [],
+      'android.ndef' : [],
+      'android.opengl' : [],
+      'android.openglperf' : [],
+      'android.permission' : [],
+      'android.permission2' : [],
+      'android.preference' : [],
+      'android.preference2' : [],
+      'android.provider' : [],
+      'android.renderscript' : [],
+      'android.rscpp' : [],
+      'android.rsg' : [],
+      'android.sax' : [],
+      'android.speech' : [],
+      'android.tests.appsecurity' : [],
+      'android.text' : [],
+      'android.textureview' : [],
+      'android.theme' : [],
+      'android.usb' : [],
+      'android.util' : [],
+      'android.view' : [],
+      'com.android.cts.dram' : [],
+      'com.android.cts.filesystemperf' : [],
+      'com.android.cts.jank' : [],
+      'com.android.cts.opengl' : [],
+      'com.android.cts.simplecpu' : [],
+      'com.android.cts.ui' : [],
+      'com.android.cts.uihost' : [],
+      'com.android.cts.videoperf' : [],
+      'zzz.android.monkey' : []}
 
 def BuildCtsFlakyTestList():
   """ Construct a defaultdict that maps package name to a list of tests