am 8e1d9711: am 8180c9e6: Reconcile with ics-mr0-release

* commit '8e1d97112f1dd6379cc7441c8afef411b36ea146':
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index e5c52fb..5e4b867 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.cts.verifier"
       android:versionCode="1"
-      android:versionName="4.0_r1">
+      android:versionName="1337">
 
     <!-- Using 10 for more complete NFC support... -->
     <uses-sdk android:minSdkVersion="10"></uses-sdk>
@@ -173,6 +173,28 @@
             <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
         </activity>
 
+        <activity android:name=".bluetooth.ConnectionAccessServerActivity"
+                android:label="@string/bt_connection_access_server"
+                android:configChanges="keyboardHidden|orientation">
+            <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/bt_device_communication" />
+            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+        </activity>
+        
+        <activity android:name=".bluetooth.ConnectionAccessClientActivity"
+                android:label="@string/bt_connection_access_client"
+                android:configChanges="keyboardHidden|orientation">
+            <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/bt_device_communication" />
+            <meta-data android:name="test_parent" android:value="com.android.cts.verifier.bluetooth.BluetoothTestActivity" />
+        </activity>
+
         <activity android:name=".bluetooth.DevicePickerActivity"
                 android:label="@string/bt_device_picker"
                 android:configChanges="keyboardHidden|orientation" />
@@ -273,6 +295,11 @@
 
         <activity android:name=".camera.analyzer.CameraAnalyzerActivity"
                 android:label="@string/camera_analyzer">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_category" android:value="@string/test_category_camera" />
         </activity>
 
         <activity android:name=".usb.UsbAccessoryTestActivity"
diff --git a/apps/CtsVerifier/lib/colorchecker/colorchecker.cpp b/apps/CtsVerifier/lib/colorchecker/colorchecker.cpp
index 1e0ae97..a7431f6 100644
--- a/apps/CtsVerifier/lib/colorchecker/colorchecker.cpp
+++ b/apps/CtsVerifier/lib/colorchecker/colorchecker.cpp
@@ -363,7 +363,7 @@
     const int outScale = width / outTargetWidth;
     const int outWidth = width / outScale;
     const int outHeight = height / outScale;
-    LOGV("Debug image dimensions: %d, %d", outWidth, outHeight);
+    ALOGV("Debug image dimensions: %d, %d", outWidth, outHeight);
 
     unsigned char *output = new unsigned char[outWidth * outHeight * totalChannels];
 
@@ -441,21 +441,21 @@
         // Find the bottom-left and top-right corners
         if ( (bl = tl->getDNeighbor(3)) == NULL ||
              (tr = tl->getRNeighbor(5)) == NULL ) continue;
-        LOGV("Candidate at %d, %d", dex, dey);
-        LOGV("  Got BL and TR");
+        ALOGV("Candidate at %d, %d", dex, dey);
+        ALOGV("  Got BL and TR");
 
         // Find the bottom-right corner
         if ( tr->getDNeighbor(3) == NULL ) {
-            LOGV("  No BR from TR");
+            ALOGV("  No BR from TR");
             continue;
         }
         br = tr->getDNeighbor(3);
         if ( br != bl->getRNeighbor(5) ) {
-            LOGV("  BR from TR and from BL don't agree");
+            ALOGV("  BR from TR and from BL don't agree");
             continue;
         }
         br->getApproxCenter(&dex, &dey);
-        LOGV("  Got BR corner at %d, %d", dex, dey);
+        ALOGV("  Got BR corner at %d, %d", dex, dey);
 
         // Check that matching grid edge lengths are about the same
         float gridTopWidth = tl->distanceTo(tr);
@@ -463,14 +463,14 @@
 
         if (gridTopWidth / gridBotWidth < minAspectRatio ||
             gridTopWidth / gridBotWidth > maxAspectRatio) continue;
-        LOGV("  Got reasonable widths: %f %f", gridTopWidth, gridBotWidth);
+        ALOGV("  Got reasonable widths: %f %f", gridTopWidth, gridBotWidth);
 
         float gridLeftWidth = tl->distanceTo(bl);
         float gridRightWidth = tr->distanceTo(br);
 
         if (gridLeftWidth / gridRightWidth < minAspectRatio ||
             gridLeftWidth / gridRightWidth > maxAspectRatio) continue;
-        LOGV("  Got reasonable heights: %f %f", gridLeftWidth, gridRightWidth);
+        ALOGV("  Got reasonable heights: %f %f", gridLeftWidth, gridRightWidth);
 
         // Calculate average grid spacing
         float gridAvgXGap = (gridTopWidth + gridBotWidth) / 2 / 5;
@@ -502,13 +502,13 @@
             bestError > error) {
             bestGrid = grid;
             bestError = error;
-            LOGV("  Best candidate, error %f", error);
+            ALOGV("  Best candidate, error %f", error);
         }
     }
 
     // Check if a grid wasn't found
     if (bestError == -1) {
-        LOGV("No color checker found!");
+        ALOGV("No color checker found!");
     }
 
     // Make sure black square is in bottom-right corner
@@ -525,7 +525,7 @@
         int brSum = brValues[0] + brValues[1] + brValues[2];
         if (brSum > tlSum) {
             // Grid is upside down, need to flip!
-            LOGV("Flipping grid to put grayscale ramp at bottom");
+            ALOGV("Flipping grid to put grayscale ramp at bottom");
             bestGrid = std::vector<int>(bestGrid.rbegin(), bestGrid.rend());
         }
     }
@@ -579,7 +579,7 @@
             }
         }
         // Print out patch colors
-        IF_LOGV() {
+        IF_ALOGV() {
             for (int y = 0; y < 4; y++) {
                 char tmpMsg[256];
                 int cnt = 0;
@@ -595,7 +595,7 @@
                                         "\t(xxx,xxx,xxx)");
                     }
                 }
-                LOGV("%s", tmpMsg);
+                ALOGV("%s", tmpMsg);
             }
         }
     }
@@ -705,7 +705,7 @@
     }
 
     int64_t endTime = systemTime();
-    LOGV("Process time: %f ms",
+    ALOGV("Process time: %f ms",
          (endTime - startTime) / 1000000.);
 
     if (bestError == -1) return false;
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 6e7d399..cbb98a9 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -206,6 +206,11 @@
         button below to goto Settings and enable it.</string>
     <string name="nfc_settings">NFC Settings</string>
 
+    <string name="ndef_push_not_enabled">NDEF Push is not enabled!</string>
+    <string name="ndef_push_not_enabled_message">These tests require Android Beam to be enabled.
+        Click the button below to goto NFC Sharing Settings and enable it.</string>
+    <string name="ndef_push_settings">NFC Sharing Settings</string>
+
     <string name="nfc_pee_2_pee">Peer-to-Peer Data Exchange</string>
     <string name="nfc_ndef_push_sender">NDEF Push Sender</string>
     <string name="nfc_ndef_push_receiver">NDEF Push Receiver</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index 3ea9451..3736711 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -164,10 +164,6 @@
             new Feature("android.hardware.screen.portrait", false),
     };
 
-    public static final Feature[] ALL_ICE_CREAM_SANDWICH_FEATURES = {
-            new Feature(PackageManager.FEATURE_WIFI_DIRECT, false),
-    };
-
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -198,9 +194,6 @@
 
         // add features from latest to last so that the latest requirements are put in the set first
         int apiVersion = Build.VERSION.SDK_INT;
-        if (apiVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
-            Collections.addAll(features, ALL_ICE_CREAM_SANDWICH_FEATURES);
-        }
         if (apiVersion >= Build.VERSION_CODES.HONEYCOMB_MR2) {
             Collections.addAll(features, ALL_HONEYCOMB_MR2_FEATURES);
         }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NdefPushReceiverActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NdefPushReceiverActivity.java
index f976a45..0697be2 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NdefPushReceiverActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NdefPushReceiverActivity.java
@@ -61,15 +61,19 @@
         mNfcAdapter = nfcManager.getDefaultAdapter();
         mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass())
                 .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
-
-        if (!mNfcAdapter.isEnabled()) {
-            showDialog(NFC_NOT_ENABLED_DIALOG_ID);
-        }
     }
 
     @Override
     protected void onResume() {
         super.onResume();
+
+        if (!mNfcAdapter.isEnabled()) {
+            showDialog(NFC_NOT_ENABLED_DIALOG_ID);
+        }
+
+        /* Only the sender requires mNfcAdapter.isNdefPushEnabled == true,
+         * so no need to check it here in the receiver. */
+
         mNfcAdapter.enableForegroundDispatch(this, mPendingIntent, null, null);
     }
 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NdefPushSenderActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NdefPushSenderActivity.java
index 2a507d3..f3f37c4 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NdefPushSenderActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NdefPushSenderActivity.java
@@ -37,6 +37,7 @@
     static final NdefMessage TEST_MESSAGE = getTestMessage();
 
     private static final int NFC_NOT_ENABLED_DIALOG_ID = 1;
+    private static final int NDEF_PUSH_NOT_ENABLED_DIALOG_ID = 2;
 
     private NfcAdapter mNfcAdapter;
 
@@ -52,10 +53,6 @@
 
         NfcManager nfcManager = (NfcManager) getSystemService(NFC_SERVICE);
         mNfcAdapter = nfcManager.getDefaultAdapter();
-
-        if (!mNfcAdapter.isEnabled()) {
-            showDialog(NFC_NOT_ENABLED_DIALOG_ID);
-        }
     }
 
     private static NdefMessage getTestMessage() {
@@ -71,6 +68,14 @@
     @Override
     protected void onResume() {
         super.onResume();
+
+        if (!mNfcAdapter.isEnabled()) {
+            showDialog(NFC_NOT_ENABLED_DIALOG_ID);
+        } else if (!mNfcAdapter.isNdefPushEnabled()) {
+            /* Sender must have NDEF push enabled */
+            showDialog(NDEF_PUSH_NOT_ENABLED_DIALOG_ID);
+        }
+
         mNfcAdapter.enableForegroundNdefPush(this, TEST_MESSAGE);
     }
 
@@ -85,7 +90,8 @@
         switch (id) {
             case NFC_NOT_ENABLED_DIALOG_ID:
                 return NfcDialogs.createNotEnabledDialog(this);
-
+            case NDEF_PUSH_NOT_ENABLED_DIALOG_ID:
+                return NfcDialogs.createNdefPushNotEnabledDialog(this);
             default:
                 return super.onCreateDialog(id, args);
         }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NfcDialogs.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NfcDialogs.java
index 1130f2d..c78062b 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NfcDialogs.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/NfcDialogs.java
@@ -35,7 +35,22 @@
                 .setPositiveButton(R.string.nfc_settings, new DialogInterface.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
-                        Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
+                        Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS);
+                        context.startActivity(intent);
+                    }
+                })
+                .create();
+    }
+
+    static AlertDialog createNdefPushNotEnabledDialog(final Context context) {
+        return new AlertDialog.Builder(context)
+                .setIcon(android.R.drawable.ic_dialog_alert)
+                .setTitle(R.string.ndef_push_not_enabled)
+                .setMessage(R.string.ndef_push_not_enabled_message)
+                .setPositiveButton(R.string.ndef_push_settings, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        Intent intent = new Intent(Settings.ACTION_NFCSHARING_SETTINGS);
                         context.startActivity(intent);
                     }
                 })
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/TagVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/TagVerifierActivity.java
index 082c143..85a9de5 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/nfc/TagVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/nfc/TagVerifierActivity.java
@@ -104,10 +104,6 @@
             mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass())
                     .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
 
-            if (!mNfcAdapter.isEnabled()) {
-                showDialog(NFC_NOT_ENABLED_DIALOG_ID);
-            }
-
             goToWriteStep();
         } else {
             finish();
@@ -128,6 +124,10 @@
     @Override
     protected void onResume() {
         super.onResume();
+        if (!mNfcAdapter.isEnabled()) {
+            showDialog(NFC_NOT_ENABLED_DIALOG_ID);
+        }
+
         mNfcAdapter.enableForegroundDispatch(this, mPendingIntent, null, null);
     }
 
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 8fef728..454198e 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -948,6 +948,15 @@
 
         <activity android:name="android.opengl.cts.EglConfigStubActivity"/>
 
+        <activity android:name="android.opengl.cts.CompressedTextureStubActivity"
+            android:label="CompressedTextureStubActivity"
+            android:screenOrientation="nosensor">
+            <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.preference.cts.PreferenceStubActivity">
             <meta-data android:name="android.preference" 
                     android:resource="@xml/preferences_from_intent" />
@@ -971,6 +980,7 @@
                   android:label="RenderscriptGLStub"/>
     </application>
 
+
     <!--Test for PackageManager, please put this at the very beginning-->
     <instrumentation android:name="android.content.pm.cts.TestPmInstrumentation"
         android:targetPackage="android"
diff --git a/tests/res/raw/basetex.png b/tests/res/raw/basetex.png
new file mode 100644
index 0000000..c47a8a5
--- /dev/null
+++ b/tests/res/raw/basetex.png
Binary files differ
diff --git a/tests/res/raw/ddstex.dds b/tests/res/raw/ddstex.dds
new file mode 100644
index 0000000..a865693
--- /dev/null
+++ b/tests/res/raw/ddstex.dds
Binary files differ
diff --git a/tests/res/raw/pvrtex.pvr b/tests/res/raw/pvrtex.pvr
new file mode 100644
index 0000000..c92962d
--- /dev/null
+++ b/tests/res/raw/pvrtex.pvr
Binary files differ
diff --git a/tests/src/android/app/cts/IntentServiceStub.java b/tests/src/android/app/cts/IntentServiceStub.java
index af4cd279..043ff85 100644
--- a/tests/src/android/app/cts/IntentServiceStub.java
+++ b/tests/src/android/app/cts/IntentServiceStub.java
@@ -18,9 +18,9 @@
 
 import android.app.IntentService;
 import android.content.Intent;
+import android.cts.util.PollingCheck;
 import android.os.Binder;
 import android.os.IBinder;
-import android.view.animation.cts.DelayedCheck;
 
 public class IntentServiceStub extends IntentService {
     public IntentServiceStub() {
@@ -50,7 +50,7 @@
     }
 
     public static void waitToFinish(long timeout) throws Throwable {
-        new DelayedCheck(timeout) {
+        new PollingCheck(timeout) {
             @Override
             protected boolean check() {
                 return IntentServiceStub.onDestroyCalled;
diff --git a/tests/src/android/view/animation/cts/DelayedCheck.java b/tests/src/android/cts/util/PollingCheck.java
similarity index 83%
rename from tests/src/android/view/animation/cts/DelayedCheck.java
rename to tests/src/android/cts/util/PollingCheck.java
index 7179426..8870fb9 100644
--- a/tests/src/android/view/animation/cts/DelayedCheck.java
+++ b/tests/src/android/cts/util/PollingCheck.java
@@ -14,25 +14,28 @@
  * limitations under the License.
  */
 
-package android.view.animation.cts;
+package android.cts.util;
 
 import junit.framework.Assert;
 
-public abstract class DelayedCheck {
-    private static final long TIME_SLICE = 200;
+public abstract class PollingCheck {
+    private static final long TIME_SLICE = 50;
     private long mTimeout = 3000;
 
-    public DelayedCheck() {
-
+    public PollingCheck() {
     }
 
-    public DelayedCheck(long timeout) {
+    public PollingCheck(long timeout) {
         mTimeout = timeout;
     }
 
     protected abstract boolean check();
 
     public void run() {
+        if (check()) {
+            return;
+        }
+
         long timeout = mTimeout;
         while (timeout > 0) {
             try {
diff --git a/tests/src/android/opengl/cts/CompressedTextureLoader.java b/tests/src/android/opengl/cts/CompressedTextureLoader.java
new file mode 100644
index 0000000..2cb6910
--- /dev/null
+++ b/tests/src/android/opengl/cts/CompressedTextureLoader.java
@@ -0,0 +1,485 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.opengl.cts;
+
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.Buffer;
+import java.nio.ByteOrder;
+import java.util.HashMap;
+
+import com.android.cts.stub.R;
+
+import android.app.Activity;
+import android.content.res.AssetFileDescriptor;
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.util.Log;
+
+import android.opengl.ETC1;
+import android.opengl.ETC1Util;
+import android.opengl.GLES20;
+
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.graphics.BitmapFactory;
+
+public class CompressedTextureLoader {
+    private static final String TAG = "CompressedTextureLoader";
+
+    public static final String TEXTURE_UNCOMPRESSED = "UNCOMPRESSED";
+    public static final String TEXTURE_ETC1 = "ETC1";
+    public static final String TEXTURE_S3TC = "S3TC";
+    public static final String TEXTURE_ATC = "ATC";
+    public static final String TEXTURE_PVRTC = "PVRTC";
+
+    public static class Texture {
+        public Texture(int width, int height, int internalformat, ByteBuffer data,
+                       String formatName) {
+            mWidth = width;
+            mHeight = height;
+            mInternalFormat = internalformat;
+            mData = data;
+            mFormatName = formatName;
+        }
+
+        /**
+         * Get the width of the texture in pixels.
+         * @return the width of the texture in pixels.
+         */
+        public int getWidth() { return mWidth; }
+
+        /**
+         * Get the height of the texture in pixels.
+         * @return the width of the texture in pixels.
+         */
+        public int getHeight() { return mHeight; }
+
+        /**
+         * Get the compressed data of the texture.
+         * @return the texture data.
+         */
+        public ByteBuffer getData() { return mData; }
+
+        /**
+         * Get the format of the texture.
+         * @return the internal format.
+         */
+        public int getFormat() { return mInternalFormat; }
+
+        /**
+         * Get the format of the texture.
+         * @return the internal format.
+         */
+        public boolean isSupported() { return isFormatSupported(mFormatName); }
+
+        private int mWidth;
+        private int mHeight;
+        private int mInternalFormat;
+        private ByteBuffer mData;
+        private String mFormatName;
+    }
+
+    /*  .pvr header is described by the following c struct
+        typedef struct PVR_TEXTURE_HEADER_TAG{
+            unsigned int  dwHeaderSize;   // size of the structure
+            unsigned int  dwHeight;    // height of surface to be created
+            unsigned int  dwWidth;    // width of input surface
+            unsigned int  dwMipMapCount;   // number of MIP-map levels requested
+            unsigned int  dwpfFlags;   // pixel format flags
+            unsigned int  dwDataSize;   // Size of the compress data
+            unsigned int  dwBitCount;   // number of bits per pixel
+            unsigned int  dwRBitMask;   // mask for red bit
+            unsigned int  dwGBitMask;   // mask for green bits
+            unsigned int  dwBBitMask;   // mask for blue bits
+            unsigned int  dwAlphaBitMask;   // mask for alpha channel
+            unsigned int  dwPVR;    // should be 'P' 'V' 'R' '!'
+            unsigned int  dwNumSurfs;   //number of slices for volume textures or skyboxes
+        } PVR_TEXTURE_HEADER;
+    */
+    static final int PVR_HEADER_SIZE = 13 * 4;
+    static final int PVR_2BPP = 24;
+    static final int PVR_4BPP = 25;
+    static final int PVR_MAGIC_NUMBER = 559044176;
+
+    static final int GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
+    static final int GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;
+    static final int GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
+    static final int GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
+
+    static class PVRHeader {
+        int mHeaderSize;   // size of the structure
+        int mHeight;    // height of surface to be created
+        int mWidth;    // width of input surface
+        int mMipMapCount;   // number of MIP-map levels requested
+        int mpfFlags;   // pixel format flags
+        int mDataSize;   // Size of the compress data
+        int mBitCount;   // number of bits per pixel
+        int mRBitMask;   // mask for red bit
+        int mGBitMask;   // mask for green bits
+        int mBBitMask;   // mask for blue bits
+        int mAlphaBitMask;   // mask for alpha channel
+        int mPVR;    // should be 'P' 'V' 'R' '!'
+        int mNumSurfs;   //number of slices for volume textures or skyboxes
+    }
+
+    protected static PVRHeader readPVRHeader(InputStream is) {
+
+        byte[] headerData = new byte[PVR_HEADER_SIZE];
+        try {
+            is.read(headerData);
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to read data");
+        }
+
+        ByteBuffer headerBuffer = ByteBuffer.allocateDirect(PVR_HEADER_SIZE)
+                .order(ByteOrder.nativeOrder());
+        headerBuffer.put(headerData, 0, PVR_HEADER_SIZE).position(0);
+
+        PVRHeader header = new PVRHeader();
+
+        header.mHeaderSize = headerBuffer.getInt();
+        header.mHeight = headerBuffer.getInt();
+        header.mWidth = headerBuffer.getInt();
+        header.mMipMapCount = headerBuffer.getInt();
+        header.mpfFlags = headerBuffer.getInt();
+        header.mDataSize = headerBuffer.getInt();
+        header.mBitCount = headerBuffer.getInt();
+        header.mRBitMask = headerBuffer.getInt();
+        header.mGBitMask = headerBuffer.getInt();
+        header.mBBitMask = headerBuffer.getInt();
+        header.mAlphaBitMask = headerBuffer.getInt();
+        header.mPVR = headerBuffer.getInt();
+        header.mNumSurfs = headerBuffer.getInt();
+
+        if (header.mHeaderSize != PVR_HEADER_SIZE ||
+            header.mPVR != PVR_MAGIC_NUMBER) {
+            throw new RuntimeException("Invalid header data");
+        }
+
+        return header;
+    }
+
+    public static Texture loadTextureATC(Resources res, int id) {
+        Texture tex = new Texture(0, 0, 0, null, "Stub!");
+        return tex;
+    }
+
+    private static ETC1Util.ETC1Texture compressTexture(Buffer input,
+                                                        int width, int height,
+                                                        int pixelSize, int stride){
+        int encodedImageSize = ETC1.getEncodedDataSize(width, height);
+        ByteBuffer compressedImage = ByteBuffer.allocateDirect(encodedImageSize).
+            order(ByteOrder.nativeOrder());
+        ETC1.encodeImage(input, width, height, pixelSize, stride, compressedImage);
+        return new ETC1Util.ETC1Texture(width, height, compressedImage);
+    }
+
+    public static Texture createFromUncompressedETC1(Bitmap bitmap) {
+        int dataSize = bitmap.getRowBytes() * bitmap.getHeight();
+
+        ByteBuffer dataBuffer;
+        dataBuffer = ByteBuffer.allocateDirect(dataSize).order(ByteOrder.nativeOrder());
+        bitmap.copyPixelsToBuffer(dataBuffer);
+        dataBuffer.position(0);
+
+        int bytesPerPixel = bitmap.getRowBytes() / bitmap.getWidth();
+        ETC1Util.ETC1Texture compressed = compressTexture(dataBuffer,
+                                                          bitmap.getWidth(),
+                                                          bitmap.getHeight(),
+                                                          bytesPerPixel,
+                                                          bitmap.getRowBytes());
+
+        Texture tex = new Texture(compressed.getWidth(), compressed.getHeight(),
+                                  ETC1.ETC1_RGB8_OES, compressed.getData(), TEXTURE_ETC1);
+
+        return tex;
+    }
+
+    private static ByteBuffer read(InputStream is, int dataSize) {
+        ByteBuffer dataBuffer;
+        dataBuffer = ByteBuffer.allocateDirect(dataSize).order(ByteOrder.nativeOrder());
+        byte[] ioBuffer = new byte[4096];
+        for (int i = 0; i < dataSize; ) {
+            int chunkSize = Math.min(ioBuffer.length, dataSize - i);
+            try {
+                is.read(ioBuffer, 0, chunkSize);
+            } catch (Exception e) {
+                throw new RuntimeException("Unable to read data");
+            }
+            dataBuffer.put(ioBuffer, 0, chunkSize);
+            i += chunkSize;
+        }
+        dataBuffer.position(0);
+        return dataBuffer;
+    }
+
+    public static Texture loadTexturePVRTC(Resources res, int id) {
+        InputStream is = null;
+        try {
+            is = res.openRawResource(id);
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to open resource " + id);
+        }
+
+        PVRHeader header = readPVRHeader(is);
+
+        int format = header.mpfFlags & 0xFF;
+        int internalFormat = 0;
+        if (format == PVR_2BPP && header.mAlphaBitMask == 1) {
+            internalFormat = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
+        } else if (format == PVR_2BPP && header.mAlphaBitMask == 0) {
+            internalFormat = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
+        } else if (format == PVR_4BPP && header.mAlphaBitMask == 1) {
+            internalFormat = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
+        } else if (format == PVR_4BPP && header.mAlphaBitMask == 0) {
+            internalFormat = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
+        }
+
+        // only load the first mip level for now
+        int dataSize = (header.mWidth * header.mHeight * header.mBitCount) >> 3;
+        ByteBuffer dataBuffer = read(is, dataSize);
+        Texture tex = new Texture(header.mWidth, header.mHeight,
+                                  internalFormat, dataBuffer,
+                                  TEXTURE_PVRTC);
+        try {
+            is.close();
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to close resource stream " + id);
+        }
+        return tex;
+    }
+
+    /* DDS Header is described by the following structs
+       typedef struct {
+          DWORD           dwSize;
+          DWORD           dwFlags;
+          DWORD           dwHeight;
+          DWORD           dwWidth;
+          DWORD           dwPitchOrLinearSize;
+          DWORD           dwDepth;
+          DWORD           dwMipMapCount;
+          DWORD           dwReserved1[11];
+          DDS_PIXELFORMAT ddspf;
+          DWORD           dwCaps;
+          DWORD           dwCaps2;
+          DWORD           dwCaps3;
+          DWORD           dwCaps4;
+          DWORD           dwReserved2;
+        } DDS_HEADER;
+
+        struct DDS_PIXELFORMAT {
+          DWORD dwSize;
+          DWORD dwFlags;
+          DWORD dwFourCC;
+          DWORD dwRGBBitCount;
+          DWORD dwRBitMask;
+          DWORD dwGBitMask;
+          DWORD dwBBitMask;
+          DWORD dwABitMask;
+        };
+
+        In the file it looks like this
+        DWORD               dwMagic;
+        DDS_HEADER          header;
+        DDS_HEADER_DXT10    header10; // If the DDS_PIXELFORMAT dwFlags is set to DDPF_FOURCC
+                                      // and dwFourCC is DX10
+
+    */
+
+    static final int DDS_HEADER_STRUCT_SIZE = 124;
+    static final int DDS_PIXELFORMAT_STRUCT_SIZE = 32;
+    static final int DDS_HEADER_SIZE = 128;
+    static final int DDS_MAGIC_NUMBER = 0x20534444;
+    static final int DDS_DDPF_FOURCC = 0x4;
+    static final int DDS_DXT1 = 0x31545844;
+    static final int DDS_DXT5 = 0x35545844;
+
+    static final int COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
+    static final int COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
+    static final int COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
+
+    static class DDSHeader {
+        int mMagic;
+        int mSize;
+        int mFlags;
+        int mHeight;
+        int mWidth;
+        int mPitchOrLinearSize;
+        int mDepth;
+        int mMipMapCount;
+        int[] mReserved1;
+        // struct DDS_PIXELFORMAT {
+            int mPixelFormatSize;
+            int mPixelFormatFlags;
+            int mPixelFormatFourCC;
+            int mPixelFormatRGBBitCount;
+            int mPixelFormatRBitMask;
+            int mPixelFormatGBitMask;
+            int mPixelFormatBBitMask;
+            int mPixelFormatABitMask;
+        // };
+        int mCaps;
+        int mCaps2;
+        int mCaps3;
+        int mCaps4;
+        int mReserved2;
+
+        DDSHeader() {
+            mReserved1 = new int[11];
+        }
+    }
+
+    protected static DDSHeader readDDSHeader(InputStream is) {
+
+        byte[] headerData = new byte[DDS_HEADER_SIZE];
+        try {
+            is.read(headerData);
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to read data");
+        }
+
+        ByteBuffer headerBuffer = ByteBuffer.allocateDirect(DDS_HEADER_SIZE)
+                .order(ByteOrder.nativeOrder());
+        headerBuffer.put(headerData, 0, DDS_HEADER_SIZE).position(0);
+
+        DDSHeader header = new DDSHeader();
+
+        header.mMagic = headerBuffer.getInt();
+        header.mSize = headerBuffer.getInt();
+        header.mFlags = headerBuffer.getInt();
+        header.mHeight = headerBuffer.getInt();
+        header.mWidth = headerBuffer.getInt();
+        header.mPitchOrLinearSize = headerBuffer.getInt();
+        header.mDepth = headerBuffer.getInt();
+        header.mMipMapCount = headerBuffer.getInt();
+        for (int i = 0; i < header.mReserved1.length; i ++) {
+            header.mReserved1[i] = headerBuffer.getInt();
+        }
+        // struct DDS_PIXELFORMAT {
+            header.mPixelFormatSize = headerBuffer.getInt();
+            header.mPixelFormatFlags = headerBuffer.getInt();
+            header.mPixelFormatFourCC = headerBuffer.getInt();
+            header.mPixelFormatRGBBitCount = headerBuffer.getInt();
+            header.mPixelFormatRBitMask = headerBuffer.getInt();
+            header.mPixelFormatGBitMask = headerBuffer.getInt();
+            header.mPixelFormatBBitMask = headerBuffer.getInt();
+            header.mPixelFormatABitMask = headerBuffer.getInt();
+        // };
+        header.mCaps = headerBuffer.getInt();
+        header.mCaps2 = headerBuffer.getInt();
+        header.mCaps3 = headerBuffer.getInt();
+        header.mCaps4 = headerBuffer.getInt();
+        header.mReserved2 = headerBuffer.getInt();
+
+        if (header.mSize != DDS_HEADER_STRUCT_SIZE ||
+            header.mPixelFormatSize != DDS_PIXELFORMAT_STRUCT_SIZE ||
+            header.mMagic != DDS_MAGIC_NUMBER) {
+            throw new RuntimeException("Invalid header data");
+        }
+
+        return header;
+    }
+
+    // Very simple loader that only reads in the header and a DXT1 mip level 0
+    public static Texture loadTextureDXT(Resources res, int id) {
+        InputStream is = null;
+        try {
+            is = res.openRawResource(id);
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to open resource " + id);
+        }
+
+        DDSHeader header = readDDSHeader(is);
+
+        if (header.mPixelFormatFlags != DDS_DDPF_FOURCC) {
+            throw new RuntimeException("Unsupported DXT data");
+        }
+
+        int internalFormat = 0;
+        int bpp = 0;
+        switch (header.mPixelFormatFourCC) {
+        case DDS_DXT1:
+            internalFormat = COMPRESSED_RGB_S3TC_DXT1_EXT;
+            bpp = 4;
+            break;
+        case DDS_DXT5:
+            internalFormat = COMPRESSED_RGBA_S3TC_DXT5_EXT;
+            bpp = 8;
+            break;
+        default:
+            throw new RuntimeException("Unsupported DXT data");
+        }
+
+        // only load the first mip level for now
+        int dataSize = (header.mWidth * header.mHeight * bpp) >> 3;
+        if (dataSize != header.mPitchOrLinearSize) {
+            throw new RuntimeException("Expected data and header mismatch");
+        }
+        ByteBuffer dataBuffer = read(is, dataSize);
+
+        Texture tex = new Texture(header.mWidth, header.mHeight, internalFormat,
+                                  dataBuffer, TEXTURE_S3TC);
+        return tex;
+    }
+
+    static HashMap<String, Boolean> sExtensionMap;
+    static HashMap<String, Boolean> sFormatMap;
+
+    private static synchronized void updateSupportedFormats() {
+        if (sExtensionMap != null) {
+            return;
+        }
+
+        sExtensionMap = new HashMap<String, Boolean>();
+        sFormatMap = new HashMap<String, Boolean>();
+        String extensionList = GLES20.glGetString(GLES20.GL_EXTENSIONS);
+
+        for (String extension : extensionList.split(" ")) {
+            sExtensionMap.put(extension, true);
+        }
+
+        // Check ETC1
+        sFormatMap.put(TEXTURE_ETC1, ETC1Util.isETC1Supported());
+        // Check ATC
+        if (sExtensionMap.get("GL_AMD_compressed_ATC_texture") != null ||
+            sExtensionMap.get("GL_ATI_compressed_texture_atitc") != null ||
+            sExtensionMap.get("GL_ATI_texture_compression_atitc") != null) {
+            sFormatMap.put(TEXTURE_ATC, true);
+        }
+        // Check DXT
+        if (sExtensionMap.get("GL_EXT_texture_compression_dxt1") != null ||
+            sExtensionMap.get("GL_EXT_texture_compression_s3tc") != null ||
+            sExtensionMap.get("OES_texture_compression_S3TC") != null) {
+            sFormatMap.put(TEXTURE_S3TC, true);
+        }
+        // Check DXT
+        if (sExtensionMap.get("GL_IMG_texture_compression_pvrtc") != null) {
+            sFormatMap.put(TEXTURE_PVRTC, true);
+        }
+
+        /*Log.i(TAG, "mIsSupportedETC1 " + sFormatMap.get(TEXTURE_ETC1));
+        Log.i(TAG, "mIsSupportedATC " + sFormatMap.get(TEXTURE_ATC));
+        Log.i(TAG, "mIsSupportedDXT " + sFormatMap.get(TEXTURE_S3TC));
+        Log.i(TAG, "mIsSupportedPVRTC " + sFormatMap.get(TEXTURE_PVRTC));*/
+    }
+
+    private static boolean isFormatSupported(String format) {
+        updateSupportedFormats();
+        Boolean supported = sFormatMap.get(format);
+        return supported != null ? supported : false;
+    }
+}
diff --git a/tests/src/android/opengl/cts/CompressedTextureStubActivity.java b/tests/src/android/opengl/cts/CompressedTextureStubActivity.java
new file mode 100644
index 0000000..bf098eb
--- /dev/null
+++ b/tests/src/android/opengl/cts/CompressedTextureStubActivity.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.opengl.cts;
+
+import com.android.cts.stub.R;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.res.AssetFileDescriptor;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.graphics.BitmapFactory;
+import android.os.Bundle;
+import android.util.Log;
+
+
+public class CompressedTextureStubActivity extends Activity {
+
+    private static final String TAG = "CompressedTextureStubActivity";
+
+    protected Resources mResources;
+
+    private CompressedTextureSurfaceView mCompressedTextureView = null;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        Bundle extras = getIntent().getExtras();
+        String formatTest = extras.getString("TextureFormat", null);
+
+        Log.i(TAG, "Testing format " + formatTest);
+
+        mResources = getResources();
+
+        CompressedTextureLoader.Texture compressed = null;
+
+        BitmapFactory.Options optionsRGB = new BitmapFactory.Options();
+        optionsRGB.inPreferredConfig = Bitmap.Config.RGB_565;
+        Bitmap bitmap = BitmapFactory.decodeResource(mResources, R.raw.basetex, optionsRGB);
+
+        if (formatTest.equals(CompressedTextureLoader.TEXTURE_ETC1)) {
+            compressed = CompressedTextureLoader.createFromUncompressedETC1(bitmap);
+        } else if (formatTest.equals(CompressedTextureLoader.TEXTURE_S3TC)) {
+            compressed = CompressedTextureLoader.loadTextureDXT(mResources, R.raw.ddstex); //stub for now
+        } else if (formatTest.equals(CompressedTextureLoader.TEXTURE_ATC)) {
+            compressed = CompressedTextureLoader.loadTextureATC(mResources, 0); //stub for now
+        } else if (formatTest.equals(CompressedTextureLoader.TEXTURE_PVRTC)) {
+            compressed = CompressedTextureLoader.loadTexturePVRTC(mResources, R.raw.pvrtex);
+        }
+
+        mCompressedTextureView = new CompressedTextureSurfaceView(this, bitmap, compressed);
+        setContentView(mCompressedTextureView);
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        mCompressedTextureView.onResume();
+    }
+}
diff --git a/tests/src/android/opengl/cts/CompressedTextureSurfaceView.java b/tests/src/android/opengl/cts/CompressedTextureSurfaceView.java
new file mode 100644
index 0000000..8d28efa0
--- /dev/null
+++ b/tests/src/android/opengl/cts/CompressedTextureSurfaceView.java
@@ -0,0 +1,402 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.opengl.cts;
+
+import java.io.IOException;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+import com.android.cts.stub.R;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.graphics.SurfaceTexture;
+import android.opengl.ETC1;
+import android.opengl.ETC1Util;
+import android.opengl.GLES20;
+import android.opengl.GLSurfaceView;
+import android.opengl.GLUtils;
+import android.opengl.Matrix;
+import android.util.Log;
+import android.view.Surface;
+
+class CompressedTextureSurfaceView extends GLSurfaceView {
+    private static final String TAG = "CompressedTextureSurfaceView";
+    private static final int SLEEP_TIME_MS = 1000;
+
+    CompressedTextureRender mRenderer;
+
+    public CompressedTextureSurfaceView(Context context,
+                                        Bitmap base,
+                                        CompressedTextureLoader.Texture compressed) {
+        super(context);
+
+        setEGLContextClientVersion(2);
+        mRenderer = new CompressedTextureRender(context, base, compressed);
+        setRenderer(mRenderer);
+        setRenderMode(RENDERMODE_WHEN_DIRTY);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+    }
+
+    private static class CompressedTextureRender implements GLSurfaceView.Renderer {
+        private static String TAG = "CompressedTextureRender";
+
+        private static final int ALLOWED_DELTA = 25;
+        private static final int FBO_PIXEL_SIZE_BYTES = 4;
+        private static final int FLOAT_SIZE_BYTES = 4;
+        private static final int TRIANGLE_VERTICES_DATA_STRIDE_BYTES = 5 * FLOAT_SIZE_BYTES;
+        private static final int TRIANGLE_VERTICES_DATA_POS_OFFSET = 0;
+        private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3;
+        private final float[] mTriangleVerticesData = {
+            // X, Y, Z, U, V
+            -1.0f, -1.0f, 0, 0.f, 0.f,
+            1.0f, -1.0f, 0, 1.f, 0.f,
+            -1.0f,  1.0f, 0, 0.f, 1.f,
+            1.0f,  1.0f, 0, 1.f, 1.f,
+        };
+
+        private FloatBuffer mTriangleVertices;
+
+        private final String mVertexShader =
+                "uniform mat4 uMVPMatrix;\n" +
+                "attribute vec4 aPosition;\n" +
+                "attribute vec4 aTextureCoord;\n" +
+                "varying vec2 vTextureCoord;\n" +
+                "void main() {\n" +
+                "  gl_Position = uMVPMatrix * aPosition;\n" +
+                "  vTextureCoord = aTextureCoord.xy;\n" +
+                "}\n";
+
+        private final String mFragmentShader =
+                "precision mediump float;\n" +
+                "varying vec2 vTextureCoord;\n" +
+                "uniform sampler2D sTexture;\n" +
+                "void main() {\n" +
+                "  gl_FragColor = texture2D(sTexture, vTextureCoord);\n" +
+                "}\n";
+
+        private float[] mMVPMatrix = new float[16];
+        private float[] mSTMatrix = new float[16];
+
+        private int mProgram;
+        private int mTextureID;
+        private int muMVPMatrixHandle;
+        private int maPositionHandle;
+        private int maTextureHandle;
+        private int msTextureHandle;
+
+        private int mColorTargetID;
+        private int mFrameBufferObjectID;
+
+        private boolean updateSurface = false;
+
+        Bitmap mBaseTexture;
+        CompressedTextureLoader.Texture mCompressedTexture;
+
+        int mWidth;
+        int mHeight;
+
+        ByteBuffer mReadBackBuffer;
+
+        public CompressedTextureRender(Context context,
+                                       Bitmap base,
+                                       CompressedTextureLoader.Texture compressed) {
+            mBaseTexture = base;
+            mCompressedTexture = compressed;
+            mTriangleVertices = ByteBuffer.allocateDirect(
+                mTriangleVerticesData.length * FLOAT_SIZE_BYTES)
+                    .order(ByteOrder.nativeOrder()).asFloatBuffer();
+            mTriangleVertices.put(mTriangleVerticesData).position(0);
+
+            Matrix.setIdentityM(mSTMatrix, 0);
+
+            int byteBufferSize = mBaseTexture.getWidth() *
+                                 mBaseTexture.getHeight() *
+                                 FBO_PIXEL_SIZE_BYTES;
+            mReadBackBuffer = ByteBuffer.allocateDirect(byteBufferSize);
+        }
+
+        private void renderQuad(int textureID) {
+            GLES20.glUseProgram(mProgram);
+            checkGlError("glUseProgram");
+
+            GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
+            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureID);
+
+            mTriangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
+            GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
+                TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
+            checkGlError("glVertexAttribPointer maPosition");
+            GLES20.glEnableVertexAttribArray(maPositionHandle);
+            checkGlError("glEnableVertexAttribArray maPositionHandle");
+
+            mTriangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
+            GLES20.glVertexAttribPointer(maTextureHandle, 3, GLES20.GL_FLOAT, false,
+                TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
+            checkGlError("glVertexAttribPointer maTextureHandle");
+            GLES20.glEnableVertexAttribArray(maTextureHandle);
+            checkGlError("glEnableVertexAttribArray maTextureHandle");
+
+            Matrix.setIdentityM(mMVPMatrix, 0);
+            GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
+
+            GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
+            checkGlError("glDrawArrays");
+        }
+
+        private int getUnsignedByte(byte val) {
+            return 0xFF & ((int)val);
+        }
+
+        private boolean comparePixel(int x, int y) {
+            int w = mBaseTexture.getWidth();
+            int sampleStart = (y * w + x) * FBO_PIXEL_SIZE_BYTES;
+
+            int R = getUnsignedByte(mReadBackBuffer.get(sampleStart));
+            int G = getUnsignedByte(mReadBackBuffer.get(sampleStart + 1));
+            int B = getUnsignedByte(mReadBackBuffer.get(sampleStart + 2));
+
+            int original = mBaseTexture.getPixel(x, y);
+
+            int deltaR = Math.abs(R - Color.red(original));
+            int deltaG = Math.abs(G - Color.green(original));
+            int deltaB = Math.abs(B - Color.blue(original));
+
+            if (deltaR <= ALLOWED_DELTA &&
+                deltaG <= ALLOWED_DELTA &&
+                deltaB <= ALLOWED_DELTA) {
+                return true;
+            }
+
+            Log.i("PIXEL DELTA", "R: " + deltaR + " G: " + deltaG + " B: " + deltaB);
+
+            return false;
+        }
+
+        private void comparePixels() {
+            int w = mBaseTexture.getWidth();
+            int h = mBaseTexture.getWidth();
+            int wOver4 = w / 4;
+            int hOver4 = h / 4;
+
+            // Sample 4 points in the image. Test is designed so that
+            // sample areas are low frequency and easy to compare
+            boolean sample1Matches = comparePixel(wOver4, hOver4);
+            boolean sample2Matches = comparePixel(wOver4 * 3, hOver4);
+            boolean sample3Matches = comparePixel(wOver4, hOver4 * 3);
+            boolean sample4Matches = comparePixel(wOver4 * 3, hOver4 * 3);
+
+            if (!sample1Matches || !sample2Matches || !sample3Matches || !sample4Matches) {
+                throw new RuntimeException("Compressed colors incorrect");
+            }
+        }
+
+        public void onDrawFrame(GL10 glUnused) {
+            if (mProgram == 0) {
+                return;
+            }
+
+            GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBufferObjectID);
+            GLES20.glViewport(0, 0, mBaseTexture.getWidth(), mBaseTexture.getHeight());
+            GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+            renderQuad(mTextureID);
+            GLES20.glReadPixels(0, 0, mBaseTexture.getWidth(), mBaseTexture.getHeight(),
+                                GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, mReadBackBuffer);
+            comparePixels();
+            GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
+
+            GLES20.glViewport(0, 0, mWidth, mHeight);
+            GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
+            GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
+
+            renderQuad(mColorTargetID);
+
+            GLES20.glFinish();
+        }
+
+        public void onSurfaceChanged(GL10 glUnused, int width, int height) {
+            mWidth = width;
+            mHeight = height;
+        }
+
+        private void setupSamplers() {
+            GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
+                    GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
+            GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
+                    GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
+            GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
+                    GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
+            GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
+                    GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
+        }
+
+        private void initFBO() {
+            int[] textures = new int[1];
+            GLES20.glGenTextures(1, textures, 0);
+
+            mColorTargetID = textures[0];
+            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mColorTargetID);
+            checkGlError("glBindTexture mColorTargetID");
+            setupSamplers();
+            GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA,
+                                mBaseTexture.getWidth(), mBaseTexture.getHeight(), 0,
+                                GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
+            checkGlError("glTexImage2D mColorTargetID");
+
+            GLES20.glGenFramebuffers(1, textures, 0);
+            mFrameBufferObjectID = textures[0];
+            GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBufferObjectID);
+
+            GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
+                                          GLES20.GL_TEXTURE_2D, mColorTargetID, 0);
+
+            int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
+            if(status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
+                throw new RuntimeException("Failed to initialize framebuffer object");
+            }
+
+            GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
+        }
+
+        public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
+            if (mCompressedTexture != null && !mCompressedTexture.isSupported()) {
+                return;
+            }
+
+            initFBO();
+
+            mProgram = createProgram(mVertexShader, mFragmentShader);
+            if (mProgram == 0) {
+                return;
+            }
+            maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
+            checkGlError("glGetAttribLocation aPosition");
+            if (maPositionHandle == -1) {
+                throw new RuntimeException("Could not get attrib location for aPosition");
+            }
+            maTextureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord");
+            checkGlError("glGetAttribLocation aTextureCoord");
+            if (maTextureHandle == -1) {
+                throw new RuntimeException("Could not get attrib location for aTextureCoord");
+            }
+
+            muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
+            checkGlError("glGetUniformLocation uMVPMatrix");
+            if (muMVPMatrixHandle == -1) {
+                throw new RuntimeException("Could not get attrib location for uMVPMatrix");
+            }
+
+            int[] textures = new int[1];
+            GLES20.glGenTextures(1, textures, 0);
+
+            mTextureID = textures[0];
+            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureID);
+            checkGlError("glBindTexture mTextureID");
+            setupSamplers();
+
+            if (mCompressedTexture == null) {
+                GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, mBaseTexture, 0);
+                checkGlError("texImage2D mBaseTexture");
+            } else {
+                GLES20.glCompressedTexImage2D(GLES20.GL_TEXTURE_2D,
+                                              0,
+                                              mCompressedTexture.getFormat(),
+                                              mCompressedTexture.getWidth(),
+                                              mCompressedTexture.getHeight(),
+                                              0,
+                                              mCompressedTexture.getData().remaining(),
+                                              mCompressedTexture.getData());
+                checkGlError("glCompressedTexImage2D mTextureID");
+            }
+        }
+
+        synchronized public void onFrameAvailable(SurfaceTexture surface) {
+            updateSurface = true;
+        }
+
+        private int loadShader(int shaderType, String source) {
+            int shader = GLES20.glCreateShader(shaderType);
+            if (shader != 0) {
+                GLES20.glShaderSource(shader, source);
+                GLES20.glCompileShader(shader);
+                int[] compiled = new int[1];
+                GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
+                if (compiled[0] == 0) {
+                    Log.e(TAG, "Could not compile shader " + shaderType + ":");
+                    Log.e(TAG, GLES20.glGetShaderInfoLog(shader));
+                    GLES20.glDeleteShader(shader);
+                    shader = 0;
+                }
+            }
+            return shader;
+        }
+
+        private int createProgram(String vertexSource, String fragmentSource) {
+            int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource);
+            if (vertexShader == 0) {
+                return 0;
+            }
+            int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
+            if (pixelShader == 0) {
+                return 0;
+            }
+
+            int program = GLES20.glCreateProgram();
+            if (program != 0) {
+                GLES20.glAttachShader(program, vertexShader);
+                checkGlError("glAttachShader");
+                GLES20.glAttachShader(program, pixelShader);
+                checkGlError("glAttachShader");
+                GLES20.glLinkProgram(program);
+                int[] linkStatus = new int[1];
+                GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
+                if (linkStatus[0] != GLES20.GL_TRUE) {
+                    Log.e(TAG, "Could not link program: ");
+                    Log.e(TAG, GLES20.glGetProgramInfoLog(program));
+                    GLES20.glDeleteProgram(program);
+                    program = 0;
+                }
+            }
+            return program;
+        }
+
+        private void checkGlError(String op) {
+            int error;
+            while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
+                Log.e(TAG, op + ": glError " + error);
+                throw new RuntimeException(op + ": glError " + error);
+            }
+        }
+
+    }  // End of class CompressedTextureRender.
+
+}  // End of class CompressedTextureSurfaceView.
diff --git a/tests/src/android/view/animation/cts/AnimationTestUtils.java b/tests/src/android/view/animation/cts/AnimationTestUtils.java
index 3ee22c7..a2b786d 100644
--- a/tests/src/android/view/animation/cts/AnimationTestUtils.java
+++ b/tests/src/android/view/animation/cts/AnimationTestUtils.java
@@ -17,6 +17,7 @@
 package android.view.animation.cts;
 
 import android.app.Instrumentation;
+import android.cts.util.PollingCheck;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.Animation;
@@ -66,7 +67,7 @@
         });
 
         // check whether it has started
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return animation.hasStarted();
@@ -74,7 +75,7 @@
         }.run();
 
         // check whether it has ended after duration
-        new DelayedCheck(duration + TIMEOUT_DELTA) {
+        new PollingCheck(duration + TIMEOUT_DELTA) {
             @Override
             protected boolean check() {
                 return animation.hasEnded();
diff --git a/tests/tests/app/src/android/app/cts/DialogTest.java b/tests/tests/app/src/android/app/cts/DialogTest.java
index 37ded56..67470a0 100644
--- a/tests/tests/app/src/android/app/cts/DialogTest.java
+++ b/tests/tests/app/src/android/app/cts/DialogTest.java
@@ -32,6 +32,7 @@
 import android.content.DialogInterface.OnKeyListener;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
+import android.cts.util.PollingCheck;
 import android.graphics.Canvas;
 import android.graphics.ColorFilter;
 import android.graphics.drawable.Drawable;
@@ -42,7 +43,6 @@
 import android.os.Message;
 import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -684,7 +684,7 @@
         mInstrumentation.waitForIdleSync();
 
         // Wait until TestDialog#OnWindowFocusChanged() is called
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return d.isOnWindowFocusChangedCalled;
             }
diff --git a/tests/tests/app/src/android/app/cts/DownloadManagerTest.java b/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
index a225749..1da6af9 100644
--- a/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/DownloadManagerTest.java
@@ -22,12 +22,12 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.cts.util.PollingCheck;
 import android.database.Cursor;
 import android.net.Uri;
 import android.os.Environment;
 import android.os.ParcelFileDescriptor;
 import android.test.AndroidTestCase;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.cts.CtsTestServer;
 
 import java.io.File;
@@ -314,7 +314,7 @@
     }
 
     private void assertDownloadQueryableByStatus(final int status) {
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 Cursor cursor= null;
diff --git a/tests/tests/app/src/android/app/cts/IntentServiceTest.java b/tests/tests/app/src/android/app/cts/IntentServiceTest.java
index d844aa9..0d2f11b 100644
--- a/tests/tests/app/src/android/app/cts/IntentServiceTest.java
+++ b/tests/tests/app/src/android/app/cts/IntentServiceTest.java
@@ -21,8 +21,8 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
+import android.cts.util.PollingCheck;
 import android.os.IBinder;
-import android.view.animation.cts.DelayedCheck;
 
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
@@ -106,7 +106,7 @@
     public void testIntentServiceLifeCycle() throws Throwable {
         // start service
         mContext.startService(mIntent);
-        new DelayedCheck(TIMEOUT_MSEC) {
+        new PollingCheck(TIMEOUT_MSEC) {
             protected boolean check() {
                 return IntentServiceStub.onHandleIntentCalled > 0;
             }
@@ -117,7 +117,7 @@
         // bind service
         ServiceConnection conn = new TestConnection();
         mContext.bindService(mIntent, conn, Context.BIND_AUTO_CREATE);
-        new DelayedCheck(TIMEOUT_MSEC) {
+        new PollingCheck(TIMEOUT_MSEC) {
             protected boolean check() {
                 return mConnected;
             }
diff --git a/tests/tests/content/src/android/content/cts/ClipboardManagerListenerTest.java b/tests/tests/content/src/android/content/cts/ClipboardManagerListenerTest.java
index ae02e0a..ca6bba7 100644
--- a/tests/tests/content/src/android/content/cts/ClipboardManagerListenerTest.java
+++ b/tests/tests/content/src/android/content/cts/ClipboardManagerListenerTest.java
@@ -18,9 +18,9 @@
 
 import android.content.ClipData;
 import android.content.ClipboardManager.OnPrimaryClipChangedListener;
+import android.cts.util.PollingCheck;
 import android.net.Uri;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 
 
 public class ClipboardManagerListenerTest
@@ -57,7 +57,7 @@
     }
 
     private void assertClipChangedCount(final int expectedCount) {
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return expectedCount == mListener.getCount();
diff --git a/tests/tests/content/src/android/content/cts/ContentResolverTest.java b/tests/tests/content/src/android/content/cts/ContentResolverTest.java
index b866375..9378e63 100644
--- a/tests/tests/content/src/android/content/cts/ContentResolverTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentResolverTest.java
@@ -29,13 +29,13 @@
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.res.AssetFileDescriptor;
+import android.cts.util.PollingCheck;
 import android.database.ContentObserver;
 import android.database.Cursor;
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.ParcelFileDescriptor;
 import android.test.AndroidTestCase;
-import android.view.animation.cts.DelayedCheck;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -637,7 +637,7 @@
         values.put(COLUMN_KEY_NAME, "key10");
         values.put(COLUMN_VALUE_NAME, 10);
         mContentResolver.update(TABLE1_URI, values, null, null);
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return mco.hadOnChanged();
@@ -689,7 +689,7 @@
         assertFalse(mco.hadOnChanged());
 
         mContentResolver.notifyChange(TABLE1_URI, mco);
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return mco.hadOnChanged();
@@ -713,7 +713,7 @@
         assertFalse(mco.hadOnChanged());
 
         mContentResolver.notifyChange(TABLE1_URI, mco, false);
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return mco.hadOnChanged();
diff --git a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
index 6ad14e0..3e1e3e4 100644
--- a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
@@ -35,6 +35,7 @@
 import android.content.SharedPreferences;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
+import android.cts.util.PollingCheck;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteCursorDriver;
 import android.database.sqlite.SQLiteDatabase;
@@ -48,7 +49,6 @@
 import android.os.IBinder;
 import android.preference.PreferenceManager;
 import android.test.AndroidTestCase;
-import android.view.animation.cts.DelayedCheck;
 
 import java.io.File;
 import java.io.IOException;
@@ -176,7 +176,7 @@
 
         final Intent broadcastIntent = new Intent(ResultReceiver.MOCK_ACTION);
         mContextWrapper.sendOrderedBroadcast(broadcastIntent, null);
-        new DelayedCheck(BROADCAST_TIMEOUT) {
+        new PollingCheck(BROADCAST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return highPriorityReceiver.hasReceivedBroadCast()
@@ -188,7 +188,7 @@
             highPriorityReceiver.notify();
         }
 
-        new DelayedCheck(BROADCAST_TIMEOUT) {
+        new PollingCheck(BROADCAST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return highPriorityReceiver.hasReceivedBroadCast()
@@ -957,7 +957,7 @@
 
         mContextWrapper.sendBroadcast(new Intent(ResultReceiver.MOCK_ACTION));
 
-        new DelayedCheck(BROADCAST_TIMEOUT){
+        new PollingCheck(BROADCAST_TIMEOUT){
             @Override
             protected boolean check() {
                 return receiver.hasReceivedBroadCast();
@@ -977,7 +977,7 @@
 
         mContextWrapper.sendBroadcast(new Intent(ResultReceiver.MOCK_ACTION), null);
 
-        new DelayedCheck(BROADCAST_TIMEOUT){
+        new PollingCheck(BROADCAST_TIMEOUT){
             @Override
             protected boolean check() {
                 return receiver.hasReceivedBroadCast();
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimationDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimationDrawableTest.java
index 3edaad8..17ab976 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/AnimationDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/AnimationDrawableTest.java
@@ -30,12 +30,12 @@
 import android.app.Activity;
 import android.content.res.Resources;
 import android.content.res.XmlResourceParser;
+import android.cts.util.PollingCheck;
 import android.graphics.drawable.AnimationDrawable;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.DrawableContainer.DrawableContainerState;
 import android.test.ActivityInstrumentationTestCase2;
 import android.util.Xml;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.ImageView;
 import android.widget.cts.ImageViewStubActivity;
 
@@ -107,7 +107,7 @@
         assertSame(mAnimationDrawable.getFrame(FIRST_FRAME_INDEX),
                 mAnimationDrawable.getCurrent());
 
-        delayedCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
+        pollingCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -159,7 +159,7 @@
         assertTrue(mAnimationDrawable.isRunning());
         assertSame(mAnimationDrawable.getFrame(FIRST_FRAME_INDEX),
                 mAnimationDrawable.getCurrent());
-        delayedCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
+        pollingCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -167,7 +167,7 @@
                 mAnimationDrawable.start();
             }
         });
-        delayedCheckDrawable(THIRD_FRAME_INDEX, SECOND_FRAME_DURATION);
+        pollingCheckDrawable(THIRD_FRAME_INDEX, SECOND_FRAME_DURATION);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -210,7 +210,7 @@
         });
 
         assertTrue(mAnimationDrawable.isRunning());
-        delayedCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
+        pollingCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -342,10 +342,10 @@
                 mAnimationDrawable.start();
             }
         });
-        delayedCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
-        delayedCheckDrawable(THIRD_FRAME_INDEX, SECOND_FRAME_DURATION);
+        pollingCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
+        pollingCheckDrawable(THIRD_FRAME_INDEX, SECOND_FRAME_DURATION);
         // begin to repeat
-        delayedCheckDrawable(FIRST_FRAME_INDEX, THIRD_FRAME_DURATION);
+        pollingCheckDrawable(FIRST_FRAME_INDEX, THIRD_FRAME_DURATION);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -355,8 +355,8 @@
                 mAnimationDrawable.start();
             }
         });
-        delayedCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
-        delayedCheckDrawable(THIRD_FRAME_INDEX, SECOND_FRAME_DURATION);
+        pollingCheckDrawable(SECOND_FRAME_INDEX, FIRST_FRAME_DURATION);
+        pollingCheckDrawable(THIRD_FRAME_INDEX, SECOND_FRAME_DURATION);
         // do not repeat
         assertStoppedAnimation(THIRD_FRAME_INDEX, THIRD_FRAME_DURATION);
     }
@@ -471,12 +471,12 @@
     }
 
     /**
-     * Delayed check specific frame should be current one in timeout.
+     * Polling check specific frame should be current one in timeout.
      * @param index - expected index of frame.
      * @param timeout - timeout.
      */
-    private void delayedCheckDrawable(final int index, long timeout) {
-        new DelayedCheck(timeout + TOLERANCE) {
+    private void pollingCheckDrawable(final int index, long timeout) {
+        new PollingCheck(timeout + TOLERANCE) {
             Drawable expected = mAnimationDrawable.getFrame(index);
             @Override
             protected boolean check() {
diff --git a/tests/tests/graphics/src/android/opengl/cts/CompressedTextureTest.java b/tests/tests/graphics/src/android/opengl/cts/CompressedTextureTest.java
new file mode 100644
index 0000000..3676d66
--- /dev/null
+++ b/tests/tests/graphics/src/android/opengl/cts/CompressedTextureTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.opengl.cts;
+
+import android.os.Bundle;
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ */
+public class CompressedTextureTest extends ActivityInstrumentationTestCase2<CompressedTextureStubActivity> {
+
+    public CompressedTextureTest() {
+        super("com.android.cts.stub", CompressedTextureStubActivity.class);
+    }
+
+    private void launchTest(String format) throws Exception {
+        Bundle extras = new Bundle();
+        extras.putString("TextureFormat", format);
+        CompressedTextureStubActivity activity = launchActivity("com.android.cts.stub",
+                CompressedTextureStubActivity.class, extras);
+        activity.finish();
+    }
+
+    public void testTextureUncompressed() throws Exception {
+        launchTest(CompressedTextureLoader.TEXTURE_UNCOMPRESSED);
+    }
+
+    public void testTextureETC1() throws Exception {
+        launchTest(CompressedTextureLoader.TEXTURE_ETC1);
+    }
+
+    public void testTexturePVRTC() throws Exception {
+        launchTest(CompressedTextureLoader.TEXTURE_PVRTC);
+    }
+
+    public void testTextureS3TC() throws Exception {
+        launchTest(CompressedTextureLoader.TEXTURE_S3TC);
+    }
+
+    /*public void testTextureATC() throws Exception {
+        launchTest(CompressedTextureLoader.TEXTURE_ATC);
+    }*/
+}
diff --git a/tests/tests/media/src/android/media/cts/AudioRecordTest.java b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
index a07c704..1ddcdd5 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecordTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
@@ -47,9 +47,6 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        if (!hasMicrophone()) {
-            return;
-        }
         /*
          * InstrumentationTestRunner.onStart() calls Looper.prepare(), which creates a looper
          * for the current thread. However, since we don't actually call loop() in the test,
@@ -83,10 +80,8 @@
 
     @Override
     protected void tearDown() throws Exception {
-        if (hasMicrophone()) {
-            mAudioRecord.release();
-            mLooper.quit();
-        }
+        mAudioRecord.release();
+        mLooper.quit();
         super.tearDown();
     }
 
diff --git a/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java b/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
index 504a304..e597827 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
@@ -17,12 +17,12 @@
 package android.media.cts;
 
 import android.content.pm.PackageManager;
+import android.cts.util.PollingCheck;
 import android.media.AudioFormat;
 import android.media.AudioRecord;
 import android.media.MediaRecorder.AudioSource;
 import android.test.AndroidTestCase;
 import android.util.Log;
-import android.view.animation.cts.DelayedCheck;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -85,7 +85,7 @@
     }
 
     private void checkRecordingState(final int state) {
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return mAudioRecord.getRecordingState() == state;
diff --git a/tests/tests/media/src/android/media/cts/MediaScannerConnectionTest.java b/tests/tests/media/src/android/media/cts/MediaScannerConnectionTest.java
index cc25d07..2c9fe1a 100644
--- a/tests/tests/media/src/android/media/cts/MediaScannerConnectionTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaScannerConnectionTest.java
@@ -26,12 +26,12 @@
 
 import android.content.ComponentName;
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.media.MediaScannerConnection;
 import android.media.MediaScannerConnection.MediaScannerConnectionClient;
 import android.net.Uri;
 import android.os.IBinder;
 import android.test.AndroidTestCase;
-import android.view.animation.cts.DelayedCheck;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -157,12 +157,12 @@
     }
 
     private void checkMediaScannerConnection() {
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             protected boolean check() {
                 return mMediaScannerConnectionClient.isOnMediaScannerConnectedCalled;
             }
         }.run();
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             protected boolean check() {
                 return mMediaScannerConnectionClient.mediaPath != null;
             }
@@ -170,7 +170,7 @@
     }
 
     private void checkConnectionState(final boolean expected) {
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             protected boolean check() {
                 return mMediaScannerConnection.isConnected() == expected;
             }
diff --git a/tests/tests/nativemedia/Android.mk b/tests/tests/nativemedia/Android.mk
index 928ebcd..1d4ec7f 100644
--- a/tests/tests/nativemedia/Android.mk
+++ b/tests/tests/nativemedia/Android.mk
@@ -1,34 +1 @@
-# Build the unit tests.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_C_INCLUDES:= \
-    bionic \
-    bionic/libstdc++/include \
-    external/gtest/include \
-    system/media/wilhelm/include \
-    external/stlport/stlport \
-    system/media/wilhelm/src/ut
-
-LOCAL_SRC_FILES:= \
-    src/SLObjectCreationTest.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-  libutils \
-  libOpenSLES \
-  libstlport
-
-LOCAL_STATIC_LIBRARIES := \
-    libOpenSLESUT \
-    libgtest
-
-LOCAL_CFLAGS += -DXP_UNIX
-
-LOCAL_MODULE:= NativeMediaTest
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
-
-include $(BUILD_EXECUTABLE)
\ No newline at end of file
+include $(call all-subdir-makefiles)
\ No newline at end of file
diff --git a/tests/tests/nativemedia/sl/Android.mk b/tests/tests/nativemedia/sl/Android.mk
new file mode 100644
index 0000000..b68976e
--- /dev/null
+++ b/tests/tests/nativemedia/sl/Android.mk
@@ -0,0 +1,32 @@
+# Build the unit tests.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_C_INCLUDES:= \
+    bionic \
+    bionic/libstdc++/include \
+    external/gtest/include \
+    system/media/wilhelm/include \
+    external/stlport/stlport \
+    system/media/wilhelm/src/ut
+
+LOCAL_SRC_FILES:= \
+    src/SLObjectCreationTest.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+  libutils \
+  libOpenSLES \
+  libstlport
+
+LOCAL_STATIC_LIBRARIES := \
+    libOpenSLESUT \
+    libgtest
+
+LOCAL_MODULE:= NativeMediaTest_SL
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
+
+include $(BUILD_EXECUTABLE)
\ No newline at end of file
diff --git a/tests/tests/nativemedia/src/SLObjectCreationTest.cpp b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
similarity index 95%
rename from tests/tests/nativemedia/src/SLObjectCreationTest.cpp
rename to tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
index e63e42fa3..450b32e 100644
--- a/tests/tests/nativemedia/src/SLObjectCreationTest.cpp
+++ b/tests/tests/nativemedia/sl/src/SLObjectCreationTest.cpp
@@ -79,7 +79,7 @@
 
     /* Test setup*/
     virtual void SetUp() {
-        LOGV("Test Setup()");
+        ALOGV("Test Setup()");
         res = SL_RESULT_UNKNOWN_ERROR;
         engineItf = NULL;
         engineObj = NULL;
@@ -96,7 +96,7 @@
     }
 
     virtual void TearDown() {
-        LOGV("Test TearDown()");
+        ALOGV("Test TearDown()");
         if (audioPlayerObj) {
             (*audioPlayerObj)->Destroy(audioPlayerObj);
             audioPlayerObj = NULL;
@@ -306,60 +306,60 @@
 
 //-------------------------------------------------------------------------------------------------
 TEST_F(SLObjectCreationTest, testEngineCreation) {
-    LOGV("Test Fixture: EngineCreation");
+    ALOGV("Test Fixture: EngineCreation");
     // nothing to do here that isn't done in SetUp()
 }
 
 TEST_F(SLObjectCreationTest, testOutputMixCreation) {
-    LOGV("Test Fixture: OutputMixCreation");
+    ALOGV("Test Fixture: OutputMixCreation");
     OutputMixCreation();
 }
 
 TEST_F(SLObjectCreationTest, testAudioPlayerFromUriCreation) {
-    LOGV("Test Fixture: AudioPlayerFromUriCreation");
+    ALOGV("Test Fixture: AudioPlayerFromUriCreation");
     // required for AudioPlayer creation
     OutputMixCreation();
     AudioPlayerFromUriCreation();
 }
 
 TEST_F(SLObjectCreationTest, testAudioPlayerFromFdCreation) {
-    LOGV("Test Fixture: AudioPlayerFromFdCreation");
+    ALOGV("Test Fixture: AudioPlayerFromFdCreation");
     // required for AudioPlayer creation
     OutputMixCreation();
     AudioPlayerFromFdCreation();
 }
 
 TEST_F(SLObjectCreationTest, testAudioPlayerFromPcmBqCreation) {
-    LOGV("Test Fixture: AudioPlayerFromPcmBqCreation");
+    ALOGV("Test Fixture: AudioPlayerFromPcmBqCreation");
     // required for AudioPlayer creation
     OutputMixCreation();
     AudioPlayerFromPcmBqCreation();
 }
 
 TEST_F(SLObjectCreationTest, testAudioPlayerFromTsAbqCreation) {
-    LOGV("Test Fixture: AudioPlayerFromTsAbqCreation");
+    ALOGV("Test Fixture: AudioPlayerFromTsAbqCreation");
     // required for AudioPlayer creation
     OutputMixCreation();
     AudioPlayerFromTsAbqCreation();
 }
 
 TEST_F(SLObjectCreationTest, testAudioPlayerFromUriToPcmBqCreation) {
-    LOGV("Test Fixture: AudioPlayerFromUriToPcmBqCreation");
+    ALOGV("Test Fixture: AudioPlayerFromUriToPcmBqCreation");
     AudioPlayerFromUriToPcmBqCreation();
 }
 
 TEST_F(SLObjectCreationTest, testAudioPlayerFromFdToPcmBqCreation) {
-    LOGV("Test Fixture: AudioPlayerFromFdToPcmBqCreation");
+    ALOGV("Test Fixture: AudioPlayerFromFdToPcmBqCreation");
     AudioPlayerFromFdToPcmBqCreation();
 }
 
 TEST_F(SLObjectCreationTest, testAudioPlayerFromAdtsAbqToPcmBqCreation) {
-    LOGV("Test Fixture: AudioPlayerFromAdtsAbqToPcmBqCreation");
+    ALOGV("Test Fixture: AudioPlayerFromAdtsAbqToPcmBqCreation");
     AudioPlayerFromAdtsAbqToPcmBqCreation();
 }
 
 TEST_F(SLObjectCreationTest, testAudioRecorderCreation) {
-    LOGV("Test Fixture: AudioRecorderCreation");
+    ALOGV("Test Fixture: AudioRecorderCreation");
     AudioRecorderCreation();
 }
 
diff --git a/tests/tests/nativemedia/xa/Android.mk b/tests/tests/nativemedia/xa/Android.mk
new file mode 100644
index 0000000..36c7f6c
--- /dev/null
+++ b/tests/tests/nativemedia/xa/Android.mk
@@ -0,0 +1,31 @@
+# Build the unit tests.
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_C_INCLUDES:= \
+    bionic \
+    bionic/libstdc++/include \
+    external/gtest/include \
+    system/media/wilhelm/include \
+    external/stlport/stlport \
+    system/media/wilhelm/src/ut
+
+LOCAL_SRC_FILES:= \
+    src/XAObjectCreationTest.cpp
+
+LOCAL_SHARED_LIBRARIES := \
+  libutils \
+  libOpenMAXAL \
+  libstlport
+
+LOCAL_STATIC_LIBRARIES := \
+    libgtest
+
+LOCAL_MODULE:= NativeMediaTest_XA
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
+
+include $(BUILD_EXECUTABLE)
\ No newline at end of file
diff --git a/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
new file mode 100644
index 0000000..3ff84c2
--- /dev/null
+++ b/tests/tests/nativemedia/xa/src/XAObjectCreationTest.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Test for testing the creation of OpenMAX AL objects.
+ * The tests verify the creation and completion of the call to Realize() for the following objects:
+ *   - Engine
+ *   - OutputMix
+ */
+
+#define LOG_NDEBUG 0
+#define LOG_TAG "XAObjectCreationTest"
+
+#include <utils/Log.h>
+#include "OMXAL/OpenMAXAL.h"
+#include "OMXAL/OpenMAXAL_Android.h"
+//#include <android/native_window_jni.h>
+#include <gtest/gtest.h>
+
+//-----------------------------------------------------------------
+/* Checks for error and displays the error code if any */
+bool IsOk(XAresult res) {
+    if (XA_RESULT_SUCCESS != res) {
+        fprintf(stderr, "IsOk failure: 0x%x, exiting\n", res);
+        return false;
+    }
+    return true;
+}
+
+//-----------------------------------------------------------------
+class XAObjectCreationTest : public ::testing::Test {
+
+protected:
+    XAresult res;
+    XAObjectItf engineObj, outputMixObj, mediaPlayerObj;
+    XAEngineItf engineItf;
+
+    XADataSource mediaSource;
+    XADataSink   audioSink;
+    XADataLocator_URI locatorUriSrc;
+    XADataLocator_AndroidBufferQueue locatorAbqSrc;
+    XADataLocator_AndroidFD locatorFdSrc;
+    XADataFormat_MIME formatMimeSrc;
+
+    XADataLocator_OutputMix locatorOutputmixSink;
+    XADataFormat_PCM formatPcmSink;
+
+    XADataLocator_NativeDisplay locatorVideoSink;
+    XADataSink imageSink;
+
+    //ANativeWindow* pNativeWindow;
+
+    XAObjectCreationTest() { }
+
+    virtual ~XAObjectCreationTest() { }
+
+    /* Test setup*/
+    virtual void SetUp() {
+        ALOGV("Test Setup()");
+        res = XA_RESULT_UNKNOWN_ERROR;
+        engineItf = NULL;
+        engineObj = NULL;
+        outputMixObj = NULL;
+        mediaPlayerObj = NULL;
+        // Engine creation
+        res = xaCreateEngine(&engineObj, 0, NULL, 0, NULL, NULL);
+        ASSERT_TRUE(IsOk(res));
+        res = (*engineObj)->Realize(engineObj, XA_BOOLEAN_FALSE);
+        ASSERT_TRUE(IsOk(res));
+        res = (*engineObj)->GetInterface(engineObj, XA_IID_ENGINE, &engineItf);
+        ASSERT_TRUE(IsOk(res));
+        ASSERT_TRUE(NULL != engineItf);
+    }
+
+    virtual void TearDown() {
+        ALOGV("Test TearDown()");
+        if (mediaPlayerObj) {
+            (*mediaPlayerObj)->Destroy(mediaPlayerObj);
+            mediaPlayerObj = NULL;
+        }
+        if (outputMixObj) {
+            (*outputMixObj)->Destroy(outputMixObj);
+            outputMixObj = NULL;
+        }
+        if (engineObj){
+            (*engineObj)->Destroy(engineObj);
+            engineObj = NULL;
+        }
+    }
+
+    //---------------------------------------------------------------------------------------------
+    // Tests
+
+    /* Test case for creating an MediaPlayer object */
+    void OutputMixCreation() {
+        res = (*engineItf)->CreateOutputMix(engineItf, &outputMixObj,
+                0, NULL/*iidArray*/, NULL/*required*/);
+        ASSERT_TRUE(IsOk(res));
+        ASSERT_TRUE(NULL != outputMixObj);
+        res = (*outputMixObj)->Realize(outputMixObj, XA_BOOLEAN_FALSE);
+        ASSERT_TRUE(IsOk(res));
+    }
+
+};
+
+//-------------------------------------------------------------------------------------------------
+TEST_F(XAObjectCreationTest, testEngineCreation) {
+    ALOGV("Test Fixture: EngineCreation");
+    // nothing to do here that isn't done in SetUp()
+}
+
+TEST_F(XAObjectCreationTest, testOutputMixCreation) {
+    ALOGV("Test Fixture: OutputMixCreation");
+    OutputMixCreation();
+}
+
+int main(int argc, char **argv) {
+    testing::InitGoogleTest(&argc, argv);
+
+    return RUN_ALL_TESTS();
+}
+
diff --git a/tests/tests/ndef/src/android/ndef/cts/BasicNdefTest.java b/tests/tests/ndef/src/android/ndef/cts/BasicNdefTest.java
index 6e2ac3c..8e10575 100644
--- a/tests/tests/ndef/src/android/ndef/cts/BasicNdefTest.java
+++ b/tests/tests/ndef/src/android/ndef/cts/BasicNdefTest.java
@@ -16,6 +16,7 @@
 
 package android.ndef.cts;
 
+import android.net.Uri;
 import android.nfc.NdefMessage;
 import android.nfc.NdefRecord;
 import android.nfc.FormatException;
@@ -33,6 +34,29 @@
             (byte) 0x6f, (byte) 0x6d
     };
 
+    public static final String URI_WWW_STRING = "http://www.nfc.com";
+    public static final byte[] URI_WWW_BYTES = new byte[] {
+            (byte) 0xd1, (byte) 0x01, (byte) 0x08, (byte) 0x55, (byte) 0x01, (byte) 0x6e,
+            (byte) 0x66, (byte) 0x63, (byte) 0x2e, (byte) 0x63, (byte) 0x6f, (byte) 0x6d
+    };
+
+    public static final String URI_TELEPHONE_NUMBER_STRING = "tel:+35891234567";
+    public static final byte[] URI_TELEPHONE_NUMBER_BYTES = new byte[] {
+            (byte) 0xd1, (byte) 0x01, (byte) 0x0d, (byte) 0x55, (byte) 0x05, (byte) 0x2b,
+            (byte) 0x33, (byte) 0x35, (byte) 0x38, (byte) 0x39, (byte) 0x31, (byte) 0x32,
+            (byte) 0x33, (byte) 0x34, (byte) 0x35, (byte) 0x36, (byte) 0x37
+    };
+
+    public void test_uriParser() {
+        NdefRecord wwwRecord = NdefRecord.createUri(Uri.parse(URI_WWW_STRING));
+        System.out.println(new String(wwwRecord.getPayload()));
+        assertByteArrayEquals(URI_WWW_BYTES, wwwRecord.toByteArray());
+
+        NdefRecord telRecord = NdefRecord.createUri(Uri.parse(URI_TELEPHONE_NUMBER_STRING));
+        System.out.println(new String(telRecord.getPayload()));
+        assertByteArrayEquals(URI_TELEPHONE_NUMBER_BYTES, telRecord.toByteArray());
+    }
+
     public void test_parseSmartPoster() throws FormatException {
         NdefMessage msg = new NdefMessage(SMART_POSTER_URL_NO_TEXT);
         NdefRecord[] records = msg.getRecords();
diff --git a/tests/tests/net/src/android/net/cts/ListeningPortsTest.java b/tests/tests/net/src/android/net/cts/ListeningPortsTest.java
deleted file mode 100644
index bcec0fe..0000000
--- a/tests/tests/net/src/android/net/cts/ListeningPortsTest.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * 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.net.cts;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Scanner;
-import java.util.regex.Pattern;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
-public class ListeningPortsTest extends TestCase {
-
-    /** Address patterns used to check whether we're checking the right column in /proc/net. */
-    private static final List<String> ADDRESS_PATTERNS = new ArrayList<String>(2);
-
-    static {
-        ADDRESS_PATTERNS.add("[0-9A-F]{8}:[0-9A-F]{4}");
-        ADDRESS_PATTERNS.add("[0-9A-F]{32}:[0-9A-F]{4}");
-    }
-
-    /** Ports that are allowed to be listening on the emulator. */
-    private static final List<String> EXCEPTION_PATTERNS = new ArrayList<String>(6);
-
-    static {
-        // IPv4 exceptions
-        EXCEPTION_PATTERNS.add("00000000:15B3"); // 0.0.0.0:5555   - emulator port
-        EXCEPTION_PATTERNS.add("0F02000A:15B3"); // 10.0.2.15:5555 - net forwarding for emulator
-        EXCEPTION_PATTERNS.add("[0-9A-F]{6}7F:[0-9A-F]{4}"); // IPv4 Loopback
-
-        // IPv6 exceptions
-        EXCEPTION_PATTERNS.add("[0]{25}1[0]{6}:[0-9A-F]{4}"); // IPv6 Loopback
-        EXCEPTION_PATTERNS.add("[0]{16}[0]{4}[0]{4}[0-9A-F]{6}7F:[0-9A-F]{4}"); // IPv4-6 Conversion
-        EXCEPTION_PATTERNS.add("[0]{16}[F]{4}[0]{4}[0-9A-F]{6}7F:[0-9A-F]{4}"); // IPv4-6 Conversion
-    }
-
-    public void testNoListeningTcpPorts() {
-        assertNoListeningPorts("/proc/net/tcp", true);
-    }
-
-    public void testNoListeningTcp6Ports() {
-        assertNoListeningPorts("/proc/net/tcp6", true);
-    }
-
-    public void testNoListeningUdpPorts() throws Exception {
-        assertNoListeningUdpPorts("/proc/net/udp");
-    }
-
-    public void testNoListeningUdp6Ports() throws Exception {
-        assertNoListeningUdpPorts("/proc/net/udp6");
-    }
-
-    private static final int RETRIES_MAX = 6;
-
-    /**
-     * UDP tests can be flaky due to DNS lookups.  Compensate.
-     */
-    private static void assertNoListeningUdpPorts(String procFilePath) throws Exception {
-        for (int i = 0; i < RETRIES_MAX; i++) {
-            try {
-                assertNoListeningPorts(procFilePath, false);
-                return;
-            } catch (ListeningPortsAssertionError e) {
-                if (i == RETRIES_MAX - 1) {
-                    throw e;
-                }
-                Thread.sleep(2 * 1000 * i);
-            }
-        }
-        throw new IllegalStateException("unreachable");
-    }
-
-    private static void assertNoListeningPorts(String procFilePath, boolean isTcp) {
-
-        /*
-         * Sample output of "cat /proc/net/tcp" on emulator:
-         *
-         * sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  ...
-         * 0: 0100007F:13AD 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0   ...
-         * 1: 00000000:15B3 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0   ...
-         * 2: 0F02000A:15B3 0202000A:CE8A 01 00000000:00000000 00:00000000 00000000     0   ...
-         *
-         */
-
-        File procFile = new File(procFilePath);
-        Scanner scanner = null;
-        try {
-            scanner = new Scanner(procFile);
-            while (scanner.hasNextLine()) {
-                String line = scanner.nextLine().trim();
-
-                // Skip column headers
-                if (line.startsWith("sl")) {
-                    continue;
-                }
-
-                String[] fields = line.split("\\s+");
-                final int expectedNumColumns = 12;
-                assertTrue(procFilePath + " should have at least " + expectedNumColumns
-                        + " columns of output " + fields, fields.length >= expectedNumColumns);
-
-                String localAddress = fields[1];
-                String state = fields[3];
-                String uid = fields[7];
-
-                assertTrue(procFilePath + " should have an IP address in the second column",
-                        isAddress(localAddress));
-
-                String localIp = localAddress.split(":")[0];
-                int localPort = Integer.parseInt(localAddress.split(":")[1], 16);
-
-                if (!isException(localAddress) && isPortListening(state, isTcp)) {
-                    throw new ListeningPortsAssertionError(
-                            "Found port listening on addr=" + localIp + ", port="
-                                + localPort + ", UID=" + uid + " in " + procFilePath);
-                }
-            }
-        } catch (FileNotFoundException notFound) {
-            fail("Could not open file " + procFilePath + " to check for listening ports.");
-        } finally {
-            if (scanner != null) {
-                scanner.close();
-            }
-        }
-    }
-
-    private static boolean isAddress(String localAddress) {
-        return isPatternMatch(ADDRESS_PATTERNS, localAddress);
-    }
-
-    private static boolean isException(String localAddress) {
-        return isPatternMatch(EXCEPTION_PATTERNS, localAddress);
-    }
-
-    private static boolean isPatternMatch(List<String> patterns, String input) {
-        for (String pattern : patterns) {
-            if (Pattern.matches(pattern, input)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    private static boolean isPortListening(String state, boolean isTcp) {
-        // 0A = TCP_LISTEN from include/net/tcp_states.h
-        String listeningState = isTcp ? "0A" : "07";
-        return listeningState.equals(state);
-    }
-
-    private static class ListeningPortsAssertionError extends AssertionFailedError {
-        private ListeningPortsAssertionError(String msg) {
-            super(msg);
-        }
-    }
-}
diff --git a/tests/tests/os/src/android/os/cts/AsyncTaskTest.java b/tests/tests/os/src/android/os/cts/AsyncTaskTest.java
index 94300b6..f5eca5e 100644
--- a/tests/tests/os/src/android/os/cts/AsyncTaskTest.java
+++ b/tests/tests/os/src/android/os/cts/AsyncTaskTest.java
@@ -21,9 +21,9 @@
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
 
+import android.cts.util.PollingCheck;
 import android.os.AsyncTask;
 import android.test.InstrumentationTestCase;
-import android.view.animation.cts.DelayedCheck;
 
 import java.util.concurrent.TimeUnit;
 
@@ -108,7 +108,7 @@
         }
 
         // wait for the task to finish completely (including onPostResult()).
-        new DelayedCheck(DURATION) {
+        new PollingCheck(DURATION) {
             protected boolean check() {
                 return mAsyncTask.getStatus() == AsyncTask.Status.FINISHED;
             }
@@ -132,7 +132,7 @@
         }
 
         // wait for progress update to be processed (happens asynchronously)
-        new DelayedCheck(DURATION) {
+        new PollingCheck(DURATION) {
             protected boolean check() {
                 return mAsyncTask.updateValue != null;
             }
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index c222e7b..317ed83 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -170,9 +170,14 @@
 
     /**
      * Verify that any publicly readable directories reachable from
-     * the root directory are not writable.  World writable directories
-     * are a security hole and an application should only be able to
-     * write to it's own home directory.
+     * the root directory are not writable.  An application should only be
+     * able to write to it's own home directory. World writable directories
+     * are a security hole because they enable a number of different attacks.
+     * <ul>
+     *   <li><a href="http://en.wikipedia.org/wiki/Symlink_race">Symlink Races</a></li>
+     *   <li>Data destruction by deleting or renaming files you don't own</li>
+     *   <li>Data substitution by replacing trusted files with untrusted files</li>
+     * </ul>
      *
      * Note: Because not all directories are readable, this is a best-effort
      * test only.  Writable directories within unreadable subdirectories
@@ -195,6 +200,7 @@
                     "/data/btips/TI",
                     "/data/btips/TI/opp",
                     "/data/dalvik-cache",
+                    "/data/data",
                     "/data/data/.drm",
                     "/data/data/.drm/.wmdrm",
                     "/data/dontpanic",
@@ -228,9 +234,15 @@
 
     /**
      * Verify that directories not discoverable by
-     * testAllOtherDirectoriesNotWritable are not writable.  World
-     * writable directories are a security hole and an application
-     * should only be able to write to it's own home directory.
+     * testAllOtherDirectoriesNotWritable are not writable.  An application
+     * should only be able to write to it's own home directory. World
+     * writable directories are a security hole because they enable a
+     * number of different attacks.
+     * <ul>
+     *   <li><a href="http://en.wikipedia.org/wiki/Symlink_race">Symlink Races</a></li>
+     *   <li>Data destruction by deleting or renaming files you don't own</li>
+     *   <li>Data substitution by replacing trusted files with untrusted files</li>
+     * </ul>
      *
      * Because /data and /data/data are not readable, we blindly try to
      * poke around in there looking for bad directories.  There has to be
diff --git a/tests/tests/provider/src/android/provider/cts/SearchRecentSuggestionsTest.java b/tests/tests/provider/src/android/provider/cts/SearchRecentSuggestionsTest.java
index 1395de1..13ef4c8 100644
--- a/tests/tests/provider/src/android/provider/cts/SearchRecentSuggestionsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/SearchRecentSuggestionsTest.java
@@ -24,11 +24,11 @@
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.database.Cursor;
 import android.net.Uri;
 import android.provider.SearchRecentSuggestions;
 import android.test.ProviderTestCase2;
-import android.view.animation.cts.DelayedCheck;
 
 @TestTargetClass(android.provider.SearchRecentSuggestions.class)
 public class SearchRecentSuggestionsTest extends
@@ -227,7 +227,7 @@
 
     private void waitForCursorCount(final Uri uri, final String[] projection,
             final int expectedCount) {
-        new DelayedCheck() {
+        new PollingCheck() {
             protected boolean check() {
                 Cursor cursor = null;
                 try {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
index 12c8fb0..a64d1d9 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
@@ -67,8 +67,10 @@
         t = new Type.Builder(mRS, Element.U8(mRS)).setX(x).create();
         Allocation out = Allocation.createTyped(mRS, t);
         fe_i8.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i8.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -82,8 +84,10 @@
         t = new Type.Builder(mRS, Element.U8_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i8_2.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i8_2.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -97,8 +101,10 @@
         t = new Type.Builder(mRS, Element.U8_3(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i8_3.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i8_3.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -112,8 +118,10 @@
         t = new Type.Builder(mRS, Element.U8_4(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i8_4.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i8_4.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -125,8 +133,10 @@
         t = new Type.Builder(mRS, Element.U16(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i16.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i16.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -140,8 +150,10 @@
         t = new Type.Builder(mRS, Element.U16_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i16_2.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i16_2.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -155,8 +167,10 @@
         t = new Type.Builder(mRS, Element.U16_3(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i16_3.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i16_3.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -170,8 +184,10 @@
         t = new Type.Builder(mRS, Element.U16_4(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i16_4.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i16_4.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -183,8 +199,10 @@
         t = new Type.Builder(mRS, Element.U32(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i32.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i32.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -198,8 +216,10 @@
         t = new Type.Builder(mRS, Element.U32_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i32_2.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i32_2.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -213,8 +233,10 @@
         t = new Type.Builder(mRS, Element.U32_3(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i32_3.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i32_3.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -228,8 +250,10 @@
         t = new Type.Builder(mRS, Element.U32_4(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i32_4.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i32_4.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -241,8 +265,10 @@
         t = new Type.Builder(mRS, Element.U64(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i64.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i64.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -256,8 +282,10 @@
         t = new Type.Builder(mRS, Element.U64_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i64_2.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i64_2.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -271,8 +299,10 @@
         t = new Type.Builder(mRS, Element.U64_3(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i64_3.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i64_3.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -286,8 +316,10 @@
         t = new Type.Builder(mRS, Element.U64_4(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i64_4.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i64_4.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -298,8 +330,10 @@
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
         fe_f32.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_f32.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -313,8 +347,10 @@
         t = new Type.Builder(mRS, Element.F32_2(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_f32_2.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_f32_2.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -327,8 +363,10 @@
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
         fe_f32_3.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_f32_3.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -341,8 +379,10 @@
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
         fe_f32_4.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_f32_4.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -353,8 +393,10 @@
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
         fe_f64.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_f64.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -367,8 +409,10 @@
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
         fe_f64_2.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_f64_2.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -381,8 +425,10 @@
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
         fe_f64_3.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_f64_3.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -395,8 +441,10 @@
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
         fe_f64_4.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_f64_4.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -408,8 +456,10 @@
         in = new ScriptField_fe_test(mRS, x).getAllocation();
         out = new ScriptField_fe_test(mRS, x).getAllocation();
         fe_struct.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_struct.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -420,8 +470,10 @@
         in = Allocation.createTyped(mRS, t);
         out = Allocation.createTyped(mRS, t);
         fe_bool.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_bool.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -432,8 +484,10 @@
         t = new Type.Builder(mRS, Element.A_8(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i8.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i8.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -444,8 +498,10 @@
         t = new Type.Builder(mRS, Element.RGBA_8888(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i8_4.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i8_4.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
@@ -456,8 +512,10 @@
         t = new Type.Builder(mRS, Element.RGB_888(mRS)).setX(x).create();
         out = Allocation.createTyped(mRS, t);
         fe_i8_3.forEach_root(in, out);
+        mRS.finish();
         try {
             fe_i8_3.forEach_root(in, badOut);
+            mRS.finish();
             fail("should throw RSRuntimeException");
         } catch (RSRuntimeException e) {
         }
diff --git a/tests/tests/security/src/android/security/cts/AslrTest.java b/tests/tests/security/src/android/security/cts/AslrTest.java
new file mode 100644
index 0000000..a4c4f80
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/AslrTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import junit.framework.TestCase;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * Verify that ASLR is properly enabled on Android Compatible devices.
+ */
+public class AslrTest extends TestCase {
+
+    public void testOneExecutableIsPie() throws IOException {
+        assertTrue(ReadElf.read(new File("/system/bin/cat")).isPIE());
+    }
+
+    public void testVaRandomize() throws IOException {
+        BufferedReader in = null;
+        try {
+            in = new BufferedReader(new FileReader("/proc/sys/kernel/randomize_va_space"));
+            int level = Integer.parseInt(in.readLine().trim());
+            assertTrue("Expected /proc/sys/kernel/randomize_va_space to be "
+                    + "greater than or equal to 2, got " + level,
+                    level >= 2);
+        } catch (FileNotFoundException e) {
+            // Odd. The file doesn't exist... Assume ASLR is enabled.
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+    }
+
+}
diff --git a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
new file mode 100644
index 0000000..17ec7b5
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import junit.framework.TestCase;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * Verify that the kernel is configured how we expect it to be
+ * configured.
+ */
+public class KernelSettingsTest extends TestCase {
+
+    /**
+     * /proc/kallsyms will show the address of exported kernel symbols. This
+     * information can be used to write a reliable kernel exploit that can run
+     * on many platforms without using hardcoded pointers. To make this more
+     * difficult for attackers, don't export kernel symbols.
+     */
+    public void testKptrRestrict() throws IOException {
+        BufferedReader in = null;
+        try {
+            in = new BufferedReader(new FileReader("/proc/sys/kernel/kptr_restrict"));
+            assertEquals("2", in.readLine().trim());
+        } catch (FileNotFoundException e) {
+            // Odd. The file doesn't exist... Assume we're ok.
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/ListeningPortsTest.java b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
new file mode 100644
index 0000000..f3112a3
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/ListeningPortsTest.java
@@ -0,0 +1,309 @@
+/*
+ * 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.security.cts;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+import java.util.regex.Pattern;
+
+/**
+ * Verifies that Android devices are not listening on accessible
+ * open ports. Open ports are often targeted by attackers looking to break
+ * into computer systems remotely, and minimizing the number of open ports
+ * is considered a security best practice.
+ */
+public class ListeningPortsTest extends TestCase {
+
+    /** Ports that are allowed to be listening. */
+    private static final List<String> EXCEPTION_PATTERNS = new ArrayList<String>(6);
+
+    static {
+        // IPv4 exceptions
+        EXCEPTION_PATTERNS.add("0.0.0.0:5555");   // emulator port
+        EXCEPTION_PATTERNS.add("10.0.2.15:5555"); // net forwarding for emulator
+        EXCEPTION_PATTERNS.add("127.0.0.1:5037"); // adb daemon "smart sockets"
+    }
+
+    /**
+     * Remotely accessible ports are often used by attackers to gain
+     * unauthorized access to computers systems without user knowledge or
+     * awareness.
+     */
+    public void testNoRemotelyAccessibleListeningTcpPorts() throws Exception {
+        assertNoAccessibleListeningPorts("/proc/net/tcp", true, false);
+    }
+
+    /**
+     * Remotely accessible ports are often used by attackers to gain
+     * unauthorized access to computers systems without user knowledge or
+     * awareness.
+     */
+    public void testNoRemotelyAccessibleListeningTcp6Ports() throws Exception {
+        assertNoAccessibleListeningPorts("/proc/net/tcp6", true, false);
+    }
+
+    /**
+     * Remotely accessible ports are often used by attackers to gain
+     * unauthorized access to computers systems without user knowledge or
+     * awareness.
+     */
+    public void testNoRemotelyAccessibleListeningUdpPorts() throws Exception {
+        assertNoRemotelyAccessibleListeningUdpPorts("/proc/net/udp", false);
+    }
+
+    /**
+     * Remotely accessible ports are often used by attackers to gain
+     * unauthorized access to computers systems without user knowledge or
+     * awareness.
+     */
+    public void testNoRemotelyAccessibleListeningUdp6Ports() throws Exception {
+        assertNoRemotelyAccessibleListeningUdpPorts("/proc/net/udp6", false);
+    }
+
+    /**
+     * Locally accessible ports are often targeted by malicious locally
+     * installed programs to gain unauthorized access to program data or
+     * cause system corruption.
+     *
+     * In all cases, a local listening IP port can be replaced by a UNIX domain
+     * socket. Unix domain sockets can be protected with unix filesystem
+     * permission. Alternatively, you can use getsockopt(SO_PEERCRED) to
+     * determine if a program is authorized to connect to your socket.
+     *
+     * Please convert loopback IP connections to unix domain sockets.
+     */
+    public void testNoListeningLoopbackTcpPorts() throws Exception {
+        assertNoAccessibleListeningPorts("/proc/net/tcp", true, true);
+    }
+
+    /**
+     * Locally accessible ports are often targeted by malicious locally
+     * installed programs to gain unauthorized access to program data or
+     * cause system corruption.
+     *
+     * In all cases, a local listening IP port can be replaced by a UNIX domain
+     * socket. Unix domain sockets can be protected with unix filesystem
+     * permission. Alternatively, you can use getsockopt(SO_PEERCRED) to
+     * determine if a program is authorized to connect to your socket.
+     *
+     * Please convert loopback IP connections to unix domain sockets.
+     */
+    public void testNoListeningLoopbackTcp6Ports() throws Exception {
+        assertNoAccessibleListeningPorts("/proc/net/tcp6", true, true);
+    }
+
+    /**
+     * Locally accessible ports are often targeted by malicious locally
+     * installed programs to gain unauthorized access to program data or
+     * cause system corruption.
+     *
+     * In all cases, a local listening IP port can be replaced by a UNIX domain
+     * socket. Unix domain sockets can be protected with unix filesystem
+     * permission.  Alternately, or you can use setsockopt(SO_PASSCRED) to
+     * send credentials, and recvmsg to retrieve the passed credentials.
+     *
+     * Please convert loopback IP connections to unix domain sockets.
+     */
+    public void testNoListeningLoopbackUdpPorts() throws Exception {
+        assertNoAccessibleListeningPorts("/proc/net/udp", false, true);
+    }
+
+    /**
+     * Locally accessible ports are often targeted by malicious locally
+     * installed programs to gain unauthorized access to program data or
+     * cause system corruption.
+     *
+     * In all cases, a local listening IP port can be replaced by a UNIX domain
+     * socket. Unix domain sockets can be protected with unix filesystem
+     * permission.  Alternately, or you can use setsockopt(SO_PASSCRED) to
+     * send credentials, and recvmsg to retrieve the passed credentials.
+     *
+     * Please convert loopback IP connections to unix domain sockets.
+     */
+    public void testNoListeningLoopbackUdp6Ports() throws Exception {
+        assertNoAccessibleListeningPorts("/proc/net/udp6", false, true);
+    }
+
+    private static final int RETRIES_MAX = 6;
+
+    /**
+     * UDP tests can be flaky due to DNS lookups.  Compensate.
+     */
+    private static void assertNoRemotelyAccessibleListeningUdpPorts(
+            String procFilePath, boolean loopback)
+            throws Exception {
+        for (int i = 0; i < RETRIES_MAX; i++) {
+            try {
+                assertNoAccessibleListeningPorts(procFilePath, false, loopback);
+                return;
+            } catch (ListeningPortsAssertionError e) {
+                if (i == RETRIES_MAX - 1) {
+                    throw e;
+                }
+                Thread.sleep(2 * 1000 * i);
+            }
+        }
+        throw new IllegalStateException("unreachable");
+    }
+
+    /**
+     * Remotely accessible ports (loopback==false) are often used by
+     * attackers to gain unauthorized access to computers systems without
+     * user knowledge or awareness.
+     *
+     * Locally accessible ports (loopback==true) are often targeted by
+     * malicious locally installed programs to gain unauthorized access to
+     * program data or cause system corruption.
+     */
+    private static void assertNoAccessibleListeningPorts(
+            String procFilePath, boolean isTcp, boolean loopback) throws IOException {
+        String errors = "";
+        List<ParsedProcEntry> entries = ParsedProcEntry.parse(procFilePath);
+        for (ParsedProcEntry entry : entries) {
+            String addrPort = entry.localAddress.getHostAddress() + ':' + entry.port;
+
+            if (isPortListening(entry.state, isTcp)
+                && !isException(addrPort)
+                && (!entry.localAddress.isLoopbackAddress() ^ loopback)) {
+                errors += "\nFound port listening on addr="
+                        + entry.localAddress.getHostAddress() + ", port="
+                        + entry.port + ", UID=" + entry.uid + " in "
+                        + procFilePath;
+            }
+        }
+        if (!errors.equals("")) {
+            fail(errors);
+        }
+    }
+
+    private static boolean isException(String localAddress) {
+        return isPatternMatch(EXCEPTION_PATTERNS, localAddress);
+    }
+
+    private static boolean isPatternMatch(List<String> patterns, String input) {
+        for (String pattern : patterns) {
+            pattern = Pattern.quote(pattern);
+            if (Pattern.matches(pattern, input)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static boolean isPortListening(String state, boolean isTcp) {
+        // 0A = TCP_LISTEN from include/net/tcp_states.h
+        String listeningState = isTcp ? "0A" : "07";
+        return listeningState.equals(state);
+    }
+
+    private static class ListeningPortsAssertionError extends AssertionFailedError {
+        private ListeningPortsAssertionError(String msg) {
+            super(msg);
+        }
+    }
+
+    private static class ParsedProcEntry {
+        private final InetAddress localAddress;
+        private final int port;
+        private final String state;
+        private final int uid;
+
+        private ParsedProcEntry(InetAddress addr, int port, String state, int uid) {
+            this.localAddress = addr;
+            this.port = port;
+            this.state = state;
+            this.uid = uid;
+        }
+
+
+        private static List<ParsedProcEntry> parse(String procFilePath) throws IOException {
+
+            List<ParsedProcEntry> retval = new ArrayList<ParsedProcEntry>();
+            /*
+            * Sample output of "cat /proc/net/tcp" on emulator:
+            *
+            * sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  ...
+            * 0: 0100007F:13AD 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0   ...
+            * 1: 00000000:15B3 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0   ...
+            * 2: 0F02000A:15B3 0202000A:CE8A 01 00000000:00000000 00:00000000 00000000     0   ...
+            *
+            */
+
+            File procFile = new File(procFilePath);
+            Scanner scanner = null;
+            try {
+                scanner = new Scanner(procFile);
+                while (scanner.hasNextLine()) {
+                    String line = scanner.nextLine().trim();
+
+                    // Skip column headers
+                    if (line.startsWith("sl")) {
+                        continue;
+                    }
+
+                    String[] fields = line.split("\\s+");
+                    final int expectedNumColumns = 12;
+                    assertTrue(procFilePath + " should have at least " + expectedNumColumns
+                            + " columns of output " + fields, fields.length >= expectedNumColumns);
+
+                    String state = fields[3];
+                    int uid = Integer.parseInt(fields[7]);
+                    InetAddress localIp = addrToInet(fields[1].split(":")[0]);
+                    int localPort = Integer.parseInt(fields[1].split(":")[1], 16);
+
+                    retval.add(new ParsedProcEntry(localIp, localPort, state, uid));
+                }
+            } finally {
+                if (scanner != null) {
+                    scanner.close();
+                }
+            }
+            return retval;
+        }
+
+        /**
+         * Convert a string stored in little endian format to an IP address.
+         */
+        private static InetAddress addrToInet(String s) throws UnknownHostException {
+            int len = s.length();
+            if (len != 8 && len != 32) {
+                throw new IllegalArgumentException(len + "");
+            }
+            byte[] retval = new byte[len / 2];
+
+            for (int i = 0; i < len / 2; i += 4) {
+                retval[i] = (byte) ((Character.digit(s.charAt(2*i + 6), 16) << 4)
+                        + Character.digit(s.charAt(2*i + 7), 16));
+                retval[i + 1] = (byte) ((Character.digit(s.charAt(2*i + 4), 16) << 4)
+                        + Character.digit(s.charAt(2*i + 5), 16));
+                retval[i + 2] = (byte) ((Character.digit(s.charAt(2*i + 2), 16) << 4)
+                        + Character.digit(s.charAt(2*i + 3), 16));
+                retval[i + 3] = (byte) ((Character.digit(s.charAt(2*i), 16) << 4)
+                        + Character.digit(s.charAt(2*i + 1), 16));
+            }
+            return InetAddress.getByAddress(retval);
+        }
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/ReadElf.java b/tests/tests/security/src/android/security/cts/ReadElf.java
new file mode 100644
index 0000000..e311c9b
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/ReadElf.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * A poor man's implementation of the readelf command. This program is
+ * designed to parse ELF (Executable and Linkable Format) files.
+ */
+class ReadElf {
+    /** The magic values for the ELF identification. */
+    private static final byte[] ELF_IDENT = {
+            (byte) 0x7F, (byte) 'E', (byte) 'L', (byte) 'F',
+    };
+
+    /** Size of the e_ident[] structure in the ELF header. */
+    private static final int EI_NIDENT = 16;
+
+    /** Offset from end of ident structure in half-word sizes. */
+    private static final int OFFSET_TYPE = 0;
+
+    /** Machine type. */
+    private static final int OFFSET_MACHINE = 1;
+
+    /** ELF version. */
+    private static final int OFFSET_VERSION = 2;
+
+    /**
+     * The offset to which the system transfers control. e.g., the first thing
+     * executed.
+     */
+    private static final int OFFSET_ENTRY = 4;
+
+    /** Program header offset in bytes. */
+    private static final int OFFSET_PHOFF = 6;
+
+    /** Segment header offset in bytes. */
+    private static final int OFFSET_SHOFF = 8;
+
+    /** Processor-specific flags for binary. */
+    private static final int OFFSET_FLAGS = 10;
+
+    /** ELF header size in bytes. */
+    private static final int OFFSET_EHSIZE = 12;
+
+    /** All program headers entry size in bytes. */
+    private static final int OFFSET_PHENTSIZE = 13;
+
+    /** Number of program headers in ELF. */
+    private static final int OFFSET_PHNUM = 14;
+
+    /** All segment headers entry size in bytes. */
+    private static final int OFFSET_SHENTSIZE = 15;
+
+    /** Number of segment headers in ELF. */
+    private static final int OFFSET_SHNUM = 16;
+
+    /** The section header index that refers to string table. */
+    private static final int OFFSET_SHTRNDX = 17;
+
+    /** Program header offset for type of this program header. */
+    private static final int PHOFF_TYPE = 0;
+
+    /** Program header offset for absolute offset in file. */
+    private static final int PHOFF_OFFSET = 2;
+
+    /** Program header offset for virtual address. */
+    private static final int PHOFF_VADDR = 4;
+
+    /** Program header offset for physical address. */
+    private static final int PHOFF_PADDR = 6;
+
+    /** Program header offset for file size in bytes. */
+    private static final int PHOFF_FILESZ = 8;
+
+    /** Program header offset for memory size in bytes. */
+    private static final int PHOFF_MEMSZ = 10;
+
+    /** Program header offset for flags. */
+    private static final int PHOFF_FLAGS = 12;
+
+    /**
+     * Program header offset for required alignment. 0 or 1 means no alignment
+     * necessary.
+     */
+    private static final int PHOFF_ALIGN = 14;
+
+    /** Index into string pool for segment name. */
+    private static final int SHOFF_NAME = 0;
+
+    /** Segment header type. */
+    private static final int SHOFF_TYPE = 2;
+
+    /** Data is presented in LSB format. */
+    private static final int ELFDATA2LSB = 1;
+
+    /** Date is presented in MSB format. */
+    private static final int ELFDATA2MSB = 2;
+
+    private static final int ELFCLASS32 = 1;
+
+    private static final int ELFCLASS64 = 2;
+
+    private static final long PT_LOAD = 1;
+
+    private RandomAccessFile mFile = null;
+    private final byte[] mBuffer = new byte[512];
+    private int mClass;
+    private int mEndian;
+    private boolean mIsDynamic;
+    private boolean mIsPIE;
+    private int mType;
+    private int mWordSize;
+    private int mHalfWordSize;
+
+    static ReadElf read(File file) throws IOException {
+        return new ReadElf(file);
+    }
+
+    boolean isDynamic() {
+        return mIsDynamic;
+    }
+
+    int getType() {
+        return mType;
+    }
+
+    boolean isPIE() {
+        return mIsPIE;
+    }
+
+    private ReadElf(File file) throws IOException {
+        try {
+            mFile = new RandomAccessFile(file, "r");
+
+            readIdent();
+
+            readHeader();
+        } finally {
+            if (mFile != null) {
+                mFile.close();
+            }
+        }
+    }
+
+    private void readHeader() throws IOException {
+        mType = readHalf(getHeaderOffset(OFFSET_TYPE));
+
+        final long shOffset = readWord(getHeaderOffset(OFFSET_SHOFF));
+        final int shNumber = readHalf(getHeaderOffset(OFFSET_SHNUM));
+        final int shSize = readHalf(getHeaderOffset(OFFSET_SHENTSIZE));
+
+        readSectionHeaders(shOffset, shNumber, shSize);
+
+        final long phOffset = readWord(getHeaderOffset(OFFSET_PHOFF));
+        final int phNumber = readHalf(getHeaderOffset(OFFSET_PHNUM));
+        final int phSize = readHalf(getHeaderOffset(OFFSET_PHENTSIZE));
+
+        readProgramHeaders(phOffset, phNumber, phSize);
+    }
+
+    private void readSectionHeaders(long shOffset, int shNumber, int shSize) throws IOException {
+        for (int i = 0; i < shNumber; i++) {
+            final long type = readWord(shOffset + i * shSize + mHalfWordSize * SHOFF_TYPE);
+            if (type == 6) {
+                mIsDynamic = true;
+            }
+        }
+    }
+
+    private void readProgramHeaders(long phOffset, int phNumber, int phSize) throws IOException {
+        for (int i = 0; i < phNumber; i++) {
+            final long baseOffset = phOffset + i * phSize;
+            final long type = readWord(baseOffset);
+            if (type == PT_LOAD) {
+                final long virtAddress = readWord(baseOffset + mHalfWordSize * PHOFF_VADDR);
+                if (virtAddress == 0) {
+                    mIsPIE = true;
+                }
+            }
+        }
+    }
+
+    private int getHeaderOffset(int halfWorldOffset) {
+        return EI_NIDENT + halfWorldOffset * mHalfWordSize;
+    }
+
+    private int readHalf(long offset) throws IOException {
+        mFile.seek(offset);
+        mFile.readFully(mBuffer, 0, mWordSize);
+
+        final int answer;
+        if (mEndian == ELFDATA2LSB) {
+            answer = mBuffer[1] << 8 | mBuffer[0];
+        } else {
+            answer = mBuffer[0] << 8 | mBuffer[1];
+        }
+
+        return answer;
+    }
+
+    private long readWord(long offset) throws IOException {
+        mFile.seek(offset);
+        mFile.readFully(mBuffer, 0, mWordSize);
+
+        int answer = 0;
+        if (mEndian == ELFDATA2LSB) {
+            for (int i = mWordSize - 1; i >= 0; i--) {
+                answer = (answer << 8) | (mBuffer[i] & 0xFF);
+            }
+        } else {
+            final int N = mWordSize - 1;
+            for (int i = 0; i <= N; i++) {
+                answer = (answer << 8) | mBuffer[i];
+            }
+        }
+
+        return answer;
+    }
+
+    private void readIdent() throws IOException {
+        mFile.seek(0);
+        mFile.readFully(mBuffer, 0, EI_NIDENT);
+
+        if (mBuffer[0] != ELF_IDENT[0] || mBuffer[1] != ELF_IDENT[1] || mBuffer[2] != ELF_IDENT[2]
+                || mBuffer[3] != ELF_IDENT[3]) {
+            throw new IllegalArgumentException("Invalid ELF file");
+        }
+
+        mClass = mBuffer[4];
+        if (mClass == ELFCLASS32) {
+            mWordSize = 4;
+            mHalfWordSize = 2;
+        } else {
+            throw new IOException("Invalid executable type " + mClass + ": not ELFCLASS32!");
+        }
+
+        mEndian = mBuffer[5];
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
index 1c45735..23891e0 100644
--- a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
@@ -455,11 +455,6 @@
 
         // Test isWellFormedSmsAddress
         assertTrue(PhoneNumberUtils.isWellFormedSmsAddress("+17005554141"));
-        // KT allow a to be a dialable character, the network portion of 'android' is 'a'
-        if (TelephonyUtils.isKt(tm)) {
-            assertTrue(PhoneNumberUtils.isWellFormedSmsAddress("android"));
-        } else {
-            assertFalse(PhoneNumberUtils.isWellFormedSmsAddress("android"));
-        }
+        assertFalse(PhoneNumberUtils.isWellFormedSmsAddress("android"));
     }
 }
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index c0c26ef..ddce3cd 100755
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -27,12 +27,12 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.PackageManager;
-import android.os.Bundle;
 import android.os.SystemClock;
 import android.telephony.SmsManager;
-import android.telephony.SmsMessage;
 import android.telephony.TelephonyManager;
 import android.test.AndroidTestCase;
+import android.telephony.SmsMessage;
+import android.os.Bundle;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -46,6 +46,7 @@
 @TestTargetClass(SmsManager.class)
 public class SmsManagerTest extends AndroidTestCase {
 
+    private static final int NUM_TEXT_PARTS = 3;
     private static final String LONG_TEXT =
         "This is a very long text. This text should be broken into three " +
         "separate messages.This is a very long text. This text should be broken into " +
@@ -156,21 +157,9 @@
     public void testDivideMessage() {
         ArrayList<String> dividedMessages = divideMessage(LONG_TEXT);
         assertNotNull(dividedMessages);
-        int numParts;
-        if (TelephonyUtils.isSkt(mTelephonyManager)) {
-            numParts = 5;
-        } else if (TelephonyUtils.isKt(mTelephonyManager)) {
-            numParts = 4;
-        } else {
-            numParts = 3;
-        }
-        assertEquals(numParts, dividedMessages.size());
-
-        String actualMessage = "";
-        for (int i = 0; i < numParts; i++) {
-            actualMessage += dividedMessages.get(i);
-        }
-        assertEquals(LONG_TEXT, actualMessage);
+        assertEquals(NUM_TEXT_PARTS, dividedMessages.size());
+        assertEquals(LONG_TEXT,
+                dividedMessages.get(0) + dividedMessages.get(1) + dividedMessages.get(2));
     }
 
     @TestTargets({
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
index 27f290b..8c6ad01 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
@@ -188,7 +188,7 @@
         int[] result = SmsMessage.calculateLength(sms.getMessageBody(), true);
         assertEquals(SMS_NUMBER1, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
+        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
         assertEquals(pdu, toHexString(sms.getPdu()));
 
@@ -220,7 +220,7 @@
         result = SmsMessage.calculateLength(msgBody, false);
         assertEquals(SMS_NUMBER2, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
+        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
 
         // Test createFromPdu Ucs to Sms
@@ -231,20 +231,10 @@
         result = SmsMessage.calculateLength(sms.getMessageBody(), true);
         assertEquals(SMS_NUMBER3, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
+        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
     }
 
-    private int getNumSeptets() {
-        if (TelephonyUtils.isSkt(mTelephonyManager)) {
-            return 80;
-        } else if (TelephonyUtils.isKt(mTelephonyManager)) {
-            return 90;
-        } else {
-            return SmsMessage.MAX_USER_DATA_SEPTETS;
-        }
-    }
-
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
diff --git a/tests/tests/telephony/src/android/telephony/cts/TelephonyUtils.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyUtils.java
deleted file mode 100644
index c2ca833..0000000
--- a/tests/tests/telephony/src/android/telephony/cts/TelephonyUtils.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.telephony.cts;
-
-import android.telephony.TelephonyManager;
-
-class TelephonyUtils {
-
-    public static boolean isSkt(TelephonyManager telephonyManager) {
-        return isOperator(telephonyManager, "45005");
-    }
-
-    public static boolean isKt(TelephonyManager telephonyManager) {
-        return isOperator(telephonyManager, "45002")
-                || isOperator(telephonyManager, "45004")
-                || isOperator(telephonyManager, "45008");
-    }
-
-    private static boolean isOperator(TelephonyManager telephonyManager, String operator) {
-        String simOperator = telephonyManager.getSimOperator();
-        return simOperator != null && simOperator.equals(operator);
-    }
-
-    private TelephonyUtils() {
-    }
-}
diff --git a/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java b/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java
index 6dde08d..087b930 100755
--- a/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java
@@ -22,6 +22,7 @@
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.ToBeFixed;
 
+import android.cts.util.PollingCheck;
 import android.graphics.Rect;
 import android.provider.Settings.SettingNotFoundException;
 import android.provider.Settings.System;
@@ -30,7 +31,6 @@
 import android.text.method.PasswordTransformationMethod;
 import android.view.KeyCharacterMap;
 import android.view.View;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.LinearLayout;
@@ -175,7 +175,7 @@
         assertTrue(mMethod.hasCalledAfterTextChanged());
 
         // it will get transformed after a while
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 // "******"
diff --git a/tests/tests/view/src/android/view/animation/cts/AnimationTest.java b/tests/tests/view/src/android/view/animation/cts/AnimationTest.java
index 6343da6..447ec84 100644
--- a/tests/tests/view/src/android/view/animation/cts/AnimationTest.java
+++ b/tests/tests/view/src/android/view/animation/cts/AnimationTest.java
@@ -26,6 +26,7 @@
 
 import android.app.Activity;
 import android.content.res.XmlResourceParser;
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
 import android.util.AttributeSet;
 import android.util.Xml;
@@ -355,7 +356,7 @@
         // test repeat mode REVERSE
         anim.setRepeatCount(1);
         anim.setRepeatMode(Animation.REVERSE);
-        // we have to DelayedCheck the animation status on test thread,
+        // we have to PollingCheck the animation status on test thread,
         // it cannot be done on UI thread, so we invoke runOnMainSync method here.
         getInstrumentation().runOnMainSync(new Runnable() {
             public void run() {
@@ -364,7 +365,7 @@
         });
 
         // check whether animation has started
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return anim.hasStarted();
@@ -386,7 +387,7 @@
 
         // wait for animation has ended.
         // timeout is larger than duration, in case the system is sluggish
-        new DelayedCheck(duration * 2 + 1000) {
+        new PollingCheck(duration * 2 + 1000) {
             @Override
             protected boolean check() {
                 return anim.hasEnded();
@@ -414,7 +415,7 @@
 
         // test repeat mode RESTART
         anim.setRepeatMode(Animation.RESTART);
-        // we have to DelayedCheck the animation status on test thread,
+        // we have to PollingCheck the animation status on test thread,
         // it cannot be done on UI thread, so we invoke runOnMainSync method here.
         getInstrumentation().runOnMainSync(new Runnable() {
             public void run() {
@@ -423,7 +424,7 @@
         });
 
         // check whether animation has started
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return anim.hasStarted();
@@ -445,7 +446,7 @@
 
         // wait for animation has ended.
         // timeout is larger than duration, in case the system is sluggish
-        new DelayedCheck(duration * 2 + 1000) {
+        new PollingCheck(duration * 2 + 1000) {
             @Override
             protected boolean check() {
                 return anim.hasEnded();
@@ -627,7 +628,7 @@
         final Animation anim = AnimationUtils.loadAnimation(mActivity, R.anim.accelerate_alpha);
         assertFalse(anim.hasStarted());
 
-        // we have to DelayedCheck the animation status on test thread,
+        // we have to PollingCheck the animation status on test thread,
         // it cannot be done on UI thread, so we invoke runOnMainSync method here.
         getInstrumentation().runOnMainSync(new Runnable() {
             public void run() {
@@ -636,7 +637,7 @@
         });
 
         // check whether animation has started
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return anim.hasStarted();
@@ -662,7 +663,7 @@
 
         // wait for animation has ended.
         // timeout is larger than duration, in case the system is sluggish
-        new DelayedCheck(2000) {
+        new PollingCheck(2000) {
             @Override
             protected boolean check() {
                 return anim.hasEnded();
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index be60976..aee9075 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -29,6 +29,7 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.content.res.XmlResourceParser;
+import android.cts.util.PollingCheck;
 import android.graphics.Bitmap;
 import android.graphics.Point;
 import android.graphics.Rect;
@@ -69,7 +70,6 @@
 import android.view.accessibility.AccessibilityEvent;
 import android.view.animation.AlphaAnimation;
 import android.view.animation.Animation;
-import android.view.animation.cts.DelayedCheck;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputConnection;
 import android.view.inputmethod.InputMethodManager;
@@ -287,7 +287,7 @@
         assertTrue(view.hasCalledOnAnimationStart());
 
         // check whether it has ended after duration, and alpha changed during this time.
-        new DelayedCheck(duration + TIMEOUT_DELTA) {
+        new PollingCheck(duration + TIMEOUT_DELTA) {
             @Override
             protected boolean check() {
                 return view.hasCalledOnSetAlpha() && view.hasCalledOnAnimationEnd();
@@ -2257,7 +2257,7 @@
         // mAttachInfo is not null
         final View view2 = mActivity.findViewById(R.id.fit_windows);
         // Wait until the window has been focused.
-        new DelayedCheck(TIMEOUT_DELTA) {
+        new PollingCheck(TIMEOUT_DELTA) {
             @Override
             protected boolean check() {
                 return view2.hasWindowFocus();
@@ -4429,7 +4429,7 @@
         viewGroup.addView(editText);
         editText.requestFocus();
 
-        new DelayedCheck(TIMEOUT_DELTA) {
+        new PollingCheck(TIMEOUT_DELTA) {
             @Override
             protected boolean check() {
                 return editText.isFocused();
diff --git a/tests/tests/view/src/android/view/cts/View_AnimationTest.java b/tests/tests/view/src/android/view/cts/View_AnimationTest.java
index 144e670..d2085c6 100644
--- a/tests/tests/view/src/android/view/cts/View_AnimationTest.java
+++ b/tests/tests/view/src/android/view/cts/View_AnimationTest.java
@@ -17,12 +17,12 @@
 package android.view.cts;
 
 import android.app.Activity;
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
 import android.view.View;
 import android.view.animation.Animation;
 import android.view.animation.TranslateAnimation;
 import android.view.animation.cts.AnimationTestUtils;
-import android.view.animation.cts.DelayedCheck;
 
 import com.android.cts.stub.R;
 
@@ -155,7 +155,7 @@
             }
         });
 
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return mAnimation.hasStarted();
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java b/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java
index 2cf6b58..1556cc3 100755
--- a/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java
+++ b/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java
@@ -25,6 +25,7 @@
 
 import android.app.Instrumentation;
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.os.Bundle;
 import android.test.ActivityInstrumentationTestCase2;
 import android.text.Editable;
@@ -35,7 +36,6 @@
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.Window;
-import android.view.animation.cts.DelayedCheck;
 import android.view.inputmethod.BaseInputConnection;
 import android.view.inputmethod.CompletionInfo;
 import android.view.inputmethod.ExtractedTextRequest;
@@ -260,7 +260,7 @@
         // dummy mode
         BaseInputConnection dummyConnection = new BaseInputConnection(mView, false);
         dummyConnection.commitText(inputText, inputText.length());
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return text2.toString().equals(mView.getText().toString());
@@ -323,7 +323,7 @@
         BaseInputConnection dummyConnection = new BaseInputConnection(mView, false);
         dummyConnection.setComposingText(str, str.length());
         dummyConnection.finishComposingText();
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return text.toString().equals(mView.getText().toString());
@@ -359,7 +359,7 @@
             mInstrumentation.sendStringSync("q");
             mInstrumentation.waitForIdleSync();
         }
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return "q".equals(mView.getText().toString());
diff --git a/tests/tests/webkit/src/android/webkit/cts/CacheManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CacheManagerTest.java
index bebb1fa..bc3918e 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CacheManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CacheManagerTest.java
@@ -22,8 +22,8 @@
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.ToBeFixed;
 
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.CacheManager;
 import android.webkit.WebView;
 import android.webkit.CacheManager.CacheResult;
@@ -32,8 +32,8 @@
 
 @TestTargetClass(android.webkit.CacheManager.class)
 public class CacheManagerTest extends ActivityInstrumentationTestCase2<WebViewStubActivity> {
-    private static final long CACHEMANAGER_INIT_TIMEOUT = 5000l;
-    private static final long NETWORK_OPERATION_DELAY = 10000l;
+    private static final long CACHEMANAGER_INIT_TIMEOUT = 5000L;
+    private static final long NETWORK_OPERATION_TIMEOUT = 10000L;
 
     private WebView mWebView;
     private CtsTestServer mWebServer;
@@ -98,7 +98,7 @@
         final String url = mWebServer.getAssetUrl(TestHtmlConstants.EMBEDDED_IMG_URL);
 
         // Wait for CacheManager#init() finish.
-        new DelayedCheck(CACHEMANAGER_INIT_TIMEOUT) {
+        new PollingCheck(CACHEMANAGER_INIT_TIMEOUT) {
             @Override
             protected boolean check() {
                 return CacheManager.getCacheFileBaseDir() != null;
@@ -106,7 +106,7 @@
         }.run();
 
         mWebView.clearCache(true);
-        new DelayedCheck(NETWORK_OPERATION_DELAY) {
+        new PollingCheck(NETWORK_OPERATION_TIMEOUT) {
             @Override
             protected boolean check() {
                 CacheResult result = CacheManager.getCacheFile(url, null);
@@ -115,7 +115,7 @@
         }.run();
 
         loadUrl(url);
-        new DelayedCheck(NETWORK_OPERATION_DELAY) {
+        new PollingCheck(NETWORK_OPERATION_TIMEOUT) {
             @Override
             protected boolean check() {
                 CacheResult result = CacheManager.getCacheFile(url, null);
@@ -141,7 +141,7 @@
     private void loadUrl(String url){
         mWebView.loadUrl(url);
         // check whether loadURL successfully
-        new DelayedCheck(NETWORK_OPERATION_DELAY) {
+        new PollingCheck(NETWORK_OPERATION_TIMEOUT) {
             @Override
             protected boolean check() {
                 return mWebView.getProgress() == 100;
diff --git a/tests/tests/webkit/src/android/webkit/cts/CacheManager_CacheResultTest.java b/tests/tests/webkit/src/android/webkit/cts/CacheManager_CacheResultTest.java
index 48a6a1f..e5077cc 100755
--- a/tests/tests/webkit/src/android/webkit/cts/CacheManager_CacheResultTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CacheManager_CacheResultTest.java
@@ -24,8 +24,8 @@
 import org.apache.http.HttpStatus;
 import org.apache.http.impl.cookie.DateUtils;
 
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.CacheManager;
 import android.webkit.WebChromeClient;
 import android.webkit.WebView;
@@ -37,7 +37,7 @@
 @TestTargetClass(android.webkit.CacheManager.CacheResult.class)
 public class CacheManager_CacheResultTest
         extends ActivityInstrumentationTestCase2<WebViewStubActivity> {
-    private static final long NETWORK_OPERATION_DELAY = 10000l;
+    private static final long NETWORK_OPERATION_TIMEOUT = 10000L;
 
     private WebView mWebView;
     private CtsTestServer mWebServer;
@@ -139,7 +139,7 @@
         mWebServer.setDocumentValidity(validity);
 
         mWebView.clearCache(true);
-        new DelayedCheck(NETWORK_OPERATION_DELAY) {
+        new PollingCheck(NETWORK_OPERATION_TIMEOUT) {
             @Override
             protected boolean check() {
                 CacheResult result =
@@ -175,7 +175,7 @@
     private void loadUrl(String url){
         mWebView.loadUrl(url);
         // check whether loadURL successfully
-        new DelayedCheck(NETWORK_OPERATION_DELAY) {
+        new PollingCheck(NETWORK_OPERATION_TIMEOUT) {
             @Override
             protected boolean check() {
                 return mWebView.getProgress() == 100;
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
index 712d641..f938e62 100755
--- a/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieManagerTest.java
@@ -22,8 +22,8 @@
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.ToBeFixed;
 
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.CookieManager;
 import android.webkit.CookieSyncManager;
 import android.webkit.WebChromeClient;
@@ -37,7 +37,7 @@
 public class CookieManagerTest extends
         ActivityInstrumentationTestCase2<CookieSyncManagerStubActivity> {
 
-    private static final int TEST_DELAY = 5000;
+    private static final int TEST_TIMEOUT = 5000;
 
     private WebView mWebView;
     private CookieManager mCookieManager;
@@ -116,7 +116,7 @@
         String url = server.getCookieUrl("conquest.html");
         loadUrl(url);
         assertEquals(null, mWebView.getTitle()); // no cookies passed
-        Thread.sleep(TEST_DELAY);
+        Thread.sleep(500);
         assertNull(mCookieManager.getCookie(url));
 
         mCookieManager.setAcceptCookie(true);
@@ -187,7 +187,7 @@
 
         // sync cookie from RAM to FLASH, because hasCookies() only counts FLASH cookies
         CookieSyncManager.getInstance().sync();
-        new DelayedCheck(TEST_DELAY) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return mCookieManager.hasCookies();
@@ -196,7 +196,7 @@
 
         // clean up all cookies
         mCookieManager.removeAllCookie();
-        new DelayedCheck(TEST_DELAY) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return !mCookieManager.hasCookies();
@@ -247,7 +247,7 @@
         assertTrue(allCookies.contains(cookie3));
 
         mCookieManager.removeSessionCookie();
-        new DelayedCheck(TEST_DELAY) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 String c = mCookieManager.getCookie(url);
                 return !c.contains(cookie1) && c.contains(cookie2) && c.contains(cookie3);
@@ -256,7 +256,7 @@
 
         Thread.sleep(expiration + 1000); // wait for cookie to expire
         mCookieManager.removeExpiredCookie();
-        new DelayedCheck(TEST_DELAY) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 String c = mCookieManager.getCookie(url);
                 return !c.contains(cookie1) && c.contains(cookie2) && !c.contains(cookie3);
@@ -264,7 +264,7 @@
         }.run();
 
         mCookieManager.removeAllCookie();
-        new DelayedCheck(TEST_DELAY) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return mCookieManager.getCookie(url) == null;
             }
@@ -273,7 +273,7 @@
 
     private void loadUrl(String url) {
         mWebView.loadUrl(url);
-        new DelayedCheck(TEST_DELAY) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return mWebView.getProgress() == 100;
             }
@@ -281,7 +281,7 @@
     }
 
     private void waitForCookie(final String url) {
-        new DelayedCheck(TEST_DELAY) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return mCookieManager.getCookie(url) != null;
             }
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
index 9450c70..8093a10 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
@@ -22,8 +22,8 @@
 import dalvik.annotation.TestTargets;
 
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.CookieManager;
 import android.webkit.CookieSyncManager;
 
@@ -31,6 +31,8 @@
 public class CookieSyncManagerTest
         extends ActivityInstrumentationTestCase2<CookieSyncManagerStubActivity> {
 
+    private final static int COOKIE_MANAGER_TIMEOUT = 5000;
+
     public CookieSyncManagerTest() {
         super("com.android.cts.stub", CookieSyncManagerStubActivity.class);
     }
@@ -65,7 +67,7 @@
 
         // Remove all cookies from the database.
         cookieManager.removeAllCookie();
-        new DelayedCheck(30000) {
+        new PollingCheck(COOKIE_MANAGER_TIMEOUT) {
             @Override
             protected boolean check() {
                 return !cookieManager.hasCookies();
@@ -83,7 +85,7 @@
 
         // Store the cookie to the database.
         csm1.sync();
-        new DelayedCheck(30000) {
+        new PollingCheck(COOKIE_MANAGER_TIMEOUT) {
             @Override
             protected boolean check() {
                 return cookieManager.hasCookies();
@@ -92,7 +94,7 @@
 
         // Remove all cookies from the database.
         cookieManager.removeAllCookie();
-        new DelayedCheck(30000) {
+        new PollingCheck(COOKIE_MANAGER_TIMEOUT) {
             @Override
             protected boolean check() {
                 return !cookieManager.hasCookies();
diff --git a/tests/tests/webkit/src/android/webkit/cts/HttpAuthHandlerTest.java b/tests/tests/webkit/src/android/webkit/cts/HttpAuthHandlerTest.java
index 8721326..f7e5402 100644
--- a/tests/tests/webkit/src/android/webkit/cts/HttpAuthHandlerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/HttpAuthHandlerTest.java
@@ -23,8 +23,8 @@
 
 import org.apache.http.HttpStatus;
 
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.HttpAuthHandler;
 import android.webkit.WebChromeClient;
 import android.webkit.WebView;
@@ -133,7 +133,7 @@
 
     private void assertLoadUrlSuccessfully(String url) throws InterruptedException {
         mWebView.loadUrl(url);
-        new DelayedCheck(TIMEOUT) {
+        new PollingCheck(TIMEOUT) {
             @Override
             protected boolean check() {
                 return mWebView.getProgress() == 100;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebBackForwardListTest.java b/tests/tests/webkit/src/android/webkit/cts/WebBackForwardListTest.java
index 6cddfb3..66730bb 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebBackForwardListTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebBackForwardListTest.java
@@ -21,8 +21,8 @@
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
 
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.WebBackForwardList;
 import android.webkit.WebHistoryItem;
 import android.webkit.WebView;
@@ -90,7 +90,7 @@
     }
 
     private void checkBackForwardList(final WebView view, final String... url) {
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 if (view.getProgress() < 100) {
                     return false;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
index cf20217..b40bfc9 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
@@ -21,10 +21,10 @@
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
 
+import android.cts.util.PollingCheck;
 import android.graphics.Bitmap;
 import android.os.Message;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.JsPromptResult;
 import android.webkit.JsResult;
 import android.webkit.WebChromeClient;
@@ -79,7 +79,7 @@
         assertFalse(webChromeClient.hadOnProgressChanged());
         mWebView.loadUrl(TestHtmlConstants.HELLO_WORLD_URL);
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnProgressChanged();
@@ -102,7 +102,7 @@
         String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
         mWebView.loadUrl(url);
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnReceivedTitle();
@@ -140,7 +140,7 @@
         String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
         mWebView.loadUrl(url);
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnReceivedIcon();
@@ -180,14 +180,14 @@
         // after which the child will be closed
         loadUrl(mWebServer.getAssetUrl(TestHtmlConstants.JS_WINDOW_URL));
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnCreateWindow();
             }
         }.run();
         assertFalse(webChromeClient.hadOnRequestFocus());
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnCloseWindow();
@@ -216,7 +216,7 @@
         // unload should trigger when we try to navigate away
         loadUrl(mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL));
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnJsBeforeUnload();
@@ -245,7 +245,7 @@
         String url = mWebServer.getAssetUrl(TestHtmlConstants.JS_ALERT_URL);
         mWebView.loadUrl(url);
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnJsAlert();
@@ -274,7 +274,7 @@
         String url = mWebServer.getAssetUrl(TestHtmlConstants.JS_CONFIRM_URL);
         mWebView.loadUrl(url);
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnJsConfirm();
@@ -305,14 +305,14 @@
         String url = mWebServer.getAssetUrl(TestHtmlConstants.JS_PROMPT_URL);
         mWebView.loadUrl(url);
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.hadOnJsPrompt();
             }
         }.run();
         // the result returned by the client gets set as the page title
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return mWebView.getTitle().equals(promptResult);
             }
@@ -322,7 +322,7 @@
 
     private void loadUrl(String url) {
         mWebView.loadUrl(url);
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return mWebView.getProgress() == 100;
             }
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java b/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
index 71ba504..bcb2924 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebHistoryItemTest.java
@@ -23,9 +23,9 @@
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.ToBeFixed;
 
+import android.cts.util.PollingCheck;
 import android.graphics.Bitmap;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.WebBackForwardList;
 import android.webkit.WebChromeClient;
 import android.webkit.WebHistoryItem;
@@ -107,7 +107,7 @@
     private void assertLoadUrlSuccessfully(final WebView view, String url) {
         view.loadUrl(url);
         // wait for the page load to complete
-        new DelayedCheck(10000) {
+        new PollingCheck(10000) {
             @Override
             protected boolean check() {
                 return view.getProgress() == 100;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index 639f795..4fad3ed 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -21,10 +21,10 @@
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.ToBeFixed;
 
+import android.cts.util.PollingCheck;
 import android.os.Build;
 import android.test.ActivityInstrumentationTestCase2;
 import android.util.Log;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.MimeTypeMap;
 import android.webkit.WebChromeClient;
 import android.webkit.WebSettings;
@@ -44,6 +44,7 @@
 @TestTargetClass(android.webkit.WebSettings.class)
 public class WebSettingsTest extends ActivityInstrumentationTestCase2<WebViewStubActivity> {
 
+    private static final int WEBVIEW_TIMEOUT = 5000;
     private static final String LOG_TAG = "WebSettingsTest";
 
     private WebView mWebView;
@@ -252,7 +253,7 @@
         assertFalse(mSettings.getBlockNetworkImage());
         assertTrue(mSettings.getLoadsImagesAutomatically());
         loadAssetUrl(url);
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return !mWebServer.getLastRequestUrl().endsWith(ext);
@@ -543,7 +544,7 @@
         mSettings.setJavaScriptCanOpenWindowsAutomatically(false);
         assertFalse(mSettings.getJavaScriptCanOpenWindowsAutomatically());
         loadAssetUrl(TestHtmlConstants.POPUP_URL);
-        new DelayedCheck(10000) {
+        new PollingCheck(WEBVIEW_TIMEOUT) {
             protected boolean check() {
                 String title = mWebView.getTitle();
                 return title != null && title.length() > 0;
@@ -554,7 +555,7 @@
         mSettings.setJavaScriptCanOpenWindowsAutomatically(true);
         assertTrue(mSettings.getJavaScriptCanOpenWindowsAutomatically());
         loadAssetUrl(TestHtmlConstants.POPUP_URL);
-        new DelayedCheck(10000) {
+        new PollingCheck(WEBVIEW_TIMEOUT) {
             protected boolean check() {
                 String title = mWebView.getTitle();
                 return title != null && title.length() > 0;
@@ -579,7 +580,7 @@
         mSettings.setJavaScriptEnabled(true);
         assertTrue(mSettings.getJavaScriptEnabled());
         loadAssetUrl(TestHtmlConstants.JAVASCRIPT_URL);
-        new DelayedCheck(10000) {
+        new PollingCheck(WEBVIEW_TIMEOUT) {
             @Override
             protected boolean check() {
                 return mWebView.getTitle() != null;
@@ -590,7 +591,7 @@
         mSettings.setJavaScriptEnabled(false);
         assertFalse(mSettings.getJavaScriptEnabled());
         loadAssetUrl(TestHtmlConstants.JAVASCRIPT_URL);
-        new DelayedCheck(10000) {
+        new PollingCheck(WEBVIEW_TIMEOUT) {
             @Override
             protected boolean check() {
                 return mWebView.getTitle() != null;
@@ -1013,7 +1014,7 @@
         mSettings.setJavaScriptEnabled(true);
 
         loadUrl(url);
-        new DelayedCheck(10000) {
+        new PollingCheck(WEBVIEW_TIMEOUT) {
             protected boolean check() {
                 return mWebView.getTitle() != null && mWebView.getTitle().equals("Done");
             }
@@ -1021,7 +1022,7 @@
 
         mSettings.setAppCachePath("/data/foo");
         loadUrl(url);
-        new DelayedCheck(10000) {
+        new PollingCheck(WEBVIEW_TIMEOUT) {
             protected boolean check() {
                 return mWebView.getTitle() != null && mWebView.getTitle().equals("Done");
             }
@@ -1061,7 +1062,7 @@
      */
     private void loadUrl(String url) {
         mWebView.loadUrl(url);
-        new DelayedCheck(10000) {
+        new PollingCheck(WEBVIEW_TIMEOUT) {
             @Override
             protected boolean check() {
                 return mWebView.getProgress() == 100;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 2cd2deb..86b8070 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
@@ -22,11 +22,11 @@
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.ToBeFixed;
 
+import android.cts.util.PollingCheck;
 import android.graphics.Bitmap;
 import android.os.Message;
 import android.test.ActivityInstrumentationTestCase2;
 import android.view.KeyEvent;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.HttpAuthHandler;
 import android.webkit.WebSettings;
 import android.webkit.WebView;
@@ -99,19 +99,19 @@
         assertFalse(webViewClient.hasOnPageFinishedCalled());
         mWebView.loadUrl(url);
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return webViewClient.hasOnPageStartedCalled();
             }
         }.run();
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return webViewClient.hasOnLoadResourceCalled();
             }
         }.run();
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return webViewClient.hasOnPageFinishedCalled();
             }
@@ -155,7 +155,7 @@
         assertFalse(url.equals(mWebView.getUrl()));
         // reloading the current URL should trigger the callback
         mWebView.reload();
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return webViewClient.hasOnFormResubmissionCalled();
             }
@@ -177,7 +177,7 @@
         String url2 = mWebServer.getAssetUrl(TestHtmlConstants.BR_TAG_URL);
         assertLoadUrlSuccessfully(mWebView, url1);
         assertLoadUrlSuccessfully(mWebView, url2);
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return webViewClient.hasDoUpdateVisitedHistoryCalled();
             }
@@ -231,7 +231,7 @@
         assertFalse(webViewClient.hasOnUnhandledKeyEventCalled());
         sendKeys(KeyEvent.KEYCODE_1);
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return webViewClient.hasOnUnhandledKeyEventCalled();
             }
@@ -260,7 +260,7 @@
     private void assertLoadUrlSuccessfully(final WebView view, String url) {
         view.loadUrl(url);
         // wait until load is complete
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return view.getProgress() == 100;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 3eb49b3..fe24012 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -25,6 +25,7 @@
 
 import android.content.Context;
 import android.content.res.AssetManager;
+import android.cts.util.PollingCheck;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
@@ -48,7 +49,6 @@
 import android.view.KeyEvent;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.animation.cts.DelayedCheck;
 import android.webkit.CacheManager;
 import android.webkit.CacheManager.CacheResult;
 import android.webkit.ConsoleMessage;
@@ -472,7 +472,7 @@
         String url = mWebServer.getDelayedAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
         mWebView.loadUrl(url);
         mWebView.stopLoading();
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return 100 == mWebView.getProgress();
@@ -524,37 +524,37 @@
         String url3 = mWebServer.getAssetUrl(TestHtmlConstants.HTML_URL3);
 
         assertLoadUrlSuccessfully(url1);
-        delayedCheckWebBackForwardList(url1, 0, 1);
+        pollingCheckWebBackForwardList(url1, 0, 1);
         assertGoBackOrForwardBySteps(false, -1);
         assertGoBackOrForwardBySteps(false, 1);
 
         assertLoadUrlSuccessfully(url2);
-        delayedCheckWebBackForwardList(url2, 1, 2);
+        pollingCheckWebBackForwardList(url2, 1, 2);
         assertGoBackOrForwardBySteps(true, -1);
         assertGoBackOrForwardBySteps(false, 1);
 
         assertLoadUrlSuccessfully(url3);
-        delayedCheckWebBackForwardList(url3, 2, 3);
+        pollingCheckWebBackForwardList(url3, 2, 3);
         assertGoBackOrForwardBySteps(true, -2);
         assertGoBackOrForwardBySteps(false, 1);
 
         mWebView.goBack();
-        delayedCheckWebBackForwardList(url2, 1, 3);
+        pollingCheckWebBackForwardList(url2, 1, 3);
         assertGoBackOrForwardBySteps(true, -1);
         assertGoBackOrForwardBySteps(true, 1);
 
         mWebView.goForward();
-        delayedCheckWebBackForwardList(url3, 2, 3);
+        pollingCheckWebBackForwardList(url3, 2, 3);
         assertGoBackOrForwardBySteps(true, -2);
         assertGoBackOrForwardBySteps(false, 1);
 
         mWebView.goBackOrForward(-2);
-        delayedCheckWebBackForwardList(url1, 0, 3);
+        pollingCheckWebBackForwardList(url1, 0, 3);
         assertGoBackOrForwardBySteps(false, -1);
         assertGoBackOrForwardBySteps(true, 2);
 
         mWebView.goBackOrForward(2);
-        delayedCheckWebBackForwardList(url3, 2, 3);
+        pollingCheckWebBackForwardList(url3, 2, 3);
         assertGoBackOrForwardBySteps(true, -2);
         assertGoBackOrForwardBySteps(false, 1);
     }
@@ -864,7 +864,7 @@
                 assertLoadUrlSuccessfully(url);
             }
         });
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return listener.callCount > 0;
             }
@@ -879,7 +879,7 @@
                 assertLoadUrlSuccessfully(newUrl);
             }
         });
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             protected boolean check() {
                 return listener.callCount > oldCallCount;
             }
@@ -931,7 +931,7 @@
             });
 
             // File saving is done in a separate thread.
-            new DelayedCheck() {
+            new PollingCheck() {
                 @Override
                 protected boolean check() {
                     return f.length() > 0;
@@ -1243,7 +1243,7 @@
     public void testFindNext() throws Throwable {
         final ScrollRunnable runnable = new ScrollRunnable();
 
-        final class StopScrollingDelayedCheck extends DelayedCheck {
+        final class StopScrollingPollingCheck extends PollingCheck {
             private int mPreviousScrollY = -1;
             @Override
             protected boolean check() {
@@ -1292,25 +1292,25 @@
 
         // Focus "all" in the second page and assert that the view scrolls.
         runTestOnUiThread(new FindNextRunnable(true));
-        new StopScrollingDelayedCheck().run();
+        new StopScrollingPollingCheck().run();
         assertTrue(runnable.getScrollY() > previousScrollY);
         previousScrollY = runnable.getScrollY();
 
         // Focus "all" in the first page and assert that the view scrolls.
         runTestOnUiThread(new FindNextRunnable(true));
-        new StopScrollingDelayedCheck().run();
+        new StopScrollingPollingCheck().run();
         assertTrue(runnable.getScrollY() < previousScrollY);
         previousScrollY = runnable.getScrollY();
 
         // Focus "all" in the second page and assert that the view scrolls.
         runTestOnUiThread(new FindNextRunnable(false));
-        new StopScrollingDelayedCheck().run();
+        new StopScrollingPollingCheck().run();
         assertTrue(runnable.getScrollY() > previousScrollY);
         previousScrollY = runnable.getScrollY();
 
         // Focus "all" in the first page and assert that the view scrolls.
         runTestOnUiThread(new FindNextRunnable(false));
-        new StopScrollingDelayedCheck().run();
+        new StopScrollingPollingCheck().run();
         assertTrue(runnable.getScrollY() < previousScrollY);
         previousScrollY = runnable.getScrollY();
 
@@ -1324,11 +1324,11 @@
 
         // can not scroll any more
         runTestOnUiThread(new FindNextRunnable(false));
-        new StopScrollingDelayedCheck().run();
+        new StopScrollingPollingCheck().run();
         assertTrue(runnable.getScrollY() == previousScrollY);
 
         runTestOnUiThread(new FindNextRunnable(true));
-        new StopScrollingDelayedCheck().run();
+        new StopScrollingPollingCheck().run();
         assertTrue(runnable.getScrollY() == previousScrollY);
     }
 
@@ -1377,7 +1377,7 @@
                 mWebView.documentHasImages(response);
             }
         });
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return handler.hasCalledHandleMessage();
@@ -1558,7 +1558,7 @@
         final String url = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
         mWebView.loadUrl(url);
         waitForLoadComplete();
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 CacheResult result = CacheManager.getCacheFile(url, null);
@@ -1575,7 +1575,7 @@
 
         mWebView.clearCache(true);
         // check the files are deleted
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return cacheFileBaseDir.list().length == 0;
@@ -1714,7 +1714,7 @@
                 mWebView.requestFocusNodeHref(hrefMsg);
             }
         });
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return handler.hasCalledHandleMessage();
@@ -1732,7 +1732,7 @@
                 mWebView.requestFocusNodeHref(hrefMsg2);
             }
         });
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return handler.hasCalledHandleMessage();
@@ -1800,7 +1800,7 @@
                 mWebView.requestImageRef(msg);
             }
         });
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return handler.hasCalledHandleMessage();
@@ -1989,18 +1989,18 @@
         String url3 = mWebServer.getAssetUrl(TestHtmlConstants.HTML_URL3);
 
         assertLoadUrlSuccessfully(url1);
-        delayedCheckWebBackForwardList(url1, 0, 1);
+        pollingCheckWebBackForwardList(url1, 0, 1);
 
         assertLoadUrlSuccessfully(url2);
-        delayedCheckWebBackForwardList(url2, 1, 2);
+        pollingCheckWebBackForwardList(url2, 1, 2);
 
         assertLoadUrlSuccessfully(url3);
-        delayedCheckWebBackForwardList(url3, 2, 3);
+        pollingCheckWebBackForwardList(url3, 2, 3);
 
         mWebView.clearHistory();
 
         // only current URL is left after clearing
-        delayedCheckWebBackForwardList(url3, 0, 1);
+        pollingCheckWebBackForwardList(url3, 0, 1);
     }
 
     @TestTargets({
@@ -2033,11 +2033,11 @@
 
         // make a history list
         assertLoadUrlSuccessfully(url1);
-        delayedCheckWebBackForwardList(url1, 0, 1);
+        pollingCheckWebBackForwardList(url1, 0, 1);
         assertLoadUrlSuccessfully(url2);
-        delayedCheckWebBackForwardList(url2, 1, 2);
+        pollingCheckWebBackForwardList(url2, 1, 2);
         assertLoadUrlSuccessfully(url3);
-        delayedCheckWebBackForwardList(url3, 2, 3);
+        pollingCheckWebBackForwardList(url3, 2, 3);
 
         // save the list
         Bundle bundle = new Bundle();
@@ -2063,7 +2063,7 @@
         assertEquals(2, saveList.getCurrentIndex());
         /* ToBeFixed: The WebHistoryItems do not get inflated. Uncomment remaining tests when fixed.
         // wait for the list items to get inflated
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return restoreList.getItemAtIndex(0).getUrl() != null &&
@@ -2169,7 +2169,7 @@
 
         runTestOnUiThread(new Runnable() {
             public void run() {
-                new DelayedCheck(TEST_TIMEOUT) {
+                new PollingCheck(TEST_TIMEOUT) {
                     @Override
                     protected boolean check() {
                         return mWebView.getCertificate() == null;
@@ -2213,7 +2213,7 @@
 
         runTestOnUiThread(new Runnable() {
             public void run() {
-                new DelayedCheck(TEST_TIMEOUT) {
+                new PollingCheck(TEST_TIMEOUT) {
                     @Override
                     protected boolean check() {
                         return mWebView.getCertificate() != null;
@@ -2508,7 +2508,7 @@
         });
         getInstrumentation().waitForIdleSync();
         getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER);
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return listener.called;
@@ -2607,7 +2607,7 @@
         });
         getInstrumentation().waitForIdleSync();
 
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return webChromeClient.onProgressChangedCalled();
@@ -2837,9 +2837,9 @@
         }
     }
 
-    private void delayedCheckWebBackForwardList(final String currUrl, final int currIndex,
+    private void pollingCheckWebBackForwardList(final String currUrl, final int currIndex,
             final int size) {
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 WebBackForwardList list = mWebView.copyBackForwardList();
@@ -2935,7 +2935,7 @@
     }
 
     private void waitForLoadComplete() {
-        new DelayedCheck(TEST_TIMEOUT) {
+        new PollingCheck(TEST_TIMEOUT) {
             @Override
             protected boolean check() {
                 return mWebView.getProgress() == 100;
diff --git a/tests/tests/widget/src/android/widget/cts/CursorAdapterTest.java b/tests/tests/widget/src/android/widget/cts/CursorAdapterTest.java
index 9627b6f..e2dd2fd 100644
--- a/tests/tests/widget/src/android/widget/cts/CursorAdapterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/CursorAdapterTest.java
@@ -19,6 +19,7 @@
 import java.io.File;
 
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.database.ContentObserver;
 import android.database.Cursor;
 import android.database.DataSetObserver;
@@ -29,7 +30,6 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.CursorAdapter;
 import android.widget.Filter;
 import android.widget.FilterQueryProvider;
@@ -428,7 +428,7 @@
         assertFalse(mMockCursorAdapter.hasContentChanged());
         // insert a new row
         mDatabase.execSQL("INSERT INTO test (number) VALUES ('" + FIRST_NUMBER + "');");
-        new DelayedCheck(TEST_TIME_OUT) {
+        new PollingCheck(TEST_TIME_OUT) {
             @Override
             protected boolean check() {
                 return mMockCursorAdapter.hasContentChanged();
diff --git a/tests/tests/widget/src/android/widget/cts/FilterTest.java b/tests/tests/widget/src/android/widget/cts/FilterTest.java
index 862cb03..1306bd28 100644
--- a/tests/tests/widget/src/android/widget/cts/FilterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/FilterTest.java
@@ -20,8 +20,8 @@
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
 
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.Filter;
 import android.widget.Filter.FilterListener;
 
@@ -70,7 +70,7 @@
             }
         });
 
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return mMockFilter.hadPerformedFiltering();
@@ -78,7 +78,7 @@
         }.run();
         assertEquals(TEST_CONSTRAINT, mMockFilter.getPerformFilteringConstraint());
 
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return mMockFilter.hadPublishedResults();
@@ -102,7 +102,7 @@
             }
         });
 
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return mMockFilter.hadPerformedFiltering();
@@ -110,7 +110,7 @@
         }.run();
         assertEquals(TEST_CONSTRAINT, mMockFilter.getPerformFilteringConstraint());
 
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return mMockFilter.hadPublishedResults();
@@ -119,7 +119,7 @@
         assertEquals(TEST_CONSTRAINT, mMockFilter.getPublishResultsConstraint());
         assertSame(mMockFilter.getExpectResults(), mMockFilter.getResults());
 
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return mockFilterListener.hasCalledOnFilterComplete();
diff --git a/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java b/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
index 31b0b7b..c6302f9 100644
--- a/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
@@ -28,6 +28,7 @@
 
 import android.app.Activity;
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.graphics.Rect;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
@@ -39,7 +40,6 @@
 import android.view.ViewGroup;
 import android.view.View.MeasureSpec;
 import android.view.ViewGroup.LayoutParams;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.HorizontalScrollView;
 import android.widget.TextView;
 
@@ -363,7 +363,7 @@
                 mScrollView.fullScroll(View.FOCUS_RIGHT);
             }
         });
-        delayedCheckSmoothScrolling(0, SCROLL_RIGHT, 0, 0);
+        pollingCheckSmoothScrolling(0, SCROLL_RIGHT, 0, 0);
         assertEquals(SCROLL_RIGHT, mScrollView.getScrollX());
 
         runTestOnUiThread(new Runnable() {
@@ -371,7 +371,7 @@
                 mScrollView.fullScroll(View.FOCUS_LEFT);
             }
         });
-        delayedCheckSmoothScrolling(SCROLL_RIGHT, 0, 0, 0);
+        pollingCheckSmoothScrolling(SCROLL_RIGHT, 0, 0, 0);
         assertEquals(0, mScrollView.getScrollX());
     }
 
@@ -521,7 +521,7 @@
                 mScrollView.smoothScrollBy(SCROLL_RIGHT, 0);
             }
         });
-        delayedCheckSmoothScrolling(0, SCROLL_RIGHT, 0, 0);
+        pollingCheckSmoothScrolling(0, SCROLL_RIGHT, 0, 0);
         assertEquals(SCROLL_RIGHT, mScrollView.getScrollX());
         assertEquals(0, mScrollView.getScrollY());
 
@@ -530,7 +530,7 @@
                 mScrollView.smoothScrollBy(-SCROLL_RIGHT, 0);
             }
         });
-        delayedCheckSmoothScrolling(SCROLL_RIGHT, 0, 0, 0);
+        pollingCheckSmoothScrolling(SCROLL_RIGHT, 0, 0, 0);
         assertEquals(0, mScrollView.getScrollX());
         assertEquals(0, mScrollView.getScrollY());
     }
@@ -549,7 +549,7 @@
                 mScrollView.smoothScrollTo(SCROLL_RIGHT, 0);
             }
         });
-        delayedCheckSmoothScrolling(0, SCROLL_RIGHT, 0, 0);
+        pollingCheckSmoothScrolling(0, SCROLL_RIGHT, 0, 0);
         assertEquals(SCROLL_RIGHT, mScrollView.getScrollX());
         assertEquals(0, mScrollView.getScrollY());
 
@@ -558,7 +558,7 @@
                 mScrollView.smoothScrollTo(0, 0);
             }
         });
-        delayedCheckSmoothScrolling(SCROLL_RIGHT, 0, 0, 0);
+        pollingCheckSmoothScrolling(SCROLL_RIGHT, 0, 0, 0);
         assertEquals(0, mScrollView.getScrollX());
         assertEquals(0, mScrollView.getScrollY());
     }
@@ -677,7 +677,7 @@
                 mScrollView.fling(velocityX);
             }
         });
-        delayedCheckFling(0, true);
+        pollingCheckFling(0, true);
 
         final int currentX = mScrollView.getScrollX();
         // fling towards left
@@ -686,7 +686,7 @@
                 mScrollView.fling(-velocityX);
             }
         });
-        delayedCheckFling(currentX, false);
+        pollingCheckFling(currentX, false);
     }
 
     @TestTargetNew(
@@ -832,7 +832,7 @@
         return current <= from && current >= to;
     }
 
-    private void delayedCheckSmoothScrolling(final int fromX, final int toX,
+    private void pollingCheckSmoothScrolling(final int fromX, final int toX,
             final int fromY, final int toY) {
 
         if (fromX == toX && fromY == toY) {
@@ -840,7 +840,7 @@
         }
 
         if (fromY != toY) {
-            new DelayedCheck() {
+            new PollingCheck() {
                 @Override
                 protected boolean check() {
                     return isInRange(mScrollView.getScrollY(), fromY, toY);
@@ -849,7 +849,7 @@
         }
 
         if (fromX != toX) {
-            new DelayedCheck() {
+            new PollingCheck() {
                 @Override
                 protected boolean check() {
                     return isInRange(mScrollView.getScrollX(), fromX, toX);
@@ -857,7 +857,7 @@
             }.run();
         }
 
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return toX == mScrollView.getScrollX() && toY == mScrollView.getScrollY();
@@ -865,8 +865,8 @@
         }.run();
     }
 
-    private void delayedCheckFling(final int startPosition, final boolean movingRight) {
-        new DelayedCheck() {
+    private void pollingCheckFling(final int startPosition, final boolean movingRight) {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 if (movingRight) {
@@ -876,7 +876,7 @@
             }
         }.run();
 
-        new DelayedCheck() {
+        new PollingCheck() {
             private int mPreviousScrollX = mScrollView.getScrollX();
 
             @Override
diff --git a/tests/tests/widget/src/android/widget/cts/MediaControllerTest.java b/tests/tests/widget/src/android/widget/cts/MediaControllerTest.java
index 9f27138..dc007e4 100644
--- a/tests/tests/widget/src/android/widget/cts/MediaControllerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/MediaControllerTest.java
@@ -29,6 +29,7 @@
 import android.app.Activity;
 import android.app.Instrumentation;
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
 import android.util.AttributeSet;
@@ -36,7 +37,6 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.MediaController;
 import android.widget.VideoView;
 
@@ -222,7 +222,7 @@
         assertTrue(mMediaController.isShowing());
 
         // isShowing() should return false, but MediaController still shows, this may be a bug.
-        new DelayedCheck(timeout + 500) {
+        new PollingCheck(timeout + 500) {
             @Override
             protected boolean check() {
                 return mMediaController.isShowing();
diff --git a/tests/tests/widget/src/android/widget/cts/ScrollViewTest.java b/tests/tests/widget/src/android/widget/cts/ScrollViewTest.java
index 681e641..cd336da 100644
--- a/tests/tests/widget/src/android/widget/cts/ScrollViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ScrollViewTest.java
@@ -28,6 +28,7 @@
 
 import android.app.Activity;
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.graphics.Rect;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
@@ -39,7 +40,6 @@
 import android.view.ViewGroup;
 import android.view.View.MeasureSpec;
 import android.view.ViewGroup.LayoutParams;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.ScrollView;
 import android.widget.TextView;
 
@@ -382,7 +382,7 @@
                 mScrollView.fullScroll(View.FOCUS_DOWN);
             }
         });
-        delayedCheckSmoothScrolling(0, 0, 0, mScrollBottom);
+        pollingCheckSmoothScrolling(0, 0, 0, mScrollBottom);
         assertEquals(mScrollBottom, mScrollView.getScrollY(), TOLERANCE);
 
         runTestOnUiThread(new Runnable() {
@@ -390,7 +390,7 @@
                 mScrollView.fullScroll(View.FOCUS_UP);
             }
         });
-        delayedCheckSmoothScrolling(0, 0, mScrollBottom, 0);
+        pollingCheckSmoothScrolling(0, 0, mScrollBottom, 0);
         assertEquals(0, mScrollView.getScrollY());
     }
 
@@ -547,7 +547,7 @@
             }
         });
         // smoothScrollBy doesn't scroll in X
-        delayedCheckSmoothScrolling(0, 0, 0, mScrollBottom);
+        pollingCheckSmoothScrolling(0, 0, 0, mScrollBottom);
         assertEquals(0, mScrollView.getScrollX());
         assertEquals(mScrollBottom, mScrollView.getScrollY());
 
@@ -556,7 +556,7 @@
                 mScrollView.smoothScrollBy(-mScrollRight, -mScrollBottom);
             }
         });
-        delayedCheckSmoothScrolling(mScrollRight, 0, mScrollBottom, 0);
+        pollingCheckSmoothScrolling(mScrollRight, 0, mScrollBottom, 0);
         assertEquals(0, mScrollView.getScrollX());
         assertEquals(0, mScrollView.getScrollY());
     }
@@ -576,7 +576,7 @@
             }
         });
         // smoothScrollTo doesn't scroll in X
-        delayedCheckSmoothScrolling(0, 0, 0, mScrollBottom);
+        pollingCheckSmoothScrolling(0, 0, 0, mScrollBottom);
         assertEquals(0, mScrollView.getScrollX());
         assertEquals(mScrollBottom, mScrollView.getScrollY());
 
@@ -585,7 +585,7 @@
                 mScrollView.smoothScrollTo(mPageWidth, mPageHeight);
             }
         });
-        delayedCheckSmoothScrolling(0, 0, mScrollBottom, mPageHeight);
+        pollingCheckSmoothScrolling(0, 0, mScrollBottom, mPageHeight);
         assertEquals(0, mScrollView.getScrollX());
         assertEquals(mPageHeight, mScrollView.getScrollY());
     }
@@ -706,7 +706,7 @@
                 mScrollView.fling(2000);
             }
         });
-        delayedCheckFling(0, true);
+        pollingCheckFling(0, true);
 
         final int currentY = mScrollView.getScrollY();
         // fling towards top
@@ -715,7 +715,7 @@
                 mScrollView.fling(-2000);
             }
         });
-        delayedCheckFling(currentY, false);
+        pollingCheckFling(currentY, false);
     }
 
     @TestTargetNew(
@@ -860,7 +860,7 @@
         return current <= from && current >= to;
     }
 
-    private void delayedCheckSmoothScrolling(final int fromX, final int toX,
+    private void pollingCheckSmoothScrolling(final int fromX, final int toX,
             final int fromY, final int toY) {
 
         if (fromX == toX && fromY == toY) {
@@ -868,7 +868,7 @@
         }
 
         if (fromY != toY) {
-            new DelayedCheck() {
+            new PollingCheck() {
                 @Override
                 protected boolean check() {
                     return isInRange(mScrollView.getScrollY(), fromY, toY);
@@ -877,7 +877,7 @@
         }
 
         if (fromX != toX) {
-            new DelayedCheck() {
+            new PollingCheck() {
                 @Override
                 protected boolean check() {
                     return isInRange(mScrollView.getScrollX(), fromX, toX);
@@ -885,7 +885,7 @@
             }.run();
         }
 
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return toX == mScrollView.getScrollX() && toY == mScrollView.getScrollY();
@@ -893,8 +893,8 @@
         }.run();
     }
 
-    private void delayedCheckFling(final int startPosition, final boolean movingDown) {
-        new DelayedCheck() {
+    private void pollingCheckFling(final int startPosition, final boolean movingDown) {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 if (movingDown) {
@@ -904,7 +904,7 @@
             }
         };
 
-        new DelayedCheck() {
+        new PollingCheck() {
             private int mPreviousScrollY = mScrollView.getScrollY();
 
             @Override
diff --git a/tests/tests/widget/src/android/widget/cts/SlidingDrawerTest.java b/tests/tests/widget/src/android/widget/cts/SlidingDrawerTest.java
index 3207a15..70310de 100644
--- a/tests/tests/widget/src/android/widget/cts/SlidingDrawerTest.java
+++ b/tests/tests/widget/src/android/widget/cts/SlidingDrawerTest.java
@@ -28,13 +28,13 @@
 
 import android.app.Activity;
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
 import android.util.AttributeSet;
 import android.util.Xml;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.ImageView;
 import android.widget.SlidingDrawer;
 import android.widget.TextView;
@@ -192,7 +192,7 @@
         assertFalse(drawer.isOpened());
         assertEquals(View.GONE, content.getVisibility());
 
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return !drawer.isMoving();
@@ -210,7 +210,7 @@
         assertTrue(drawer.isOpened());
         assertEquals(View.GONE, content.getVisibility());
 
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return !drawer.isMoving();
@@ -253,7 +253,7 @@
         assertFalse(drawer.isOpened());
         assertEquals(View.GONE, content.getVisibility());
 
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return !drawer.isMoving();
@@ -271,7 +271,7 @@
         assertTrue(drawer.isOpened());
         assertEquals(View.GONE, content.getVisibility());
 
-        new DelayedCheck() {
+        new PollingCheck() {
             @Override
             protected boolean check() {
                 return !drawer.isMoving();
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index c714d8a..dcf574c 100755
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -35,6 +35,7 @@
 import android.content.Intent;
 import android.content.res.ColorStateList;
 import android.content.res.Resources.NotFoundException;
+import android.cts.util.PollingCheck;
 import android.graphics.Bitmap;
 import android.graphics.Color;
 import android.graphics.Paint;
@@ -86,7 +87,6 @@
 import android.view.ContextMenu.ContextMenuInfo;
 import android.view.View.OnCreateContextMenuListener;
 import android.view.View.OnLongClickListener;
-import android.view.animation.cts.DelayedCheck;
 import android.view.inputmethod.BaseInputConnection;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.ExtractedText;
@@ -2580,7 +2580,7 @@
         mInstrumentation.waitForIdleSync();
 
         // it will get transformed after a while
-        new DelayedCheck(TIMEOUT) {
+        new PollingCheck(TIMEOUT) {
             @Override
             protected boolean check() {
                 // "******"
@@ -3432,7 +3432,7 @@
 
         // wait for the marquee to run
         // fading is shown on both sides if the marquee runs for a while
-        new DelayedCheck(TIMEOUT) {
+        new PollingCheck(TIMEOUT) {
             @Override
             protected boolean check() {
                 return textView.getLeftFadingEdgeStrength() > 0.0f
@@ -3446,7 +3446,7 @@
         // wait for the marquee to continue
         // the left fading becomes thicker while the right fading becomes thiner
         // as the text moves towards left
-        new DelayedCheck(TIMEOUT) {
+        new PollingCheck(TIMEOUT) {
             @Override
             protected boolean check() {
                 return leftFadingEdgeStrength < textView.getLeftFadingEdgeStrength()
diff --git a/tests/tests/widget/src/android/widget/cts/ToastTest.java b/tests/tests/widget/src/android/widget/cts/ToastTest.java
index c54b205..c5f1c9f 100644
--- a/tests/tests/widget/src/android/widget/cts/ToastTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ToastTest.java
@@ -26,6 +26,7 @@
 
 import android.app.Activity;
 import android.app.Instrumentation;
+import android.cts.util.PollingCheck;
 import android.graphics.drawable.Drawable;
 import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;
@@ -33,7 +34,6 @@
 import android.view.Gravity;
 import android.view.View;
 import android.view.WindowManager;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.ImageView;
 import android.widget.Toast;
 
@@ -78,7 +78,7 @@
     }
 
     private void assertShowToast(final View view) {
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return null != view.getParent();
@@ -88,7 +88,7 @@
 
     private void assertShowAndHide(final View view) {
         assertShowToast(view);
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return null == view.getParent();
diff --git a/tests/tests/widget/src/android/widget/cts/VideoViewTest.java b/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
index 57ea598..6b3cc4e 100644
--- a/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/VideoViewTest.java
@@ -26,13 +26,13 @@
 import android.app.Activity;
 import android.app.Instrumentation;
 import android.content.Context;
+import android.cts.util.PollingCheck;
 import android.media.MediaPlayer;
 import android.media.MediaPlayer.OnCompletionListener;
 import android.media.MediaPlayer.OnErrorListener;
 import android.media.MediaPlayer.OnPreparedListener;
 import android.test.ActivityInstrumentationTestCase2;
 import android.view.View.MeasureSpec;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.MediaController;
 import android.widget.VideoView;
 
@@ -214,7 +214,7 @@
                 mVideoView.setVideoPath(mVideoPath);
             }
         });
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return preparedListener.isTriggered();
@@ -228,7 +228,7 @@
             }
         });
         // wait time is longer than duration in case system is sluggish
-        new DelayedCheck(mVideoView.getDuration() + TIME_OUT) {
+        new PollingCheck(mVideoView.getDuration() + TIME_OUT) {
             @Override
             protected boolean check() {
                 return completionListener.isTriggered();
@@ -254,7 +254,7 @@
         });
         mInstrumentation.waitForIdleSync();
 
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return listener.isTriggered();
@@ -278,7 +278,7 @@
         });
         mInstrumentation.waitForIdleSync();
 
-        new DelayedCheck(TIME_OUT) {
+        new PollingCheck(TIME_OUT) {
             @Override
             protected boolean check() {
                 return prepareListener.isTriggered();
diff --git a/tests/tests/widget/src/android/widget/cts/ZoomButtonTest.java b/tests/tests/widget/src/android/widget/cts/ZoomButtonTest.java
index 4bb412c..f98528a 100644
--- a/tests/tests/widget/src/android/widget/cts/ZoomButtonTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ZoomButtonTest.java
@@ -27,13 +27,13 @@
 import org.xmlpull.v1.XmlPullParser;
 
 import android.app.Activity;
+import android.cts.util.PollingCheck;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
 import android.util.AttributeSet;
 import android.util.Xml;
 import android.view.View;
 import android.view.View.OnClickListener;
-import android.view.animation.cts.DelayedCheck;
 import android.widget.ListView;
 import android.widget.ZoomButton;
 
@@ -157,7 +157,7 @@
 
         assertFalse(listener.hasOnClickCalled());
         mZoomButton.performLongClick();
-        new DelayedCheck(speed + 500) {
+        new PollingCheck(speed + 500) {
             @Override
             protected boolean check() {
                 return listener.hasOnClickCalled();
diff --git a/tools/utils/host_config.xml b/tools/utils/host_config.xml
index 1a99e75..661b1a3 100644
--- a/tools/utils/host_config.xml
+++ b/tools/utils/host_config.xml
@@ -34,7 +34,7 @@
     <!-- Max time [ms] from start of package in batch mode and the first test status update. -->
     <IntValue name="batchStartTimeoutMs" value="1800000" />
     <!-- Max time [ms] from start of test in individual mode to the first test status update. -->
-    <IntValue name="individualStartTimeoutMs" value="600000" />
+    <IntValue name="individualStartTimeoutMs" value="300000" />
     <!-- Timeout [ms] for the signature check. -->
     <IntValue name="signatureTestTimeoutMs" value="600000" />
     <!-- Timeout [ms] for package installations. -->