Merge "Disable ui toolkit hardwareRendering for android.opengl.cts package" into lmp-dev
diff --git a/tests/Android.mk b/tests/Android.mk
index 19dafe0..39a27fe 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -19,7 +19,6 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)\
               $(call all-renderscript-files-under, src)\
-              src/android/app/cts/ISecondary.aidl
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 3802c73..3cbe53c 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -80,5 +80,19 @@
     "android.admin.cts.DevicePolicyManagerTest#testGetMaximumFailedPasswordsForWipe"
   ],
   bug: 17496766
+},
+{
+  description: "instrumentation target context and test context are the same after move test target inside the test itself",
+  names: [
+    "android.app.cts.InstrumentationTest#testContext"
+  ],
+  bug: 17614217
+},
+{
+  description: "Current implementation of uninstallAllUserCaCerts does not throw expected security exception, wait for fix from framework",
+  names: [
+    "android.admin.cts.DevicePolicyManagerTest#testUninstallAllUserCaCerts_failIfNotProfileOwner"
+  ],
+  bug: 17508787
 }
 ]
diff --git a/tests/src/android/text/EmojiStubActivity.java b/tests/src/android/text/EmojiStubActivity.java
deleted file mode 100644
index 8d09250..0000000
--- a/tests/src/android/text/EmojiStubActivity.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.text.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.webkit.WebView;
-import android.webkit.cts.NullWebViewUtils;
-
-public class EmojiStubActivity extends Activity {
-    private WebView mWebView;
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        try {
-            super.onCreate(savedInstanceState);
-            setContentView(R.layout.webview_layout);
-            mWebView = (WebView) findViewById(R.id.web_page);
-        } catch (Exception e) {
-            NullWebViewUtils.determineIfWebViewAvailable(this, e);
-        }
-    }
-
-    public WebView getWebView() {
-        return mWebView;
-    }
-
-    @Override
-    public void onDestroy() {
-        if (mWebView != null) {
-            mWebView.destroy();
-        }
-        super.onDestroy();
-    }
-}
diff --git a/tests/src/android/text/format/cts/LocaleUtils.java b/tests/src/android/text/format/cts/LocaleUtils.java
deleted file mode 100644
index 131d745..0000000
--- a/tests/src/android/text/format/cts/LocaleUtils.java
+++ /dev/null
@@ -1,31 +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.text.format.cts;
-
-import android.content.Context;
-
-import java.util.Locale;
-
-public class LocaleUtils {
-
-    /** Return whether or not the given locale is the device's current locale. */
-    public static boolean isCurrentLocale(Context context, Locale locale) {
-        // TODO: Change the locale on the device using public API if it becomes available.
-        Locale currentLocale = context.getResources().getConfiguration().locale;
-        return locale.equals(currentLocale);
-    }
-}
diff --git a/tests/src/android/text/method/cts/KeyListenerStubActivity.java b/tests/src/android/text/method/cts/KeyListenerStubActivity.java
deleted file mode 100644
index 149ad87..0000000
--- a/tests/src/android/text/method/cts/KeyListenerStubActivity.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.text.method.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.text.method.BaseKeyListener;
-import android.text.method.DateKeyListener;
-import android.text.method.DateTimeKeyListener;
-import android.text.method.DigitsKeyListener;
-import android.text.method.MultiTapKeyListener;
-import android.text.method.NumberKeyListener;
-import android.text.method.QwertyKeyListener;
-import android.text.method.TextKeyListener;
-import android.text.method.TimeKeyListener;
-import android.util.Log;
-
-/**
- * This Activity is used for testing:
- * {@link DigitsKeyListener}
- * {@link BaseKeyListener}
- * {@link MultiTapKeyListener}
- * {@link NumberKeyListener}
- * {@link QwertyKeyListener}
- * {@link TextKeyListener}
- * {@link DateKeyListener}
- * {@link DateTimeKeyListener}
- * {@link TimeKeyListener}
- *
- * @see DigitsKeyListener
- * @see BaseKeyListener
- * @see MultiTapKeyListener
- * @see NumberKeyListener
- * @see QwertyKeyListener
- * @see TextKeyListener
- * @see DateKeyListener
- * @see DateTimeKeyListener
- * @see TimeKeyListener
- */
-
-public class KeyListenerStubActivity extends Activity {
-    private boolean mHasWindowFocus = false;
-    private Object mHasWindowFocusLock = new Object();
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.keylistener_layout);
-    }
-
-    @Override
-    public void onWindowFocusChanged(boolean hasFocus) {
-        super.onWindowFocusChanged(hasFocus);
-        if (!hasFocus) {
-            Log.w("KeyListenerStubActivity", "KeyListenerStubActivity lost window focus");
-        }
-        synchronized(mHasWindowFocusLock) {
-            mHasWindowFocus = hasFocus;
-            mHasWindowFocusLock.notify();
-        }
-    }
-
-    /**
-     * Blocks the calling thread until the {@link KeyListenerStubActivity} has window focus or the
-     * specified duration (in milliseconds) has passed.
-     */
-    public boolean waitForWindowFocus(long durationMillis) {
-        long elapsedMillis = SystemClock.elapsedRealtime();
-        synchronized(mHasWindowFocusLock) {
-            mHasWindowFocus = hasWindowFocus();
-            while (!mHasWindowFocus && durationMillis > 0) {
-                long newElapsedMillis = SystemClock.elapsedRealtime();
-                durationMillis -= (newElapsedMillis - elapsedMillis);
-                elapsedMillis = newElapsedMillis;
-                if (durationMillis > 0) {
-                    try {
-                        mHasWindowFocusLock.wait(durationMillis);
-                    } catch (InterruptedException e) {
-                    }
-                }
-            }
-            return mHasWindowFocus;
-        }
-    }
-}
diff --git a/tests/src/android/text/method/cts/StubActivity.java b/tests/src/android/text/method/cts/StubActivity.java
deleted file mode 100644
index f3dad52..0000000
--- a/tests/src/android/text/method/cts/StubActivity.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.text.method.cts;
-
-import android.app.Activity;
-import android.text.method.ArrowKeyMovementMethod;
-import android.text.method.LinkMovementMethod;
-import android.text.method.ScrollingMovementMethod;
-
-/**
- * This Activity is used for testing:
- * {@link LinkMovementMethod}
- * {@link ArrowKeyMovementMethod}
- * {@link ScrollingMovementMethod}
- *
- * The content view will be set in the test cases.
- *
- * @see LinkMovementMethodTest
- * @see ArrowKeyMovementMethodTest
- * @see ScrollingMovementMethodTest
- */
-public class StubActivity extends Activity {
-}
diff --git a/tests/src/android/text/method/cts/TextMethodUtils.java b/tests/src/android/text/method/cts/TextMethodUtils.java
deleted file mode 100644
index 0785cff..0000000
--- a/tests/src/android/text/method/cts/TextMethodUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.text.method.cts;
-
-import android.view.KeyEvent;
-
-import junit.framework.Assert;
-
-public class TextMethodUtils {
-    /**
-     * Assert that two char arrays are equal.
-     *
-     * @param expected the expected char array.
-     * @param actual the actual char array.
-     */
-    public static void assertEquals(char[] expected, char[] actual) {
-        if (expected != actual) {
-            if (expected == null || actual == null) {
-                Assert.fail("the char arrays are not equal");
-            }
-
-            Assert.assertEquals(String.valueOf(expected), String.valueOf(actual));
-        }
-    }
-
-    /**
-     * Get an unaccepted key code.
-     *
-     * @param acceptedChars accepted chars array.
-     * @return return key code if we find unaccepted one, or return -1.
-     */
-    public static int getUnacceptedKeyCode(char[] acceptedChars) {
-        for (int keyCode = KeyEvent.KEYCODE_A; keyCode <= KeyEvent.KEYCODE_Z; keyCode++) {
-            KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
-            if ('\0' == event.getMatch(acceptedChars)) {
-                return keyCode;
-            }
-        }
-        return -1;
-    }
-}
diff --git a/tests/src/android/text/style/cts/MockURLSpanTestActivity.java b/tests/src/android/text/style/cts/MockURLSpanTestActivity.java
deleted file mode 100644
index 1edb3e0..0000000
--- a/tests/src/android/text/style/cts/MockURLSpanTestActivity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.text.style.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-/**
- * A Mock application for {@link URLSpan} test.
- */
-public class MockURLSpanTestActivity extends Activity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.urlspan_layout);
-    }
-}
diff --git a/tests/src/android/text/style/cts/URLSpanStubActivity.java b/tests/src/android/text/style/cts/URLSpanStubActivity.java
deleted file mode 100644
index a09a83e..0000000
--- a/tests/src/android/text/style/cts/URLSpanStubActivity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.text.style.cts;
-
-import com.android.cts.stub.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-/**
- * A minimal application for {@link URLSpan} test.
- */
-public class URLSpanStubActivity extends Activity {
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.urlspan_layout);
-    }
-}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
index 43acbcd..f8cf4dd 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityWindowQueryTest.java
@@ -29,12 +29,14 @@
 import android.graphics.Rect;
 import android.os.SystemClock;
 import android.test.suitebuilder.annotation.MediumTest;
-import android.util.Log;
+import android.view.Gravity;
+import android.view.WindowManager;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
 import android.view.accessibility.AccessibilityWindowInfo;
 
+import android.widget.Button;
 import com.android.cts.accessibilityservice.R;
 
 import java.util.ArrayList;
@@ -268,152 +270,26 @@
     }
 
     @MediumTest
-    public void testInteractWithNavBarWindow() throws Exception {
-        setAccessInteractiveWindowsFlag();
-        try {
-            final UiAutomation uiAutomation = getInstrumentation().getUiAutomation();
-            uiAutomation.executeAndWaitForEvent(new Runnable() {
-                @Override
-                public void run() {
-                    AccessibilityWindowInfo window = uiAutomation.getWindows().get(0);
-                    assertTrue(window.getRoot().performAction(
-                            AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS));
-                }
-            }, new UiAutomation.AccessibilityEventFilter() {
-                @Override
-                public boolean accept(AccessibilityEvent event) {
-                    return event.getEventType() ==
-                            AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
-                }
-            }, TIMEOUT_ASYNC_PROCESSING);
-        } finally {
-            ensureAccessibilityFocusCleared();
-            clearAccessInteractiveWindowsFlag();
-        }
-    }
-
-    @MediumTest
-    public void testInteractWithStatusBarWindow() throws Exception {
-        setAccessInteractiveWindowsFlag();
-        try {
-            final UiAutomation uiAutomation = getInstrumentation().getUiAutomation();
-            uiAutomation.executeAndWaitForEvent(new Runnable() {
-                @Override
-                public void run() {
-                    AccessibilityWindowInfo window = uiAutomation.getWindows().get(1);
-                    assertTrue(window.getRoot().performAction(
-                            AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS));
-
-                }
-            }, new UiAutomation.AccessibilityEventFilter() {
-                @Override
-                public boolean accept(AccessibilityEvent event) {
-                    return event.getEventType() ==
-                            AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED;
-                }
-            }, TIMEOUT_ASYNC_PROCESSING);
-        } finally {
-            ensureAccessibilityFocusCleared();
-            clearAccessInteractiveWindowsFlag();
-        }
-    }
-
-    @MediumTest
     public void testSingleAccessibilityFocusAcrossWindows() throws Exception {
         setAccessInteractiveWindowsFlag();
         try {
-            final UiAutomation uiAutomation = getInstrumentation().getUiAutomation();
+            // Add two more windows.
+            addTwoAppPanelWindows();
 
-            uiAutomation.waitForIdle(TIMEOUT_WINDOW_STATE_IDLE, TIMEOUT_ASYNC_PROCESSING);
-
-            getInstrumentation().getUiAutomation().executeAndWaitForEvent(new Runnable() {
-                @Override
-                public void run() {
-                    // Set focus in the first window.
-                    List<AccessibilityWindowInfo> windows = uiAutomation.getWindows();
-                    AccessibilityNodeInfo firstWindowRoot = windows.get(0).getRoot();
-                    assertTrue(firstWindowRoot.performAction(
-                            AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS));
-                }
-            }, new UiAutomation.AccessibilityEventFilter() {
-                @Override
-                public boolean accept(AccessibilityEvent event) {
-                    return event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED;
-                }
-            }, TIMEOUT_ASYNC_PROCESSING);
-
-            // Wait for things to settle.
-            waitForIdle();
-
-            List<AccessibilityWindowInfo> windows = uiAutomation.getWindows();
-
-            AccessibilityNodeInfo firstWindowRoot = windows.get(0).getRoot();
-            AccessibilityNodeInfo secondWindowRoot = windows.get(1).getRoot();
-            AccessibilityNodeInfo thirdWindowRoot = windows.get(2).getRoot();
-
-            // Ensure accessibility focus is where we put it.
-            assertTrue(windows.get(0).isAccessibilityFocused());
-
+            // Put accessibility focus in the first app window.
+            ensureAppWindowFocusedOrFail(0);
             // Make sure there only one accessibility focus.
-            assertEquals(uiAutomation.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY), firstWindowRoot);
-            assertEquals(firstWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY), firstWindowRoot);
-            assertNull(secondWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
-            assertNull(thirdWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
+            assertSingleAccessibilityFocus();
 
-
-            // Set focus in the second window.
-            assertTrue(secondWindowRoot.performAction(
-                    AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS));
-
-            // Wait for things to settle.
-            uiAutomation.waitForIdle(TIMEOUT_WINDOW_STATE_IDLE, TIMEOUT_ASYNC_PROCESSING);
-
+            // Put accessibility focus in the second app window.
+            ensureAppWindowFocusedOrFail(1);
             // Make sure there only one accessibility focus.
-            assertEquals(uiAutomation.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY), secondWindowRoot);
-            assertEquals(secondWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY), secondWindowRoot);
-            assertNull(firstWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
-            assertNull(thirdWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
+            assertSingleAccessibilityFocus();
 
-
-            // Set focus in the third window.
-            assertTrue(thirdWindowRoot.performAction(
-                    AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS));
-
-            // Wait for things to settle.
-            uiAutomation.waitForIdle(TIMEOUT_WINDOW_STATE_IDLE, TIMEOUT_ASYNC_PROCESSING);
-
+            // Put accessibility focus in the third app window.
+            ensureAppWindowFocusedOrFail(2);
             // Make sure there only one accessibility focus.
-            assertEquals(uiAutomation.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY), thirdWindowRoot);
-            assertEquals(thirdWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY), thirdWindowRoot);
-            assertNull(firstWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
-            assertNull(secondWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
-
-
-            // Clear focus.
-            assertTrue(thirdWindowRoot.performAction(
-                    AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS));
-
-            // Make sure there is not accessibility focus.
-            assertNull(uiAutomation.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
-            assertNull(firstWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
-            assertNull(secondWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
-            assertNull(thirdWindowRoot.findFocus(
-                    AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
+            assertSingleAccessibilityFocus();
         } finally {
             ensureAccessibilityFocusCleared();
             clearAccessInteractiveWindowsFlag();
@@ -761,6 +637,152 @@
         }
     }
 
+    private void assertSingleAccessibilityFocus() {
+        UiAutomation uiAutomation = getInstrumentation().getUiAutomation();
+        List<AccessibilityWindowInfo> windows = uiAutomation.getWindows();
+        AccessibilityWindowInfo focused = null;
+
+        final int windowCount = windows.size();
+        for (int i = 0; i < windowCount; i++) {
+            AccessibilityWindowInfo window = windows.get(i);
+
+            if (window.isAccessibilityFocused()) {
+                if (focused == null) {
+                    focused = window;
+
+                    AccessibilityNodeInfo root = window.getRoot();
+                    assertEquals(uiAutomation.findFocus(
+                            AccessibilityNodeInfo.FOCUS_ACCESSIBILITY), root);
+                    assertEquals(root.findFocus(
+                            AccessibilityNodeInfo.FOCUS_ACCESSIBILITY), root);
+                } else {
+                    throw new AssertionError("Duplicate accessibility focus");
+                }
+            } else {
+                assertNull(window.getRoot().findFocus(
+                        AccessibilityNodeInfo.FOCUS_ACCESSIBILITY));
+            }
+        }
+    }
+
+    private void ensureAppWindowFocusedOrFail(int appWindowIndex) throws TimeoutException {
+        UiAutomation uiAutomation = getInstrumentation().getUiAutomation();
+        List<AccessibilityWindowInfo> windows = uiAutomation.getWindows();
+        AccessibilityWindowInfo focusTareget = null;
+
+        int visitedAppWindows = -1;
+        final int windowCount = windows.size();
+        for (int i = 0; i < windowCount; i++) {
+            AccessibilityWindowInfo window = windows.get(i);
+            if (window.getType() == AccessibilityWindowInfo.TYPE_APPLICATION) {
+                visitedAppWindows++;
+                if (appWindowIndex <= visitedAppWindows) {
+                    focusTareget = window;
+                    break;
+                }
+            }
+        }
+
+        if (focusTareget == null) {
+            throw new IllegalStateException("Couldn't find app window: " + appWindowIndex);
+        }
+
+        if (focusTareget.isAccessibilityFocused()) {
+            return;
+        }
+
+        final AccessibilityWindowInfo finalFocusTarget = focusTareget;
+        uiAutomation.executeAndWaitForEvent(new Runnable() {
+            @Override
+            public void run() {
+                assertTrue(finalFocusTarget.getRoot().performAction(
+                        AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS));
+            }
+        }, new UiAutomation.AccessibilityEventFilter() {
+            @Override
+            public boolean accept(AccessibilityEvent event) {
+                return event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED;
+            }
+        }, TIMEOUT_ASYNC_PROCESSING);
+
+        windows = uiAutomation.getWindows();
+        for (int i = 0; i < windowCount; i++) {
+            AccessibilityWindowInfo window = windows.get(i);
+            if (window.getId() == focusTareget.getId()) {
+                assertTrue(window.isAccessibilityFocused());
+                break;
+            }
+        }
+    }
+
+    private void addTwoAppPanelWindows() throws TimeoutException {
+        final UiAutomation uiAutomation = getInstrumentation().getUiAutomation();
+
+        uiAutomation.waitForIdle(TIMEOUT_WINDOW_STATE_IDLE, TIMEOUT_ASYNC_PROCESSING);
+
+        // Add the first window.
+        uiAutomation.executeAndWaitForEvent(new Runnable() {
+            @Override
+            public void run() {
+                getInstrumentation().runOnMainSync(new Runnable() {
+                    @Override
+                    public void run() {
+                        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
+                        params.gravity = Gravity.TOP;
+                        params.width = WindowManager.LayoutParams.MATCH_PARENT;
+                        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
+                        params.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+                                | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
+                                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+                                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
+                        params.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
+                        params.token = getActivity().getWindow().getDecorView().getWindowToken();
+
+                        Button button = new Button(getActivity());
+                        button.setText(R.string.button1);
+                        getActivity().getWindowManager().addView(button, params);
+                    }
+                });
+            }
+        }, new UiAutomation.AccessibilityEventFilter() {
+            @Override
+            public boolean accept(AccessibilityEvent event) {
+                return event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED;
+            }
+        }, TIMEOUT_ASYNC_PROCESSING);
+
+        // Add the second window.
+        uiAutomation.executeAndWaitForEvent(new Runnable() {
+            @Override
+            public void run() {
+                getInstrumentation().runOnMainSync(new Runnable() {
+                    @Override
+                    public void run() {
+                        WindowManager.LayoutParams params = new WindowManager.LayoutParams();
+                        params.gravity = Gravity.BOTTOM;
+                        params.width = WindowManager.LayoutParams.MATCH_PARENT;
+                        params.height = WindowManager.LayoutParams.WRAP_CONTENT;
+                        params.flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
+                                | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
+                                | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+                                | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
+                        params.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
+                        params.token = getActivity().getWindow().getDecorView().getWindowToken();
+
+                        Button button = new Button(getActivity());
+                        button.setText(R.string.button2);
+                        getActivity().getWindowManager().addView(button, params);
+                    }
+                });
+            }
+        }, new UiAutomation.AccessibilityEventFilter() {
+            @Override
+            public boolean accept(AccessibilityEvent event) {
+                return event.getEventType() == AccessibilityEvent.TYPE_WINDOWS_CHANGED;
+            }
+        }, TIMEOUT_ASYNC_PROCESSING);
+    }
+
     private void setAccessInteractiveWindowsFlag () {
         UiAutomation uiAutomation = getInstrumentation().getUiAutomation();
         AccessibilityServiceInfo info = uiAutomation.getServiceInfo();
diff --git a/tests/tests/accounts/Android.mk b/tests/tests/accounts/Android.mk
index 39dbfb1..1579822 100644
--- a/tests/tests/accounts/Android.mk
+++ b/tests/tests/accounts/Android.mk
@@ -21,7 +21,7 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES += android-common ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/accounts/AndroidManifest.xml b/tests/tests/accounts/AndroidManifest.xml
index cf7f7d8..22362ab 100644
--- a/tests/tests/accounts/AndroidManifest.xml
+++ b/tests/tests/accounts/AndroidManifest.xml
@@ -28,6 +28,13 @@
     <application>
         <uses-library android:name="android.test.runner" />
 
+        <activity android:name="android.accounts.cts.AccountDummyActivity" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
         <service android:name="MockAccountService" android:exported="true"
                  android:process="android.accounts.cts">
             <intent-filter>
diff --git a/tests/tests/accounts/src/android/accounts/cts/AccountDummyActivity.java b/tests/tests/accounts/src/android/accounts/cts/AccountDummyActivity.java
new file mode 100644
index 0000000..a345dcc
--- /dev/null
+++ b/tests/tests/accounts/src/android/accounts/cts/AccountDummyActivity.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.accounts.cts;
+
+import android.app.Activity;
+
+/**
+ * An activity.
+ */
+public class AccountDummyActivity extends Activity {
+}
diff --git a/tests/tests/accounts/src/android/accounts/cts/AccountManagerTest.java b/tests/tests/accounts/src/android/accounts/cts/AccountManagerTest.java
index f443d30..e5cc45a 100644
--- a/tests/tests/accounts/src/android/accounts/cts/AccountManagerTest.java
+++ b/tests/tests/accounts/src/android/accounts/cts/AccountManagerTest.java
@@ -28,8 +28,9 @@
 import android.content.Context;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.StrictMode;
-import android.test.AndroidTestCase;
+import android.test.ActivityInstrumentationTestCase2;
 
 import java.io.IOException;
 import java.util.concurrent.CountDownLatch;
@@ -41,9 +42,9 @@
  *  adb shell am instrument
  *   -e debug false -w
  *   -e class android.accounts.cts.AccountManagerTest
- * android.accounts.cts/android.test.InstrumentationTestRunner
+ * android.accounts.cts/android.support.test.runner.AndroidJUnitRunner
  */
-public class AccountManagerTest extends AndroidTestCase {
+public class AccountManagerTest extends ActivityInstrumentationTestCase2<AccountDummyActivity> {
 
     public static final String ACCOUNT_NAME = "android.accounts.cts.account.name";
     public static final String ACCOUNT_NEW_NAME = "android.accounts.cts.account.name.rename";
@@ -70,7 +71,6 @@
 
     public static final String[] REQUIRED_FEATURES = new String[] { FEATURE_1, FEATURE_2 };
 
-    public static final Activity ACTIVITY = new Activity();
     public static final Bundle OPTIONS_BUNDLE = new Bundle();
 
     public static final Bundle USERDATA_BUNDLE = new Bundle();
@@ -94,18 +94,27 @@
         return mockAuthenticator;
     }
 
+    private Activity mActivity;
+    private Context mContext;
+
+    public AccountManagerTest() {
+        super(AccountDummyActivity.class);
+    }
+
     @Override
     public void setUp() throws Exception {
         super.setUp();
+        mActivity = getActivity();
+        mContext = getInstrumentation().getTargetContext();
 
         OPTIONS_BUNDLE.putString(OPTION_NAME_1, OPTION_VALUE_1);
         OPTIONS_BUNDLE.putString(OPTION_NAME_2, OPTION_VALUE_2);
 
         USERDATA_BUNDLE.putString(USERDATA_NAME_1, USERDATA_VALUE_1);
 
-        getMockAuthenticator(getContext());
+        getMockAuthenticator(mContext);
 
-        am = AccountManager.get(getContext());
+        am = AccountManager.get(mContext);
     }
 
     @Override
@@ -264,7 +273,7 @@
      * Test singleton
      */
     public void testGet() {
-        assertNotNull(AccountManager.get(getContext()));
+        assertNotNull(AccountManager.get(mContext));
     }
 
     /**
@@ -278,7 +287,7 @@
                 AUTH_TOKEN_TYPE,
                 REQUIRED_FEATURES,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 null /* callback */,
                 null /* handler */);
 
@@ -302,7 +311,7 @@
             AuthenticatorException, OperationCanceledException {
 
         testAddAccountWithCallbackAndHandler(null /* handler */);
-        testAddAccountWithCallbackAndHandler(new Handler());
+        testAddAccountWithCallbackAndHandler(new Handler(Looper.getMainLooper()));
     }
 
     private void testAddAccountWithCallbackAndHandler(Handler handler) throws IOException,
@@ -343,7 +352,7 @@
                 AUTH_TOKEN_TYPE,
                 REQUIRED_FEATURES,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 callback,
                 handler);
 
@@ -549,7 +558,7 @@
         addAccountExplicitly(ACCOUNT, ACCOUNT_PASSWORD, null /* userData */);
 
         testGetAccountsByTypeAndFeaturesWithCallbackAndHandler(null /* handler */);
-        testGetAccountsByTypeAndFeaturesWithCallbackAndHandler(new Handler());
+        testGetAccountsByTypeAndFeaturesWithCallbackAndHandler(new Handler(Looper.getMainLooper()));
     }
 
     private void testGetAccountsByTypeAndFeaturesWithCallbackAndHandler(Handler handler) throws
@@ -702,7 +711,7 @@
         addAccountExplicitly(ACCOUNT, ACCOUNT_PASSWORD, null /* userData */);
 
         testGetAuthTokenWithCallbackAndHandler(null /* handler */);
-        testGetAuthTokenWithCallbackAndHandler(new Handler());
+        testGetAuthTokenWithCallbackAndHandler(new Handler(Looper.getMainLooper()));
     }
 
     private void testGetAuthTokenWithCallbackAndHandler(Handler handler) throws IOException,
@@ -764,7 +773,7 @@
         AccountManagerFuture<Bundle> futureBundle = am.getAuthToken(ACCOUNT,
                 AUTH_TOKEN_TYPE,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 null /* no callback */,
                 null /* no handler */
         );
@@ -793,7 +802,7 @@
         addAccountExplicitly(ACCOUNT, ACCOUNT_PASSWORD, null /* userData */);
 
         testGetAuthTokenWithOptionsAndCallbackAndHandler(null /* handler */);
-        testGetAuthTokenWithOptionsAndCallbackAndHandler(new Handler());
+        testGetAuthTokenWithOptionsAndCallbackAndHandler(new Handler(Looper.getMainLooper()));
     }
 
     private void testGetAuthTokenWithOptionsAndCallbackAndHandler(Handler handler) throws
@@ -827,7 +836,7 @@
         AccountManagerFuture<Bundle> futureBundle = am.getAuthToken(ACCOUNT,
                 AUTH_TOKEN_TYPE,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 callback,
                 handler
         );
@@ -871,7 +880,7 @@
         // Now test with existing features and an activity
         resultBundle = getAuthTokenByFeature(
                 new String[] { NON_EXISTING_FEATURE },
-                ACTIVITY
+                mActivity
         );
 
         // Assert returned result
@@ -903,7 +912,7 @@
         // Now test with existing features and an activity
         resultBundle = getAuthTokenByFeature(
                 REQUIRED_FEATURES,
-                ACTIVITY
+                mActivity
         );
 
         // Assert returned result
@@ -926,7 +935,7 @@
 
         AccountManagerFuture<Bundle> futureBundle = am.confirmCredentials(ACCOUNT,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 null /* callback*/,
                 null /* handler */);
 
@@ -945,7 +954,7 @@
         addAccountExplicitly(ACCOUNT, ACCOUNT_PASSWORD, null /* userData */);
 
         testConfirmCredentialsWithCallbackAndHandler(null /* handler */);
-        testConfirmCredentialsWithCallbackAndHandler(new Handler());
+        testConfirmCredentialsWithCallbackAndHandler(new Handler(Looper.getMainLooper()));
     }
 
     private void testConfirmCredentialsWithCallbackAndHandler(Handler handler) throws IOException,
@@ -979,7 +988,7 @@
 
         AccountManagerFuture<Bundle> futureBundle = am.confirmCredentials(ACCOUNT,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 callback,
                 handler);
 
@@ -1004,7 +1013,7 @@
         AccountManagerFuture<Bundle> futureBundle = am.updateCredentials(ACCOUNT,
                 AUTH_TOKEN_TYPE,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 null /* callback*/,
                 null /* handler */);
 
@@ -1025,7 +1034,7 @@
         addAccountExplicitly(ACCOUNT, ACCOUNT_PASSWORD, null /* userData */);
 
         testUpdateCredentialsWithCallbackAndHandler(null /* handler */);
-        testUpdateCredentialsWithCallbackAndHandler(new Handler());
+        testUpdateCredentialsWithCallbackAndHandler(new Handler(Looper.getMainLooper()));
     }
 
     private void testUpdateCredentialsWithCallbackAndHandler(Handler handler) throws IOException,
@@ -1060,7 +1069,7 @@
         AccountManagerFuture<Bundle> futureBundle = am.updateCredentials(ACCOUNT,
                 AUTH_TOKEN_TYPE,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 callback,
                 handler);
 
@@ -1081,7 +1090,7 @@
             OperationCanceledException {
 
         AccountManagerFuture<Bundle> futureBundle = am.editProperties(ACCOUNT_TYPE,
-                ACTIVITY,
+                mActivity,
                 null /* callback */,
                 null /* handler*/);
 
@@ -1098,7 +1107,7 @@
      */
     public void testEditPropertiesWithCallbackAndHandler() {
         testEditPropertiesWithCallbackAndHandler(null /* handler */);
-        testEditPropertiesWithCallbackAndHandler(new Handler());
+        testEditPropertiesWithCallbackAndHandler(new Handler(Looper.getMainLooper()));
     }
 
     private void testEditPropertiesWithCallbackAndHandler(Handler handler) {
@@ -1117,7 +1126,7 @@
         };
 
         AccountManagerFuture<Bundle> futureBundle = am.editProperties(ACCOUNT_TYPE,
-                ACTIVITY,
+                mActivity,
                 callback,
                 handler);
 
@@ -1147,13 +1156,13 @@
         // Need to cleanup intermediate state
         assertTrue(removeAccount(am, ACCOUNT, null /* callback */));
 
-        testAddOnAccountsUpdatedListenerWithHandler(new Handler(),
+        testAddOnAccountsUpdatedListenerWithHandler(new Handler(Looper.getMainLooper()),
                 false /* updateImmediately */);
 
         // Need to cleanup intermediate state
         assertTrue(removeAccount(am, ACCOUNT, null /* callback */));
 
-        testAddOnAccountsUpdatedListenerWithHandler(new Handler(),
+        testAddOnAccountsUpdatedListenerWithHandler(new Handler(Looper.getMainLooper()),
                 true /* updateImmediately */);
     }
 
@@ -1197,7 +1206,7 @@
         // Need to cleanup intermediate state
         assertTrue(removeAccount(am, ACCOUNT, null /* callback */));
 
-        testRemoveOnAccountsUpdatedListenerWithHandler(new Handler());
+        testRemoveOnAccountsUpdatedListenerWithHandler(new Handler(Looper.getMainLooper()));
     }
 
     private void testRemoveOnAccountsUpdatedListenerWithHandler(Handler handler) {
@@ -1234,10 +1243,10 @@
             throws IOException, AuthenticatorException, OperationCanceledException {
 
         assertHasFeature(null /* handler */);
-        assertHasFeature(new Handler());
+        assertHasFeature(new Handler(Looper.getMainLooper()));
 
         assertHasFeatureWithCallback(null /* handler */);
-        assertHasFeatureWithCallback(new Handler());
+        assertHasFeatureWithCallback(new Handler(Looper.getMainLooper()));
     }
 
     private void assertHasFeature(Handler handler)
@@ -1247,7 +1256,7 @@
                 AUTH_TOKEN_TYPE,
                 REQUIRED_FEATURES,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 null /* callback */,
                 null /* handler */);
 
@@ -1338,7 +1347,7 @@
                 AUTH_TOKEN_TYPE,
                 REQUIRED_FEATURES,
                 OPTIONS_BUNDLE,
-                ACTIVITY,
+                mActivity,
                 null /* callback */,
                 null /* handler */);
 
diff --git a/tests/tests/app/Android.mk b/tests/tests/app/Android.mk
index d4387b4..136f072 100644
--- a/tests/tests/app/Android.mk
+++ b/tests/tests/app/Android.mk
@@ -23,12 +23,11 @@
 
 LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common voip-common
 
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner ctstestserver
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+              src/android/app/cts/ISecondary.aidl
 
 LOCAL_PACKAGE_NAME := CtsAppTestCases
 
-LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
-
 include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/app/AndroidManifest.xml b/tests/tests/app/AndroidManifest.xml
index a558564..6cafe80 100644
--- a/tests/tests/app/AndroidManifest.xml
+++ b/tests/tests/app/AndroidManifest.xml
@@ -16,23 +16,273 @@
  -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.android.app.cts">
+    package="com.android.cts.app">
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
-    <application>
+
+    <permission android:name="android.app.cts.permission.TEST_GRANTED"
+        android:protectionLevel="normal"
+            android:label="@string/permlab_testGranted"
+            android:description="@string/permdesc_testGranted">
+        <meta-data android:name="android.app.cts.string" android:value="foo" />
+        <meta-data android:name="android.app.cts.boolean" android:value="true" />
+        <meta-data android:name="android.app.cts.integer" android:value="100" />
+        <meta-data android:name="android.app.cts.color" android:value="#ff000000" />
+        <meta-data android:name="android.app.cts.float" android:value="100.1" />
+        <meta-data android:name="android.app.cts.reference" android:resource="@xml/metadata" />
+    </permission>
+
+    <uses-permission android:name="android.app.cts.permission.TEST_GRANTED" />
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+    <uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+    <application android:label="Android TestCase"
+                android:icon="@drawable/size_48x48"
+                android:maxRecents="1"
+                android:multiArch="true"
+                android:name="android.app.cts.MockApplication"
+                android:supportsRtl="true">
         <uses-library android:name="android.test.runner" />
 
-        <service android:name="android.speech.tts.cts.StubTextToSpeechService">
+        <activity android:name="android.app.cts.ActionBarActivity" />
+
+        <activity android:name="android.app.cts.DialogCtsActivity"
+            android:label="DialogCtsActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize">
             <intent-filter>
-                <action android:name="android.intent.action.TTS_SERVICE" />
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.MockActivity" android:label="MockActivity">
+            <meta-data android:name="android.app.alias"
+                android:resource="@xml/alias" />
+            <meta-data android:name="android.app.intent.filter"
+                android:resource="@xml/intentfilter" />
+        </activity>
+
+        <activity android:name="android.app.cts.MockApplicationActivity"
+            android:label="MockApplicationActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.InstrumentationTestActivity"
+                  android:theme="@style/Theme_NoSwipeDismiss"
+                  android:label="InstrumentationTestActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.DEFAULT" />
+                <data android:mimeType="vnd.android.cursor.dir/person" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.AliasActivityStub">
+            <meta-data android:name="android.app.alias"
+                android:resource="@xml/alias" />
+        </activity>
+
+        <activity android:name="android.app.cts.ChildActivity"
+                        android:label="ChildActivity" />
+
+        <receiver android:name="android.app.cts.MockReceiver">
+            <intent-filter>
+                <action android:name="android.app.cts.PendingIntentTest.TEST_RECEIVER" />
+            </intent-filter>
+        </receiver>
+
+        <service android:name="android.app.cts.MockService" />
+
+        <activity android:name="android.app.cts.SearchManagerCtsActivity"
+                android:label="SearchManagerCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.SEARCH" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
+            <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" />
+        </activity>
+
+        <service android:name="android.app.cts.LocalService">
+            <intent-filter>
+                <action android:name="android.app.cts.activity.SERVICE_LOCAL" />
+            </intent-filter>
+            <meta-data android:name="android.app.cts.string" android:value="foo" />
+            <meta-data android:name="android.app.cts.boolean" android:value="true" />
+            <meta-data android:name="android.app.cts.integer" android:value="100" />
+            <meta-data android:name="android.app.cts.color" android:value="#ff000000" />
+            <meta-data android:name="android.app.cts.float" android:value="100.1" />
+            <meta-data android:name="android.app.cts.reference" android:resource="@xml/metadata" />
         </service>
 
+        <service android:name="android.app.cts.LocalGrantedService"
+             android:permission="android.app.cts.permission.TEST_GRANTED">
+            <intent-filter>
+                <action android:name="android.app.cts.activity.SERVICE_LOCAL_GRANTED" />
+            </intent-filter>
+        </service>
+
+        <service android:name="android.app.cts.LocalDeniedService"
+               android:permission="android.app.cts.permission.TEST_DENIED">
+            <intent-filter>
+                <action android:name="android.app.cts.activity.SERVICE_LOCAL_DENIED" />
+            </intent-filter>
+        </service>
+
+        <activity android:name="android.app.cts.TestedScreen"
+                android:process=":remoteScreen">
+        </activity>
+        <activity android:name="android.app.cts.LocalScreen" android:multiprocess="true">
+        </activity>
+        <activity android:name="android.app.cts.ClearTop" android:multiprocess="true"
+               android:launchMode="singleTop">
+        </activity>
+        <activity android:name="android.app.cts.LocalDialog" android:multiprocess="true"
+               android:theme="@android:style/Theme.Dialog">
+        </activity>
+
+        <activity android:name="android.app.cts.PendingIntentCtsActivity"
+             android:label="PendingIntentCtsActivity"/>
+
+        <activity android:name="android.app.cts.LocalActivityManagerCtsActivity"
+                        android:label="LocalActivityManagerCtsActivity" />
+
+        <activity android:name="android.app.cts.LocalActivityManagerTestHelper"
+            android:label="LocalActivityManagerTestHelper" />
+
+        <activity android:name="android.app.cts.LaunchpadTabActivity" android:multiprocess="true">
+        </activity>
+
+        <activity android:name="android.app.cts.LocalActivity" android:multiprocess="true">
+            <meta-data android:name="android.app.cts.string" android:value="foo" />
+            <meta-data android:name="android.app.cts.boolean" android:value="true" />
+            <meta-data android:name="android.app.cts.integer" android:value="100" />
+            <meta-data android:name="android.app.cts.color" android:value="#ff000000" />
+            <meta-data android:name="android.app.cts.float" android:value="100.1" />
+            <meta-data android:name="android.app.cts.reference" android:resource="@xml/metadata" />
+        </activity>
+
+        <activity android:name="android.app.cts.TestedActivity"
+                android:process=":remoteActivity">
+        </activity>
+
+        <activity android:name="android.app.cts.ExpandableListTestActivity"
+            android:label="ExpandableListTestActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.ChildTabActivity" android:label="ChildTabActivity" />
+
+        <activity android:name="android.app.cts.LauncherActivityStub"
+                  android:label="LauncherActivityStub" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.MockTabActivity" android:label="MockTabActivity" />
+
+        <activity android:name="android.app.cts.AppCtsActivity" android:label="AppCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.DialogCtsActivity"
+                  android:theme="@style/Theme_NoSwipeDismiss"
+                  android:label="DialogCtsActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.ActivityManagerStubFooActivity"
+            android:label="ActivityManagerStubFooActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.ActivityManagerRecentOneActivity"
+            android:label="ActivityManagerRecentOneActivity"
+            android:allowTaskReparenting="true"
+            android:taskAffinity="android.app.cts.recentOne">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.ActivityManagerRecentTwoActivity"
+            android:label="ActivityManagerRecentTwoActivity"
+            android:allowTaskReparenting="true"
+            android:taskAffinity="android.app.cts.recentTwo">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+        </activity>
+
+        <activity android:name="android.app.cts.ActivityManagerStubCrashActivity"
+            android:label="ActivityManagerStubCrashActivity"
+            android:multiprocess="true"
+            android:process=":ActivityManagerStubCrashActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+            </intent-filter>
+        </activity>
+
+        <service android:name="android.app.cts.StubRemoteService"
+            android:process=":remote">
+            <intent-filter>
+                <action
+                    android:name="android.app.cts.ISecondary" />
+                <action
+                    android:name="android.app.REMOTESERVICE" />
+            </intent-filter>
+        </service>
+
+        <activity android:name="android.app.ActivityGroup"
+            android:label="ActivityGroup" />
+
+        <activity android:name="android.app.cts.KeyguardManagerActivity"
+            android:label="KeyguardManagerActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+
+        <service android:name="android.app.cts.IntentServiceStub"/>
+
+        <activity android:name="android.app.cts.LaunchpadActivity"
+                  android:configChanges="keyboardHidden|orientation|screenSize"
+                  android:multiprocess="true">
+        </activity>
+
+        <activity android:name="android.app.cts.ActivityManagerMemoryClassLaunchActivity" />
+
+        <activity android:name="android.app.cts.ActivityManagerMemoryClassTestActivity"
+                android:process=":memoryclass" />
+
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="com.android.cts.stub"
+                     android:targetPackage="com.android.cts.app"
                      android:label="CTS tests of android.app">
         <meta-data android:name="listener"
             android:value="com.android.cts.runner.CtsTestRunListener" />
diff --git a/tests/assets/noiseandchirps b/tests/tests/app/assets/noiseandchirps
similarity index 100%
rename from tests/assets/noiseandchirps
rename to tests/tests/app/assets/noiseandchirps
Binary files differ
diff --git a/tests/assets/noiseandchirps.mp3 b/tests/tests/app/assets/noiseandchirps.mp3
similarity index 100%
rename from tests/assets/noiseandchirps.mp3
rename to tests/tests/app/assets/noiseandchirps.mp3
Binary files differ
diff --git a/tests/assets/noiseandchirps.ogg b/tests/tests/app/assets/noiseandchirps.ogg
similarity index 100%
rename from tests/assets/noiseandchirps.ogg
rename to tests/tests/app/assets/noiseandchirps.ogg
Binary files differ
diff --git a/tests/assets/noiseandchirps.wrong b/tests/tests/app/assets/noiseandchirps.wrong
similarity index 100%
rename from tests/assets/noiseandchirps.wrong
rename to tests/tests/app/assets/noiseandchirps.wrong
Binary files differ
diff --git a/tests/tests/app/res/drawable/icon_black.jpg b/tests/tests/app/res/drawable/icon_black.jpg
new file mode 100644
index 0000000..4c9062a
--- /dev/null
+++ b/tests/tests/app/res/drawable/icon_black.jpg
Binary files differ
diff --git a/tests/tests/app/res/drawable/icon_blue.jpg b/tests/tests/app/res/drawable/icon_blue.jpg
new file mode 100644
index 0000000..9e6c1c8
--- /dev/null
+++ b/tests/tests/app/res/drawable/icon_blue.jpg
Binary files differ
diff --git a/tests/tests/app/res/drawable/icon_green.jpg b/tests/tests/app/res/drawable/icon_green.jpg
new file mode 100644
index 0000000..55a78f2
--- /dev/null
+++ b/tests/tests/app/res/drawable/icon_green.jpg
Binary files differ
diff --git a/tests/tests/app/res/drawable/icon_red.jpg b/tests/tests/app/res/drawable/icon_red.jpg
new file mode 100644
index 0000000..6bc9e1f
--- /dev/null
+++ b/tests/tests/app/res/drawable/icon_red.jpg
Binary files differ
diff --git a/tests/tests/app/res/drawable/icon_yellow.jpg b/tests/tests/app/res/drawable/icon_yellow.jpg
new file mode 100644
index 0000000..e748059
--- /dev/null
+++ b/tests/tests/app/res/drawable/icon_yellow.jpg
Binary files differ
diff --git a/tests/tests/app/res/drawable/ninepatch_0.9.png b/tests/tests/app/res/drawable/ninepatch_0.9.png
new file mode 100644
index 0000000..24019d8
--- /dev/null
+++ b/tests/tests/app/res/drawable/ninepatch_0.9.png
Binary files differ
diff --git a/tests/tests/app/res/drawable/ninepatch_1.9.png b/tests/tests/app/res/drawable/ninepatch_1.9.png
new file mode 100644
index 0000000..c56b1db
--- /dev/null
+++ b/tests/tests/app/res/drawable/ninepatch_1.9.png
Binary files differ
diff --git a/tests/tests/app/res/drawable/pass.jpg b/tests/tests/app/res/drawable/pass.jpg
new file mode 100644
index 0000000..2f4b083
--- /dev/null
+++ b/tests/tests/app/res/drawable/pass.jpg
Binary files differ
diff --git a/tests/tests/app/res/drawable/robot.png b/tests/tests/app/res/drawable/robot.png
new file mode 100644
index 0000000..8a9e698
--- /dev/null
+++ b/tests/tests/app/res/drawable/robot.png
Binary files differ
diff --git a/tests/tests/app/res/drawable/size_48x48.jpg b/tests/tests/app/res/drawable/size_48x48.jpg
new file mode 100644
index 0000000..5c2291e
--- /dev/null
+++ b/tests/tests/app/res/drawable/size_48x48.jpg
Binary files differ
diff --git a/tests/tests/app/res/layout/alert_dialog_text_entry.xml b/tests/tests/app/res/layout/alert_dialog_text_entry.xml
new file mode 100644
index 0000000..8b87a5d
--- /dev/null
+++ b/tests/tests/app/res/layout/alert_dialog_text_entry.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/username_view"
+        android:layout_height="wrap_content"
+        android:layout_width="wrap_content"
+        android:layout_marginLeft="20dip"
+        android:layout_marginRight="20dip"
+        android:text="@string/alert_dialog_username"
+        android:gravity="left"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <EditText
+        android:id="@+id/username_edit"
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_marginLeft="20dip"
+        android:layout_marginRight="20dip"
+        android:scrollHorizontally="true"
+        android:autoText="false"
+        android:capitalize="none"
+        android:gravity="fill_horizontal"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <TextView
+        android:id="@+id/password_view"
+        android:layout_height="wrap_content"
+        android:layout_width="wrap_content"
+        android:layout_marginLeft="20dip"
+        android:layout_marginRight="20dip"
+        android:text="@string/alert_dialog_password"
+        android:gravity="left"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <EditText
+        android:id="@+id/password_edit"
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_marginLeft="20dip"
+        android:layout_marginRight="20dip"
+        android:scrollHorizontally="true"
+        android:autoText="false"
+        android:capitalize="none"
+        android:gravity="fill_horizontal"
+        android:password="true"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+</LinearLayout>
diff --git a/tests/tests/app/res/layout/alert_dialog_text_entry_2.xml b/tests/tests/app/res/layout/alert_dialog_text_entry_2.xml
new file mode 100644
index 0000000..848b342
--- /dev/null
+++ b/tests/tests/app/res/layout/alert_dialog_text_entry_2.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/username_view"
+        android:layout_height="wrap_content"
+        android:layout_width="wrap_content"
+        android:layout_marginLeft="20dip"
+        android:layout_marginRight="20dip"
+        android:text="@string/alert_dialog_username"
+        android:gravity="left" />
+
+    <EditText
+        android:id="@+id/username_edit"
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:layout_marginLeft="20dip"
+        android:layout_marginRight="20dip"
+        android:scrollHorizontally="true"
+        android:autoText="false"
+        android:capitalize="none"
+        android:gravity="fill_horizontal" />
+
+</LinearLayout>
diff --git a/tests/tests/app/res/layout/alertdialog_custom_title.xml b/tests/tests/app/res/layout/alertdialog_custom_title.xml
new file mode 100644
index 0000000..ff36f2a
--- /dev/null
+++ b/tests/tests/app/res/layout/alertdialog_custom_title.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/alertdialog_custom_title"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:gravity="center_vertical|center_horizontal"
+    android:textAppearance="?android:attr/textAppearanceMedium"
+    android:text="@string/hello_world"/>
diff --git a/tests/tests/app/res/layout/app_activity.xml b/tests/tests/app/res/layout/app_activity.xml
new file mode 100644
index 0000000..8b7206f
--- /dev/null
+++ b/tests/tests/app/res/layout/app_activity.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<!-- Demonstrates receiving activity results.
+     See corresponding Java code com.android.sdk.app.ReceiveResult.java. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:padding="4dip"
+    android:gravity="center_horizontal"
+    android:layout_width="match_parent" android:layout_height="match_parent">
+
+    <TextView
+        android:layout_width="match_parent" android:layout_height="wrap_content"
+        android:layout_weight="0"
+        android:paddingBottom="4dip"
+        android:text="@string/forwarding"/>
+
+    <Button android:id="@+id/go"
+        android:layout_width="wrap_content" android:layout_height="wrap_content"
+        android:text="@string/go">
+        <requestFocus />
+    </Button>
+
+</LinearLayout>
+
diff --git a/tests/tests/app/res/layout/checkbox_layout.xml b/tests/tests/app/res/layout/checkbox_layout.xml
new file mode 100644
index 0000000..a1f1718
--- /dev/null
+++ b/tests/tests/app/res/layout/checkbox_layout.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2008 The Android Open Source Project.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical">
+
+    <CheckBox android:id="@+id/check_box"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/hello_world" />
+
+</LinearLayout>
diff --git a/tests/tests/app/res/layout/dialog_stub_layout.xml b/tests/tests/app/res/layout/dialog_stub_layout.xml
new file mode 100644
index 0000000..c6eb10d
--- /dev/null
+++ b/tests/tests/app/res/layout/dialog_stub_layout.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        >
+</LinearLayout>
diff --git a/tests/tests/app/res/menu/browser.xml b/tests/tests/app/res/menu/browser.xml
new file mode 100644
index 0000000..29e5149
--- /dev/null
+++ b/tests/tests/app/res/menu/browser.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <group android:id="@+id/MAIN_MENU">
+        <item android:id="@+id/goto_menu_id"
+            android:title="@string/hello_world"
+            android:alphabeticShortcut="l"/>
+    </group>
+
+</menu>
diff --git a/tests/tests/app/res/values/arrays.xml b/tests/tests/app/res/values/arrays.xml
new file mode 100644
index 0000000..71e0133
--- /dev/null
+++ b/tests/tests/app/res/values/arrays.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<resources>
+    <item type="integer" name="reference" format="integer">101</item>
+
+      <string-array name="strings">
+        <item>zero</item>
+        <item>1</item>
+        <item>@string/reference</item>
+    </string-array>
+
+    <integer-array name="integers">
+        <item>0</item>
+        <item>1</item>
+        <item>@integer/reference</item>
+    </integer-array>
+
+    <array name="difficultyLevel">
+        <item>Easy</item>
+        <item>Medium</item>
+        <item>Hard</item>
+    </array>
+
+    <string-array name="string">
+        <item>Test String 1</item>
+        <item>Test String 2</item>
+        <item>Test String 3</item>
+    </string-array>
+
+    <integer-array name="table_row_layout">
+        <item>1</item>
+        <item>2</item>
+        <item>3</item>
+        <item>4</item>
+        <item>5</item>
+        <item>6</item>
+        <item>7</item>
+        <item>8</item>
+        <item>9</item>
+        <item>10</item>
+    </integer-array>
+</resources>
diff --git a/tests/tests/app/res/values/attrs.xml b/tests/tests/app/res/values/attrs.xml
new file mode 100644
index 0000000..4c3d9db
--- /dev/null
+++ b/tests/tests/app/res/values/attrs.xml
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<resources>
+    <declare-styleable name="Style1">
+        <attr name="Type1" format="integer">
+            <enum name="type" value="28" />
+            <enum name="data" value="0xff00ff00" />
+            <enum name="asset_cookie" value="0" />
+            <enum name="resource_id" value="0" />
+            <enum name="changing_config" value="0" />
+        </attr>
+        <attr name="Type2" format="integer">
+            <enum name="type" value="28" />
+            <enum name="data" value="0xff0000ff" />
+            <enum name="asset_cookie" value="0" />
+            <enum name="resource_id" value="0" />
+            <enum name="changing_config" value="0" />
+        </attr>
+    </declare-styleable>
+    <attr name="type1" format="boolean"/>
+    <attr name="type2" format="boolean"/>
+    <attr name="type3" format="color"/>
+    <attr name="type4" format="reference|color"/>
+    <attr name="type5" format="dimension"/>
+    <attr name="type6" format="dimension"/>
+    <attr name="type7" format="dimension"/>
+    <attr name="type8" format="reference"/>
+    <attr name="type9" format="float"/>
+    <attr name="type10" format="fraction"/>
+    <attr name="type11" format="integer"/>
+    <attr name="type12" format="integer"/>
+    <attr name="type13" format="reference|string"/>
+    <attr name="type14" format="string"/>
+    <attr name="type15" format="reference"/>
+    <attr name="type16" format="string"/>
+    <declare-styleable name="style1">
+        <attr name="type1"/>
+        <attr name="type2"/>
+        <attr name="type3"/>
+        <attr name="type4"/>
+        <attr name="type5"/>
+        <attr name="type6"/>
+        <attr name="type7"/>
+        <attr name="type8"/>
+        <attr name="type9"/>
+        <attr name="type10"/>
+        <attr name="type11"/>
+        <attr name="type12"/>
+        <attr name="type13"/>
+        <attr name="type14"/>
+        <attr name="type15"/>
+        <attr name="type16"/>
+    </declare-styleable>
+    <attr name="testEnum">
+        <enum name="val1" value="1" />
+        <enum name="val2" value="2" />
+        <enum name="val10" value="10" />
+    </attr>
+    <attr name="testFlags">
+        <flag name="bit1" value="0x1" />
+        <flag name="bit2" value="0x2" />
+        <flag name="bit31" value="0x40000000" />
+    </attr>
+    <attr name="testString" format="string" />
+    <declare-styleable name="EnumStyle">
+        <attr name="testEnum" />
+    </declare-styleable>
+    <declare-styleable name="FlagStyle">
+        <attr name="testFlags" />
+    </declare-styleable>
+    <declare-styleable name="TestConfig">
+        <attr name="testString" />
+    </declare-styleable>
+    <!-- Size of text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp).
+         Supported values include the following:<p/>
+    <ul>
+        <li><b>px</b> Pixels</li>
+        <li><b>sp</b> Scaled pixels (scaled to relative pixel size on screen). See {@link android.util.DisplayMetrics} for more information.</li>
+        <li><b>pt</b> Points</li>
+        <li><b>dip</b> Device independent pixels. See {@link android.util.DisplayMetrics} for more information.</li>
+    </ul>
+    -->
+    <attr name="textSize" format="dimension" />
+    <attr name="typeface">
+        <enum name="normal" value="0" />
+        <enum name="sans" value="1" />
+        <enum name="serif" value="2" />
+        <enum name="monospace" value="3" />
+    </attr>
+    <!-- Default text typeface style. -->
+    <attr name="textStyle">
+        <flag name="normal" value="0" />
+        <flag name="bold" value="1" />
+        <flag name="italic" value="2" />
+    </attr>
+    <!-- Color of text (usually same as colorForeground). -->
+    <attr name="textColor" format="reference|color" />
+    <!-- Color of highlighted text. -->
+    <attr name="textColorHighlight" format="reference|color" />
+    <!-- Color of hint text (displayed when the field is empty). -->
+    <attr name="textColorHint" format="reference|color" />
+    <!-- Color of link text (URLs). -->
+    <attr name="textColorLink" format="reference|color" />
+    <declare-styleable name="TextAppearance">
+        <attr name="textColor"/>
+        <attr name="textSize"/>
+        <attr name="textStyle"/>
+        <attr name="typeface"/>
+        <attr name="textColorHighlight"/>
+        <attr name="textColorHint"/>
+        <attr name="textColorLink"/>
+    </declare-styleable>
+    <!-- Integer used to uniquely identify theme overrides. -->
+    <attr name="themeType" format="integer"/>
+    <!-- Theme reference used to override parent theme. -->
+    <attr name="themeOverrideAttr" format="reference"/>
+
+    <!-- Drawable theming attributes -->
+    <attr name="themeBoolean" />
+    <attr name="themeColor" />
+    <attr name="themeFloat" />
+    <attr name="themeInteger" />
+    <attr name="themeDimension" />
+    <attr name="themeDrawable" />
+    <attr name="themeBitmap" />
+    <attr name="themeNinePatch" />
+    <attr name="themeGravity" />
+    <attr name="themeTileMode" />
+    <attr name="themeAngle" />
+</resources>
diff --git a/tests/tests/app/res/values/colors.xml b/tests/tests/app/res/values/colors.xml
new file mode 100644
index 0000000..f3cc325
--- /dev/null
+++ b/tests/tests/app/res/values/colors.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<resources>
+    <drawable name="red">#7f00</drawable>
+    <drawable name="blue">#770000ff</drawable>
+    <drawable name="black">#77ffffff</drawable>
+    <drawable name="yellow">#77ffff00</drawable>
+    <color name="testcolor1">#ff00ff00</color>
+    <color name="testcolor2">#ffff0000</color>
+    <color name="failColor">#ff0000ff</color>
+</resources>
diff --git a/tests/tests/app/res/values/strings.xml b/tests/tests/app/res/values/strings.xml
new file mode 100644
index 0000000..c167278
--- /dev/null
+++ b/tests/tests/app/res/values/strings.xml
@@ -0,0 +1,179 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="permlab_testGranted">Test Granted</string>
+    <string name="permdesc_testGranted">Used for running CTS tests, for testing operations
+        where we have the permission.</string>
+    <string name="permlab_testDynamic">Test Dynamic</string>
+    <string name="permdesc_testDynamic">Used for running CTS tests, for testing adding
+        dynamic permissions.</string>
+    <string name="permlab_testDenied">Test Denied</string>
+    <string name="permdesc_testDenied">Used for running CTS tests, for testing operations
+        where we do not have the permission.</string>
+    <string name="explain">1. click start. \n2. if above image shaked, then press pass button,
+         else press failed button.</string>
+    <string name="text_view_hello">Hello! Text view!</string>
+    <string name="text_view_hello_two_lines">Hello! \nText view!</string>
+    <string name="text_view_simple_hint">This is a hint.</string>
+    <string name="text_view_hint">This is a string for testing hint of textview.</string>
+    <string name="activity_forwarding">App/Forwarding</string>
+    <string name="forwarding">$$$</string>
+    <string name="go">Go</string>
+    <string name="back">Back</string>
+    <string name="forward_target">
+        Press back button and notice we don\'t see the previous activity.
+    </string>
+    <string name="edit_text">testing</string>
+    <string name="text">DialogTest</string>
+    <string name="text_country">Country</string>
+    <string name="text_name">Name</string>
+    <string name="hello_world">Hello, World!</string>
+    <string name="hello_android">Hello, Android!</string>
+    <string name="alert_dialog_username">Name:</string>
+    <string name="alert_dialog_password">Password:</string>
+    <string name="alert_dialog_positive">Positive</string>
+    <string name="alert_dialog_negative">Negative</string>
+    <string name="alert_dialog_neutral">Neutral</string>
+    <string name="notify">Notify </string>
+    <string name="tabs_1">testing</string>
+    <string name="table_layout_first">first</string>
+    <string name="table_layout_second">second</string>
+    <string name="table_layout_third">third</string>
+    <string name="table_layout_long">Very long to make the string out of the screen</string>
+    <string name="chronometer_text">Test Chronometer</string>
+    <string name="am">AM</string>
+    <string name="pm">PM</string>
+    <string name="viewgroup_test">ViewGroup test</string>
+    <string name="viewanimator_test">ViewAnimator test</string>
+    <string name="id_ok">OK</string>
+    <string name="id_cancel">Cancel</string>
+    <string name="context_test_string1">This is %s string.</string>
+    <string name="context_test_string2">This is test string.</string>
+    <string name="animationutils_test_instructions">Choose different animations</string>
+    <string name="animationutils_test_alpha">Alpha animation</string>
+    <string name="animationutils_test_scale">Scale animation</string>
+    <string name="animationutils_test_rotate">Rotate animation</string>
+    <string name="animationutils_test_translate">Translate animation</string>
+    <string name="animationutils_test_set">Animation set</string>
+    <string name="animationutils_test_layout">Layout animation</string>
+    <string name="animationutils_test_gridlayout">Grid layout animation</string>
+    <string name="twolinelistitem_test_text1">text1</string>
+    <string name="twolinelistitem_test_text2">text2</string>
+    <string name="metadata_text">metadata text</string>
+    <string name="horizontal_text_1">horizontal 1</string>
+    <string name="horizontal_text_2">horizontal 2</string>
+    <string name="horizontal_text_3">horizontal 3</string>
+    <string name="vertical_text_1">vertical 1</string>
+    <string name="vertical_text_2">vertical 2</string>
+    <string name="vertical_text_3">vertical 3</string>
+    <string name="reference">here</string>
+    <string name="coerceIntegerToString">100</string>
+    <string name="coerceBooleanToString">true</string>
+    <string name="coerceColorToString">#fff</string>
+    <string name="coerceFloatToString">100.0</string>
+    <string name="coerceDimensionToString">100px</string>
+    <string name="coerceFractionToString">100<xliff:g id="percent">%</xliff:g></string>
+    <string name="formattedStringNone">Format[]</string>
+    <string name="formattedStringOne">Format[<xliff:g id="format">%d</xliff:g>]</string>
+    <string name="formattedStringTwo">Format[<xliff:g id="format">%3$d,%2$s</xliff:g>]</string>
+    <string name="checkboxpref_key">checkboxpref_key</string>
+   <string name="checkboxpref_title">title of preference</string>
+   <string name="checkboxpref_summary">summary of preference</string>
+   <string name="checkboxpref_summary_on">summary on of preference</string>
+   <string name="checkboxpref_summary_off">summary off of preference</string>
+   <string name="checkboxpref_depend">checkboxpref_depend</string>
+   <string name="checkboxpref_depend_title"> depend title of preference</string>
+   <string name="checkboxpref_depend_summary"> depend summary of preference</string>
+   <string name="edittextpref_key">edittextpref_key</string>
+   <string name="edittextpref_default_value">default value of preference</string>
+   <string name="edittextpref_title">title of edit text preference</string>
+   <string name="edittextpref_summary">summary of edit text preference</string>
+   <string name="edittextpref_dialog_title">dialog title of edit text preference</string>
+   <string name="edittextpref_text">text of  edit text preference</string>
+   <string name="listpref_key">listpref_key</string>
+   <string name="listpref_title">title of list preference</string>
+   <string name="listpref_summary">summary of list preference</string>
+   <string name="listpref_dialogtitle">dialog title of list preference</string>
+   <string name="easy">Easy</string>
+   <string name="medium">Medium</string>
+   <string name="hard">Hard</string>
+   <string name="footer_view">Footer view</string>
+   <string name="header_view">Header view</string>
+   <string name="dialogpref_title">title of dialog preference </string>
+   <string name="dialogpref_dialog_title">dialog title of dialog preference </string>
+   <string name="dialogpref_key">dialogpref_key</string>
+   <string name="dialogpref_default_value">default value of dialog preference</string>
+   <string name="dialogpref_summary">summary of dialog preference</string>
+   <string name="dialogpref_message">message of dialog preference</string>
+   <string name="dialogpref_sure">Sure</string>
+   <string name="dialogpref_cancel">Cancel</string>
+   <string name="pref_key">pref_key</string>
+   <string name="pref_title">title of preference</string>
+   <string name="pref_summary">summary of preference</string>
+   <string name="pref_depend_key">pref_depend_key</string>
+   <string name="pref_depend_title"> depend title of preference</string>
+   <string name="pref_depend_summary"> depend summary of preference</string>
+   <string name="android_intent_action_preference">android.intent.action.PREFERENCE</string>
+   <string name="def_pref_key">def_pref_key</string>
+   <string name="def_pref_title">default preference</string>
+   <string name="def_pref_summary">This is default preference of cts</string>
+   <string name="relative_view1">view 1</string>
+   <string name="relative_view2">view 2</string>
+   <string name="relative_view3">view 3</string>
+   <string name="relative_view4">view 4</string>
+   <string name="relative_view5">view 5</string>
+   <string name="relative_view6">view 6</string>
+   <string name="relative_view7">view 7</string>
+   <string name="relative_view8">view 8</string>
+   <string name="relative_view9">view 9</string>
+   <string name="relative_view10">view 10</string>
+   <string name="relative_view11">view 11</string>
+   <string name="relative_view12">view 12</string>
+   <string name="relative_view13">view 13</string>
+   <string name="country">Country:</string>
+   <string name="symbol">Symbol:</string>
+   <string name="country_warning">No such country registered</string>
+   <string name="version_cur">base</string>
+   <string name="version_old">base</string>
+   <string name="version_v3">base</string>
+   <string name="authenticator_label">Android CTS</string>
+   <string name="search_label">Android CTS</string>
+   <string name="tag1">tag 1</string>
+   <string name="tag2">tag 2</string>
+
+   <string name="button">Button</string>
+   <string name="holo_test">Holo Test</string>
+   <string name="holo_generator">Holo Generator</string>
+   <string name="holo_light_test">Holo Light Test</string>
+   <string name="holo_light_generator">Holo Light Generator</string>
+   <string name="reference_image">Reference Image: </string>
+   <string name="generated_image">Generated Image: </string>
+   <string name="themes_prompt">Select a Theme:</string>
+   <string name="sample_text">Sample text goes here. I wanted something creative and whimsical
+but then I just got bored...</string>
+    <string name="long_text">This is a really long string which exceeds the width of the view.
+New devices have a much larger screen which actually enables long strings to be displayed
+with no fading. I have made this string longer to fix this case. If you are correcting this
+text, I would love to see the kind of devices you guys now use! Guys, maybe some devices need longer string!
+I think so, so how about double this string, like copy and paste!
+This is a really long string which exceeds the width of the view.
+New devices have a much larger screen which actually enables long strings to be displayed
+with no fading. I have made this string longer to fix this case. If you are correcting this
+text, I would love to see the kind of devices you guys now use! Guys, maybe some devices need longer string!
+I think so, so how about double this string, like copy and paste! </string>
+    <string name="rectangle200">"M 0,0 l 200,0 l 0, 200 l -200, 0 z"</string>
+</resources>
diff --git a/tests/tests/app/res/values/styles.xml b/tests/tests/app/res/values/styles.xml
new file mode 100644
index 0000000..81925cc
--- /dev/null
+++ b/tests/tests/app/res/values/styles.xml
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <style name="Whatever">
+        <item name="type1">true</item>
+        <item name="type2">false</item>
+        <item name="type3">#ff0000ff</item>
+        <item name="type4">#ff00ff00</item>
+        <item name="type5">0.75px</item>
+        <item name="type6">10px</item>
+        <item name="type7">18px</item>
+        <item name="type8">@drawable/pass</item>
+        <item name="type9">3.14</item>
+        <item name="type10">100%</item>
+        <item name="type11">365</item>
+        <item name="type12">86400</item>
+        <item name="type13">@string/hello_android</item>
+        <item name="type14">TypedArray Test!</item>
+        <item name="type15">@array/difficultyLevel</item>
+        <item name="type16">Typed Value!</item>
+    </style>
+
+    <style name="TextViewWithoutColorAndAppearance">
+        <item name="android:textSize">18sp</item>
+    </style>
+
+    <style name="TextViewWithColorButWithOutAppearance">
+        <item name="android:textColor">#ff0000ff</item>
+    </style>
+
+    <style name="TextViewWithColorAndAppearance">
+        <item name="android:textColor">#ff0000ff</item>
+        <item name="android:textAppearance">@style/TextAppearance.WithColor</item>
+    </style>
+
+    <style name="TextViewWithoutColorButWithAppearance">
+        <item name="android:textAppearance">@style/TextAppearance.WithColor</item>
+    </style>
+
+    <style name="TextAppearance" parent="android:TextAppearance">
+    </style>
+
+    <style name="TextAppearance.WithColor">
+        <item name="android:textColor">#ffff0000</item>
+    </style>
+
+    <style name="TextAppearance.All">
+        <item name="android:textColor">@drawable/black</item>
+        <item name="android:textSize">20px</item>
+        <item name="android:textStyle">bold</item>
+        <item name="android:textColorHint">@drawable/red</item>
+        <item name="android:textColorLink">@drawable/blue</item>
+        <item name="android:textColorHighlight">@drawable/yellow</item>
+    </style>
+
+    <style name="TextAppearance.Colors">
+        <item name="android:textColor">@drawable/black</item>
+        <item name="android:textColorHint">@drawable/blue</item>
+        <item name="android:textColorLink">@drawable/yellow</item>
+        <item name="android:textColorHighlight">@drawable/red</item>
+    </style>
+
+    <style name="TextAppearance.NotColors">
+        <item name="android:textSize">17px</item>
+        <item name="android:typeface">sans</item>
+        <item name="android:textStyle">normal</item>
+    </style>
+
+    <style name="TextAppearance.Style">
+        <item name="android:textStyle">normal</item>
+    </style>
+
+    <style name="TestEnum1">
+        <item name="testEnum">val1</item>
+    </style>
+
+    <style name="TestEnum2">
+        <item name="testEnum">val2</item>
+    </style>
+
+    <style name="TestEnum10">
+        <item name="testEnum">val10</item>
+    </style>
+
+    <style name="TestFlag1">
+        <item name="testFlags">bit1</item>
+    </style>
+
+    <style name="TestFlag2">
+        <item name="testFlags">bit2</item>
+    </style>
+
+    <style name="TestFlag31">
+        <item name="testFlags">bit31</item>
+    </style>
+
+    <style name="TestFlag1And2">
+        <item name="testFlags">bit1|bit2</item>
+    </style>
+
+    <style name="TestFlag1And2And31">
+        <item name="testFlags">bit1|bit2|bit31</item>
+    </style>
+
+    <style name="TestEnum1.EmptyInherit" />
+
+    <style name="Theme_AlertDialog">
+        <item name="android:textSize">18sp</item>
+    </style>
+
+    <style name="TestProgressBar">
+        <item name="android:indeterminateOnly">false</item>
+        <item name="android:progressDrawable">?android:drawable/progress_horizontal</item>
+        <item name="android:indeterminateDrawable">?android:drawable/progress_horizontal</item>
+        <item name="android:minHeight">20dip</item>
+        <item name="android:maxHeight">20dip</item>
+        <item name="android:focusable">true</item>
+    </style>
+
+    <style name="Test_Theme">
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:panelColorForeground">#ff000000</item>
+        <item name="android:panelColorBackground">#ffffffff</item>
+    </style>
+
+    <style name="Theme_OverrideOuter">
+        <item name="themeType">1</item>
+    </style>
+
+    <style name="Theme_OverrideInner">
+        <item name="themeType">2</item>
+        <item name="themeOverrideAttr">@style/Theme_OverrideAttr</item>
+    </style>
+
+    <style name="Theme_OverrideAttr">
+        <item name="themeType">3</item>
+    </style>
+
+    <style name="Theme_ThemedDrawableTest">
+        <item name="themeBoolean">true</item>
+        <item name="themeColor">@android:color/black</item>
+        <item name="themeFloat">1.0</item>
+        <item name="themeAngle">45.0</item>
+        <item name="themeInteger">1</item>
+        <item name="themeDimension">1px</item>
+        <item name="themeDrawable">@drawable/icon_black</item>
+        <item name="themeBitmap">@drawable/icon_black</item>
+        <item name="themeNinePatch">@drawable/ninepatch_0</item>
+        <item name="themeGravity">48</item>
+        <item name="themeTileMode">2</item>
+    </style>
+
+    <style name="Theme_NoSwipeDismiss">
+        <item name="android:windowSwipeToDismiss">false</item>
+    </style>
+
+</resources>
diff --git a/tests/tests/app/res/xml/alias.xml b/tests/tests/app/res/xml/alias.xml
new file mode 100644
index 0000000..a03104f
--- /dev/null
+++ b/tests/tests/app/res/xml/alias.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+-->
+
+<alias xmlns:android="http://schemas.android.com/apk/res/android">
+    <intent android:action="android.intent.action.MAIN"
+        android:targetPackage="com.android.cts.app"
+        android:targetClass="android.app.cts.ChildActivity"
+        android:data="http://www.google.com/">
+    </intent>
+</alias>
+
diff --git a/tests/tests/app/res/xml/intentfilter.xml b/tests/tests/app/res/xml/intentfilter.xml
new file mode 100644
index 0000000..7ed3a53
--- /dev/null
+++ b/tests/tests/app/res/xml/intentfilter.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+-->
+<intent-filter xmlns="http://schemas.android.com/apk/res/android">
+    <action name="testAction"/>
+    <cat name="testCategory" />
+    <type name="vnd.android.cursor.dir/person"/>
+    <scheme name="testScheme"/>
+    <auth host="testHost" port="80"/>
+    <path name="testPath" literal="test"/>
+    <path name="testPath" prefix="test"/>
+    <path name="testPath" sglob="test"/>
+</intent-filter>
diff --git a/tests/tests/app/res/xml/metadata.xml b/tests/tests/app/res/xml/metadata.xml
new file mode 100644
index 0000000..336b931
--- /dev/null
+++ b/tests/tests/app/res/xml/metadata.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<thedata xmlns:android="http://schemas.android.com/apk/res/android"
+    rawText="some raw text"
+    rawColor="#ffffff00"
+    android:color="#f00"
+    android:text="@string/metadata_text"/>
diff --git a/tests/tests/app/res/xml/searchable.xml b/tests/tests/app/res/xml/searchable.xml
new file mode 100644
index 0000000..f09c917
--- /dev/null
+++ b/tests/tests/app/res/xml/searchable.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<searchable xmlns:android="http://schemas.android.com/apk/res/android"
+    android:label="@string/search_label"
+/>
diff --git a/tests/tests/app/src/android/app/backup/cts/BackupManagerTest.java b/tests/tests/app/src/android/app/backup/cts/BackupManagerTest.java
index f21f847..3ee1104 100644
--- a/tests/tests/app/src/android/app/backup/cts/BackupManagerTest.java
+++ b/tests/tests/app/src/android/app/backup/cts/BackupManagerTest.java
@@ -26,7 +26,7 @@
         // Check that these don't crash as if they were called in an app...
         BackupManager backupManager = new BackupManager(mContext);
         backupManager.dataChanged();
-        BackupManager.dataChanged("com.android.cts.stub");
+        BackupManager.dataChanged("com.android.cts.app");
 
         // Backup isn't expected to work in this test but check for obvious bugs...
         int result = backupManager.requestRestore(new RestoreObserver() {});
diff --git a/tests/src/android/app/cts/ActivityManagerMemoryClassLaunchActivity.java b/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassLaunchActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ActivityManagerMemoryClassLaunchActivity.java
rename to tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassLaunchActivity.java
diff --git a/tests/src/android/app/cts/ActivityManagerMemoryClassTestActivity.java b/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTestActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ActivityManagerMemoryClassTestActivity.java
rename to tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTestActivity.java
diff --git a/tests/src/android/app/cts/ActivityManagerRecentOneActivity.java b/tests/tests/app/src/android/app/cts/ActivityManagerRecentOneActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ActivityManagerRecentOneActivity.java
rename to tests/tests/app/src/android/app/cts/ActivityManagerRecentOneActivity.java
diff --git a/tests/src/android/app/cts/ActivityManagerRecentTwoActivity.java b/tests/tests/app/src/android/app/cts/ActivityManagerRecentTwoActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ActivityManagerRecentTwoActivity.java
rename to tests/tests/app/src/android/app/cts/ActivityManagerRecentTwoActivity.java
diff --git a/tests/src/android/app/cts/ActivityManagerStubCrashActivity.java b/tests/tests/app/src/android/app/cts/ActivityManagerStubCrashActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ActivityManagerStubCrashActivity.java
rename to tests/tests/app/src/android/app/cts/ActivityManagerStubCrashActivity.java
diff --git a/tests/src/android/app/cts/ActivityManagerStubFooActivity.java b/tests/tests/app/src/android/app/cts/ActivityManagerStubFooActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ActivityManagerStubFooActivity.java
rename to tests/tests/app/src/android/app/cts/ActivityManagerStubFooActivity.java
diff --git a/tests/tests/app/src/android/app/cts/ActivityManagerTest.java b/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
index 6a1ccb5..dfec7db 100644
--- a/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
@@ -35,7 +35,7 @@
 import android.test.InstrumentationTestCase;
 
 public class ActivityManagerTest extends InstrumentationTestCase {
-    private static final String STUB_PACKAGE_NAME = "com.android.cts.stub";
+    private static final String STUB_PACKAGE_NAME = "com.android.cts.app";
     private static final int WAITFOR_MSEC = 5000;
     private static final String SERVICE_NAME = "android.app.cts.MockService";
     private static final int WAIT_TIME = 2000;
@@ -222,13 +222,13 @@
         assertTrue(hasSystemProcess && hasTestProcess);
 
         for (RunningAppProcessInfo ra : list) {
-            if (ra.processName.equals("com.android.cts.stub:remote")) {
-                fail("should be no process named com.android.cts.stub:remote");
+            if (ra.processName.equals("com.android.cts.app:remote")) {
+                fail("should be no process named com.android.cts.app:remote");
             }
         }
         // start a new process
         mIntent = new Intent("android.app.REMOTESERVICE");
-        mIntent.setPackage("com.android.cts.stub");
+        mIntent.setPackage("com.android.cts.app");
         mInstrumentation.getTargetContext().startService(mIntent);
         Thread.sleep(WAITFOR_MSEC);
 
@@ -236,11 +236,11 @@
         assertTrue(list.size() <= listNew.size());
 
         for (RunningAppProcessInfo ra : listNew) {
-            if (ra.processName.equals("com.android.cts.stub:remote")) {
+            if (ra.processName.equals("com.android.cts.app:remote")) {
                 return;
             }
         }
-        fail("com.android.cts.stub:remote process should be available");
+        fail("com.android.cts.app:remote process should be available");
     }
 
     public void testGetProcessInErrorState() throws Exception {
diff --git a/tests/src/android/app/cts/ActivityTestsBase.java b/tests/tests/app/src/android/app/cts/ActivityTestsBase.java
similarity index 100%
rename from tests/src/android/app/cts/ActivityTestsBase.java
rename to tests/tests/app/src/android/app/cts/ActivityTestsBase.java
diff --git a/tests/tests/app/src/android/app/cts/AlertDialogTest.java b/tests/tests/app/src/android/app/cts/AlertDialogTest.java
index aefcf01..a35fd9c 100644
--- a/tests/tests/app/src/android/app/cts/AlertDialogTest.java
+++ b/tests/tests/app/src/android/app/cts/AlertDialogTest.java
@@ -35,17 +35,17 @@
 /*
  * Test AlertDialog
  */
-public class AlertDialogTest extends ActivityInstrumentationTestCase2<DialogStubActivity> {
+public class AlertDialogTest extends ActivityInstrumentationTestCase2<DialogCtsActivity> {
     private static final String ALERTDIALOG_CUSTOM_TITLE = "Hello, World!";
 
     private Instrumentation mInstrumentation;
-    private DialogStubActivity mActivity;
+    private DialogCtsActivity mActivity;
     private Button mPositiveButton;
     private Button mNegativeButton;
     private Button mNeutralButton;
 
     public AlertDialogTest() {
-        super("com.android.cts.stub", DialogStubActivity.class);
+        super("com.android.cts.app", DialogCtsActivity.class);
     }
 
     @Override
@@ -55,7 +55,7 @@
     }
 
     protected void startDialogActivity(int dialogNumber) {
-        mActivity = DialogStubActivity.startDialogActivity(this, dialogNumber);
+        mActivity = DialogCtsActivity.startDialogActivity(this, dialogNumber);
         new PollingCheck() {
             @Override
             protected boolean check() {
@@ -65,7 +65,7 @@
     }
 
     public void testAlertDialog() throws Throwable {
-        doTestAlertDialog(DialogStubActivity.TEST_ALERTDIALOG);
+        doTestAlertDialog(DialogCtsActivity.TEST_ALERTDIALOG);
     }
 
     private void doTestAlertDialog(int index) throws Throwable {
@@ -75,17 +75,17 @@
         mPositiveButton = ((AlertDialog) (mActivity.getDialog())).getButton(
                 DialogInterface.BUTTON_POSITIVE);
         assertNotNull(mPositiveButton);
-        assertEquals(mActivity.getString(com.android.cts.stub.R.string.alert_dialog_positive),
+        assertEquals(mActivity.getString(com.android.cts.app.R.string.alert_dialog_positive),
                 mPositiveButton.getText());
         mNeutralButton = ((AlertDialog) (mActivity.getDialog())).getButton(
                 DialogInterface.BUTTON_NEUTRAL);
         assertNotNull(mNeutralButton);
-        assertEquals(mActivity.getString(com.android.cts.stub.R.string.alert_dialog_neutral),
+        assertEquals(mActivity.getString(com.android.cts.app.R.string.alert_dialog_neutral),
                 mNeutralButton.getText());
         mNegativeButton = ((AlertDialog) (mActivity.getDialog())).getButton(
                 DialogInterface.BUTTON_NEGATIVE);
         assertNotNull(mNegativeButton);
-        assertEquals(mActivity.getString(com.android.cts.stub.R.string.alert_dialog_negative),
+        assertEquals(mActivity.getString(com.android.cts.app.R.string.alert_dialog_negative),
                 mNegativeButton.getText());
 
         assertFalse(mActivity.isPositiveButtonClicked);
@@ -102,40 +102,40 @@
     }
 
     public void testAlertDialogDeprecatedAPI() throws Throwable {
-        doTestAlertDialog(DialogStubActivity.TEST_ALERTDIALOG_DEPRECATED);
+        doTestAlertDialog(DialogCtsActivity.TEST_ALERTDIALOG_DEPRECATED);
     }
 
     public void testAlertDialogDeprecatedAPIWithMessage() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_ALERTDIALOG_DEPRECATED_WITH_MESSAGE);
+        startDialogActivity(DialogCtsActivity.TEST_ALERTDIALOG_DEPRECATED_WITH_MESSAGE);
         assertTrue(mActivity.getDialog().isShowing());
 
         mPositiveButton = ((AlertDialog) (mActivity.getDialog())).getButton(
                 DialogInterface.BUTTON_POSITIVE);
         assertNotNull(mPositiveButton);
-        assertEquals(mActivity.getString(com.android.cts.stub.R.string.alert_dialog_positive),
+        assertEquals(mActivity.getString(com.android.cts.app.R.string.alert_dialog_positive),
                 mPositiveButton.getText());
         mNegativeButton = ((AlertDialog) (mActivity.getDialog())).getButton(
                 DialogInterface.BUTTON_NEGATIVE);
         assertNotNull(mNegativeButton);
-        assertEquals(mActivity.getString(com.android.cts.stub.R.string.alert_dialog_negative),
+        assertEquals(mActivity.getString(com.android.cts.app.R.string.alert_dialog_negative),
                 mNegativeButton.getText());
         mNeutralButton = ((AlertDialog) (mActivity.getDialog())).getButton(
                 DialogInterface.BUTTON_NEUTRAL);
         assertNotNull(mNeutralButton);
-        assertEquals(mActivity.getString(com.android.cts.stub.R.string.alert_dialog_neutral),
+        assertEquals(mActivity.getString(com.android.cts.app.R.string.alert_dialog_neutral),
                 mNeutralButton.getText());
 
-        DialogStubActivity.buttonIndex = 0;
+        DialogCtsActivity.buttonIndex = 0;
         performClick(mPositiveButton);
-        assertEquals(DialogInterface.BUTTON_POSITIVE, DialogStubActivity.buttonIndex);
+        assertEquals(DialogInterface.BUTTON_POSITIVE, DialogCtsActivity.buttonIndex);
 
-        DialogStubActivity.buttonIndex = 0;
+        DialogCtsActivity.buttonIndex = 0;
         performClick(mNeutralButton);
-        assertEquals(DialogInterface.BUTTON_NEUTRAL, DialogStubActivity.buttonIndex);
+        assertEquals(DialogInterface.BUTTON_NEUTRAL, DialogCtsActivity.buttonIndex);
 
-        DialogStubActivity.buttonIndex = 0;
+        DialogCtsActivity.buttonIndex = 0;
         performClick(mNegativeButton);
-        assertEquals(DialogInterface.BUTTON_NEGATIVE, DialogStubActivity.buttonIndex);
+        assertEquals(DialogInterface.BUTTON_NEGATIVE, DialogCtsActivity.buttonIndex);
     }
 
     private void performClick(final Button button) throws Throwable {
@@ -148,18 +148,18 @@
     }
 
     public void testCustomAlertDialog() {
-        startDialogActivity(DialogStubActivity.TEST_CUSTOM_ALERTDIALOG);
+        startDialogActivity(DialogCtsActivity.TEST_CUSTOM_ALERTDIALOG);
         assertTrue(mActivity.getDialog().isShowing());
     }
 
     public void testCustomAlertDialogView() {
-        startDialogActivity(DialogStubActivity.TEST_CUSTOM_ALERTDIALOG_VIEW);
+        startDialogActivity(DialogCtsActivity.TEST_CUSTOM_ALERTDIALOG_VIEW);
         assertTrue(mActivity.getDialog().isShowing());
     }
 
 
     public void testCallback() {
-        startDialogActivity(DialogStubActivity.TEST_ALERTDIALOG_CALLBACK);
+        startDialogActivity(DialogCtsActivity.TEST_ALERTDIALOG_CALLBACK);
         assertTrue(mActivity.onCreateCalled);
 
         mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_0);
@@ -169,12 +169,12 @@
     }
 
     public void testAlertDialogTheme() throws Exception {
-        startDialogActivity(DialogStubActivity.TEST_ALERTDIALOG_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_ALERTDIALOG_THEME);
         assertTrue(mActivity.getDialog().isShowing());
     }
 
     public void testAlertDialogCancelable() throws Exception {
-        startDialogActivity(DialogStubActivity.TEST_ALERTDIALOG_CANCELABLE);
+        startDialogActivity(DialogCtsActivity.TEST_ALERTDIALOG_CANCELABLE);
         assertTrue(mActivity.getDialog().isShowing());
         assertFalse(mActivity.onCancelCalled);
         mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
@@ -183,7 +183,7 @@
     }
 
     public void testAlertDialogNotCancelable() throws Exception {
-        startDialogActivity(DialogStubActivity.TEST_ALERTDIALOG_NOT_CANCELABLE);
+        startDialogActivity(DialogCtsActivity.TEST_ALERTDIALOG_NOT_CANCELABLE);
         assertTrue(mActivity.getDialog().isShowing());
         assertFalse(mActivity.onCancelCalled);
         mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK);
diff --git a/tests/tests/app/src/android/app/cts/AlertDialog_BuilderTest.java b/tests/tests/app/src/android/app/cts/AlertDialog_BuilderTest.java
index 5f826eb..b07a4d5 100644
--- a/tests/tests/app/src/android/app/cts/AlertDialog_BuilderTest.java
+++ b/tests/tests/app/src/android/app/cts/AlertDialog_BuilderTest.java
@@ -47,7 +47,7 @@
 import android.widget.AdapterView.OnItemSelectedListener;
 
 
-public class AlertDialog_BuilderTest extends ActivityInstrumentationTestCase2<DialogStubActivity> {
+public class AlertDialog_BuilderTest extends ActivityInstrumentationTestCase2<DialogCtsActivity> {
     private Builder mBuilder;
     private Context mContext;
     private Instrumentation mInstrumentation;
@@ -127,7 +127,7 @@
     }
 
     public AlertDialog_BuilderTest() {
-        super("com.android.cts.stub", DialogStubActivity.class);
+        super("com.android.cts.app", DialogCtsActivity.class);
     }
 
     public void testConstructor() {
@@ -208,14 +208,14 @@
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setNegativeButton(com.android.cts.stub.R.string.notify, mOnClickListener);
+                mBuilder.setNegativeButton(com.android.cts.app.R.string.notify, mOnClickListener);
                 mDialog = mBuilder.show();
                 mButton = mDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
                 mButton.performClick();
             }
         });
         mInstrumentation.waitForIdleSync();
-        assertEquals(mContext.getText(com.android.cts.stub.R.string.notify), mButton.getText());
+        assertEquals(mContext.getText(com.android.cts.app.R.string.notify), mButton.getText());
         assertTrue(mResult);
     }
 
@@ -223,14 +223,14 @@
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setNeutralButton(com.android.cts.stub.R.string.notify, mOnClickListener);
+                mBuilder.setNeutralButton(com.android.cts.app.R.string.notify, mOnClickListener);
                 mDialog = mBuilder.show();
                 mButton = mDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
                 mButton.performClick();
             }
         });
         mInstrumentation.waitForIdleSync();
-        assertEquals(mContext.getText(com.android.cts.stub.R.string.notify), mButton.getText());
+        assertEquals(mContext.getText(com.android.cts.app.R.string.notify), mButton.getText());
         assertTrue(mResult);
     }
 
@@ -321,7 +321,7 @@
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setItems(com.android.cts.stub.R.array.difficultyLevel, mOnClickListener);
+                mBuilder.setItems(com.android.cts.app.R.array.difficultyLevel, mOnClickListener);
                 mDialog = mBuilder.show();
                 mListView = mDialog.getListView();
             }
@@ -329,13 +329,13 @@
         mInstrumentation.waitForIdleSync();
 
         final CharSequence[] levels = mContext.getResources().getTextArray(
-                com.android.cts.stub.R.array.difficultyLevel);
+                com.android.cts.app.R.array.difficultyLevel);
         assertEquals(levels[0], mListView.getItemAtPosition(0));
     }
 
     public void testSetItemsWithParamCharSequence() throws Throwable {
         final CharSequence[] expect = mContext.getResources().getTextArray(
-                com.android.cts.stub.R.array.difficultyLevel);
+                com.android.cts.app.R.array.difficultyLevel);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -386,12 +386,12 @@
     public void testSetMultiChoiceItemsWithParamInt() throws Throwable {
 
         final CharSequence[] items = mContext.getResources().getTextArray(
-                com.android.cts.stub.R.array.difficultyLevel);
+                com.android.cts.app.R.array.difficultyLevel);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setMultiChoiceItems(com.android.cts.stub.R.array.difficultyLevel, null,
+                mBuilder.setMultiChoiceItems(com.android.cts.app.R.array.difficultyLevel, null,
                         mOnMultiChoiceClickListener);
                 mDialog = mBuilder.show();
                 mListView = mDialog.getListView();
@@ -409,7 +409,7 @@
 
     public void testSetMultiChoiceItemsWithParamCharSequence() throws Throwable {
         final CharSequence[] items = mContext.getResources().getTextArray(
-                com.android.cts.stub.R.array.difficultyLevel);
+                com.android.cts.app.R.array.difficultyLevel);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -454,12 +454,12 @@
 
     public void testSetSingleChoiceItemsWithParamInt() throws Throwable {
         final CharSequence[] items = mContext.getResources().getTextArray(
-                com.android.cts.stub.R.array.difficultyLevel);
+                com.android.cts.app.R.array.difficultyLevel);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setSingleChoiceItems(com.android.cts.stub.R.array.difficultyLevel, 0,
+                mBuilder.setSingleChoiceItems(com.android.cts.app.R.array.difficultyLevel, 0,
                         mOnClickListener);
                 mDialog = mBuilder.show();
                 mListView = mDialog.getListView();
@@ -507,7 +507,7 @@
 
     public void testSetSingleChoiceItemsWithParamCharSequence() throws Throwable {
         final CharSequence[] items = mContext.getResources().getTextArray(
-                com.android.cts.stub.R.array.difficultyLevel);
+                com.android.cts.app.R.array.difficultyLevel);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -527,7 +527,7 @@
 
     public void testSetSingleChoiceItems() throws Throwable {
         final CharSequence[] items = mContext.getResources().getTextArray(
-                com.android.cts.stub.R.array.difficultyLevel);
+                com.android.cts.app.R.array.difficultyLevel);
 
         runTestOnUiThread(new Runnable() {
             public void run() {
@@ -552,7 +552,7 @@
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setOnItemSelectedListener(mOnItemSelectedListener);
-                mBuilder.setItems(com.android.cts.stub.R.array.difficultyLevel, mOnClickListener);
+                mBuilder.setItems(com.android.cts.app.R.array.difficultyLevel, mOnClickListener);
                 mDialog = mBuilder.show();
                 mListView = mDialog.getListView();
                 mListView.pointToPosition(0, 0);
diff --git a/tests/src/android/app/cts/AliasActivityStub.java b/tests/tests/app/src/android/app/cts/AliasActivityStub.java
similarity index 100%
rename from tests/src/android/app/cts/AliasActivityStub.java
rename to tests/tests/app/src/android/app/cts/AliasActivityStub.java
diff --git a/tests/src/android/app/cts/AppStubActivity.java b/tests/tests/app/src/android/app/cts/AppCtsActivity.java
similarity index 97%
rename from tests/src/android/app/cts/AppStubActivity.java
rename to tests/tests/app/src/android/app/cts/AppCtsActivity.java
index fa786fa..a1722bb 100644
--- a/tests/src/android/app/cts/AppStubActivity.java
+++ b/tests/tests/app/src/android/app/cts/AppCtsActivity.java
@@ -26,12 +26,12 @@
 import android.view.View;
 import android.view.ContextMenu.ContextMenuInfo;
 
-import com.android.cts.stub.R;
+import com.android.cts.app.R;
 
 /**
  * A minimal "Hello, World!" application.
  */
-public class AppStubActivity extends Activity {
+public class AppCtsActivity extends Activity {
     private Dialog mDialog;
     public boolean mOnPrepareDialog;
     public boolean mOnOptionsMenuClosedCalled;
@@ -47,7 +47,7 @@
     public boolean mCreateContextMenuCalled;
     public boolean mRequestWinFeatureRet = false;
 
-    public AppStubActivity() {
+    public AppCtsActivity() {
 
     }
 
diff --git a/tests/src/android/app/cts/ChildActivity.java b/tests/tests/app/src/android/app/cts/ChildActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ChildActivity.java
rename to tests/tests/app/src/android/app/cts/ChildActivity.java
diff --git a/tests/src/android/app/cts/ChildTabActivity.java b/tests/tests/app/src/android/app/cts/ChildTabActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ChildTabActivity.java
rename to tests/tests/app/src/android/app/cts/ChildTabActivity.java
diff --git a/tests/src/android/app/cts/ClearTop.java b/tests/tests/app/src/android/app/cts/ClearTop.java
similarity index 100%
rename from tests/src/android/app/cts/ClearTop.java
rename to tests/tests/app/src/android/app/cts/ClearTop.java
diff --git a/tests/src/android/app/cts/DialogStubActivity.java b/tests/tests/app/src/android/app/cts/DialogCtsActivity.java
similarity index 97%
rename from tests/src/android/app/cts/DialogStubActivity.java
rename to tests/tests/app/src/android/app/cts/DialogCtsActivity.java
index 817e716..2fb293e 100644
--- a/tests/src/android/app/cts/DialogStubActivity.java
+++ b/tests/tests/app/src/android/app/cts/DialogCtsActivity.java
@@ -16,7 +16,7 @@
 
 package android.app.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.app.R;
 
 import android.app.Activity;
 import android.app.AlertDialog;
@@ -43,7 +43,7 @@
 /*
  * Stub class for  Dialog, AlertDialog, DatePickerDialog, TimePickerDialog etc.
  */
-public class DialogStubActivity extends Activity {
+public class DialogCtsActivity extends Activity {
     public static final int TEST_DIALOG_WITHOUT_THEME = 0;
     public static final int TEST_DIALOG_WITH_THEME = 1;
     public static final int TEST_ALERTDIALOG = 2;
@@ -71,7 +71,7 @@
 
     public static final String DEFAULT_ALERTDIALOG_TITLE = "AlertDialog";
     public static final String DEFAULT_ALERTDIALOG_MESSAGE = "AlertDialog message";
-    private static final String LOG_TAG = "DialogStubActivity";
+    private static final String LOG_TAG = "DialogCtsActivity";
 
     public boolean isPositiveButtonClicked = false;
     public boolean isNegativeButtonClicked = false;
@@ -235,8 +235,8 @@
 
     @SuppressWarnings("deprecation")
     private AlertDialog getAlertDialogInstance(boolean deprecated) {
-        mAlertDialog = new AlertDialog.Builder(DialogStubActivity.this).create();
-        mAlertDialog.setIcon(com.android.cts.stub.R.drawable.pass);
+        mAlertDialog = new AlertDialog.Builder(DialogCtsActivity.this).create();
+        mAlertDialog.setIcon(com.android.cts.app.R.drawable.pass);
         mAlertDialog.setTitle(DEFAULT_ALERTDIALOG_TITLE);
         mAlertDialog.setMessage(DEFAULT_ALERTDIALOG_MESSAGE);
         mAlertDialog.setInverseBackgroundForced(true);
@@ -267,7 +267,7 @@
         final LayoutInflater inflate = getLayoutInflater();
         final View customTitleViewCustom = inflate.inflate(R.layout.alertdialog_custom_title, null);
         final View textEntryView = inflate.inflate(R.layout.alert_dialog_text_entry_2, null);
-        mAlertDialog = new AlertDialog.Builder(DialogStubActivity.this).create();
+        mAlertDialog = new AlertDialog.Builder(DialogCtsActivity.this).create();
         mAlertDialog.setCustomTitle(customTitleViewCustom);
         mAlertDialog.setMessage(DEFAULT_ALERTDIALOG_MESSAGE);
         if (withSpacing) {
diff --git a/tests/tests/app/src/android/app/cts/DialogTest.java b/tests/tests/app/src/android/app/cts/DialogTest.java
index 7fb4731..2bbe346 100644
--- a/tests/tests/app/src/android/app/cts/DialogTest.java
+++ b/tests/tests/app/src/android/app/cts/DialogTest.java
@@ -15,7 +15,7 @@
  */
 package android.app.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.app.R;
 
 import android.app.Dialog;
 import android.app.Instrumentation;
@@ -50,10 +50,10 @@
 
 import java.lang.ref.WeakReference;
 
-public class DialogTest extends ActivityInstrumentationTestCase2<DialogStubActivity> {
+public class DialogTest extends ActivityInstrumentationTestCase2<DialogCtsActivity> {
 
     protected static final long SLEEP_TIME = 200;
-    private static final String STUB_ACTIVITY_PACKAGE = "com.android.cts.stub";
+    private static final String STUB_ACTIVITY_PACKAGE = "com.android.cts.app";
     private static final long TEST_TIMEOUT = 1000L;
 
     /**
@@ -69,11 +69,11 @@
 
     private Instrumentation mInstrumentation;
     private Context mContext;
-    private DialogStubActivity mActivity;
+    private DialogCtsActivity mActivity;
 
 
     public DialogTest() {
-        super(STUB_ACTIVITY_PACKAGE, DialogStubActivity.class);
+        super(STUB_ACTIVITY_PACKAGE, DialogCtsActivity.class);
     }
 
     @Override
@@ -84,7 +84,7 @@
     }
 
     private void startDialogActivity(int dialogNumber) {
-        mActivity = DialogStubActivity.startDialogActivity(this, dialogNumber);
+        mActivity = DialogCtsActivity.startDialogActivity(this, dialogNumber);
     }
 
     @UiThreadTest
@@ -106,14 +106,14 @@
     }
 
     public void testConstructor_protectedCancellable() {
-        startDialogActivity(DialogStubActivity.TEST_PROTECTED_CANCELABLE);
+        startDialogActivity(DialogCtsActivity.TEST_PROTECTED_CANCELABLE);
         mActivity.onCancelListenerCalled = false;
         sendKeys(KeyEvent.KEYCODE_BACK);
         assertTrue(mActivity.onCancelListenerCalled);
     }
 
     public void testConstructor_protectedNotCancellable() {
-        startDialogActivity(DialogStubActivity.TEST_PROTECTED_NOT_CANCELABLE);
+        startDialogActivity(DialogCtsActivity.TEST_PROTECTED_NOT_CANCELABLE);
         mActivity.onCancelListenerCalled = false;
         sendKeys(KeyEvent.KEYCODE_BACK);
         assertFalse(mActivity.onCancelListenerCalled);
@@ -142,7 +142,7 @@
     }
 
     public void testOnStartCreateStop(){
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
 
         assertTrue(d.isOnStartCalled);
@@ -154,7 +154,7 @@
     }
 
     public void testAccessOwnerActivity() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         Dialog d = mActivity.getDialog();
         assertNotNull(d);
         assertSame(mActivity, d.getOwnerActivity());
@@ -178,7 +178,7 @@
     }
 
     public void testShow() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
         final View decor = d.getWindow().getDecorView();
 
@@ -206,7 +206,7 @@
     }
 
     public void testOnSaveInstanceState() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
 
         assertFalse(d.isOnSaveInstanceStateCalled);
@@ -226,7 +226,7 @@
     }
 
     public void testGetCurrentFocus() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
         assertNull(d.getCurrentFocus());
         runTestOnUiThread(new Runnable() {
@@ -243,7 +243,7 @@
     }
 
     public void testSetContentView() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
         assertNotNull(d);
 
@@ -317,7 +317,7 @@
 
     public void testSetTitle() {
         final String expectedTitle = "Test Dialog Without theme";
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
 
         assertNotNull(mActivity.getDialog());
         mActivity.setUpTitle(expectedTitle);
@@ -333,7 +333,7 @@
     }
 
     public void testOnKeyDownKeyUp() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
         assertFalse(d.isOnKeyDownCalled);
         assertFalse(d.isOnKeyUpCalled);
@@ -352,7 +352,7 @@
     }
 
      public void testOnKeyMultiple() {
-         startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+         startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
          final TestDialog d = (TestDialog) mActivity.getDialog();
 
          assertNull(d.keyMultipleEvent);
@@ -364,7 +364,7 @@
      }
 
     public void testTouchEvent() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
 
         assertNull(d.onTouchEvent);
@@ -415,7 +415,7 @@
     }
 
     public void testTrackballEvent() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
         long eventTime = SystemClock.uptimeMillis();
         final MotionEvent trackBallEvent = MotionEvent.obtain(eventTime, eventTime,
@@ -444,7 +444,7 @@
     }
 
     public void testOnWindowAttributesChanged() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
 
         assertTrue(d.isOnWindowAttributesChangedCalled);
@@ -464,7 +464,7 @@
     }
 
     public void testOnContentChanged() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
         assertNotNull(d);
 
@@ -481,7 +481,7 @@
     }
 
     public void testOnWindowFocusChanged() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
         assertTrue(d.isOnWindowFocusChangedCalled);
         d.isOnWindowFocusChangedCalled = false;
@@ -489,7 +489,7 @@
         // show a new dialog, the new dialog get focus
         runTestOnUiThread(new Runnable() {
             public void run() {
-                mActivity.showDialog(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+                mActivity.showDialog(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
             }
         });
         mInstrumentation.waitForIdleSync();
@@ -503,7 +503,7 @@
     }
 
     public void testDispatchKeyEvent() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
 
         sendKeys(KeyEvent.KEYCODE_0);
@@ -551,7 +551,7 @@
      * the user canceling the menu with the back/menu button, or when an item is selected).
      */
     public void testContextMenu() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
         final LinearLayout parent = new LinearLayout(mContext);
         final MockView v = new MockView(mContext);
@@ -627,7 +627,7 @@
     }
 
     public void testTakeKeyEvents() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
         final View v = d.getWindow().getDecorView();
         assertNull(d.getCurrentFocus());
@@ -654,13 +654,13 @@
     }
 
     public void testRequestWindowFeature() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         // called requestWindowFeature at TestDialog onCreate method
         assertTrue(((TestDialog) mActivity.getDialog()).isRequestWindowFeature);
     }
 
     public void testSetFeatureDrawableResource() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mActivity.getDialog().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
@@ -671,28 +671,28 @@
     }
 
     public void testSetFeatureDrawableUri() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         mActivity.getDialog().setFeatureDrawableUri(0, Uri.parse("http://www.google.com"));
     }
 
     public void testSetFeatureDrawable() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         mActivity.getDialog().setFeatureDrawable(0, new MockDrawable());
     }
 
     public void testSetFeatureDrawableAlpha() {
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         mActivity.getDialog().setFeatureDrawableAlpha(0, 0);
     }
 
     public void testGetLayoutInflater() {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
         assertEquals(d.getWindow().getLayoutInflater(), d.getLayoutInflater());
     }
 
     public void testSetCancelable_true() {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
 
         d.setCancelable(true);
@@ -702,7 +702,7 @@
     }
 
     public void testSetCancellable_false() {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
 
         d.setCancelable(false);
@@ -717,7 +717,7 @@
      * 2. Set a listener to be invoked when the dialog is canceled.
      */
     public void testCancel_listener() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
 
         assertTrue(d.isShowing());
@@ -734,7 +734,7 @@
     }
 
     public void testCancel_noListener() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
 
         assertTrue(d.isShowing());
@@ -748,7 +748,7 @@
 
     public void testSetCancelMessage() throws Exception {
         mCalledCallback = false;
-        startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
+        startDialogActivity(DialogCtsActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();
         final HandlerThread ht = new HandlerThread("DialogTest");
         ht.start();
@@ -775,7 +775,7 @@
      */
     public void testSetOnDismissListener_listener() throws Throwable {
         mCalledCallback = false;
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
 
         d.setOnDismissListener(new OnDismissListener() {
@@ -792,7 +792,7 @@
     }
 
     public void testSetOnDismissListener_noListener() throws Throwable {
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
         assertTrue(d.isShowing());
         mCalledCallback = false;
@@ -804,7 +804,7 @@
 
     public void testSetDismissMessage() throws Throwable {
         mCalledCallback = false;
-        startDialogActivity(DialogStubActivity.TEST_DIALOG_WITHOUT_THEME);
+        startDialogActivity(DialogCtsActivity.TEST_DIALOG_WITHOUT_THEME);
         final Dialog d = mActivity.getDialog();
 
         final HandlerThread ht = new HandlerThread("DialogTest");
diff --git a/tests/src/android/app/cts/ExpandableListTestActivity.java b/tests/tests/app/src/android/app/cts/ExpandableListTestActivity.java
similarity index 100%
rename from tests/src/android/app/cts/ExpandableListTestActivity.java
rename to tests/tests/app/src/android/app/cts/ExpandableListTestActivity.java
diff --git a/tests/src/android/app/cts/IBinderParcelable.java b/tests/tests/app/src/android/app/cts/IBinderParcelable.java
similarity index 100%
rename from tests/src/android/app/cts/IBinderParcelable.java
rename to tests/tests/app/src/android/app/cts/IBinderParcelable.java
diff --git a/tests/src/android/app/cts/ISecondary.aidl b/tests/tests/app/src/android/app/cts/ISecondary.aidl
similarity index 100%
rename from tests/src/android/app/cts/ISecondary.aidl
rename to tests/tests/app/src/android/app/cts/ISecondary.aidl
diff --git a/tests/tests/app/src/android/app/cts/InstrumentationTest.java b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
index fe14c39..f528789 100644
--- a/tests/tests/app/src/android/app/cts/InstrumentationTest.java
+++ b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
@@ -16,7 +16,7 @@
 
 package android.app.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.app.R;
 
 import android.app.Activity;
 import android.app.Application;
diff --git a/tests/src/android/app/cts/InstrumentationTestActivity.java b/tests/tests/app/src/android/app/cts/InstrumentationTestActivity.java
similarity index 99%
rename from tests/src/android/app/cts/InstrumentationTestActivity.java
rename to tests/tests/app/src/android/app/cts/InstrumentationTestActivity.java
index 1cedd9f..ac1039b 100644
--- a/tests/src/android/app/cts/InstrumentationTestActivity.java
+++ b/tests/tests/app/src/android/app/cts/InstrumentationTestActivity.java
@@ -29,7 +29,7 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.widget.TextView;
-import com.android.cts.stub.R;
+import com.android.cts.app.R;
 
 public class InstrumentationTestActivity extends Activity {
 
diff --git a/tests/src/android/app/cts/IntentServiceStub.java b/tests/tests/app/src/android/app/cts/IntentServiceStub.java
similarity index 100%
rename from tests/src/android/app/cts/IntentServiceStub.java
rename to tests/tests/app/src/android/app/cts/IntentServiceStub.java
diff --git a/tests/src/android/app/cts/KeyguardManagerActivity.java b/tests/tests/app/src/android/app/cts/KeyguardManagerActivity.java
similarity index 100%
rename from tests/src/android/app/cts/KeyguardManagerActivity.java
rename to tests/tests/app/src/android/app/cts/KeyguardManagerActivity.java
diff --git a/tests/tests/app/src/android/app/cts/KeyguardManagerTest.java b/tests/tests/app/src/android/app/cts/KeyguardManagerTest.java
index 13264ac..3f04340 100644
--- a/tests/tests/app/src/android/app/cts/KeyguardManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/KeyguardManagerTest.java
@@ -27,7 +27,7 @@
     private static final String TAG = "KeyguardManagerTest";
 
     public KeyguardManagerTest() {
-        super("com.android.cts.stub", KeyguardManagerActivity.class);
+        super("com.android.cts.app", KeyguardManagerActivity.class);
     }
 
     public void testNewKeyguardLock() {
diff --git a/tests/src/android/app/cts/LauncherActivityStub.java b/tests/tests/app/src/android/app/cts/LauncherActivityStub.java
similarity index 100%
rename from tests/src/android/app/cts/LauncherActivityStub.java
rename to tests/tests/app/src/android/app/cts/LauncherActivityStub.java
diff --git a/tests/tests/app/src/android/app/cts/LauncherActivityTest.java b/tests/tests/app/src/android/app/cts/LauncherActivityTest.java
index 2c8532a..040ff83 100644
--- a/tests/tests/app/src/android/app/cts/LauncherActivityTest.java
+++ b/tests/tests/app/src/android/app/cts/LauncherActivityTest.java
@@ -36,7 +36,7 @@
     private LauncherActivityStub mActivity;
 
     public LauncherActivityTest() {
-        super("com.android.cts.stub", LauncherActivityStub.class);
+        super("com.android.cts.app", LauncherActivityStub.class);
     }
 
     @Override
diff --git a/tests/tests/app/src/android/app/cts/LauncherActivity_IconResizerTest.java b/tests/tests/app/src/android/app/cts/LauncherActivity_IconResizerTest.java
index 695050a..e36cf57 100644
--- a/tests/tests/app/src/android/app/cts/LauncherActivity_IconResizerTest.java
+++ b/tests/tests/app/src/android/app/cts/LauncherActivity_IconResizerTest.java
@@ -16,7 +16,7 @@
 
 package android.app.cts;
 
-import com.android.cts.stub.R;
+import com.android.cts.app.R;
 
 
 import android.app.LauncherActivity;
@@ -27,7 +27,7 @@
 public class LauncherActivity_IconResizerTest extends
         ActivityInstrumentationTestCase2<LauncherActivityStub> {
 
-    private static final String PACKAGE = "com.android.cts.stub";
+    private static final String PACKAGE = "com.android.cts.app";
     private LauncherActivityStub mActivity;
 
     public LauncherActivity_IconResizerTest() {
diff --git a/tests/src/android/app/cts/LaunchpadActivity.java b/tests/tests/app/src/android/app/cts/LaunchpadActivity.java
similarity index 100%
rename from tests/src/android/app/cts/LaunchpadActivity.java
rename to tests/tests/app/src/android/app/cts/LaunchpadActivity.java
diff --git a/tests/src/android/app/cts/LaunchpadTabActivity.java b/tests/tests/app/src/android/app/cts/LaunchpadTabActivity.java
similarity index 100%
rename from tests/src/android/app/cts/LaunchpadTabActivity.java
rename to tests/tests/app/src/android/app/cts/LaunchpadTabActivity.java
diff --git a/tests/src/android/app/cts/LocalActivity.java b/tests/tests/app/src/android/app/cts/LocalActivity.java
similarity index 100%
rename from tests/src/android/app/cts/LocalActivity.java
rename to tests/tests/app/src/android/app/cts/LocalActivity.java
diff --git a/tests/src/android/app/cts/LocalActivityManagerStubActivity.java b/tests/tests/app/src/android/app/cts/LocalActivityManagerCtsActivity.java
similarity index 95%
rename from tests/src/android/app/cts/LocalActivityManagerStubActivity.java
rename to tests/tests/app/src/android/app/cts/LocalActivityManagerCtsActivity.java
index e64c75a..93da3e4 100644
--- a/tests/src/android/app/cts/LocalActivityManagerStubActivity.java
+++ b/tests/tests/app/src/android/app/cts/LocalActivityManagerCtsActivity.java
@@ -19,7 +19,7 @@
 import android.app.Activity;
 import android.os.Bundle;
 
-public class LocalActivityManagerStubActivity extends Activity{
+public class LocalActivityManagerCtsActivity extends Activity{
 
     public static boolean sIsOnResumeCalled;
     public static boolean sIsOnStopCalled;
diff --git a/tests/src/android/app/cts/LocalActivityManagerTestHelper.java b/tests/tests/app/src/android/app/cts/LocalActivityManagerTestHelper.java
similarity index 90%
rename from tests/src/android/app/cts/LocalActivityManagerTestHelper.java
rename to tests/tests/app/src/android/app/cts/LocalActivityManagerTestHelper.java
index 76af648..5c0aca0 100644
--- a/tests/src/android/app/cts/LocalActivityManagerTestHelper.java
+++ b/tests/tests/app/src/android/app/cts/LocalActivityManagerTestHelper.java
@@ -87,7 +87,7 @@
 
     private void testRemoveAllActivity() {
         final String id = "id_remove_activity";
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mLocalActivityManager.startActivity(id, intent);
 
@@ -98,7 +98,7 @@
         }
 
         if (!activity.getClass().getName().equals("android.app.cts."
-                    + "LocalActivityManagerStubActivity")) {
+                    + "LocalActivityManagerCtsActivity")) {
             fail();
             return;
         }
@@ -115,27 +115,27 @@
     private void testDispatchDestroy() {
         final String id1 = "id_dispatch_destroy1";
         final String id2 = "id_dispatch_destroy2";
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mLocalActivityManager.startActivity(id1, intent);
 
-        LocalActivityManagerStubActivity.sIsOnDestroyCalled = false;
+        LocalActivityManagerCtsActivity.sIsOnDestroyCalled = false;
         mLocalActivityManager.dispatchDestroy(false);
         if (mLocalActivityManager.getCurrentActivity().isFinishing()){
             fail();
             return;
         }
 
-        if (!LocalActivityManagerStubActivity.sIsOnDestroyCalled) {
+        if (!LocalActivityManagerCtsActivity.sIsOnDestroyCalled) {
             fail();
             return;
         }
 
         mLocalActivityManager.startActivity(id2, intent);
-        LocalActivityManagerStubActivity.sIsOnDestroyCalled = false;
+        LocalActivityManagerCtsActivity.sIsOnDestroyCalled = false;
         mLocalActivityManager.dispatchDestroy(true);
 
-        if (!LocalActivityManagerStubActivity.sIsOnDestroyCalled) {
+        if (!LocalActivityManagerCtsActivity.sIsOnDestroyCalled) {
             fail();
             return;
         }
@@ -157,7 +157,7 @@
         }
 
         final String id = "id_dispatch_pause";
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mLocalActivityManager.startActivity(id, intent);
 
@@ -176,12 +176,12 @@
 
     private void testDispatchPauseFalse() {
         final String id = "id_dispatch_pause";
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mLocalActivityManager.startActivity(id, intent);
-        LocalActivityManagerStubActivity.sIsOnPauseCalled = false;
+        LocalActivityManagerCtsActivity.sIsOnPauseCalled = false;
         mLocalActivityManager.dispatchPause(false);
-        if (!LocalActivityManagerStubActivity.sIsOnPauseCalled) {
+        if (!LocalActivityManagerCtsActivity.sIsOnPauseCalled) {
             fail();
             return;
         }
@@ -190,12 +190,12 @@
 
     private void testDispatchPauseTrue() {
         final String id = "id_dispatch_pause";
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mLocalActivityManager.startActivity(id, intent);
-        LocalActivityManagerStubActivity.sIsOnPauseCalled = false;
+        LocalActivityManagerCtsActivity.sIsOnPauseCalled = false;
         mLocalActivityManager.dispatchPause(true);
-        if (!LocalActivityManagerStubActivity.sIsOnPauseCalled) {
+        if (!LocalActivityManagerCtsActivity.sIsOnPauseCalled) {
             fail();
             return;
         }
@@ -204,7 +204,7 @@
 
     private void testDispatchStop() {
         final String id = "id_dispatch_stop";
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mLocalActivityManager.startActivity(id, intent);
         if (mLocalActivityManager.getCurrentActivity() == null) {
@@ -212,10 +212,10 @@
             return;
         }
 
-        LocalActivityManagerStubActivity.sIsOnStopCalled = false;
+        LocalActivityManagerCtsActivity.sIsOnStopCalled = false;
         mLocalActivityManager.dispatchStop();
 
-        if (!LocalActivityManagerStubActivity.sIsOnStopCalled) {
+        if (!LocalActivityManagerCtsActivity.sIsOnStopCalled) {
             fail();
             return;
         }
@@ -226,7 +226,7 @@
         final Bundle EXPECTED = new Bundle();
         final String id = "id";
 
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mLocalActivityManager.startActivity("_id" + System.currentTimeMillis(), intent);
         final Bundle bundle = mLocalActivityManager.saveInstanceState();
@@ -261,7 +261,7 @@
     }
 
     private void testStartActivity() {
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         final String id = "_id_resume_test";
         final Window w = mLocalActivityManager.startActivity(id, intent);
@@ -315,13 +315,13 @@
     }
 
     private void testDispatchResume() {
-        final Intent intent = new Intent(this, LocalActivityManagerStubActivity.class);
+        final Intent intent = new Intent(this, LocalActivityManagerCtsActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mLocalActivityManager.startActivity("_id_resume_test", intent);
         mLocalActivityManager.dispatchStop();
-        LocalActivityManagerStubActivity.sIsOnResumeCalled = false;
+        LocalActivityManagerCtsActivity.sIsOnResumeCalled = false;
         mLocalActivityManager.dispatchResume();
-        if (LocalActivityManagerStubActivity.sIsOnResumeCalled) {
+        if (LocalActivityManagerCtsActivity.sIsOnResumeCalled) {
             pass();
         } else {
             fail();
diff --git a/tests/src/android/app/cts/LocalDeniedService.java b/tests/tests/app/src/android/app/cts/LocalDeniedService.java
similarity index 100%
rename from tests/src/android/app/cts/LocalDeniedService.java
rename to tests/tests/app/src/android/app/cts/LocalDeniedService.java
diff --git a/tests/src/android/app/cts/LocalDialog.java b/tests/tests/app/src/android/app/cts/LocalDialog.java
similarity index 100%
rename from tests/src/android/app/cts/LocalDialog.java
rename to tests/tests/app/src/android/app/cts/LocalDialog.java
diff --git a/tests/src/android/app/cts/LocalGrantedService.java b/tests/tests/app/src/android/app/cts/LocalGrantedService.java
similarity index 100%
rename from tests/src/android/app/cts/LocalGrantedService.java
rename to tests/tests/app/src/android/app/cts/LocalGrantedService.java
diff --git a/tests/src/android/app/cts/LocalScreen.java b/tests/tests/app/src/android/app/cts/LocalScreen.java
similarity index 100%
rename from tests/src/android/app/cts/LocalScreen.java
rename to tests/tests/app/src/android/app/cts/LocalScreen.java
diff --git a/tests/src/android/app/cts/LocalService.java b/tests/tests/app/src/android/app/cts/LocalService.java
similarity index 100%
rename from tests/src/android/app/cts/LocalService.java
rename to tests/tests/app/src/android/app/cts/LocalService.java
diff --git a/tests/src/android/app/cts/MockActivity.java b/tests/tests/app/src/android/app/cts/MockActivity.java
similarity index 100%
rename from tests/src/android/app/cts/MockActivity.java
rename to tests/tests/app/src/android/app/cts/MockActivity.java
diff --git a/tests/src/android/app/cts/MockAlarmReceiver.java b/tests/tests/app/src/android/app/cts/MockAlarmReceiver.java
similarity index 100%
rename from tests/src/android/app/cts/MockAlarmReceiver.java
rename to tests/tests/app/src/android/app/cts/MockAlarmReceiver.java
diff --git a/tests/src/android/app/cts/MockApplication.java b/tests/tests/app/src/android/app/cts/MockApplication.java
similarity index 100%
rename from tests/src/android/app/cts/MockApplication.java
rename to tests/tests/app/src/android/app/cts/MockApplication.java
diff --git a/tests/src/android/app/cts/MockApplicationActivity.java b/tests/tests/app/src/android/app/cts/MockApplicationActivity.java
similarity index 100%
rename from tests/src/android/app/cts/MockApplicationActivity.java
rename to tests/tests/app/src/android/app/cts/MockApplicationActivity.java
diff --git a/tests/src/android/app/cts/MockReceiver.java b/tests/tests/app/src/android/app/cts/MockReceiver.java
similarity index 100%
rename from tests/src/android/app/cts/MockReceiver.java
rename to tests/tests/app/src/android/app/cts/MockReceiver.java
diff --git a/tests/src/android/app/cts/MockService.java b/tests/tests/app/src/android/app/cts/MockService.java
similarity index 100%
rename from tests/src/android/app/cts/MockService.java
rename to tests/tests/app/src/android/app/cts/MockService.java
diff --git a/tests/src/android/app/cts/MockTabActivity.java b/tests/tests/app/src/android/app/cts/MockTabActivity.java
similarity index 95%
rename from tests/src/android/app/cts/MockTabActivity.java
rename to tests/tests/app/src/android/app/cts/MockTabActivity.java
index aca19f5..ebbeb7b 100644
--- a/tests/src/android/app/cts/MockTabActivity.java
+++ b/tests/tests/app/src/android/app/cts/MockTabActivity.java
@@ -46,7 +46,7 @@
                 .setContent(new Intent(this, MockActivity.class)));
 
         tabHost.addTab(tabHost.newTabSpec(TAB3).setIndicator(TAB3).setContent(
-                new Intent(this, AppStubActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
+                new Intent(this, AppCtsActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
 
     }
 
diff --git a/tests/tests/app/src/android/app/cts/NotificationManagerTest.java b/tests/tests/app/src/android/app/cts/NotificationManagerTest.java
index 4add582..94b410f 100644
--- a/tests/tests/app/src/android/app/cts/NotificationManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/NotificationManagerTest.java
@@ -24,7 +24,7 @@
 import android.provider.Telephony.Threads;
 import android.test.AndroidTestCase;
 
-import com.android.cts.stub.R;
+import com.android.cts.app.R;
 
 
 public class NotificationManagerTest extends AndroidTestCase {
diff --git a/tests/src/android/app/cts/OrientationTestUtils.java b/tests/tests/app/src/android/app/cts/OrientationTestUtils.java
similarity index 100%
rename from tests/src/android/app/cts/OrientationTestUtils.java
rename to tests/tests/app/src/android/app/cts/OrientationTestUtils.java
diff --git a/tests/src/android/app/cts/PendingIntentStubActivity.java b/tests/tests/app/src/android/app/cts/PendingIntentCtsActivity.java
similarity index 93%
rename from tests/src/android/app/cts/PendingIntentStubActivity.java
rename to tests/tests/app/src/android/app/cts/PendingIntentCtsActivity.java
index a2a3bd8..f11fe10 100644
--- a/tests/src/android/app/cts/PendingIntentStubActivity.java
+++ b/tests/tests/app/src/android/app/cts/PendingIntentCtsActivity.java
@@ -19,7 +19,7 @@
 import android.app.Activity;
 import android.os.Bundle;
 
-public class PendingIntentStubActivity extends Activity {
+public class PendingIntentCtsActivity extends Activity {
 
     public static final int INVALIDATE = -1;
     public static final int ON_CREATE = 0;
diff --git a/tests/tests/app/src/android/app/cts/PendingIntentTest.java b/tests/tests/app/src/android/app/cts/PendingIntentTest.java
index d2c1b31..fb32291 100644
--- a/tests/tests/app/src/android/app/cts/PendingIntentTest.java
+++ b/tests/tests/app/src/android/app/cts/PendingIntentTest.java
@@ -95,11 +95,11 @@
     }
 
     public void testGetActivity() throws InterruptedException, CanceledException {
-        PendingIntentStubActivity.status = PendingIntentStubActivity.INVALIDATE;
+        PendingIntentCtsActivity.status = PendingIntentCtsActivity.INVALIDATE;
         mPendingIntent = null;
         mIntent = new Intent();
 
-        mIntent.setClass(mContext, PendingIntentStubActivity.class);
+        mIntent.setClass(mContext, PendingIntentCtsActivity.class);
         mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mPendingIntent = PendingIntent.getActivity(mContext, 1, mIntent,
                 PendingIntent.FLAG_CANCEL_CURRENT);
@@ -109,7 +109,7 @@
 
         Thread.sleep(WAIT_TIME);
         assertNotNull(mPendingIntent);
-        assertEquals(PendingIntentStubActivity.status, PendingIntentStubActivity.ON_CREATE);
+        assertEquals(PendingIntentCtsActivity.status, PendingIntentCtsActivity.ON_CREATE);
 
         // test getActivity return null
         mPendingIntent.cancel();
diff --git a/tests/tests/app/src/android/app/cts/ProgressDialogTest.java b/tests/tests/app/src/android/app/cts/ProgressDialogTest.java
index aa37b39..106b504 100644
--- a/tests/tests/app/src/android/app/cts/ProgressDialogTest.java
+++ b/tests/tests/app/src/android/app/cts/ProgressDialogTest.java
@@ -50,7 +50,7 @@
     private MockActivity mActivity;
 
     public ProgressDialogTest() {
-        super("com.android.cts.stub", MockActivity.class);
+        super("com.android.cts.app", MockActivity.class);
     }
 
     @Override
@@ -62,7 +62,7 @@
         mActivity = getActivity();
         mContext = mActivity;
         mDrawable = getActivity().getResources().getDrawable(
-                com.android.cts.stub.R.drawable.yellow);
+                com.android.cts.app.R.drawable.yellow);
     }
 
     @UiThreadTest
@@ -72,7 +72,7 @@
 
     @UiThreadTest
     public void testProgressDialog2(){
-        new ProgressDialog(mContext, com.android.cts.stub.R.style.Theme_AlertDialog);
+        new ProgressDialog(mContext, com.android.cts.app.R.style.Theme_AlertDialog);
     }
 
     @UiThreadTest
diff --git a/tests/src/android/app/cts/SearchManagerStubActivity.java b/tests/tests/app/src/android/app/cts/SearchManagerCtsActivity.java
similarity index 97%
rename from tests/src/android/app/cts/SearchManagerStubActivity.java
rename to tests/tests/app/src/android/app/cts/SearchManagerCtsActivity.java
index 6385fef..7198e8d 100644
--- a/tests/src/android/app/cts/SearchManagerStubActivity.java
+++ b/tests/tests/app/src/android/app/cts/SearchManagerCtsActivity.java
@@ -25,9 +25,9 @@
 import android.os.Message;
 import android.util.Log;
 
-public class SearchManagerStubActivity extends Activity {
+public class SearchManagerCtsActivity extends Activity {
 
-    private static final String TAG = "SearchManagerStubActivity";
+    private static final String TAG = "SearchManagerCtsActivity";
 
     public static final String TEST_STOP_SEARCH = "stopSearch";
     public static final String TEST_ON_DISMISSLISTENER = "setOnDismissListener";
diff --git a/tests/tests/app/src/android/app/cts/SearchManagerTest.java b/tests/tests/app/src/android/app/cts/SearchManagerTest.java
index 8e465e8..ef7a0e0 100644
--- a/tests/tests/app/src/android/app/cts/SearchManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/SearchManagerTest.java
@@ -24,25 +24,25 @@
         Intent intent = new Intent();
         intent.setAction(action);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        intent.setClass(getInstrumentation().getTargetContext(), SearchManagerStubActivity.class);
+        intent.setClass(getInstrumentation().getTargetContext(), SearchManagerCtsActivity.class);
         getInstrumentation().getTargetContext().startActivity(intent);
     }
 
     public void testStopSearch() throws InterruptedException {
-        SearchManagerStubActivity.setCTSResult(this);
-        setupActivity(SearchManagerStubActivity.TEST_STOP_SEARCH);
+        SearchManagerCtsActivity.setCTSResult(this);
+        setupActivity(SearchManagerCtsActivity.TEST_STOP_SEARCH);
         waitForResult();
     }
 
     public void testSetOnDismissListener() throws InterruptedException {
-        SearchManagerStubActivity.setCTSResult(this);
-        setupActivity(SearchManagerStubActivity.TEST_ON_DISMISSLISTENER);
+        SearchManagerCtsActivity.setCTSResult(this);
+        setupActivity(SearchManagerCtsActivity.TEST_ON_DISMISSLISTENER);
         waitForResult();
     }
 
     public void testSetOnCancelListener() throws InterruptedException {
-        SearchManagerStubActivity.setCTSResult(this);
-        setupActivity(SearchManagerStubActivity.TEST_ON_CANCELLISTENER);
+        SearchManagerCtsActivity.setCTSResult(this);
+        setupActivity(SearchManagerCtsActivity.TEST_ON_CANCELLISTENER);
         waitForResult();
     }
 }
diff --git a/tests/src/android/app/cts/StubRemoteService.java b/tests/tests/app/src/android/app/cts/StubRemoteService.java
similarity index 100%
rename from tests/src/android/app/cts/StubRemoteService.java
rename to tests/tests/app/src/android/app/cts/StubRemoteService.java
diff --git a/tests/tests/app/src/android/app/cts/SystemFeaturesTest.java b/tests/tests/app/src/android/app/cts/SystemFeaturesTest.java
index e3dca19..165e67b 100644
--- a/tests/tests/app/src/android/app/cts/SystemFeaturesTest.java
+++ b/tests/tests/app/src/android/app/cts/SystemFeaturesTest.java
@@ -136,9 +136,15 @@
         }
 
         if (frontCameraId > -1) {
-            assertAvailable(PackageManager.FEATURE_CAMERA_FRONT);
+            assertTrue("Device has front-facing camera but does not report either " +
+                    "the FEATURE_CAMERA_FRONT or FEATURE_CAMERA_EXTERNAL feature",
+                    mPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT) ||
+                    mPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_EXTERNAL));
         } else {
-            assertNotAvailable(PackageManager.FEATURE_CAMERA_FRONT);
+            assertFalse("Device does not have front-facing camera but reports either " +
+                    "the FEATURE_CAMERA_FRONT or FEATURE_CAMERA_EXTERNAL feature",
+                    mPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT) ||
+                    mPackageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_EXTERNAL));
         }
     }
 
diff --git a/tests/tests/app/src/android/app/cts/TabActivityTest.java b/tests/tests/app/src/android/app/cts/TabActivityTest.java
index 29c369d..403b393 100644
--- a/tests/tests/app/src/android/app/cts/TabActivityTest.java
+++ b/tests/tests/app/src/android/app/cts/TabActivityTest.java
@@ -61,7 +61,7 @@
             }
         });
         mInstrumentation.waitForIdleSync();
-        final String packageName = "com.android.cts.stub";
+        final String packageName = "com.android.cts.app";
         final Intent intent = new Intent(Intent.ACTION_MAIN);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         intent.setClassName(packageName, MockTabActivity.class.getName());
diff --git a/tests/src/android/app/cts/TestDialog.java b/tests/tests/app/src/android/app/cts/TestDialog.java
similarity index 100%
rename from tests/src/android/app/cts/TestDialog.java
rename to tests/tests/app/src/android/app/cts/TestDialog.java
diff --git a/tests/src/android/app/cts/TestedActivity.java b/tests/tests/app/src/android/app/cts/TestedActivity.java
similarity index 100%
rename from tests/src/android/app/cts/TestedActivity.java
rename to tests/tests/app/src/android/app/cts/TestedActivity.java
diff --git a/tests/src/android/app/cts/TestedScreen.java b/tests/tests/app/src/android/app/cts/TestedScreen.java
similarity index 100%
rename from tests/src/android/app/cts/TestedScreen.java
rename to tests/tests/app/src/android/app/cts/TestedScreen.java
diff --git a/tests/tests/app/src/android/app/cts/TimePickerDialogTest.java b/tests/tests/app/src/android/app/cts/TimePickerDialogTest.java
index 86db13d..2fe2d69 100644
--- a/tests/tests/app/src/android/app/cts/TimePickerDialogTest.java
+++ b/tests/tests/app/src/android/app/cts/TimePickerDialogTest.java
@@ -28,7 +28,7 @@
 /**
  * Test {@link TimePickerDialog}.
  */
-public class TimePickerDialogTest extends ActivityInstrumentationTestCase2<DialogStubActivity> {
+public class TimePickerDialogTest extends ActivityInstrumentationTestCase2<DialogCtsActivity> {
     private static final String HOUR = "hour";
     private static final String MINUTE = "minute";
     private static final String IS_24_HOUR = "is24hour";
@@ -42,10 +42,10 @@
     private OnTimeSetListener mOnTimeSetListener;
 
     private Context mContext;
-    private DialogStubActivity mActivity;
+    private DialogCtsActivity mActivity;
 
     public TimePickerDialogTest() {
-        super("com.android.cts.stub", DialogStubActivity.class);
+        super("com.android.cts.app", DialogCtsActivity.class);
     }
 
     @Override
@@ -74,8 +74,9 @@
 
         int minute = 13;
         tD = new TimePickerDialog(
-                mContext, com.android.cts.stub.R.style.Theme_AlertDialog,
+                mContext, com.android.cts.app.R.style.Theme_AlertDialog,
                     mOnTimeSetListener, TARGET_HOUR, minute, false);
+
         b = tD.onSaveInstanceState();
 
         assertEquals(TARGET_HOUR, b.getInt(HOUR));
@@ -94,7 +95,7 @@
 
     public void testOnTimeChanged() throws Throwable {
         final int minute = 34;
-        startDialogActivity(DialogStubActivity.TEST_TIMEPICKERDIALOG);
+        startDialogActivity(DialogCtsActivity.TEST_TIMEPICKERDIALOG);
         final TimePickerDialog d = (TimePickerDialog) mActivity.getDialog();
 
         runTestOnUiThread(new Runnable() {
@@ -139,7 +140,7 @@
     }
 
     private void startDialogActivity(int dialogNumber) {
-        mActivity = DialogStubActivity.startDialogActivity(this, dialogNumber);
+        mActivity = DialogCtsActivity.startDialogActivity(this, dialogNumber);
     }
 
     private TimePickerDialog buildDialog() {
diff --git a/tests/tests/content/src/android/content/cts/AsyncQueryHandlerTest.java b/tests/tests/content/src/android/content/cts/AsyncQueryHandlerTest.java
index 18e0b2e..3d4ca81 100644
--- a/tests/tests/content/src/android/content/cts/AsyncQueryHandlerTest.java
+++ b/tests/tests/content/src/android/content/cts/AsyncQueryHandlerTest.java
@@ -25,14 +25,15 @@
 import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.Looper;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
+import android.test.UiThreadTest;
 
 /**
  * Test {@link AsyncQueryHandler} and {@link WorkerHandler}}.
  *
  * @see DummyProvider
  */
-public class AsyncQueryHandlerTest extends AndroidTestCase {
+public class AsyncQueryHandlerTest extends InstrumentationTestCase {
     private static final long TEST_TIME_OUT = DummyProvider.MOCK_OPERATION_SLEEP_TIME + 5000;
 
     private static final int INSERT_TOKEN_1    = 100;
@@ -74,7 +75,7 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        mResolver = mContext.getContentResolver();
+        mResolver = getInstrumentation().getTargetContext().getContentResolver();
 
         ContentValues values0 = new ContentValues();
         values0.put(DummyProvider.NAME, NAME0);
@@ -96,9 +97,9 @@
         super.tearDown();
     }
 
+    @UiThreadTest
     public void testConstructor() {
         new AsyncQueryHandler(mResolver) {};
-
         new AsyncQueryHandler(null) {};
     }
 
@@ -257,9 +258,10 @@
         }
     }
 
+    @UiThreadTest
     public void testCreateHandler() {
         MockAsyncQueryHandler wrapper = new MockAsyncQueryHandler(mResolver);
-        Handler result = wrapper.createHandler(Looper.myLooper());
+        Handler result = wrapper.createHandler(Looper.getMainLooper());
         assertNotNull(result);
         assertSame(Looper.myLooper(), result.getLooper());
 
diff --git a/tests/tests/content/src/android/content/cts/ClipboardManagerTest.java b/tests/tests/content/src/android/content/cts/ClipboardManagerTest.java
index bf0a175..e92834c 100644
--- a/tests/tests/content/src/android/content/cts/ClipboardManagerTest.java
+++ b/tests/tests/content/src/android/content/cts/ClipboardManagerTest.java
@@ -23,39 +23,44 @@
 import android.content.Intent;
 import android.content.ClipData.Item;
 import android.net.Uri;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
+import android.test.UiThreadTest;
 
-public class ClipboardManagerTest extends AndroidTestCase {
-
-    private ClipboardManager mClipboardManager;
+public class ClipboardManagerTest extends InstrumentationTestCase {
+    private Context mContext;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        mClipboardManager = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
+        mContext = getInstrumentation().getTargetContext();
     }
 
+    @UiThreadTest
     public void testSetGetText() {
-        mClipboardManager.setText("Test Text 1");
-        assertEquals("Test Text 1", mClipboardManager.getText());
+        ClipboardManager clipboardManager = makeClipboardManager();
+        clipboardManager.setText("Test Text 1");
+        assertEquals("Test Text 1", clipboardManager.getText());
 
-        mClipboardManager.setText("Test Text 2");
-        assertEquals("Test Text 2", mClipboardManager.getText());
+        clipboardManager.setText("Test Text 2");
+        assertEquals("Test Text 2", clipboardManager.getText());
     }
 
+    @UiThreadTest
     public void testHasPrimaryClip() {
-        if (mClipboardManager.hasPrimaryClip()) {
-            assertNotNull(mClipboardManager.getPrimaryClip());
-            assertNotNull(mClipboardManager.getPrimaryClipDescription());
+        ClipboardManager clipboardManager = makeClipboardManager();
+        if (clipboardManager.hasPrimaryClip()) {
+            assertNotNull(clipboardManager.getPrimaryClip());
+            assertNotNull(clipboardManager.getPrimaryClipDescription());
         } else {
-            assertNull(mClipboardManager.getPrimaryClip());
-            assertNull(mClipboardManager.getPrimaryClipDescription());
+            assertNull(clipboardManager.getPrimaryClip());
+            assertNull(clipboardManager.getPrimaryClipDescription());
         }
 
-        mClipboardManager.setPrimaryClip(ClipData.newPlainText("Label", "Text"));
-        assertTrue(mClipboardManager.hasPrimaryClip());
+        clipboardManager.setPrimaryClip(ClipData.newPlainText("Label", "Text"));
+        assertTrue(clipboardManager.hasPrimaryClip());
     }
 
+    @UiThreadTest
     public void testSetPrimaryClip_plainText() {
         ClipData textData = ClipData.newPlainText("TextLabel", "Text");
         assertSetPrimaryClip(textData, "TextLabel",
@@ -63,6 +68,7 @@
                 new ExpectedClipItem("Text", null, null));
     }
 
+    @UiThreadTest
     public void testSetPrimaryClip_intent() {
         Intent intent = new Intent(mContext, ClipboardManagerTest.class);
         ClipData intentData = ClipData.newIntent("IntentLabel", intent);
@@ -71,6 +77,7 @@
                 new ExpectedClipItem(null, intent, null));
     }
 
+    @UiThreadTest
     public void testSetPrimaryClip_rawUri() {
         Uri uri = Uri.parse("http://www.google.com");
         ClipData uriData = ClipData.newRawUri("UriLabel", uri);
@@ -79,15 +86,17 @@
                 new ExpectedClipItem(null, null, uri));
     }
 
+    @UiThreadTest
     public void testSetPrimaryClip_contentUri() {
         Uri contentUri = Uri.parse("content://cts/test/for/clipboardmanager");
-        ClipData contentUriData = ClipData.newUri(getContext().getContentResolver(),
+        ClipData contentUriData = ClipData.newUri(mContext.getContentResolver(),
                 "ContentUriLabel", contentUri);
         assertSetPrimaryClip(contentUriData, "ContentUriLabel",
                 new String[] {ClipDescription.MIMETYPE_TEXT_URILIST},
                 new ExpectedClipItem(null, null, contentUri));
     }
 
+    @UiThreadTest
     public void testSetPrimaryClip_complexItem() {
         Intent intent = new Intent(mContext, ClipboardManagerTest.class);
         Uri uri = Uri.parse("http://www.google.com");
@@ -103,6 +112,7 @@
                 new ExpectedClipItem("Text", intent, uri));
     }
 
+    @UiThreadTest
     public void testSetPrimaryClip_multipleItems() {
         Intent intent = new Intent(mContext, ClipboardManagerTest.class);
         Uri uri = Uri.parse("http://www.google.com");
@@ -134,22 +144,23 @@
             String expectedLabel,
             String[] expectedMimeTypes,
             ExpectedClipItem... expectedClipItems) {
+        ClipboardManager clipboardManager = makeClipboardManager();
 
-        mClipboardManager.setPrimaryClip(clipData);
-        assertTrue(mClipboardManager.hasPrimaryClip());
+        clipboardManager.setPrimaryClip(clipData);
+        assertTrue(clipboardManager.hasPrimaryClip());
 
         if (expectedClipItems != null
                 && expectedClipItems.length > 0
                 && expectedClipItems[0].mText != null) {
-            assertTrue(mClipboardManager.hasText());
+            assertTrue(clipboardManager.hasText());
         } else {
-            assertFalse(mClipboardManager.hasText());
+            assertFalse(clipboardManager.hasText());
         }
 
-        assertNotNull(mClipboardManager.getPrimaryClip());
-        assertNotNull(mClipboardManager.getPrimaryClipDescription());
+        assertNotNull(clipboardManager.getPrimaryClip());
+        assertNotNull(clipboardManager.getPrimaryClipDescription());
 
-        ClipData data = mClipboardManager.getPrimaryClip();
+        ClipData data = clipboardManager.getPrimaryClip();
         if (expectedClipItems != null) {
             assertEquals(expectedClipItems.length, data.getItemCount());
             for (int i = 0; i < expectedClipItems.length; i++) {
@@ -162,7 +173,7 @@
         assertClipDescription(data.getDescription(),
                 expectedLabel, expectedMimeTypes);
 
-        assertClipDescription(mClipboardManager.getPrimaryClipDescription(),
+        assertClipDescription(clipboardManager.getPrimaryClipDescription(),
                 expectedLabel, expectedMimeTypes);
     }
 
@@ -189,4 +200,8 @@
             assertNull(item.getUri());
         }
     }
+
+    private ClipboardManager makeClipboardManager() {
+        return (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
+    }
 }
diff --git a/tests/tests/content/src/android/content/cts/ContentQueryMapTest.java b/tests/tests/content/src/android/content/cts/ContentQueryMapTest.java
index ac23a5b..2385b0f 100644
--- a/tests/tests/content/src/android/content/cts/ContentQueryMapTest.java
+++ b/tests/tests/content/src/android/content/cts/ContentQueryMapTest.java
@@ -20,11 +20,13 @@
 import android.content.ContentQueryMap;
 import android.content.ContentResolver;
 import android.content.ContentValues;
+import android.content.Context;
 import android.database.Cursor;
 import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.Looper;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
+import android.test.UiThreadTest;
 
 import java.util.Map;
 import java.util.Observable;
@@ -33,7 +35,7 @@
 /**
  * Test {@link ContentQueryMap}.
  */
-public class ContentQueryMapTest extends AndroidTestCase {
+public class ContentQueryMapTest extends InstrumentationTestCase {
     private static final int TEST_TIME_OUT = 5000;
 
     private static final String NAME0  = "name0";
@@ -52,10 +54,12 @@
     private ContentResolver mResolver;
     private Cursor mCursor;
     private ContentQueryMap mContentQueryMap;
+    private Context mContext;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
+        mContext = getInstrumentation().getTargetContext();
         mResolver = mContext.getContentResolver();
 
         ContentValues values0 = new ContentValues();
@@ -88,6 +92,7 @@
         super.tearDown();
     }
 
+    @UiThreadTest
     public void testConstructor() {
         new ContentQueryMap(mCursor, DummyProvider.NAME, true, null);
 
@@ -106,6 +111,7 @@
         }
     }
 
+    @UiThreadTest
     public void testGetRows() {
         // handler can be null
         mContentQueryMap = new ContentQueryMap(mCursor, DummyProvider.NAME, true, null);
diff --git a/tests/tests/content/src/android/content/cts/MutableContextWrapperTest.java b/tests/tests/content/src/android/content/cts/MutableContextWrapperTest.java
index aaba30c..e7288af 100644
--- a/tests/tests/content/src/android/content/cts/MutableContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/MutableContextWrapperTest.java
@@ -18,9 +18,10 @@
 
 import android.content.Context;
 import android.content.MutableContextWrapper;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
+import android.test.UiThreadTest;
 
-public class MutableContextWrapperTest extends AndroidTestCase {
+public class MutableContextWrapperTest extends InstrumentationTestCase {
 
     MutableContextWrapper mMutableContextWrapper;
     Context mContext;
@@ -29,7 +30,7 @@
     protected void setUp() throws Exception {
         super.setUp();
         mMutableContextWrapper = null;
-        mContext = getContext();
+        mContext = getInstrumentation().getTargetContext();
     }
 
     public void testConstructor() {
@@ -38,6 +39,7 @@
         assertNotNull(mMutableContextWrapper);
     }
 
+    @UiThreadTest
     public void testSetBaseContext() {
         mMutableContextWrapper = new MutableContextWrapper(mContext);
         assertTrue(mContext.equals(mMutableContextWrapper.getBaseContext()));
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
index 1d28e6d..ec7ecf8 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
@@ -239,7 +239,6 @@
                 requestKeys.add(CaptureRequest.CONTROL_AE_LOCK);
                 requestKeys.add(CaptureRequest.CONTROL_AE_MODE);
                 requestKeys.add(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE);
-                requestKeys.add(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER);
                 requestKeys.add(CaptureRequest.CONTROL_AF_MODE);
                 requestKeys.add(CaptureRequest.CONTROL_AF_TRIGGER);
                 requestKeys.add(CaptureRequest.CONTROL_AWB_LOCK);
@@ -255,7 +254,6 @@
                 requestKeys.add(CaptureRequest.JPEG_QUALITY);
                 requestKeys.add(CaptureRequest.JPEG_THUMBNAIL_QUALITY);
                 requestKeys.add(CaptureRequest.JPEG_THUMBNAIL_SIZE);
-                requestKeys.add(CaptureRequest.LENS_FOCUS_DISTANCE);
                 requestKeys.add(CaptureRequest.SCALER_CROP_REGION);
                 requestKeys.add(CaptureRequest.STATISTICS_FACE_DETECT_MODE);
                 if (mStaticInfo.getAeMaxRegionsChecked() > 0) {
diff --git a/tests/tests/location/src/android/location/cts/LocationManagerTest.java b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
index ab11b3c..a985aee 100644
--- a/tests/tests/location/src/android/location/cts/LocationManagerTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
@@ -37,6 +37,7 @@
 import android.os.SystemClock;
 import android.provider.Settings;
 import android.test.InstrumentationTestCase;
+import android.test.UiThreadTest;
 
 import java.util.List;
 
@@ -615,6 +616,7 @@
         }
     }
 
+    @UiThreadTest
     public void testGpsStatusListener() {
         MockGpsStatusListener listener = new MockGpsStatusListener();
         mManager.addGpsStatusListener(listener);
diff --git a/tests/tests/os/src/android/os/cts/HandlerTest.java b/tests/tests/os/src/android/os/cts/HandlerTest.java
index 326218d..fc775e4 100644
--- a/tests/tests/os/src/android/os/cts/HandlerTest.java
+++ b/tests/tests/os/src/android/os/cts/HandlerTest.java
@@ -22,6 +22,7 @@
 import android.os.Message;
 import android.os.SystemClock;
 import android.os.Handler.Callback;
+import android.test.UiThreadTest;
 import android.util.Printer;
 
 public class HandlerTest extends TestCase {
@@ -35,8 +36,9 @@
     static final long DELAYED = RUNTIME + 50;
 
     // Handler
-    Handler mHandler = new Handler();
-    MockHandler mHandler1 = new MockHandler();
+    private final Handler mHandler = new Handler(Looper.getMainLooper());
+    private final MockHandler mHandler1 = new MockHandler(Looper.getMainLooper());
+    private final Object mLock = new Object();
 
     @Override
     protected void tearDown() throws Exception {
@@ -44,18 +46,24 @@
         super.tearDown();
     }
 
-    public void testConstructor() {
-        Callback cb = new Callback() {
+    public void testConstructor() throws Throwable {
+        final Callback cb = new Callback() {
             public boolean handleMessage(Message msg) {
                 return false;
             }
         };
 
+        new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+                new Handler();
+                new Handler(cb);
+            }
+        }).runTest(RUNTIME);
+
         // new the Handler instance
-        new Handler();
-        new Handler(Looper.myLooper());
-        new Handler(cb);
-        new Handler(Looper.myLooper(), cb);
+        new Handler(Looper.getMainLooper());
+        new Handler(Looper.getMainLooper(), cb);
     }
 
     public void testPostAtTime1() {
@@ -162,9 +170,9 @@
 
     public void testGetLooper() {
         // new the Handler instance
-        Looper looper = Looper.myLooper();
-        mHandler = new Handler(looper);
-        assertSame(looper, mHandler.getLooper());
+        Looper looper = Looper.getMainLooper();
+        Handler handler = new Handler(looper);
+        assertSame(looper, handler.getLooper());
     }
 
     public void testRemoveCallbacks() {
@@ -280,7 +288,7 @@
 
     public void testObtainMessageWithInt() {
          // new the Handler instance
-         Handler handler = new Handler();
+         Handler handler = new Handler(Looper.getMainLooper());
          Message msg = handler.obtainMessage();
          msg.what = 100;
          Message msg1 = mHandler.obtainMessage(msg.what);
@@ -291,7 +299,7 @@
 
     public void testObtainMessageWithIntObject() {
         // new the Handler instance
-        Handler handler = new Handler();
+        Handler handler = new Handler(Looper.getMainLooper());
         Message msg = handler.obtainMessage();
         msg.what = 100;
         msg.obj = new Object();
@@ -304,7 +312,7 @@
 
     public void testObtainMessageWithMutiInt() {
         // new the Handler instance
-        Handler handler = new Handler();
+        Handler handler = new Handler(Looper.getMainLooper());
         Message msg = handler.obtainMessage();
         msg.what = 100;
         msg.arg1 = 101;
@@ -319,7 +327,7 @@
 
     public void testObtainMessageWithMutiIntObject() {
         // new the Handler instance
-        Handler handler = new Handler();
+        Handler handler = new Handler(Looper.getMainLooper());
         Message msg = handler.obtainMessage();
         msg.what = 100;
         msg.arg1 = 1000;
@@ -464,6 +472,14 @@
         public Message message;
         public int what;
 
+        MockHandler() {
+            super(Looper.getMainLooper());
+        }
+
+        MockHandler(Looper looper) {
+            super(looper);
+        }
+
         @Override
         public void handleMessage(Message msg) {
             message = msg;
diff --git a/tests/tests/os/src/android/os/cts/LooperTest.java b/tests/tests/os/src/android/os/cts/LooperTest.java
index 6631599..e71b752 100644
--- a/tests/tests/os/src/android/os/cts/LooperTest.java
+++ b/tests/tests/os/src/android/os/cts/LooperTest.java
@@ -38,7 +38,7 @@
     public void testDump() {
         StringBuilderPrinter printer = new StringBuilderPrinter(new StringBuilder());
         final String prefix = "LooperTest";
-        Looper.myLooper().dump(printer, prefix);
+        Looper.getMainLooper().dump(printer, prefix);
     }
 
     public void testGetMainLooper() {
@@ -78,9 +78,6 @@
     }
 
     public void testMyQueue() throws Throwable {
-        MessageQueue mq = Looper.myQueue();
-        assertNotNull(mq);
-
         TestThread t = new TestThread(new Runnable() {
             public void run() {
                 try {
@@ -89,6 +86,9 @@
                 } catch (Throwable e) {
                     // expected
                 }
+                Looper.prepare();
+                MessageQueue mq = Looper.myQueue();
+                assertNotNull(mq);
             }
         });
 
@@ -96,13 +96,6 @@
     }
 
     public void testPrepare() throws Throwable {
-        try {
-            Looper.prepare();
-            fail("should throw exception because current thread already has a looper");
-        } catch (RuntimeException e) {
-            //expected
-        }
-
         TestThread t = new TestThread(new Runnable() {
             public void run() {
                 Looper.prepare();
@@ -191,7 +184,7 @@
     }
 
     public void testToString() {
-        assertNotNull(Looper.myLooper().toString());
+        assertNotNull(Looper.getMainLooper().toString());
     }
 
     class MockPrinter implements Printer {
diff --git a/tests/tests/os/src/android/os/cts/MessageQueueTest.java b/tests/tests/os/src/android/os/cts/MessageQueueTest.java
index 8c38d5f..5b5bf5c 100644
--- a/tests/tests/os/src/android/os/cts/MessageQueueTest.java
+++ b/tests/tests/os/src/android/os/cts/MessageQueueTest.java
@@ -208,17 +208,17 @@
     public void testReleaseSyncBarrierThrowsIfTokenNotValid() throws Exception {
         // Invalid token
         try {
-            Looper.myLooper().removeSyncBarrier(-1);
+            Looper.getMainLooper().removeSyncBarrier(-1);
             fail("Should have thrown IllegalStateException");
         } catch (IllegalStateException ex) {
             // expected
         }
 
         // Token already removed.
-        int barrierToken = Looper.myLooper().postSyncBarrier();
-        Looper.myLooper().removeSyncBarrier(barrierToken);
+        int barrierToken = Looper.getMainLooper().postSyncBarrier();
+        Looper.getMainLooper().removeSyncBarrier(barrierToken);
         try {
-            Looper.myLooper().removeSyncBarrier(barrierToken);
+            Looper.getMainLooper().removeSyncBarrier(barrierToken);
             fail("Should have thrown IllegalStateException");
         } catch (IllegalStateException ex) {
             // expected
diff --git a/tests/tests/os/src/android/os/cts/MessageTest.java b/tests/tests/os/src/android/os/cts/MessageTest.java
index cc45c4b..978897b 100644
--- a/tests/tests/os/src/android/os/cts/MessageTest.java
+++ b/tests/tests/os/src/android/os/cts/MessageTest.java
@@ -18,6 +18,7 @@
 
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
 import android.os.Parcel;
 import android.test.AndroidTestCase;
@@ -33,7 +34,7 @@
     private Message mMessage;
     private boolean mMessageHandlerCalled;
 
-    private Handler mHandler = new Handler() {
+    private Handler mHandler = new Handler(Looper.getMainLooper()) {
         public void handleMessage(Message msg) {
             mMessageHandlerCalled = true;
         }
diff --git a/tests/tests/os/src/android/os/cts/MessengerTest.java b/tests/tests/os/src/android/os/cts/MessengerTest.java
index 0512b23..72bf247 100644
--- a/tests/tests/os/src/android/os/cts/MessengerTest.java
+++ b/tests/tests/os/src/android/os/cts/MessengerTest.java
@@ -43,7 +43,7 @@
     private static final int MSG_ARG1 = 100;
     private static final int MSG_ARG2 = 1000;
     private static final int WHAT = 2008;
-    private Handler mHandler = new Handler() {
+    private Handler mHandler = new Handler(Looper.getMainLooper()) {
         @Override
         public boolean sendMessageAtTime(Message msg, long uptimeMillis) {
             mResult = true;
diff --git a/tests/tests/os/src/android/os/cts/ResultReceiverTest.java b/tests/tests/os/src/android/os/cts/ResultReceiverTest.java
index e784444..47a5d99 100644
--- a/tests/tests/os/src/android/os/cts/ResultReceiverTest.java
+++ b/tests/tests/os/src/android/os/cts/ResultReceiverTest.java
@@ -16,16 +16,15 @@
 
 package android.os.cts;
 
-
-
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Parcel;
 import android.os.ResultReceiver;
 import android.test.AndroidTestCase;
 
 public class ResultReceiverTest extends AndroidTestCase {
-    private Handler mHandler = new Handler();
+    private Handler mHandler = new Handler(Looper.getMainLooper());
     private static final long DURATION = 100l;
 
     public void testResultReceiver() throws InterruptedException {
diff --git a/tests/tests/permission/src/android/permission/cts/NoLocationPermissionTest.java b/tests/tests/permission/src/android/permission/cts/NoLocationPermissionTest.java
index a2cbfb7..93e26ac 100644
--- a/tests/tests/permission/src/android/permission/cts/NoLocationPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/NoLocationPermissionTest.java
@@ -28,28 +28,31 @@
 import android.os.Looper;
 import android.telephony.PhoneStateListener;
 import android.telephony.TelephonyManager;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
 import android.test.suitebuilder.annotation.SmallTest;
+import android.test.UiThreadTest;
 
 import java.util.List;
 
 /**
  * Verify the location access without specific permissions.
  */
-public class NoLocationPermissionTest extends AndroidTestCase {
+public class NoLocationPermissionTest extends InstrumentationTestCase {
     private static final String TEST_PROVIDER_NAME = "testProvider";
 
     private LocationManager mLocationManager;
     private List<String> mAllProviders;
     private boolean mHasTelephony;
+    private Context mContext;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        mLocationManager = (LocationManager) getContext().getSystemService(
+        mContext = getInstrumentation().getTargetContext();
+        mLocationManager = (LocationManager) mContext.getSystemService(
                 Context.LOCATION_SERVICE);
         mAllProviders = mLocationManager.getAllProviders();
-        mHasTelephony = getContext().getPackageManager().hasSystemFeature(
+        mHasTelephony = mContext.getPackageManager().hasSystemFeature(
                 PackageManager.FEATURE_TELEPHONY);
 
         assertNotNull(mLocationManager);
@@ -66,13 +69,13 @@
      * Requires Permission: {@link
      * android.Manifest.permission#ACCESS_COARSE_LOCATION.}
      */
-    @SmallTest
+    @UiThreadTest
     public void testListenCellLocation() {
         if (!mHasTelephony) {
             return;
         }
 
-        TelephonyManager telephonyManager = (TelephonyManager) getContext().getSystemService(
+        TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
                 Context.TELEPHONY_SERVICE);
         PhoneStateListener phoneStateListener = new PhoneStateListener();
         try {
@@ -97,13 +100,13 @@
      * Requires Permission: {@link
      * android.Manifest.permission#ACCESS_COARSE_LOCATION.}
      */
-    @SmallTest
+    @UiThreadTest
     public void testListenCellLocation2() {
         if (!mHasTelephony) {
             return;
         }
 
-        TelephonyManager telephonyManager = (TelephonyManager) getContext().getSystemService(
+        TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(
                 Context.TELEPHONY_SERVICE);
         PhoneStateListener phoneStateListener = new PhoneStateListener();
 
@@ -159,7 +162,7 @@
      * Requires Permission:
      * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
      */
-    @SmallTest
+    @UiThreadTest
     public void testRequestLocationUpdatesNetwork() {
         checkRequestLocationUpdates(LocationManager.NETWORK_PROVIDER);
     }
@@ -170,7 +173,7 @@
      * Requires Permission:
      * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}.
      */
-    @SmallTest
+    @UiThreadTest
     public void testRequestLocationUpdatesGps() {
         checkRequestLocationUpdates(LocationManager.GPS_PROVIDER);
     }
@@ -183,7 +186,7 @@
      */
     @SmallTest
     public void testAddProximityAlert() {
-        PendingIntent mockPendingIntent = PendingIntent.getBroadcast(getContext(),
+        PendingIntent mockPendingIntent = PendingIntent.getBroadcast(mContext,
                 0, new Intent("mockIntent"), PendingIntent.FLAG_ONE_SHOT);
         try {
             mLocationManager.addProximityAlert(0, 0, 100, -1, mockPendingIntent);
diff --git a/tests/tests/rscpp/librscpptest/setelementat.rs b/tests/tests/rscpp/librscpptest/setelementat.rs
index 1251ec1..5a84552 100644
--- a/tests/tests/rscpp/librscpptest/setelementat.rs
+++ b/tests/tests/rscpp/librscpptest/setelementat.rs
@@ -1,5 +1,5 @@
 #pragma version(1)
-#pragma rs java_package_name(com.android.cts.stub)
+#pragma rs java_package_name(com.android.cts.rscpp)
 #pragma rs_fp_relaxed
 
 int memset_toValue = 0;
diff --git a/tests/tests/telecomm/Android.mk b/tests/tests/telecomm/Android.mk
index de1d8b3..6984b18 100644
--- a/tests/tests/telecomm/Android.mk
+++ b/tests/tests/telecomm/Android.mk
@@ -30,8 +30,6 @@
 
 LOCAL_PACKAGE_NAME := CtsTelecomTestCases
 
-LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
-
 # uncomment when b/13250611 is fixed
 #LOCAL_SDK_VERSION := current
 LOCAL_JAVA_LIBRARIES += android.test.runner
diff --git a/tests/tests/telecomm/AndroidManifest.xml b/tests/tests/telecomm/AndroidManifest.xml
index 97906c6..9179a0a 100644
--- a/tests/tests/telecomm/AndroidManifest.xml
+++ b/tests/tests/telecomm/AndroidManifest.xml
@@ -25,7 +25,7 @@
     </application>
 
     <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
-                     android:targetPackage="com.android.cts.stub"
+                     android:targetPackage="com.android.cts.telecom"
                      android:label="CTS tests of android.telecom">
         <meta-data android:name="listener"
             android:value="com.android.cts.runner.CtsTestRunListener" />
diff --git a/tests/tests/text/AndroidManifest.xml b/tests/tests/text/AndroidManifest.xml
index 0b31354..f247f82 100644
--- a/tests/tests/text/AndroidManifest.xml
+++ b/tests/tests/text/AndroidManifest.xml
@@ -20,9 +20,8 @@
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
     <uses-permission android:name="android.permission.WRITE_SETTINGS" />
-    <application>
-        <uses-library android:name="android.test.runner"
-            android:maxRecents="1"/>
+    <application android:maxRecents="1">
+        <uses-library android:name="android.test.runner" />
 
         <activity android:name="android.text.cts.EmojiCtsActivity"
             android:label="AvailableIntentsActivity">
diff --git a/tests/tests/text/src/android/text/cts/ClipboardManagerTest.java b/tests/tests/text/src/android/text/cts/ClipboardManagerTest.java
index e62e0f8..f0fc0fa 100644
--- a/tests/tests/text/src/android/text/cts/ClipboardManagerTest.java
+++ b/tests/tests/text/src/android/text/cts/ClipboardManagerTest.java
@@ -18,36 +18,45 @@
 
 
 import android.content.Context;
-import android.test.AndroidTestCase;
+import android.test.InstrumentationTestCase;
+import android.test.UiThreadTest;
 import android.text.ClipboardManager;
 
 /**
  * Test {@link ClipboardManager}.
  */
-public class ClipboardManagerTest extends AndroidTestCase {
-    private ClipboardManager mClipboardManager;
+public class ClipboardManagerTest extends InstrumentationTestCase {
+
+    private Context mContext;
 
     @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mClipboardManager = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
+    public void setUp() {
+        mContext = getInstrumentation().getContext();
     }
 
+    @UiThreadTest
     public void testAccessText() {
+        ClipboardManager clipboardManager =
+                (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
+
         // set the expected value
         CharSequence expected = "test";
-        mClipboardManager.setText(expected);
-        assertEquals(expected, mClipboardManager.getText());
+        clipboardManager.setText(expected);
+        assertEquals(expected, clipboardManager.getText());
     }
 
+    @UiThreadTest
     public void testHasText() {
-        mClipboardManager.setText("");
-        assertFalse(mClipboardManager.hasText());
+        ClipboardManager clipboardManager =
+                (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
 
-        mClipboardManager.setText("test");
-        assertTrue(mClipboardManager.hasText());
+        clipboardManager.setText("");
+        assertFalse(clipboardManager.hasText());
 
-        mClipboardManager.setText(null);
-        assertFalse(mClipboardManager.hasText());
+        clipboardManager.setText("test");
+        assertTrue(clipboardManager.hasText());
+
+        clipboardManager.setText(null);
+        assertFalse(clipboardManager.hasText());
     }
 }
diff --git a/tests/tests/text/src/android/text/cts/EmojiTest.java b/tests/tests/text/src/android/text/cts/EmojiTest.java
index 5e2ca93..b753739 100644
--- a/tests/tests/text/src/android/text/cts/EmojiTest.java
+++ b/tests/tests/text/src/android/text/cts/EmojiTest.java
@@ -31,7 +31,7 @@
 public class EmojiTest extends ActivityInstrumentationTestCase2<EmojiCtsActivity> {
 
     public EmojiTest() {
-        super("com.android.cts.stub", EmojiCtsActivity.class);
+        super("com.android.cts.text", EmojiCtsActivity.class);
     }
 
     protected void setUp() throws Exception {
@@ -105,7 +105,7 @@
     /**
      * Tests EditText handles Emoji
      */
-    public void testEmojiEditable() {
+    public void testEmojiEditable() throws Throwable {
         int testedCodePoints[] = {
             0xAE,    // registered mark
             0x2764,    // heavy black heart
@@ -118,15 +118,21 @@
         for (int i = 0; i < testedCodePoints.length; i++) {
             origStr = "Test character  ";
             // cannot reuse CaptureTextView as 2nd setText call throws NullPointerException
-            EditText editText = new EditText(getInstrumentation().getContext());
+            final EditText editText = new EditText(getInstrumentation().getContext());
             editText.setText(origStr + String.valueOf(Character.toChars(testedCodePoints[i])));
 
             // confirm the emoji is added.
             newStr = editText.getText().toString();
             assertEquals(newStr.codePointCount(0, newStr.length()), origStr.length() + 1);
 
-            // Delete added character by sending KEYCODE_DEL event
-            editText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
+            runTestOnUiThread(new Runnable() {
+                public void run() {
+                    // Delete added character by sending KEYCODE_DEL event
+                    editText.dispatchKeyEvent(
+                            new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
+                }
+            });
+            getInstrumentation().waitForIdleSync();
 
             newStr = editText.getText().toString();
             assertEquals(newStr.codePointCount(0, newStr.length()), origStr.length() + 1);
diff --git a/tests/tests/text/src/android/text/cts/MyanmarTest.java b/tests/tests/text/src/android/text/cts/MyanmarTest.java
index 60fe608..d59f2b9 100644
--- a/tests/tests/text/src/android/text/cts/MyanmarTest.java
+++ b/tests/tests/text/src/android/text/cts/MyanmarTest.java
@@ -25,7 +25,7 @@
 public class MyanmarTest extends ActivityInstrumentationTestCase2<Activity> {
 
     public MyanmarTest() {
-        super("com.android.cts.stub", Activity.class);
+        super("com.android.cts.text", Activity.class);
     }
 
     protected void setUp() throws Exception {
diff --git a/tests/tests/text/src/android/text/method/cts/ArrowKeyMovementMethodTest.java b/tests/tests/text/src/android/text/method/cts/ArrowKeyMovementMethodTest.java
index 74fab00..10d08d0 100644
--- a/tests/tests/text/src/android/text/method/cts/ArrowKeyMovementMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/ArrowKeyMovementMethodTest.java
@@ -56,7 +56,7 @@
     private MyMetaKeyKeyListener mMetaListener;
 
     public ArrowKeyMovementMethodTest() {
-        super("com.android.cts.stub", CtsActivity.class);
+        super("com.android.cts.text", CtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/text/src/android/text/method/cts/CharacterPickerDialogTest.java b/tests/tests/text/src/android/text/method/cts/CharacterPickerDialogTest.java
index 3c20988..382fc77 100644
--- a/tests/tests/text/src/android/text/method/cts/CharacterPickerDialogTest.java
+++ b/tests/tests/text/src/android/text/method/cts/CharacterPickerDialogTest.java
@@ -21,6 +21,7 @@
 import android.content.Context;
 import android.os.Bundle;
 import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
 import android.text.Editable;
 import android.text.Selection;
 import android.text.method.CharacterPickerDialog;
@@ -34,7 +35,7 @@
     private Activity mActivity;
 
     public CharacterPickerDialogTest() {
-        super("com.android.cts.stub", CtsActivity.class);
+        super("com.android.cts.text", CtsActivity.class);
     }
 
     @Override
@@ -43,6 +44,7 @@
         mActivity = getActivity();
     }
 
+    @UiThreadTest
     public void testConstructor() {
         final CharSequence str = "123456";
         final Editable content = Editable.Factory.getInstance().newEditable(str);
@@ -61,6 +63,7 @@
         // Do not test. Implementation details.
     }
 
+    @UiThreadTest
     public void testOnItemClick() {
         final Gallery parent = new Gallery(mActivity);
         final CharSequence str = "123456";
@@ -102,6 +105,7 @@
         assertFalse(insertPickerDialog.isShowing());
     }
 
+    @UiThreadTest
     public void testOnClick() {
         final CharSequence str = "123456";
         final Editable content = Editable.Factory.getInstance().newEditable(str);
diff --git a/tests/tests/text/src/android/text/method/cts/KeyListenerTestCase.java b/tests/tests/text/src/android/text/method/cts/KeyListenerTestCase.java
index a5a76af..8bb2adf 100644
--- a/tests/tests/text/src/android/text/method/cts/KeyListenerTestCase.java
+++ b/tests/tests/text/src/android/text/method/cts/KeyListenerTestCase.java
@@ -53,7 +53,7 @@
     protected TextView mTextView;
 
     public KeyListenerTestCase() {
-        super("com.android.cts.stub", KeyListenerCtsActivity.class);
+        super("com.android.cts.text", KeyListenerCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/text/src/android/text/method/cts/LinkMovementMethodTest.java b/tests/tests/text/src/android/text/method/cts/LinkMovementMethodTest.java
index 8027d49..336921a 100644
--- a/tests/tests/text/src/android/text/method/cts/LinkMovementMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/LinkMovementMethodTest.java
@@ -56,7 +56,7 @@
     private MockClickableSpan mClickable1;
 
     public LinkMovementMethodTest() {
-        super("com.android.cts.stub", CtsActivity.class);
+        super("com.android.cts.text", CtsActivity.class);
     }
 
     @Override
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 66e4fc8..4262a31 100644
--- a/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java
@@ -58,7 +58,7 @@
     private CharSequence mTransformedText;
 
     public PasswordTransformationMethodTest() {
-        super("com.android.cts.stub", CtsActivity.class);
+        super("com.android.cts.text", CtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/text/src/android/text/method/cts/ReplacementTransformationMethodTest.java b/tests/tests/text/src/android/text/method/cts/ReplacementTransformationMethodTest.java
index 7dabd16..dadce15 100644
--- a/tests/tests/text/src/android/text/method/cts/ReplacementTransformationMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/ReplacementTransformationMethodTest.java
@@ -37,7 +37,7 @@
     private EditText mEditText;
 
     public ReplacementTransformationMethodTest() {
-        super("com.android.cts.stub", CtsActivity.class);
+        super("com.android.cts.text", CtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
index f9a7d0d..c186cde 100644
--- a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
@@ -55,7 +55,7 @@
     private int mScaledTouchSlop;
 
     public ScrollingMovementMethodTest() {
-        super("com.android.cts.stub", CtsActivity.class);
+        super("com.android.cts.text", CtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/text/src/android/text/method/cts/SingleLineTransformationMethodTest.java b/tests/tests/text/src/android/text/method/cts/SingleLineTransformationMethodTest.java
index 89f1026..460ce3d 100644
--- a/tests/tests/text/src/android/text/method/cts/SingleLineTransformationMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/SingleLineTransformationMethodTest.java
@@ -28,7 +28,7 @@
 public class SingleLineTransformationMethodTest
         extends ActivityInstrumentationTestCase2<CtsActivity> {
     public SingleLineTransformationMethodTest() {
-        super("com.android.cts.stub", CtsActivity.class);
+        super("com.android.cts.text", CtsActivity.class);
     }
 
     public void testConstructor() {
diff --git a/tests/tests/text/src/android/text/method/cts/TouchTest.java b/tests/tests/text/src/android/text/method/cts/TouchTest.java
index 2d3d146..343847e 100644
--- a/tests/tests/text/src/android/text/method/cts/TouchTest.java
+++ b/tests/tests/text/src/android/text/method/cts/TouchTest.java
@@ -43,7 +43,7 @@
     private boolean mReturnFromTouchEvent;
 
     public TouchTest() {
-        super("com.android.cts.stub", CtsActivity.class);
+        super("com.android.cts.text", CtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/text/src/android/text/style/cts/URLSpanTest.java b/tests/tests/text/src/android/text/style/cts/URLSpanTest.java
index 832e48d..7cfe56e 100644
--- a/tests/tests/text/src/android/text/style/cts/URLSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/URLSpanTest.java
@@ -33,7 +33,7 @@
     private Activity mActivity;
 
     public URLSpanTest() {
-        super("com.android.cts.stub", URLSpanCtsActivity.class);
+        super("com.android.cts.text", URLSpanCtsActivity.class);
     }
 
     @Override
diff --git a/tests/tests/view/src/android/view/cts/GestureDetectorTest.java b/tests/tests/view/src/android/view/cts/GestureDetectorTest.java
index 3d8ba05..c568cf1 100644
--- a/tests/tests/view/src/android/view/cts/GestureDetectorTest.java
+++ b/tests/tests/view/src/android/view/cts/GestureDetectorTest.java
@@ -18,7 +18,9 @@
 
 import android.content.Context;
 import android.os.Handler;
+import android.os.Looper;
 import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
 import android.view.GestureDetector;
 import android.view.GestureDetector.SimpleOnGestureListener;
 
@@ -50,11 +52,13 @@
         mActivity.onSingleTapConfirmed = false;
     }
 
+    @UiThreadTest
     public void testConstructor() {
 
-        new GestureDetector(mContext, new SimpleOnGestureListener(), new Handler());
+        new GestureDetector(
+                mContext, new SimpleOnGestureListener(), new Handler(Looper.getMainLooper()));
         new GestureDetector(mContext, new SimpleOnGestureListener());
-        new GestureDetector(new SimpleOnGestureListener(), new Handler());
+        new GestureDetector(new SimpleOnGestureListener(), new Handler(Looper.getMainLooper()));
         new GestureDetector(new SimpleOnGestureListener());
 
         try {
diff --git a/tests/tests/view/src/android/view/cts/SurfaceViewTest.java b/tests/tests/view/src/android/view/cts/SurfaceViewTest.java
index d3902bb..a84653d 100644
--- a/tests/tests/view/src/android/view/cts/SurfaceViewTest.java
+++ b/tests/tests/view/src/android/view/cts/SurfaceViewTest.java
@@ -55,6 +55,7 @@
         mMockSurfaceView = activity.getSurfaceView();
     }
 
+    @UiThreadTest
     public void testConstructor() {
         new SurfaceView(mContext);
         new SurfaceView(mContext, null);
diff --git a/tests/tests/view/src/android/view/cts/WindowTest.java b/tests/tests/view/src/android/view/cts/WindowTest.java
index 9df13dc..ead4d5b 100644
--- a/tests/tests/view/src/android/view/cts/WindowTest.java
+++ b/tests/tests/view/src/android/view/cts/WindowTest.java
@@ -36,6 +36,7 @@
 import android.os.Handler;
 import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.ActionMode;
@@ -68,6 +69,7 @@
     private Context mContext;
     private Instrumentation mInstrumentation;
     private WindowCtsActivity mActivity;
+    private SurfaceView surfaceView;
 
     private static final int VIEWGROUP_LAYOUT_HEIGHT = 100;
     private static final int VIEWGROUP_LAYOUT_WIDTH = 200;
@@ -97,6 +99,7 @@
         super.tearDown();
     }
 
+    @UiThreadTest
     public void testConstructor() throws Exception {
         mWindow = new MockWindow(mContext);
         assertSame(mContext, mWindow.getContext());
@@ -652,7 +655,13 @@
      * Test setLocalFocus together with injectInputEvent.
      */
     public void testSetLocalFocus() throws Throwable {
-        final SurfaceView surfaceView = new SurfaceView(mContext);
+        runTestOnUiThread(new Runnable() {
+            public void run() {
+                surfaceView = new SurfaceView(mContext);
+            }
+        });
+        mInstrumentation.waitForIdleSync();
+
         final Semaphore waitingSemaphore = new Semaphore(0);
         surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
             @Override
@@ -676,6 +685,7 @@
                 mWindow.setContentView(surfaceView);
             }
         });
+        mInstrumentation.waitForIdleSync();
         assertTrue(waitingSemaphore.tryAcquire(5, TimeUnit.SECONDS));
         assertNotNull(mVirtualDisplay);
         assertNotNull(mPresentation);
diff --git a/tests/webgl/Android.mk b/tests/webgl/Android.mk
index ce22dd8..624d82a 100755
--- a/tests/webgl/Android.mk
+++ b/tests/webgl/Android.mk
@@ -24,7 +24,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := ctsdeviceutil ctstestrunner
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_SRC_FILES := $(call all-java-files-under, src)\
+		../src/android/webkit/cts/NullWebViewUtils.java
 
 # Must match the package name in CtsTestCaseList.mk
 LOCAL_PACKAGE_NAME := CtsWebGLTestCases
diff --git a/tests/webgl/src/android/webgl/WebGLActivity.java b/tests/webgl/src/android/webgl/WebGLActivity.java
index ebba905..f851a76 100644
--- a/tests/webgl/src/android/webgl/WebGLActivity.java
+++ b/tests/webgl/src/android/webgl/WebGLActivity.java
@@ -25,6 +25,7 @@
 import android.webkit.WebView;
 import android.webkit.JavascriptInterface;
 import android.webkit.WebViewClient;
+import android.webkit.cts.NullWebViewUtils;
 import android.widget.Toast;
 import java.lang.Override;
 import java.io.InputStream;
@@ -51,7 +52,16 @@
         super.onCreate(icicle);
 
         mWebGlHarnessUrl = "file://" + getCacheDir() + "/harness.html";
-        mWebView = new WebView(this);
+        try {
+            mWebView = new WebView(this);
+        } catch (Exception e) {
+            NullWebViewUtils.determineIfWebViewAvailable(this, e);
+        }
+
+        if (mWebView == null) {
+            return;
+        }
+
         mWebView.getSettings().setJavaScriptEnabled(true);
         mWebView.getSettings().setAllowFileAccessFromFileURLs(true);
         mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false);
@@ -92,6 +102,10 @@
     }
 
     public void navigateToTest(String url) throws Exception {
+        if (!NullWebViewUtils.isWebViewAvailable()) {
+            return;
+        }
+
         synchronized(WebGLActivity.this) {
             mWebGLTestUrl = url;
         }