Merge change 3974 into donut

* changes:
  Integrate unsubmitted cupcake change 147342: 	CTS: clean up code in android.net package
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index a4b61e6..b3abf4a 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -458,6 +458,13 @@
             </intent-filter>
         </activity>
 
+        <activity android:name="android.widget.cts.DialerFilterStubActivity"
+            android:label="DialerFilterStubActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
         <activity android:name="android.widget.cts.MultiAutoCompleteTextViewStubActivity"
             android:label="MultiAutoCompleteTextView Test Activity">
             <intent-filter>
diff --git a/tests/res/layout/dialerfilter_layout.xml b/tests/res/layout/dialerfilter_layout.xml
index aa3e562..8d048e6 100644
--- a/tests/res/layout/dialerfilter_layout.xml
+++ b/tests/res/layout/dialerfilter_layout.xml
@@ -14,48 +14,19 @@
      limitations under the License.
 -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<DialerFilter android:id="@+id/dialer_filter"
+    xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
-    android:layout_height="wrap_content">
+    android:layout_height="fill_parent">
 
-    <LinearLayout android:id="@+id/inputArea"
+    <EditText android:id="@android:id/hint"
         android:layout_width="fill_parent"
-        android:layout_height="80dip"
-        android:orientation="vertical"
-        android:padding="0dip"
-        android:visibility="gone">
+        android:layout_height="wrap_content"
+        android:background="@android:drawable/editbox_background"/>
 
-        <DialerFilter android:id="@android:id/input"
-            android:layout_width="fill_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="5dip"
-            android:layout_marginLeft="7dip"
-            android:layout_marginRight="5dip">
+    <EditText android:id="@android:id/primary"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_below="@android:id/hint"/>
 
-            <EditText android:id="@android:id/hint"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="14sp"
-                android:textStyle="bold"
-                android:background="@null"
-                android:autoText="false"
-                android:capitalize="none"/>
-
-            <EditText android:id="@android:id/primary"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_below="@android:id/hint"
-                android:textSize="24sp"
-                android:background="@null"
-                android:autoText="false"
-                android:capitalize="none"/>
-
-            <ImageView android:id="@android:id/icon"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentRight="true"
-                android:layout_centerVertical="true"
-                android:src="@android:drawable/sym_action_call"/>
-        </DialerFilter>
-    </LinearLayout>
-</LinearLayout>
+</DialerFilter>
diff --git a/tests/src/android/os/cts/TestThread.java b/tests/src/android/os/cts/TestThread.java
index 65d18ce..1a28a20 100644
--- a/tests/src/android/os/cts/TestThread.java
+++ b/tests/src/android/os/cts/TestThread.java
@@ -29,7 +29,7 @@
     }
 
     @Override
-    public void run() {
+    public final void run() {
         try {
             mTarget.run();
         } catch (Throwable t) {
@@ -40,23 +40,13 @@
     /**
      * Run the target Runnable object and wait until the test finish or throw
      * out Exception if test fail.
-     * 
+     *
      * @param runTime
      * @throws Throwable
      */
     public void runTest(long runTime) throws Throwable {
         start();
-        this.join(runTime);
-
-        if (this.isAlive()) {
-            this.interrupt();
-            this.join(runTime);
-            throw new Exception("Thread did not finish within allotted time.");
-        }
-
-        if(mThrowable != null) {
-            throw mThrowable;
-        }
+        joinAndCheck(runTime);
     }
 
     /**
@@ -68,8 +58,32 @@
     }
 
     /**
+     * Set the Throwable object which is thrown when test running
+     * @param t The Throwable object
+     */
+    public void setThrowable(Throwable t) {
+        mThrowable = t;
+    }
+
+    /**
+     * Wait for the test thread to complete and throw the stored exception if there is one.
+     *
+     * @param runTime The time to wait for the test thread to complete.
+     * @throws Throwable
+     */
+    public void joinAndCheck(long runTime) throws Throwable {
+        this.join(runTime);
+        if (this.isAlive()) {
+            this.interrupt();
+            this.join(runTime);
+            throw new Exception("Thread did not finish within allotted time.");
+        }
+        checkException();
+    }
+
+    /**
      * Check whether there is an exception when running Runnable object.
-     * @throws The Throwable object
+     * @throws Throwable
      */
     public void checkException() throws Throwable {
         if (mThrowable != null) {
diff --git a/tests/src/android/widget/cts/DialerFilterStubActivity.java b/tests/src/android/widget/cts/DialerFilterStubActivity.java
new file mode 100644
index 0000000..b67803a
--- /dev/null
+++ b/tests/src/android/widget/cts/DialerFilterStubActivity.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.widget.cts;
+
+import android.app.Activity;
+import android.os.Bundle;
+import com.android.cts.stub.R;
+
+/**
+ * A minimal application for DialerFilter test.
+ */
+public class DialerFilterStubActivity extends Activity {
+    /**
+     * Called with the activity is first created.
+     */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.dialerfilter_layout);
+    }
+}
diff --git a/tests/tests/os/src/android/os/cts/ConditionVariableTest.java b/tests/tests/os/src/android/os/cts/ConditionVariableTest.java
index 10384df..6a45d0f 100644
--- a/tests/tests/os/src/android/os/cts/ConditionVariableTest.java
+++ b/tests/tests/os/src/android/os/cts/ConditionVariableTest.java
@@ -24,6 +24,7 @@
 
 @TestTargetClass(ConditionVariable.class)
 public class ConditionVariableTest extends TestCase {
+    private static final int WAIT_TIME = 3000;
     private static final int BLOCK_TIME = 1000;
     private static final int BLOCK_TIME_DELTA = 200;
     private static final int SLEEP_TIME = 1000;
@@ -39,13 +40,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of {@link ConditionVariable}",
             method = "ConditionVariable",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of {@link ConditionVariable}",
             method = "ConditionVariable",
             args = {boolean.class}
         )
@@ -59,75 +58,73 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: block",
             method = "block",
             args = {long.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: open",
             method = "open",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: close",
             method = "close",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: block",
             method = "block",
             args = {}
         )
     })
-    public void testConditionVariable() {
-        try {
-            // test open then block(long)
-            mConditionVariable.open();
-            long time = System.currentTimeMillis();
-            assertTrue(mConditionVariable.block(BLOCK_TIME));
-            assertTrue(System.currentTimeMillis() - time < TOLERANCE_MS);
+    public void testConditionVariable() throws Throwable {
+        // test open then block(long)
+        mConditionVariable.open();
+        long time = System.currentTimeMillis();
+        assertTrue(mConditionVariable.block(BLOCK_TIME));
+        assertTrue(System.currentTimeMillis() - time < TOLERANCE_MS);
 
-            // test close then block(long)
-            mConditionVariable.close();
-            time = System.currentTimeMillis();
-            assertFalse(mConditionVariable.block(BLOCK_TIME));
-            assertTrue(System.currentTimeMillis() - time >= BLOCK_TIME);
+        // test close then block(long)
+        mConditionVariable.close();
+        time = System.currentTimeMillis();
+        assertFalse(mConditionVariable.block(BLOCK_TIME));
+        assertTrue(System.currentTimeMillis() - time >= BLOCK_TIME);
 
-            // test block then open
-            time = System.currentTimeMillis();
-            new Thread(){
-                public void run() {
-                    try {
-                        Thread.sleep(SLEEP_TIME);
-                    } catch (InterruptedException e) {
-                        fail(e.getMessage());
-                    }
-                    mConditionVariable.open();
+        // test block then open
+        time = System.currentTimeMillis();
+        TestThread t = new TestThread(new Runnable() {
+
+            public void run() {
+                try {
+                    Thread.sleep(SLEEP_TIME);
+                } catch (InterruptedException e) {
+                    fail(e.getMessage());
                 }
-            }.start();
+                mConditionVariable.open();
+            }
+        });
 
-            mConditionVariable.block();
-            long timeDelta = System.currentTimeMillis() - time;
-            assertTrue(timeDelta >= BLOCK_TIME && timeDelta <= BLOCK_TIME + BLOCK_TIME_DELTA);
+        t.start();
+        mConditionVariable.block();
+        long timeDelta = System.currentTimeMillis() - time;
+        assertTrue(timeDelta >= BLOCK_TIME && timeDelta <= BLOCK_TIME + BLOCK_TIME_DELTA);
+        t.joinAndCheck(WAIT_TIME);
 
-            time = System.currentTimeMillis();
-            new Thread(){
-                public void run() {
-                    try {
-                        Thread.sleep(BLOCK_TIME >> 1);
-                    } catch (InterruptedException e) {
-                        fail(e.getMessage());
-                    }
-                    mConditionVariable.open();
+        time = System.currentTimeMillis();
+        t = new TestThread(new Runnable() {
+
+            public void run() {
+                try {
+                    Thread.sleep(BLOCK_TIME >> 1);
+                } catch (InterruptedException e) {
+                    fail(e.getMessage());
                 }
-            }.start();
+                mConditionVariable.open();
+            }
+        });
+        t.start();
 
-            assertTrue(mConditionVariable.block(BLOCK_TIME));
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+        assertTrue(mConditionVariable.block(BLOCK_TIME));
+        t.joinAndCheck(WAIT_TIME);
     }
 }
diff --git a/tests/tests/os/src/android/os/cts/DeadObjectExceptionTest.java b/tests/tests/os/src/android/os/cts/DeadObjectExceptionTest.java
index 3342450..11a7c4d 100644
--- a/tests/tests/os/src/android/os/cts/DeadObjectExceptionTest.java
+++ b/tests/tests/os/src/android/os/cts/DeadObjectExceptionTest.java
@@ -17,10 +17,9 @@
 
 import junit.framework.TestCase;
 import android.os.DeadObjectException;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
 
 @TestTargetClass(DeadObjectException.class)
 public class DeadObjectExceptionTest extends TestCase {
diff --git a/tests/tests/os/src/android/os/cts/LooperTest.java b/tests/tests/os/src/android/os/cts/LooperTest.java
index 0c06f60..0730a23 100644
--- a/tests/tests/os/src/android/os/cts/LooperTest.java
+++ b/tests/tests/os/src/android/os/cts/LooperTest.java
@@ -27,6 +27,7 @@
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
 
 @TestTargetClass(Looper.class)
 public class LooperTest extends AndroidTestCase {
@@ -41,7 +42,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: dump",
         method = "dump",
         args = {Printer.class, String.class}
     )
@@ -53,7 +53,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: getMainLooper",
         method = "getMainLooper",
         args = {}
     )
@@ -64,7 +63,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: loop",
         method = "loop",
         args = {}
     )
@@ -82,7 +80,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: myLooper",
         method = "myLooper",
         args = {}
     )
@@ -100,7 +97,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: myQueue",
         method = "myQueue",
         args = {}
     )
@@ -124,7 +120,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: prepare",
         method = "prepare",
         args = {}
     )
@@ -154,7 +149,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: prepareMainLooper",
         method = "prepareMainLooper",
         args = {}
     )
@@ -182,12 +176,18 @@
         t.runTest(WAIT_TIME);
     }
 
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        notes = "Test method: quit",
-        method = "quit",
-        args = {}
-    )
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "quit",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getThread",
+            args = {}
+        )
+    })
     public void testQuit() throws Throwable {
         TestThread t = new TestThread(new Runnable() {
             public void run() {
@@ -199,10 +199,12 @@
                 mHasQuit = true;
             }
         });
+
         // Here doesn't call runTest() because we don't want to wait the runTest finish.
         // Just need to handle Looper#quit();
         t.start();
         Thread.sleep(WAIT_TIME);
+        assertSame(t, mLooper.getThread());
         int time = 100;
         // Send message before Looper has quit.
         assertTrue(mLoopHandler.sendEmptyMessageAtTime(0, SystemClock.uptimeMillis() + time));
@@ -214,12 +216,11 @@
         assertFalse(mLoopHandler.sendEmptyMessageAtTime(1, SystemClock.uptimeMillis() + time));
         assertTrue(mHasQuit);
 
-        t.checkException();
+        t.joinAndCheck(WAIT_TIME);
     }
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: setMessageLogging",
         method = "setMessageLogging",
         args = {Printer.class}
     )
@@ -250,7 +251,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: toString",
         method = "toString",
         args = {}
     )
diff --git a/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java b/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
index 1282fd6..ce6658f 100644
--- a/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelFileDescriptorTest.java
@@ -16,43 +16,45 @@
 
 package android.os.cts;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.UnknownHostException;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+import dalvik.annotation.ToBeFixed;
+
 import android.content.Context;
 import android.os.Parcel;
 import android.os.ParcelFileDescriptor;
 import android.os.Parcelable;
 import android.os.ParcelFileDescriptor.AutoCloseInputStream;
 import android.test.AndroidTestCase;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargets;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
 
 @TestTargetClass(ParcelFileDescriptor.class)
 public class ParcelFileDescriptorTest extends AndroidTestCase {
+    private static final long DURATION = 100l;
+
+    private TestThread mTestThread;
+
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of {@link ParcelFileDescriptor}",
             method = "ParcelFileDescriptor",
             args = {android.os.ParcelFileDescriptor.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: open",
             method = "open",
             args = {java.io.File.class, int.class}
         )
     })
-    public void testConstructorAndOpen() {
+    public void testConstructorAndOpen() throws Exception {
         ParcelFileDescriptor tempFile = makeParcelFileDescriptor(getContext());
 
         ParcelFileDescriptor pfd = new ParcelFileDescriptor(tempFile);
@@ -63,65 +65,52 @@
             assertEquals(1, in.read());
             assertEquals(2, in.read());
             assertEquals(3, in.read());
-        } catch (IOException e) {
-            fail(e.getMessage());
         } finally {
-            try {
-                in.close();
-            } catch (IOException e) {
-                fail(e.getMessage());
-            }
+            in.close();
         }
     }
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: fromSocket",
         method = "fromSocket",
         args = {java.net.Socket.class}
     )
-    public void testFromSocket() {
+    public void testFromSocket() throws Throwable {
         final int PORT = 12222;
         final int DATA = 1;
 
-        new Thread(){
+        mTestThread = new TestThread(new Runnable() {
             public void run() {
-                ServerSocket ss;
-
                 try {
+                    ServerSocket ss;
                     ss = new ServerSocket(PORT);
                     Socket sSocket = ss.accept();
                     OutputStream out = sSocket.getOutputStream();
                     out.write(DATA);
-                    ParcelFileDescriptorTest.this.sleep(100);
+                    Thread.sleep(DURATION);
                     out.close();
-                } catch (IOException e) {
-                    fail(e.getMessage());
+                } catch (Exception e) {
+                    mTestThread.setThrowable(e);
                 }
             }
-        }.start();
+        });
+        mTestThread.start();
 
-        sleep(100);
+        Thread.sleep(DURATION);
         Socket socket;
+        socket = new Socket(InetAddress.getLocalHost(), PORT);
+        ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
+        AutoCloseInputStream in = new AutoCloseInputStream(pfd);
+        assertEquals(DATA, in.read());
+        in.close();
+        socket.close();
+        pfd.close();
 
-        try {
-            socket = new Socket(InetAddress.getLocalHost(), PORT);
-            ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
-            AutoCloseInputStream in = new AutoCloseInputStream(pfd);
-            assertEquals(DATA, in.read());
-            in.close();
-            socket.close();
-            pfd.close();
-        } catch (UnknownHostException e) {
-            fail(e.getMessage());
-        } catch (IOException e) {
-            fail(e.getMessage());
-        }
+        mTestThread.joinAndCheck(DURATION * 2);
     }
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: toString",
         method = "toString",
         args = {}
     )
@@ -132,11 +121,10 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: writeToParcel",
         method = "writeToParcel",
         args = {android.os.Parcel.class, int.class}
     )
-    public void testWriteToParcel() {
+    public void testWriteToParcel() throws Exception {
         ParcelFileDescriptor pf = makeParcelFileDescriptor(getContext());
 
         Parcel pl = Parcel.obtain();
@@ -150,31 +138,21 @@
             assertEquals(1, in.read());
             assertEquals(2, in.read());
             assertEquals(3, in.read());
-        } catch (IOException e) {
-            fail(e.getMessage());
         } finally {
-            try {
-                in.close();
-            } catch (IOException e) {
-                fail(e.getMessage());
-            }
+            in.close();
         }
     }
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test method: close",
         method = "close",
         args = {}
     )
-    public void testClose() throws IOException {
+    public void testClose() throws Exception {
         ParcelFileDescriptor pf = makeParcelFileDescriptor(getContext());
-
         AutoCloseInputStream in1 = new AutoCloseInputStream(pf);
         try {
             assertEquals(0, in1.read());
-        } catch (Exception e) {
-            fail("shouldn't come here");
         } finally {
             in1.close();
         }
@@ -184,7 +162,7 @@
         AutoCloseInputStream in2 = new AutoCloseInputStream(pf);
         try {
             assertEquals(0, in2.read());
-            fail("shouldn't come here");
+            fail("Failed to throw exception.");
         } catch (Exception e) {
             // expected
         } finally {
@@ -193,6 +171,18 @@
     }
 
     @TestTargetNew(
+        level = TestLevel.SUFFICIENT,
+        method = "getStatSize",
+        args = {}
+    )
+    @ToBeFixed(bug="1695243", explanation="getStatSize() will return -1 if the fd is not a file,"
+            + " but here it will throw IllegalArgumentException, it's not the same with javadoc.")
+    public void testGetStatSize() throws Exception {
+        ParcelFileDescriptor pf = makeParcelFileDescriptor(getContext());
+        assertTrue(pf.getStatSize() >= 0);
+    }
+
+    @TestTargetNew(
         level = TestLevel.COMPLETE,
         notes = "Test method: getFileDescriptor",
         method = "getFileDescriptor",
@@ -217,47 +207,25 @@
         assertTrue((Parcelable.CONTENTS_FILE_DESCRIPTOR & pfd.describeContents()) != 0);
     }
 
-    static ParcelFileDescriptor makeParcelFileDescriptor(Context con) {
+    static ParcelFileDescriptor makeParcelFileDescriptor(Context con) throws Exception {
         final String fileName = "testParcelFileDescriptor";
 
         FileOutputStream fout = null;
 
-        try {
-            fout = con.openFileOutput(fileName, Context.MODE_WORLD_WRITEABLE);
-        } catch (FileNotFoundException e1) {
-            fail(e1.getMessage());
-        }
+        fout = con.openFileOutput(fileName, Context.MODE_WORLD_WRITEABLE);
 
         try {
-            fout.write(new byte[]{0x0, 0x1, 0x2, 0x3});
-        } catch (IOException e2) {
-            fail(e2.getMessage());
+            fout.write(new byte[] { 0x0, 0x1, 0x2, 0x3 });
         } finally {
-            try {
-                fout.close();
-            } catch (IOException e) {
-                // ignore this
-            }
+            fout.close();
         }
 
         File dir = con.getFilesDir();
         File file = new File(dir, fileName);
         ParcelFileDescriptor pf = null;
 
-        try {
-            pf = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE);
-        } catch (FileNotFoundException e) {
-            fail(e.getMessage());
-        }
+        pf = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE);
 
         return pf;
     }
-
-    private void sleep(int time) {
-        try {
-            Thread.sleep(time);
-        } catch (InterruptedException e) {
-            fail("shouldn't interrupted in sleep");
-        }
-    }
 }
diff --git a/tests/tests/os/src/android/os/cts/ParcelFileDescriptor_AutoCloseInputStreamTest.java b/tests/tests/os/src/android/os/cts/ParcelFileDescriptor_AutoCloseInputStreamTest.java
index ab8cff5..38a24f6 100644
--- a/tests/tests/os/src/android/os/cts/ParcelFileDescriptor_AutoCloseInputStreamTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelFileDescriptor_AutoCloseInputStreamTest.java
@@ -27,40 +27,30 @@
 import dalvik.annotation.TestTargets;
 
 @TestTargetClass(ParcelFileDescriptor.AutoCloseInputStream.class)
-public class ParcelFileDescriptor_AutoCloseInputStreamTest extends  AndroidTestCase {
+public class ParcelFileDescriptor_AutoCloseInputStreamTest extends AndroidTestCase {
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of {@link AutoCloseInputStream}",
             method = "AutoCloseInputStream",
             args = {android.os.ParcelFileDescriptor.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: close",
             method = "close",
             args = {}
         )
     })
-    public void testAutoCloseInputStream(){
+    public void testAutoCloseInputStream() throws Exception {
         ParcelFileDescriptor pf = ParcelFileDescriptorTest.makeParcelFileDescriptor(getContext());
 
         AutoCloseInputStream in = new AutoCloseInputStream(pf);
-        try {
-            assertEquals(0, in.read());
-        } catch (Exception e) {
-            fail("shouldn't come here");
-        }
+        assertEquals(0, in.read());
 
-        try {
-            in.close();
-        } catch (IOException e) {
-            fail("shouldn't come here");
-        }
+        in.close();
 
         try {
             in.read();
-            fail("shouldn't come here");
+            fail("Failed to throw exception.");
         } catch (IOException e) {
             // expected
         }
diff --git a/tests/tests/os/src/android/os/cts/ParcelFileDescriptor_AutoCloseOutputStreamTest.java b/tests/tests/os/src/android/os/cts/ParcelFileDescriptor_AutoCloseOutputStreamTest.java
index e58a223..927c849 100644
--- a/tests/tests/os/src/android/os/cts/ParcelFileDescriptor_AutoCloseOutputStreamTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelFileDescriptor_AutoCloseOutputStreamTest.java
@@ -41,26 +41,18 @@
             args = {}
         )
     })
-    public void testAutoCloseOutputStream(){
+    public void testAutoCloseOutputStream() throws Exception {
         ParcelFileDescriptor pf = ParcelFileDescriptorTest.makeParcelFileDescriptor(getContext());
 
         AutoCloseOutputStream out = new AutoCloseOutputStream(pf);
 
-        try {
-            out.write(2);
-        } catch (IOException e) {
-            fail("shouldn't come here");
-        }
+        out.write(2);
 
-        try {
-            out.close();
-        } catch (IOException e) {
-            fail("shouldn't come here");
-        }
+        out.close();
 
         try {
             out.write(2);
-            fail("shouldn't come here");
+            fail("Failed to throw exception.");
         } catch (IOException e) {
             // expected
         }
diff --git a/tests/tests/os/src/android/os/cts/ParcelTest.java b/tests/tests/os/src/android/os/cts/ParcelTest.java
index 0b97c0b..a7b71c1 100644
--- a/tests/tests/os/src/android/os/cts/ParcelTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelTest.java
@@ -22,6 +22,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
 import android.content.pm.Signature;
 import android.os.BadParcelableException;
 import android.os.Binder;
@@ -43,18 +44,23 @@
 
 @TestTargetClass(Parcel.class)
 public class ParcelTest extends AndroidTestCase {
+
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: obtain ",
             method = "obtain",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: recycle",
             method = "recycle",
             args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.NOT_FEASIBLE,
+            notes = "This method is protected final, which can't be invoked in test case.",
+            method = "obtain",
+            args = {int.class}
         )
     })
     public void testObtain() {
@@ -85,7 +91,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: appendFrom ",
             method = "appendFrom",
             args = {Parcel.class, int.class, int.class}
         )
@@ -142,7 +147,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: dataCapacity ",
             method = "dataCapacity",
             args = {}
         )
@@ -163,9 +167,8 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: setDataCapacity ",
-            method = "dataCapacity",
-            args = {}
+            method = "setDataCapacity",
+            args = {int.class}
         )
     })
     public void testSetDataCapacity() {
@@ -185,7 +188,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: dataPosition ",
             method = "dataPosition",
             args = {}
         )
@@ -206,7 +208,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: setDataPosition ",
             method = "setDataPosition",
             args = {int.class}
         )
@@ -234,7 +235,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: dataSize ",
             method = "dataSize",
             args = {}
         )
@@ -256,7 +256,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: setDataSize ",
             method = "setDataSize",
             args = {int.class}
         )
@@ -283,13 +282,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: enforceInterface ",
             method = "enforceInterface",
             args = {String.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeInterfaceToken ",
             method = "writeInterfaceToken",
             args = {String.class}
         )
@@ -319,13 +316,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: marshall ",
             method = "marshall",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: unmarshall ",
             method = "unmarshall",
             args = {byte[].class, int.class, int.class}
         )
@@ -357,13 +352,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readValue ",
             method = "readValue",
             args = {ClassLoader.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeValue ",
             method = "writeValue",
             args = {Object.class}
         )
@@ -645,13 +638,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readByte ",
             method = "readByte",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeByte ",
             method = "writeByte",
             args = {byte.class}
         )
@@ -711,13 +702,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readByteArray ",
             method = "readByteArray",
             args = {byte[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeByteArray ",
             method = "writeByteArray",
             args = {byte[].class}
         )
@@ -792,7 +781,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeByteArray ",
             method = "writeByteArray",
             args = {byte[].class, int.class, int.class}
         )
@@ -900,7 +888,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createByteArray ",
             method = "createByteArray",
             args = {}
         )
@@ -961,13 +948,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readCharArray ",
             method = "readCharArray",
             args = {char[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeCharArray ",
             method = "writeCharArray",
             args = {char[].class}
         )
@@ -1043,7 +1028,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createCharArray ",
             method = "createCharArray",
             args = {}
         )
@@ -1105,13 +1089,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readInt ",
             method = "readInt",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeInt ",
             method = "writeInt",
             args = {int.class}
         )
@@ -1171,13 +1153,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readIntArray ",
             method = "readIntArray",
             args = {int[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeIntArray ",
             method = "writeIntArray",
             args = {int[].class}
         )
@@ -1251,7 +1231,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createIntArray ",
             method = "createIntArray",
             args = {}
         )
@@ -1311,13 +1290,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readLong ",
             method = "readLong",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeLong ",
             method = "writeLong",
             args = {long.class}
         )
@@ -1365,13 +1342,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readLongArray ",
             method = "readLongArray",
             args = {long[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeLongArray ",
             method = "writeLongArray",
             args = {long[].class}
         )
@@ -1445,7 +1420,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createLongArray ",
             method = "createLongArray",
             args = {}
         )
@@ -1505,13 +1479,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readFloat ",
             method = "readFloat",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeFloat ",
             method = "writeFloat",
             args = {float.class}
         )
@@ -1571,13 +1543,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readFloatArray ",
             method = "readFloatArray",
             args = {float[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeFloatArray ",
             method = "writeFloatArray",
             args = {float[].class}
         )
@@ -1651,7 +1621,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createFloatArray ",
             method = "createFloatArray",
             args = {}
         )
@@ -1711,13 +1680,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readDouble ",
             method = "readDouble",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeDouble ",
             method = "writeDouble",
             args = {double.class}
         )
@@ -1855,7 +1822,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createDoubleArray ",
             method = "createDoubleArray",
             args = {}
         )
@@ -1866,7 +1832,9 @@
         double[] a = {2.1d};
         double[] b;
 
-        double[] c = {Double.MAX_VALUE, 11.1d, 1.1d, 0.1d, .0d, -0.1d, -1.1d, -11.1d, Double.MIN_VALUE};
+        double[] c = {
+                Double.MAX_VALUE, 11.1d, 1.1d, 0.1d, .0d, -0.1d, -1.1d, -11.1d, Double.MIN_VALUE
+        };
         double[] d;
 
         double[] e = {};
@@ -1915,13 +1883,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readBooleanArray ",
             method = "readBooleanArray",
             args = {boolean[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeBooleanArray ",
             method = "writeBooleanArray",
             args = {boolean[].class}
         )
@@ -1995,7 +1961,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createBooleanArray ",
             method = "createBooleanArray",
             args = {}
         )
@@ -2056,13 +2021,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readString ",
             method = "readString",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeString ",
             method = "writeString",
             args = {String.class}
         )
@@ -2110,13 +2073,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readStringArray ",
             method = "readStringArray",
             args = {String[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeStringArray ",
             method = "writeStringArray",
             args = {String[].class}
         )
@@ -2193,7 +2154,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createStringArray ",
             method = "createStringArray",
             args = {}
         )
@@ -2256,13 +2216,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readStringList ",
             method = "readStringList",
             args = {List.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeStringList ",
             method = "writeStringList",
             args = {List.class}
         )
@@ -2337,7 +2295,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createStringArrayList ",
             method = "createStringArrayList",
             args = {}
         )
@@ -2396,13 +2353,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readSerializable ",
             method = "readSerializable",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeSerializable ",
             method = "writeSerializable",
             args = {Serializable.class}
         )
@@ -2427,13 +2382,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readParcelable ",
             method = "readParcelable",
             args = {ClassLoader.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeParcelable ",
             method = "writeParcelable",
             args = {Parcelable.class, int.class}
         )
@@ -2512,12 +2465,12 @@
         @TestTargetNew(
             level = TestLevel.COMPLETE,
             method = "readTypedArray",
-            args = {Parcelable[].class, android.os.Parcelable.Creator.class}
+            args = {Object[].class, android.os.Parcelable.Creator.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
             method = "writeTypedArray",
-            args = {Parcelable[].class, int.class}
+            args = {android.os.Parcelable[].class, int.class}
         )
     })
     public void testReadTypedArray() {
@@ -2592,7 +2545,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeTypedArray ",
             method = "writeTypedArray",
             args = {Parcelable[].class, int.class}
         )
@@ -2639,13 +2591,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createTypedArray ",
             method = "createTypedArray",
             args = {Parcelable.Creator.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeTypedArray ",
             method = "writeTypedArray",
             args = {Parcelable[].class, int.class}
         )
@@ -2691,13 +2641,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readTypedList ",
             method = "readTypedList",
             args = {List.class, Parcelable.Creator.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeTypedList ",
             method = "writeTypedList",
             args = {List.class}
         )
@@ -2773,13 +2721,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createTypedArrayList ",
             method = "createTypedArrayList",
             args = {Parcelable.Creator.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeTypedList ",
             method = "writeTypedList",
             args = {List.class}
         )
@@ -2826,8 +2772,7 @@
 
     @TestTargets({
         @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "Test method: readException ",
+            level = TestLevel.NOT_FEASIBLE,
             method = "readException",
             args = {int.class, String.class}
         )
@@ -2840,9 +2785,13 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeException ",
             method = "writeException",
             args = {Exception.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "readException",
+            args = {}
         )
     })
     public void testReadException2() {
@@ -2911,9 +2860,13 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeNoException ",
             method = "writeNoException",
             args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "readException",
+            args = {}
         )
     })
     public void testWriteNoException() {
@@ -2927,13 +2880,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeFileDescriptor ",
             method = "writeFileDescriptor",
             args = {FileDescriptor.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readFileDescriptor ",
             method = "readFileDescriptor",
             args = {}
         )
@@ -2960,7 +2911,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: hasFileDescriptors ",
             method = "hasFileDescriptors",
             args = {}
         )
@@ -2985,13 +2935,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readBundle ",
             method = "readBundle",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeBundle ",
             method = "writeBundle",
             args = {Bundle.class}
         )
@@ -3102,13 +3050,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeArray ",
             method = "writeArray",
             args = {Object[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readArray ",
             method = "readArray",
             args = {ClassLoader.class}
         )
@@ -3145,13 +3091,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readArrayList ",
             method = "readArrayList",
             args = {ClassLoader.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeArray ",
             method = "writeArray",
             args = {Object[].class}
         )
@@ -3189,13 +3133,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeSparseArray ",
             method = "writeSparseArray",
             args = {SparseArray.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readSparseArray ",
             method = "readSparseArray",
             args = {ClassLoader.class}
         )
@@ -3237,13 +3179,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeSparseBooleanArray ",
             method = "writeSparseBooleanArray",
             args = {SparseBooleanArray.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readSparseBooleanArray ",
             method = "readSparseBooleanArray",
             args = {}
         )
@@ -3284,13 +3224,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeStrongBinder ",
             method = "writeStrongBinder",
             args = {IBinder.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readStrongBinder ",
             method = "readStrongBinder",
             args = {}
         )
@@ -3317,7 +3255,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeStrongInterface ",
             method = "writeStrongInterface",
             args = {IInterface.class}
         )
@@ -3344,13 +3281,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeBinderArray ",
             method = "writeBinderArray",
             args = {IBinder[].class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readBinderArray ",
             method = "readBinderArray",
             args = {IBinder[].class}
         )
@@ -3419,7 +3354,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createBinderArray ",
             method = "createBinderArray",
             args = {}
         )
@@ -3461,13 +3395,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeBinderList ",
             method = "writeBinderList",
             args = {List.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readBinderList ",
             method = "readBinderList",
             args = {List.class}
         )
@@ -3520,7 +3452,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: createBinderArrayList ",
             method = "createBinderArrayList",
             args = {}
         )
@@ -3562,13 +3493,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeMap ",
             method = "writeMap",
             args = {Map.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readMap ",
             method = "readMap",
             args = {Map.class, ClassLoader.class}
         )
@@ -3606,13 +3535,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readHashMap ",
             method = "readHashMap",
             args = {ClassLoader.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeMap ",
             method = "writeMap",
             args = {Map.class}
         )
@@ -3650,13 +3577,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: readList ",
             method = "readList",
             args = {List.class, ClassLoader.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test method: writeList ",
             method = "writeList",
             args = {List.class}
         )
diff --git a/tests/tests/os/src/android/os/cts/ProcessTest.java b/tests/tests/os/src/android/os/cts/ProcessTest.java
index 980ca85..6216f06 100644
--- a/tests/tests/os/src/android/os/cts/ProcessTest.java
+++ b/tests/tests/os/src/android/os/cts/ProcessTest.java
@@ -94,6 +94,9 @@
         if (mIntent != null) {
             getContext().stopService(mIntent);
         }
+        if (mSecondaryConnection != null) {
+            getContext().unbindService(mSecondaryConnection);
+        }
     }
 
     @TestTargets({
@@ -255,18 +258,15 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "test send a signal to a process",
             method = "sendSignal",
             args = {int.class, int.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "test myPid() in StubRemoteService",
             method = "myPid",
             args = {}
         )
     })
-
     /**
      * Test myPid() point.
      * Returns the identifier of this process, which can be used with
diff --git a/tests/tests/os/src/android/os/cts/RemoteCallbackListTest.java b/tests/tests/os/src/android/os/cts/RemoteCallbackListTest.java
index 71d64f0..f4031ff 100644
--- a/tests/tests/os/src/android/os/cts/RemoteCallbackListTest.java
+++ b/tests/tests/os/src/android/os/cts/RemoteCallbackListTest.java
@@ -64,6 +64,10 @@
                 }
             }
         };
+        mIntent = new Intent(SERVICE_ACTION);
+        assertTrue(mContext.bindService(new Intent(ISecondary.class.getName()),
+                mSecondaryConnection, Context.BIND_AUTO_CREATE));
+
     }
 
     private static class Sync {
@@ -74,6 +78,9 @@
     @Override
     public void tearDown() throws Exception {
         super.tearDown();
+        if (mSecondaryConnection != null) {
+            mContext.unbindService(mSecondaryConnection);
+        }
         if (mIntent != null) {
             mContext.stopService(mIntent);
         }
@@ -117,10 +124,6 @@
     public void testRemoteCallbackList() throws Exception {
         // Test constructor(default one).
         MockRemoteCallbackList<IInterface> rc = new MockRemoteCallbackList<IInterface>();
-        mIntent = new Intent(SERVICE_ACTION);
-        mContext.startService(mIntent);
-        mContext.bindService(new Intent(ISecondary.class.getName()), mSecondaryConnection,
-                Context.BIND_AUTO_CREATE);
         synchronized (mSync) {
             if (!mSync.mIsConnected) {
                 mSync.wait();
@@ -176,10 +179,6 @@
     )
     public void testKill() {
         MockRemoteCallbackList<IInterface> rc = new MockRemoteCallbackList<IInterface>();
-        mIntent = new Intent(SERVICE_ACTION);
-        mContext.startService(mIntent);
-        mContext.bindService(new Intent(ISecondary.class.getName()), mSecondaryConnection,
-                Context.BIND_AUTO_CREATE);
         synchronized (mSync) {
             if (!mSync.mIsConnected) {
                 try {
diff --git a/tests/tests/os/src/android/os/cts/ResultReceiverTest.java b/tests/tests/os/src/android/os/cts/ResultReceiverTest.java
new file mode 100644
index 0000000..90ab141
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/ResultReceiverTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os.cts;
+
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Parcel;
+import android.os.ResultReceiver;
+import android.test.AndroidTestCase;
+
+@TestTargetClass(ResultReceiver.class)
+public class ResultReceiverTest extends AndroidTestCase {
+    private Handler mHandler = new Handler();
+    private static final long DURATION = 100l;
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "send",
+            args = {int.class, Bundle.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "onReceiveResult",
+            args = {int.class, Bundle.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "ResultReceiver",
+            args = {Handler.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "writeToParcel",
+            args = {Parcel.class, int.class}
+        )
+    })
+    public void testResultReceiver() throws InterruptedException {
+        MockResultReceiver sender = new MockResultReceiver(mHandler);
+        Bundle bundle = new Bundle();
+        int resultCode = 1;
+        sender.send(resultCode, bundle);
+        Thread.sleep(DURATION);
+        assertEquals(resultCode, sender.getResultCode());
+        assertSame(bundle, sender.getResultData());
+
+        ResultReceiver receiver = new ResultReceiver(mHandler);
+        assertEquals(0, receiver.describeContents());
+
+        Parcel p = Parcel.obtain();
+        receiver.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        ResultReceiver target = ResultReceiver.CREATOR.createFromParcel(p);
+        assertNotNull(target);
+    }
+
+    private class MockResultReceiver extends ResultReceiver {
+
+        private Bundle mResultData;
+        private int mResultCode;
+
+        public MockResultReceiver(Handler handler) {
+            super(handler);
+        }
+
+        @Override
+        protected void onReceiveResult(int resultCode, Bundle resultData) {
+            super.onReceiveResult(resultCode, resultData);
+            mResultData = resultData;
+            mResultCode = resultCode;
+        }
+
+        public Bundle getResultData() {
+            return mResultData;
+        }
+
+        public int getResultCode() {
+            return mResultCode;
+        }
+    }
+}
diff --git a/tests/tests/os/src/android/os/cts/StatFsTest.java b/tests/tests/os/src/android/os/cts/StatFsTest.java
index 93b58eb..e879611 100644
--- a/tests/tests/os/src/android/os/cts/StatFsTest.java
+++ b/tests/tests/os/src/android/os/cts/StatFsTest.java
@@ -29,38 +29,32 @@
 public class StatFsTest extends TestCase {
     @TestTargets({
         @TestTargetNew(
-            level = TestLevel.TODO,
-            notes = "Test constructor(s) of {@link StatFs}",
+            level = TestLevel.COMPLETE,
             method = "StatFs",
-            args = {}
+            args = {String.class}
         ),
         @TestTargetNew(
-            level = TestLevel.TODO,
-            notes = "Test method: restat",
+            level = TestLevel.COMPLETE,
             method = "restat",
-            args = {}
+            args = {String.class}
         ),
         @TestTargetNew(
-            level = TestLevel.TODO,
-            notes = "Test method: getBlockSize",
+            level = TestLevel.COMPLETE,
             method = "getBlockSize",
             args = {}
         ),
         @TestTargetNew(
-            level = TestLevel.TODO,
-            notes = "Test method: getBlockCount",
+            level = TestLevel.COMPLETE,
             method = "getBlockCount",
             args = {}
         ),
         @TestTargetNew(
-            level = TestLevel.TODO,
-            notes = "Test method: getFreeBlocks",
+            level = TestLevel.COMPLETE,
             method = "getFreeBlocks",
             args = {}
         ),
         @TestTargetNew(
-            level = TestLevel.TODO,
-            notes = "Test method: getAvailableBlocks",
+            level = TestLevel.COMPLETE,
             method = "getAvailableBlocks",
             args = {}
         )
diff --git a/tests/tests/os/src/android/os/cts/SystemClockTest.java b/tests/tests/os/src/android/os/cts/SystemClockTest.java
index 3286e13..7d76ac1 100644
--- a/tests/tests/os/src/android/os/cts/SystemClockTest.java
+++ b/tests/tests/os/src/android/os/cts/SystemClockTest.java
@@ -18,34 +18,23 @@
 
 import android.os.SystemClock;
 import android.test.AndroidTestCase;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
 
 @TestTargetClass(SystemClock.class)
 public class SystemClockTest extends AndroidTestCase {
 
-    /**
-     * sleep 100 milliseconds
-     */
-    private void sleep(long sleepTime) {
-        try {
-            Thread.sleep(sleepTime);
-        } catch (InterruptedException e) {
-        }
-    }
-
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         notes = "Test currentThreadTimeMillis(), the sleep() will not affect the thread",
         method = "currentThreadTimeMillis",
         args = {}
     )
-    public void testCurrentThreadTimeMillis() {
+    public void testCurrentThreadTimeMillis() throws InterruptedException {
 
         long start = SystemClock.currentThreadTimeMillis();
-        sleep(100);
+        Thread.sleep(100);
         long end = SystemClock.currentThreadTimeMillis();
         assertFalse(end - 100 >= start);
 
@@ -53,14 +42,13 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test elapsedRealtime()",
         method = "elapsedRealtime",
         args = {}
     )
-    public void testElapsedRealtime() {
+    public void testElapsedRealtime() throws InterruptedException {
 
         long start = SystemClock.elapsedRealtime();
-        sleep(100);
+        Thread.sleep(100);
         long end = SystemClock.elapsedRealtime();
         assertTrue(end - 100 >= start);
 
@@ -68,7 +56,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test setCurrentTimeMillis(long).",
         method = "setCurrentTimeMillis",
         args = {long.class}
     )
@@ -108,17 +95,15 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test uptimeMillis()",
         method = "uptimeMillis",
         args = {}
     )
-    public void testUptimeMillis() {
+    public void testUptimeMillis() throws InterruptedException {
 
         long start = SystemClock.uptimeMillis();
-        sleep(100);
+        Thread.sleep(100);
         long end = SystemClock.uptimeMillis();
         assertTrue(end - 100 >= start);
-
     }
 
 }
diff --git a/tests/tests/view/src/android/view/cts/ViewGroup_LayoutParamsTest.java b/tests/tests/view/src/android/view/cts/ViewGroup_LayoutParamsTest.java
index bff1f47..f38b899 100644
--- a/tests/tests/view/src/android/view/cts/ViewGroup_LayoutParamsTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewGroup_LayoutParamsTest.java
@@ -43,19 +43,16 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructors",
             method = "ViewGroup.LayoutParams",
             args = {int.class, int.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructors",
             method = "ViewGroup.LayoutParams",
             args = {android.content.Context.class, android.util.AttributeSet.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructors",
             method = "ViewGroup.LayoutParams",
             args = {android.view.ViewGroup.LayoutParams.class}
         )
@@ -82,26 +79,16 @@
     public void testSetBaseAttributes() throws XmlPullParserException, IOException {
         MockLayoutParams mockLayoutParams = new MockLayoutParams(240, 320);
 
-        XmlResourceParser parser = mContext.getResources().getLayout(
-                R.layout.viewgroup_margin_layout);
-
-        XmlUtils.beginDocument(parser, "LinearLayout");
-        TypedArray array = mContext.obtainStyledAttributes(parser,
-                com.android.internal.R.styleable.ViewGroup_Layout);
-        mockLayoutParams.setBaseAttributes(array,
-                com.android.internal.R.styleable.ViewGroup_Layout_layout_width,
-                com.android.internal.R.styleable.ViewGroup_Layout_layout_height);
+        int[] attrs = R.styleable.style1;
+        TypedArray array = mContext.getTheme().obtainStyledAttributes(R.style.Whatever, attrs);
+        mockLayoutParams.setBaseAttributes(array, R.styleable.style1_type6,
+                R.styleable.style1_type7);
+        int defValue = -1;
+        assertEquals(array.getDimensionPixelSize(R.styleable.style1_type6, defValue),
+                mockLayoutParams.width);
+        assertEquals(array.getDimensionPixelSize(R.styleable.style1_type7, defValue),
+                mockLayoutParams.height);
         array.recycle();
-        assertEquals(200, mockLayoutParams.width);
-        assertEquals(300, mockLayoutParams.height);
-
-        try {
-            mockLayoutParams.setBaseAttributes(null,
-                com.android.internal.R.styleable.ViewGroup_Layout_layout_width,
-                com.android.internal.R.styleable.ViewGroup_Layout_layout_height);
-            fail("should throw NullPointerException");
-        } catch (NullPointerException e) {
-        }
     }
 
     private class MockLayoutParams extends LayoutParams {
diff --git a/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java b/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java
new file mode 100644
index 0000000..f95057a
--- /dev/null
+++ b/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java
@@ -0,0 +1,586 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.widget.cts;
+
+import com.android.cts.stub.R;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+import dalvik.annotation.ToBeFixed;
+
+import org.xmlpull.v1.XmlPullParser;
+
+import android.app.Activity;
+import android.app.Instrumentation;
+import android.content.Context;
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
+import android.text.Editable;
+import android.text.Spannable;
+import android.text.TextWatcher;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.util.Xml;
+import android.view.KeyEvent;
+import android.widget.DialerFilter;
+import android.widget.EditText;
+import android.widget.RelativeLayout;
+
+@TestTargetClass(DialerFilter.class)
+public class DialerFilterTest extends ActivityInstrumentationTestCase2<DialerFilterStubActivity> {
+    private Activity mActivity;
+    private Instrumentation mInstrumentation;
+    private DialerFilter mDialerFilter;
+
+    public DialerFilterTest() {
+        super("com.android.cts.stub", DialerFilterStubActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mActivity = getActivity();
+        mInstrumentation = getInstrumentation();
+
+        mDialerFilter = (DialerFilter) mActivity.findViewById(R.id.dialer_filter);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "DialerFilter",
+            args = {Context.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "DialerFilter",
+            args = {Context.class, AttributeSet.class}
+        )
+    })
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testConstructor() {
+        final XmlPullParser parser = mActivity.getResources().getXml(R.layout.dialerfilter_layout);
+        final AttributeSet attrs = Xml.asAttributeSet(parser);
+
+        new DialerFilter(mActivity);
+        new DialerFilter(mActivity, attrs);
+
+        new DialerFilter(null);
+        try {
+            new DialerFilter(null, null);
+            fail("There should be a NullPointerException thrown out.");
+        } catch (final NullPointerException e) {
+            // expected, test success
+        }
+    }
+
+    @TestTargetNew(
+        level = TestLevel.SUFFICIENT,
+        method = "isQwertyKeyboard",
+        args = {}
+    )
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testIsQwertyKeyboard() {
+        // Simply call the method. Return value may depend on the default keyboard.
+        mDialerFilter.isQwertyKeyboard();
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "onKeyUp",
+            args = {int.class, KeyEvent.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "onKeyDown",
+            args = {int.class, KeyEvent.class}
+        )
+    })
+    public void testOnKeyUpDown() {
+        // The exact behavior depends on the implementation of DialerKeyListener and
+        // TextKeyListener, but even that may be changed. Simply assert basic scenarios.
+
+        mInstrumentation.runOnMainSync(new Runnable() {
+            public void run() {
+                mDialerFilter.setMode(DialerFilter.DIGITS_ONLY);
+            }
+        });
+        mInstrumentation.waitForIdleSync();
+
+        sendKeys(KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_3);
+        assertEquals("", mDialerFilter.getLetters().toString());
+        assertEquals("123", mDialerFilter.getDigits().toString());
+
+        mInstrumentation.runOnMainSync(new Runnable() {
+            public void run() {
+                mDialerFilter.clearText();
+                mDialerFilter.setMode(DialerFilter.LETTERS_ONLY);
+            }
+        });
+        mInstrumentation.waitForIdleSync();
+
+        sendKeys(KeyEvent.KEYCODE_A, KeyEvent.KEYCODE_D, KeyEvent.KEYCODE_G);
+        assertEquals("ADG", mDialerFilter.getLetters().toString());
+        assertEquals("", mDialerFilter.getDigits().toString());
+
+        mInstrumentation.runOnMainSync(new Runnable() {
+            public void run() {
+                mDialerFilter.clearText();
+                mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+            }
+        });
+        mInstrumentation.waitForIdleSync();
+
+        sendKeys(KeyEvent.KEYCODE_A, KeyEvent.KEYCODE_D, KeyEvent.KEYCODE_G);
+        assertEquals("ADG", mDialerFilter.getLetters().toString());
+        // A, D, K may map to numbers on some keyboards. Don't test.
+
+        mInstrumentation.runOnMainSync(new Runnable() {
+            public void run() {
+                mDialerFilter.clearText();
+                mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+            }
+        });
+        mInstrumentation.waitForIdleSync();
+
+        sendKeys(KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_3);
+        // 1, 2, 3 may map to letters on some keyboards. Don't test.
+        assertEquals("123", mDialerFilter.getDigits().toString());
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setMode",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getMode",
+            args = {}
+        )
+    })
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testAccessMode() {
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS_NO_LETTERS);
+        assertEquals(DialerFilter.DIGITS_AND_LETTERS_NO_LETTERS, mDialerFilter.getMode());
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+        assertEquals(DialerFilter.DIGITS_AND_LETTERS, mDialerFilter.getMode());
+
+        mDialerFilter.setMode(-1);
+        assertEquals(-1, mDialerFilter.getMode());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getLetters",
+        args = {}
+    )
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testGetLetters() {
+        assertEquals("", mDialerFilter.getLetters().toString());
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+        mDialerFilter.append("ANDROID");
+        assertEquals("ANDROID", mDialerFilter.getLetters().toString());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getDigits",
+        args = {}
+    )
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testGetDigits() {
+        assertEquals("", mDialerFilter.getDigits().toString());
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+        mDialerFilter.append("12345");
+        assertEquals("12345", mDialerFilter.getDigits().toString());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getFilterText",
+        args = {}
+    )
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testGetFilterText() {
+        assertEquals("", mDialerFilter.getFilterText().toString());
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+        mDialerFilter.append("CTS12345");
+        assertEquals("CTS12345", mDialerFilter.getFilterText().toString());
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_ONLY);
+        assertEquals("12345", mDialerFilter.getFilterText().toString());
+
+        mDialerFilter.setMode(DialerFilter.LETTERS_ONLY);
+        assertEquals("CTS12345", mDialerFilter.getFilterText().toString());
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "append",
+            args = {java.lang.String.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setMode",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getLetters",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getDigits",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getFilterText",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "clearText",
+            args = {}
+        )
+    })
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testAppend() {
+        mDialerFilter.setMode(DialerFilter.LETTERS_ONLY);
+        mDialerFilter.append("ANDROID");
+        assertEquals("ANDROID", mDialerFilter.getLetters().toString());
+        assertEquals("", mDialerFilter.getDigits().toString());
+        assertEquals("ANDROID", mDialerFilter.getFilterText().toString());
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_ONLY);
+        mDialerFilter.append("123");
+        assertEquals("", mDialerFilter.getLetters().toString());
+        assertEquals("123", mDialerFilter.getDigits().toString());
+        assertEquals("123", mDialerFilter.getFilterText().toString());
+
+        mDialerFilter.clearText();
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+        mDialerFilter.append("ABC123DEF456GHI789");
+        assertEquals("ABC123DEF456GHI789", mDialerFilter.getLetters().toString());
+        assertEquals("123456789", mDialerFilter.getDigits().toString());
+        assertEquals("ABC123DEF456GHI789", mDialerFilter.getFilterText().toString());
+
+        mDialerFilter.clearText();
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS_NO_DIGITS);
+        mDialerFilter.append("ABC123DEF456GHI789");
+        assertEquals("ABC123DEF456GHI789", mDialerFilter.getLetters().toString());
+        assertEquals("", mDialerFilter.getDigits().toString());
+        assertEquals("ABC123DEF456GHI789", mDialerFilter.getFilterText().toString());
+
+        mDialerFilter.clearText();
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS_NO_LETTERS);
+        mDialerFilter.append("ABC123DEF456GHI789");
+        assertEquals("", mDialerFilter.getLetters().toString());
+        assertEquals("123456789", mDialerFilter.getDigits().toString());
+        assertEquals("", mDialerFilter.getFilterText().toString());
+
+        mDialerFilter.clearText();
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+        mDialerFilter.append("");
+        assertEquals("", mDialerFilter.getLetters().toString());
+        assertEquals("", mDialerFilter.getDigits().toString());
+        assertEquals("", mDialerFilter.getFilterText().toString());
+
+        try {
+            mDialerFilter.append(null);
+            fail("A NullPointerException should be thrown out.");
+        } catch (final NullPointerException e) {
+            // expected, test success.
+        }
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "clearText",
+        args = {}
+    )
+    @UiThreadTest
+    public void testClearText() {
+        assertEquals("", mDialerFilter.getLetters().toString());
+        assertEquals("", mDialerFilter.getDigits().toString());
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_AND_LETTERS);
+        mDialerFilter.append("CTS12345");
+        assertEquals("CTS12345", mDialerFilter.getLetters().toString());
+        assertEquals("12345", mDialerFilter.getDigits().toString());
+
+        mDialerFilter.clearText();
+        assertEquals("", mDialerFilter.getLetters().toString());
+        assertEquals("", mDialerFilter.getDigits().toString());
+        assertEquals(DialerFilter.DIGITS_AND_LETTERS, mDialerFilter.getMode());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setLettersWatcher",
+        args = {TextWatcher.class}
+    )
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testSetLettersWatcher() {
+        MockTextWatcher tw = new MockTextWatcher("A");
+
+        Spannable span = (Spannable) mDialerFilter.getLetters();
+        assertEquals(-1, span.getSpanStart(tw));
+        assertEquals(-1, span.getSpanEnd(tw));
+
+        mDialerFilter.setMode(DialerFilter.LETTERS_ONLY);
+        mDialerFilter.setLettersWatcher(tw);
+        mDialerFilter.append("ANDROID");
+        assertEquals("ANDROID", tw.getText());
+
+        span = (Spannable) mDialerFilter.getLetters();
+        assertEquals(0, span.getSpanStart(tw));
+        assertEquals(mDialerFilter.getLetters().length(), span.getSpanEnd(tw));
+        assertEquals("ANDROID", span.toString());
+
+        tw = new MockTextWatcher("");
+        mDialerFilter.setLettersWatcher(tw);
+        mDialerFilter.append("");
+        assertEquals("", tw.getText());
+
+        try {
+            mDialerFilter.setLettersWatcher(new MockTextWatcher(null));
+            mDialerFilter.append(null);
+            fail("A NullPointerException should be thrown out.");
+        } catch (final NullPointerException e) {
+            // expected, test success.
+        }
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setDigitsWatcher",
+        args = {TextWatcher.class}
+    )
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testSetDigitsWatcher() {
+        final MockTextWatcher tw = new MockTextWatcher("9");
+
+        Spannable span = (Spannable) mDialerFilter.getDigits();
+        assertEquals(-1, span.getSpanStart(tw));
+        assertEquals(-1, span.getSpanEnd(tw));
+
+        mDialerFilter.setDigitsWatcher(tw);
+        assertEquals(0, span.getSpanStart(tw));
+        assertEquals(mDialerFilter.getDigits().length(), span.getSpanEnd(tw));
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_ONLY);
+        mDialerFilter.append("12345");
+        assertEquals("12345", tw.getText());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setFilterWatcher",
+        args = {TextWatcher.class}
+    )
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testSetFilterWatcher() {
+        final MockTextWatcher tw = new MockTextWatcher("A");
+
+        Spannable span = (Spannable) mDialerFilter.getLetters();
+        assertEquals(-1, span.getSpanStart(tw));
+        assertEquals(-1, span.getSpanEnd(tw));
+
+        mDialerFilter.setMode(DialerFilter.LETTERS_ONLY);
+        mDialerFilter.setFilterWatcher(tw);
+        mDialerFilter.append("ANDROID");
+        assertEquals("ANDROID", tw.getText());
+        span = (Spannable) mDialerFilter.getLetters();
+
+        assertEquals(0, span.getSpanStart(tw));
+        assertEquals(mDialerFilter.getLetters().length(), span.getSpanEnd(tw));
+
+        mDialerFilter.setMode(DialerFilter.DIGITS_ONLY);
+        mDialerFilter.setFilterWatcher(tw);
+        mDialerFilter.append("12345");
+        assertEquals("12345", tw.getText());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "removeFilterWatcher",
+        args = {TextWatcher.class}
+    )
+    @UiThreadTest
+    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
+    public void testRemoveFilterWatcher() {
+        final MockTextWatcher tw = new MockTextWatcher("A");
+
+        Spannable span = (Spannable) mDialerFilter.getLetters();
+        assertEquals(-1, span.getSpanStart(tw));
+        assertEquals(-1, span.getSpanEnd(tw));
+
+        mDialerFilter.setMode(DialerFilter.LETTERS_ONLY);
+        mDialerFilter.setFilterWatcher(tw);
+        mDialerFilter.append("ANDROID");
+        assertEquals("ANDROID", tw.getText());
+
+        span = (Spannable) mDialerFilter.getLetters();
+        assertEquals(0, span.getSpanStart(tw));
+        assertEquals(mDialerFilter.getLetters().length(), span.getSpanEnd(tw));
+
+        mDialerFilter.removeFilterWatcher(tw);
+        mDialerFilter.append("GOLF");
+        assertEquals("ANDROID", tw.getText());
+
+        assertEquals(-1, span.getSpanStart(tw));
+        assertEquals(-1, span.getSpanEnd(tw));
+    }
+
+    @TestTargetNew(
+        level = TestLevel.NOT_NECESSARY,
+        method = "onFinishInflate",
+        args = {}
+    )
+    public void testOnFinishInflate() {
+        // onFinishInflate() is implementation details, do NOT test
+    }
+
+    @TestTargetNew(
+        level = TestLevel.NOT_NECESSARY,
+        method = "onFocusChanged",
+        args = {boolean.class, int.class, android.graphics.Rect.class}
+    )
+    public void testOnFocusChanged() {
+        // onFocusChanged() is implementation details, do NOT test
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "onModeChange",
+        args = {int.class, int.class}
+    )
+    @UiThreadTest
+    public void testOnModechange() {
+        final MockDialerFilter dialerFilter = createMyDialerFilter();
+        dialerFilter.onFinishInflate();
+
+        assertEquals(0, dialerFilter.getOldMode());
+        assertEquals(MockDialerFilter.DIGITS_AND_LETTERS, dialerFilter.getNewMode());
+
+        dialerFilter.setMode(MockDialerFilter.DIGITS_AND_LETTERS_NO_LETTERS);
+        assertEquals(MockDialerFilter.DIGITS_AND_LETTERS, dialerFilter.getOldMode());
+        assertEquals(MockDialerFilter.DIGITS_AND_LETTERS_NO_LETTERS, dialerFilter.getNewMode());
+
+        dialerFilter.setMode(MockDialerFilter.DIGITS_AND_LETTERS_NO_DIGITS);
+        assertEquals(MockDialerFilter.DIGITS_AND_LETTERS_NO_LETTERS, dialerFilter.getOldMode());
+        assertEquals(MockDialerFilter.DIGITS_AND_LETTERS_NO_DIGITS, dialerFilter.getNewMode());
+    }
+
+    private MockDialerFilter createMyDialerFilter() {
+        final MockDialerFilter dialerFilter = new MockDialerFilter(mActivity);
+
+        final EditText text1 = new EditText(mActivity);
+        text1.setId(com.android.internal.R.id.hint);
+        final EditText text2 = new EditText(mActivity);
+        text2.setId(com.android.internal.R.id.primary);
+
+        dialerFilter.addView(text1, new RelativeLayout.LayoutParams(
+                RelativeLayout.LayoutParams.WRAP_CONTENT,
+                RelativeLayout.LayoutParams.WRAP_CONTENT));
+        dialerFilter.addView(text2, new RelativeLayout.LayoutParams(
+                RelativeLayout.LayoutParams.WRAP_CONTENT,
+                RelativeLayout.LayoutParams.WRAP_CONTENT));
+
+        return dialerFilter;
+    }
+
+    private class MockTextWatcher implements TextWatcher {
+        private String mString;
+
+        public MockTextWatcher(final String s) {
+            mString = s;
+        }
+
+        public void beforeTextChanged(final CharSequence s, final int start, final int count,
+                final int after) {
+            Log.d("DialerFilterTest", "MockTextWatcher beforeTextChanged");
+        }
+
+        public void onTextChanged(final CharSequence s, final int start, final int before,
+                final int count) {
+            Log.d("DialerFilterTest", "MockTextWatcher onTextChanged");
+            mString = s.toString();
+        }
+
+        public void afterTextChanged(final Editable s) {
+            Log.d("DialerFilterTest", "MockTextWatcher afterTextChanged");
+        }
+
+        public String getText() {
+            return mString;
+        }
+    }
+
+    /**
+     * MockDialerFilter for test
+     */
+    private class MockDialerFilter extends DialerFilter {
+        private int mOldMode = 0;
+        private int mNewMode = 0;
+
+        public MockDialerFilter(Context context) {
+            super(context);
+        }
+
+        @Override
+        protected void onFinishInflate() {
+            super.onFinishInflate();
+        }
+
+        @Override
+        protected void onModeChange(final int oldMode, final int newMode) {
+            super.onModeChange(oldMode, newMode);
+            mOldMode = oldMode;
+            mNewMode = newMode;
+        }
+
+        public int getOldMode() {
+            return mOldMode;
+        }
+
+        public int getNewMode() {
+            return mNewMode;
+        }
+    }
+}