Merge change 7969 into donut

* changes:
  Cts content tests cleanup.
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index f945f5e..6e56af6 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -465,6 +465,9 @@
             <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
         </activity>
 
+       <activity android:name="android.media.cts.FaceDetectorStub"
+            android:label="FaceDetectorStub"/>
+
         <activity android:name="android.widget.cts.ListViewStubActivity"
             android:label="ListViewStubActivity">
             <intent-filter>
diff --git a/tests/res/drawable/single_face.jpg b/tests/res/drawable/single_face.jpg
new file mode 100644
index 0000000..064ee00
--- /dev/null
+++ b/tests/res/drawable/single_face.jpg
Binary files differ
diff --git a/tests/res/raw/a_4.ogg b/tests/res/raw/a_4.ogg
new file mode 100644
index 0000000..155e790
--- /dev/null
+++ b/tests/res/raw/a_4.ogg
Binary files differ
diff --git a/tests/res/raw/b_5.ogg b/tests/res/raw/b_5.ogg
new file mode 100644
index 0000000..c64e508
--- /dev/null
+++ b/tests/res/raw/b_5.ogg
Binary files differ
diff --git a/tests/res/raw/c_sharp_5.ogg b/tests/res/raw/c_sharp_5.ogg
new file mode 100644
index 0000000..18900f9
--- /dev/null
+++ b/tests/res/raw/c_sharp_5.ogg
Binary files differ
diff --git a/tests/res/raw/e_5.ogg b/tests/res/raw/e_5.ogg
new file mode 100644
index 0000000..2597e75
--- /dev/null
+++ b/tests/res/raw/e_5.ogg
Binary files differ
diff --git a/tests/res/raw/g_sharp_5.ogg b/tests/res/raw/g_sharp_5.ogg
new file mode 100644
index 0000000..02e8112
--- /dev/null
+++ b/tests/res/raw/g_sharp_5.ogg
Binary files differ
diff --git a/tests/src/android/media/cts/FaceDetectorStub.java b/tests/src/android/media/cts/FaceDetectorStub.java
new file mode 100644
index 0000000..4c8344b
--- /dev/null
+++ b/tests/src/android/media/cts/FaceDetectorStub.java
@@ -0,0 +1,44 @@
+/*
+ * 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.media.cts;
+
+import com.android.cts.stub.R;
+
+import android.app.Activity;
+import android.media.FaceDetector.Face;
+import android.os.Bundle;
+
+import java.util.List;
+
+public class FaceDetectorStub extends Activity {
+
+    public static final String IMAGE_ID = "imageId";
+
+    private FaceView mFaceView;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        int imageId = getIntent().getIntExtra(IMAGE_ID, R.drawable.single_face);
+        mFaceView = new FaceView(this, imageId);
+        setContentView(mFaceView);
+    }
+
+    public List<Face> getDetectedFaces() {
+        return mFaceView.detectedFaces;
+    }
+}
\ No newline at end of file
diff --git a/tests/src/android/media/cts/FaceView.java b/tests/src/android/media/cts/FaceView.java
new file mode 100644
index 0000000..8d54413
--- /dev/null
+++ b/tests/src/android/media/cts/FaceView.java
@@ -0,0 +1,91 @@
+/*
+ * 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.media.cts;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.PointF;
+import android.graphics.Rect;
+import android.media.FaceDetector;
+import android.media.FaceDetector.Face;
+import android.view.View;
+
+import java.util.ArrayList;
+
+public class FaceView extends View {
+    private static final int NUM_FACES = 10;
+    private FaceDetector mFaceDetector;
+    private Face[] mAllFaces = new Face[NUM_FACES];
+    private Bitmap mSourceImage;
+    private Paint mTmpPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+    private Paint mPOuterBullsEye = new Paint(Paint.ANTI_ALIAS_FLAG);
+    private Paint mPInnerBullsEye = new Paint(Paint.ANTI_ALIAS_FLAG);
+    private int mPicWidth;
+    private int mPicHeight;
+
+    public ArrayList<Face> detectedFaces = new ArrayList<Face>();
+
+    public FaceView(Context context, int resId) {
+        super(context);
+
+        mPInnerBullsEye.setStyle(Paint.Style.FILL);
+        mPInnerBullsEye.setColor(Color.RED);
+
+        mPOuterBullsEye.setStyle(Paint.Style.STROKE);
+        mPOuterBullsEye.setColor(Color.RED);
+
+        mTmpPaint.setStyle(Paint.Style.STROKE);
+        mTmpPaint.setTextAlign(Paint.Align.CENTER);
+
+        BitmapFactory.Options bfo = new BitmapFactory.Options();
+        bfo.inPreferredConfig = Bitmap.Config.RGB_565;
+
+        mSourceImage = BitmapFactory.decodeResource(getResources(), resId, bfo);
+
+        mPicWidth = mSourceImage.getWidth();
+        mPicHeight = mSourceImage.getHeight();
+
+        mFaceDetector = new FaceDetector(mPicWidth, mPicHeight, NUM_FACES);
+        int numFaces = mFaceDetector.findFaces(mSourceImage, mAllFaces);
+
+        for (int i = 0; i < numFaces; i++) {
+            detectedFaces.add(mAllFaces[i]);
+        }
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        float scale = Math.min((float) getWidth() / mPicWidth, (float) getHeight() / mPicHeight);
+        Rect scaledRect = new Rect(0, 0, mPicWidth, mPicHeight);
+        scaledRect.scale(scale);
+        canvas.drawBitmap(mSourceImage, null, scaledRect, mTmpPaint);
+        for (Face face : detectedFaces) {
+            PointF eyesMP = new PointF();
+            face.getMidPoint(eyesMP);
+            float centerX = eyesMP.x * scale;
+            float centerY = eyesMP.y * scale;
+            float eyesDistance = face.eyesDistance() * scale;
+            mPOuterBullsEye.setStrokeWidth(eyesDistance / 6);
+            canvas.drawCircle(centerX, centerY, eyesDistance / 2, mPOuterBullsEye);
+            canvas.drawCircle(centerX, centerY, eyesDistance / 6, mPInnerBullsEye);
+        }
+    }
+}
diff --git a/tests/tests/media/src/android/media/cts/FaceDetectorTest.java b/tests/tests/media/src/android/media/cts/FaceDetectorTest.java
new file mode 100644
index 0000000..dcb5546
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/FaceDetectorTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.media.cts;
+
+import com.android.cts.stub.R;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.media.FaceDetector;
+import android.media.FaceDetector.Face;
+import android.test.InstrumentationTestCase;
+
+@TestTargetClass(FaceDetector.class)
+public class FaceDetectorTest extends InstrumentationTestCase {
+
+    private FaceDetectorStub mActivity;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        Intent intent = new Intent();
+        intent.setClass(getInstrumentation().getTargetContext(), FaceDetectorStub.class);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        intent.putExtra(FaceDetectorStub.IMAGE_ID, R.drawable.baby_face);
+        mActivity = (FaceDetectorStub) getInstrumentation().startActivitySync(intent);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        mActivity.finish();
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "findFaces",
+            args = {Bitmap.class, Face[].class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "FaceDetector",
+            args = {int.class, int.class, int.class}
+        )
+    })
+    public void testFindFaces() throws Exception {
+        long waitMsec = 5000;
+        Thread.sleep(waitMsec);
+        assertTrue(mActivity.getDetectedFaces().size() == 5);
+    }
+
+}
diff --git a/tests/tests/media/src/android/media/cts/FaceDetector_FaceTest.java b/tests/tests/media/src/android/media/cts/FaceDetector_FaceTest.java
new file mode 100644
index 0000000..5f767ad
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/FaceDetector_FaceTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.media.cts;
+
+import com.android.cts.stub.R;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.content.Intent;
+import android.graphics.PointF;
+import android.media.FaceDetector;
+import android.media.FaceDetector.Face;
+import android.test.InstrumentationTestCase;
+
+import java.util.List;
+
+@TestTargetClass(Face.class)
+public class FaceDetector_FaceTest extends InstrumentationTestCase {
+    private FaceDetectorStub mActivity;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        Intent intent = new Intent();
+        intent.setClass(getInstrumentation().getTargetContext(), FaceDetectorStub.class);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        intent.putExtra(FaceDetectorStub.IMAGE_ID, R.drawable.single_face);
+        mActivity = (FaceDetectorStub) getInstrumentation().startActivitySync(intent);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        mActivity.finish();
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "eyesDistance",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "confidence",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getMidPoint",
+            args = {PointF.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            notes = "This method is not currently implemented (returns 0)",
+            method = "pose",
+            args = {int.class}
+        )
+    })
+    public void testFaceProperties() throws Exception {
+        long waitMsec = 5000;
+        Thread.sleep(waitMsec);
+        List<Face> detectedFaces = mActivity.getDetectedFaces();
+        assertEquals(1, detectedFaces.size());
+        Face face = detectedFaces.get(0);
+        PointF eyesMP = new PointF();
+        face.getMidPoint(eyesMP);
+        float tolerance = 5f;
+        float goodConfidence = 0.3f;
+        assertTrue(face.confidence() >= goodConfidence);
+        float eyesDistance = 20.0f;
+        assertEquals(eyesDistance, face.eyesDistance(), tolerance);
+        float eyesMidpointX = 60.0f;
+        float eyesMidpointY = 60.0f;
+        assertEquals(eyesMidpointX, eyesMP.x, tolerance);
+        assertEquals(eyesMidpointY, eyesMP.y, tolerance);
+        face.pose(FaceDetector.Face.EULER_X);
+        face.pose(FaceDetector.Face.EULER_Y);
+        face.pose(FaceDetector.Face.EULER_Z);
+
+        int ErrorEuler = 100;
+        try {
+            face.pose(ErrorEuler);
+            fail("Should throw IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+}
+
diff --git a/tests/tests/media/src/android/media/cts/MediaScannerConnectionTest.java b/tests/tests/media/src/android/media/cts/MediaScannerConnectionTest.java
new file mode 100644
index 0000000..cc25d07
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/MediaScannerConnectionTest.java
@@ -0,0 +1,220 @@
+/*
+ * 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.media.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 android.content.ComponentName;
+import android.content.Context;
+import android.media.MediaScannerConnection;
+import android.media.MediaScannerConnection.MediaScannerConnectionClient;
+import android.net.Uri;
+import android.os.IBinder;
+import android.test.AndroidTestCase;
+import android.view.animation.cts.DelayedCheck;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+@TestTargetClass(MediaScannerConnection.class)
+public class MediaScannerConnectionTest extends AndroidTestCase {
+
+    private static final String MEDIA_TYPE = "audio/mpeg";
+    private File mMediaFile;
+    private static final int TIME_OUT = 2000;
+    private MockMediaScannerConnection mMediaScannerConnection;
+    private MockMediaScannerConnectionClient mMediaScannerConnectionClient;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        // prepare the media file.
+        InputStream in = null;
+        FileOutputStream fOut = null;
+        String fileName = "test" + System.currentTimeMillis();
+        try {
+            fOut = getContext().openFileOutput(fileName, Context.MODE_WORLD_READABLE);
+            in = getContext().getResources().openRawResource(R.raw.testmp3);
+            byte[] bs = new byte[1024];
+            int size = in.read(bs);
+            while (size != -1) {
+                fOut.write(bs, 0, size);
+                size = in.read(bs);
+            }
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+            if (fOut != null) {
+                fOut.flush();
+                fOut.close();
+            }
+        }
+        File dir = getContext().getFilesDir();
+        mMediaFile = new File(dir, fileName);
+        assertTrue(mMediaFile.exists());
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        if (mMediaFile != null) {
+            mMediaFile.delete();
+        }
+        if (mMediaScannerConnection != null) {
+            mMediaScannerConnection.disconnect();
+            mMediaScannerConnection = null;
+        }
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "MediaScannerConnection",
+            args = {Context.class, MediaScannerConnectionClient.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "connect",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "disconnect",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isConnected",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "onServiceConnected",
+            args = {ComponentName.class, IBinder.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.NOT_FEASIBLE,
+            method = "onServiceDisconnected",
+            args = {ComponentName.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "scanFile",
+            args = {String.class, String.class}
+        )
+    })
+    @ToBeFixed(bug = "1567087", explanation = "onServiceDisconnected is not called")
+    public void testMediaScannerConnection() throws InterruptedException {
+        mMediaScannerConnectionClient = new MockMediaScannerConnectionClient();
+        mMediaScannerConnection = new MockMediaScannerConnection(getContext(),
+                                    mMediaScannerConnectionClient);
+
+        assertFalse(mMediaScannerConnection.isConnected());
+
+        // test connect and disconnect.
+        mMediaScannerConnection.connect();
+        checkConnectionState(true);
+
+        assertTrue(mMediaScannerConnection.mIsOnServiceConnectedCalled);
+        mMediaScannerConnection.disconnect();
+
+        checkConnectionState(false);
+
+        // FIXME: onServiceDisconnected is not called.
+        assertFalse(mMediaScannerConnection.mIsOnServiceDisconnectedCalled);
+        mMediaScannerConnection.connect();
+
+        checkConnectionState(true);
+
+        mMediaScannerConnection.scanFile(mMediaFile.getAbsolutePath(), MEDIA_TYPE);
+
+        checkMediaScannerConnection();
+
+        assertEquals(mMediaFile.getAbsolutePath(), mMediaScannerConnectionClient.mediaPath);
+        assertNotNull(mMediaScannerConnectionClient.mediaUri);
+    }
+
+    private void checkMediaScannerConnection() {
+        new DelayedCheck(TIME_OUT) {
+            protected boolean check() {
+                return mMediaScannerConnectionClient.isOnMediaScannerConnectedCalled;
+            }
+        }.run();
+        new DelayedCheck(TIME_OUT) {
+            protected boolean check() {
+                return mMediaScannerConnectionClient.mediaPath != null;
+            }
+        }.run();
+    }
+
+    private void checkConnectionState(final boolean expected) {
+        new DelayedCheck(TIME_OUT) {
+            protected boolean check() {
+                return mMediaScannerConnection.isConnected() == expected;
+            }
+        }.run();
+    }
+
+    class MockMediaScannerConnection extends MediaScannerConnection {
+
+        public boolean mIsOnServiceConnectedCalled;
+        public boolean mIsOnServiceDisconnectedCalled;
+        public MockMediaScannerConnection(Context context, MediaScannerConnectionClient client) {
+            super(context, client);
+        }
+
+        @Override
+        public void onServiceConnected(ComponentName className, IBinder service) {
+            super.onServiceConnected(className, service);
+            mIsOnServiceConnectedCalled = true;
+        }
+
+        @Override
+        public void onServiceDisconnected(ComponentName className) {
+            super.onServiceDisconnected(className);
+            mIsOnServiceDisconnectedCalled = true;
+            // this is not called.
+        }
+    }
+
+    class MockMediaScannerConnectionClient implements MediaScannerConnectionClient {
+
+        public boolean isOnMediaScannerConnectedCalled;
+        public String mediaPath;
+        public Uri mediaUri;
+        public void onMediaScannerConnected() {
+            isOnMediaScannerConnectedCalled = true;
+        }
+
+        public void onScanCompleted(String path, Uri uri) {
+            mediaPath = path;
+            if (uri != null) {
+                mediaUri = uri;
+            }
+        }
+
+    }
+
+}
diff --git a/tests/tests/media/src/android/media/cts/SoundPoolTest.java b/tests/tests/media/src/android/media/cts/SoundPoolTest.java
new file mode 100644
index 0000000..2764c8b
--- /dev/null
+++ b/tests/tests/media/src/android/media/cts/SoundPoolTest.java
@@ -0,0 +1,364 @@
+/*
+ * 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.media.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 android.content.Context;
+import android.content.res.AssetFileDescriptor;
+import android.media.AudioManager;
+import android.media.SoundPool;
+import android.test.AndroidTestCase;
+
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+@TestTargetClass(SoundPool.class)
+public class SoundPoolTest extends AndroidTestCase {
+
+    private static final int SOUNDPOOL_STREAMS = 4;
+    private static final int SOUND_A = R.raw.a_4;
+    private static final int SOUND_CS = R.raw.c_sharp_5;
+    private static final int SOUND_E = R.raw.e_5;
+    private static final int SOUND_B = R.raw.b_5;
+    private static final int SOUND_GS = R.raw.g_sharp_5;
+    private static final int PRIORITY = 1;
+    private static final int LOUD = 20;
+    private static final int QUIET = LOUD / 2;
+    private static final int SILENT = 0;
+
+    private static final int[] SOUNDS = { SOUND_A, SOUND_CS, SOUND_E, SOUND_B, SOUND_GS };
+
+    private static final String FILE_NAME = "a_4.ogg";
+    private File mFile;
+    private SoundPool mSoundPool;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mFile = new File(mContext.getFilesDir(), FILE_NAME);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        if (mFile.exists()) {
+            mFile.delete();
+        }
+        if (mSoundPool != null) {
+            mSoundPool.release();
+            mSoundPool = null;
+            return;
+        }
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "load",
+            args = {AssetFileDescriptor.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "load",
+            args = {Context.class, int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "load",
+            args = {FileDescriptor.class, long.class, long.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "load",
+            args = {String.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "unload",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "release",
+            args = {}
+        )
+    })
+    @ToBeFixed(explanation = "unload() does not return true as specified")
+    public void testLoad() throws Exception {
+        int srcQuality = 100;
+        mSoundPool = new SoundPool(SOUNDPOOL_STREAMS, AudioManager.STREAM_MUSIC, srcQuality);
+        int sampleId1 = mSoundPool.load(mContext, SOUND_A, PRIORITY);
+        waitUntilLoaded(sampleId1);
+        // should return true, but returns false
+        mSoundPool.unload(sampleId1);
+
+        AssetFileDescriptor afd = mContext.getResources().openRawResourceFd(SOUND_CS);
+        int sampleId2;
+        sampleId2 = mSoundPool.load(afd, PRIORITY);
+        waitUntilLoaded(sampleId2);
+        mSoundPool.unload(sampleId2);
+
+        FileDescriptor fd = afd.getFileDescriptor();
+        long offset = afd.getStartOffset();
+        long length = afd.getLength();
+        int sampleId3;
+        sampleId3 = mSoundPool.load(fd, offset, length, PRIORITY);
+        waitUntilLoaded(sampleId3);
+        mSoundPool.unload(sampleId3);
+
+        String path = mFile.getAbsolutePath();
+        createSoundFile(mFile);
+        int sampleId4;
+        sampleId4 = mSoundPool.load(path, PRIORITY);
+        waitUntilLoaded(sampleId4);
+        mSoundPool.unload(sampleId4);
+    }
+
+    private void createSoundFile(File f) throws Exception {
+        FileOutputStream fOutput = null;
+        try {
+            fOutput = new FileOutputStream(f);
+            InputStream is = mContext.getResources().openRawResource(SOUND_A);
+            byte[] buffer = new byte[1024];
+            int length = is.read(buffer);
+            while (length != -1) {
+                fOutput.write(buffer, 0, length);
+                length = is.read(buffer);
+            }
+        } finally {
+            if (fOutput != null) {
+                fOutput.flush();
+                fOutput.close();
+            }
+        }
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "load",
+            args = {Context.class, int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "pause",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "play",
+            args = {int.class, float.class, float.class, int.class, int.class, float.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "resume",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setLoop",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setPriority",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setRate",
+            args = {int.class, float.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setVolume",
+            args = {int.class, float.class, float.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "SoundPool",
+            args = {int.class, int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "stop",
+            args = {int.class}
+        )
+    })
+    public void testSoundPoolOp() throws Exception {
+        int srcQuality = 100;
+        mSoundPool = new SoundPool(SOUNDPOOL_STREAMS, AudioManager.STREAM_MUSIC, srcQuality);
+        int sampleID = loadSampleSync(SOUND_A, PRIORITY);
+
+        int waitMsec = 1000;
+        float leftVolume = SILENT;
+        float rightVolume = LOUD;
+        int priority = 1;
+        int loop = 0;
+        float rate = 1f;
+        int streamID = mSoundPool.play(sampleID, leftVolume, rightVolume, priority, loop, rate);
+        assertTrue(streamID != 0);
+        Thread.sleep(waitMsec);
+        rate = 1.4f;
+        mSoundPool.setRate(streamID, rate);
+        Thread.sleep(waitMsec);
+        mSoundPool.setRate(streamID, 1f);
+        Thread.sleep(waitMsec);
+        mSoundPool.pause(streamID);
+        Thread.sleep(waitMsec);
+        mSoundPool.resume(streamID);
+        Thread.sleep(waitMsec);
+        mSoundPool.stop(streamID);
+
+        streamID = mSoundPool.play(sampleID, leftVolume, rightVolume, priority, loop, rate);
+        assertTrue(streamID != 0);
+        loop = -1;// loop forever
+        mSoundPool.setLoop(streamID, loop);
+        Thread.sleep(waitMsec);
+        leftVolume = SILENT;
+        rightVolume = SILENT;
+        mSoundPool.setVolume(streamID, leftVolume, rightVolume);
+        Thread.sleep(waitMsec);
+        rightVolume = LOUD;
+        mSoundPool.setVolume(streamID, leftVolume, rightVolume);
+        priority = 0;
+        mSoundPool.setPriority(streamID, priority);
+        Thread.sleep(waitMsec * 10);
+        mSoundPool.stop(streamID);
+        mSoundPool.unload(sampleID);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "load",
+            args = {Context.class, int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "play",
+            args = {int.class, float.class, float.class, int.class, int.class, float.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "SoundPool",
+            args = {int.class, int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "stop",
+            args = {int.class}
+        )
+    })
+    public void testMultiSound() throws Exception {
+        int srcQuality = 100;
+        mSoundPool = new SoundPool(SOUNDPOOL_STREAMS, AudioManager.STREAM_MUSIC, srcQuality);
+        int sampleID1 = loadSampleSync(SOUND_A, PRIORITY);
+        int sampleID2 = loadSampleSync(SOUND_CS, PRIORITY);
+        long waitMsec = 1000;
+        Thread.sleep(waitMsec);
+
+        // play sounds one at a time
+        int streamID1 = mSoundPool.play(sampleID1, LOUD, QUIET, PRIORITY, -1, 1);
+        assertTrue(streamID1 != 0);
+        Thread.sleep(waitMsec * 4);
+        mSoundPool.stop(streamID1);
+        int streamID2 = mSoundPool.play(sampleID2, QUIET, LOUD, PRIORITY, -1, 1);
+        assertTrue(streamID2 != 0);
+        Thread.sleep(waitMsec * 4);
+        mSoundPool.stop(streamID2);
+
+        // play both at once repeating the first, but not the second
+        streamID1 = mSoundPool.play(sampleID1, LOUD, QUIET, PRIORITY, 1, 1);
+        streamID2 = mSoundPool.play(sampleID2, QUIET, LOUD, PRIORITY, 0, 1);
+        assertTrue(streamID1 != 0);
+        assertTrue(streamID2 != 0);
+        Thread.sleep(4000);
+        // both streams should have stopped by themselves; no way to check
+
+        mSoundPool.release();
+        mSoundPool = null;
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "load",
+            args = {Context.class, int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "SoundPool",
+            args = {int.class, int.class, int.class}
+        )
+    })
+    public void testLoadMore() throws Exception {
+        mSoundPool = new SoundPool(SOUNDPOOL_STREAMS, AudioManager.STREAM_MUSIC, 0);
+        int[] soundIds = new int[SOUNDS.length];
+        int[] streamIds = new int[SOUNDS.length];
+        for (int i = 0; i < SOUNDS.length; i++) {
+            soundIds[i] = loadSampleSync(SOUNDS[i], PRIORITY);
+            System.out.println("load: " + soundIds[i]);
+        }
+        for (int i = 0; i < soundIds.length; i++) {
+            streamIds[i] = mSoundPool.play(soundIds[i], LOUD, LOUD, PRIORITY, -1, 1);
+        }
+        Thread.sleep(3000);
+        for (int stream : streamIds) {
+            assertTrue(stream != 0);
+            mSoundPool.stop(stream);
+        }
+        for (int sound : soundIds) {
+            mSoundPool.unload(sound);
+        }
+        mSoundPool.release();
+    }
+
+    /**
+     * Load a sample and wait until it is ready to be played.
+     * @return The sample ID.
+     * @throws InterruptedException
+     */
+    private int loadSampleSync(int sampleId, int prio) throws InterruptedException {
+        int sample = mSoundPool.load(mContext, sampleId, prio);
+        waitUntilLoaded(sample);
+        return sample;
+    }
+
+    /**
+     * Wait until the specified sample is loaded.
+     * @param sampleId The sample ID.
+     * @throws InterruptedException
+     */
+    private void waitUntilLoaded(int sampleId) throws InterruptedException {
+        int stream = 0;
+        while (stream == 0) {
+            Thread.sleep(500);
+            stream = mSoundPool.play(sampleId, SILENT, SILENT, 1, 0, 1);
+        }
+        mSoundPool.stop(stream);
+    }
+}
diff --git a/tests/tests/telephony/Android.mk b/tests/tests/telephony/Android.mk
new file mode 100644
index 0000000..62b256e
--- /dev/null
+++ b/tests/tests/telephony/Android.mk
@@ -0,0 +1,33 @@
+# 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.
+
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsTelephonyTestCases
+
+LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
+
diff --git a/tests/tests/telephony/AndroidManifest.xml b/tests/tests/telephony/AndroidManifest.xml
new file mode 100644
index 0000000..a565fad
--- /dev/null
+++ b/tests/tests/telephony/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.cts.telephony">
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
+                     android:targetPackage="com.android.cts.stub"
+                     android:label="CTS tests of android.telephony"/>
+
+</manifest>
+
diff --git a/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java b/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
new file mode 100644
index 0000000..9cf1fb6
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/CellLocationTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.telephony.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.content.Context;
+import android.os.Looper;
+import android.os.cts.TestThread;
+import android.telephony.CellLocation;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
+import android.telephony.gsm.GsmCellLocation;
+import android.test.AndroidTestCase;
+
+@TestTargetClass(CellLocation.class)
+public class CellLocationTest extends AndroidTestCase {
+    private boolean mOnCellLocationChangedCalled;
+    private final Object mLock = new Object();
+    private TelephonyManager mTelephonyManager;
+    private Looper mLooper;
+    private PhoneStateListener mListener;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mTelephonyManager =
+                (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mLooper != null) {
+            mLooper.quit();
+        }
+        if (mListener != null) {
+            // unregister listener
+            mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_NONE);
+        }
+        super.tearDown();
+    }
+
+    @TestTargets({
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getEmpty",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "requestLocationUpdate",
+        args = {}
+      )
+    })
+    public void testCellLocation() throws Throwable {
+        CellLocation cl = CellLocation.getEmpty();
+        if (cl instanceof GsmCellLocation) {
+            GsmCellLocation gcl = (GsmCellLocation) cl;
+            assertNotNull(gcl);
+            assertEquals(-1, gcl.getCid());
+            assertEquals(-1, gcl.getLac());
+        }
+
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onCellLocationChanged(CellLocation location) {
+                        synchronized (mLock) {
+                            mOnCellLocationChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_CELL_LOCATION);
+
+                Looper.loop();
+            }
+        });
+
+        t.start();
+
+        CellLocation.requestLocationUpdate();
+        synchronized (mLock) {
+            while (!mOnCellLocationChangedCalled) {
+                mLock.wait();
+            }
+        }
+        Thread.sleep(1000);
+        assertTrue(mOnCellLocationChangedCalled);
+        t.checkException();
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/NeighboringCellInfoTest.java b/tests/tests/telephony/src/android/telephony/cts/NeighboringCellInfoTest.java
new file mode 100644
index 0000000..1851d54
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/NeighboringCellInfoTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.telephony.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Parcel;
+import android.telephony.NeighboringCellInfo;
+import android.test.AndroidTestCase;
+
+@TestTargetClass(NeighboringCellInfo.class)
+public class NeighboringCellInfoTest extends AndroidTestCase{
+    private static final int RSSI = 20;
+    private static final int CID = 0x0000ffff;
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "NeighboringCellInfo",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "NeighboringCellInfo",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "NeighboringCellInfo",
+            args = {Parcel.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getRssi",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getCid",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setRssi",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setCid",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "toString",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "writeToParcel",
+            args = {Parcel.class, int.class}
+        )
+    })
+    public void testNeighboringCellInfo() {
+        Parcel p = Parcel.obtain();
+        Integer[] val = { RSSI, CID };
+        p.writeArray(val);
+        new NeighboringCellInfo(p);
+        NeighboringCellInfo info = new NeighboringCellInfo(RSSI, CID);
+        assertEquals(RSSI, info.getRssi());
+        assertEquals(CID, info.getCid());
+
+        info = new NeighboringCellInfo();
+        assertEquals(NeighboringCellInfo.UNKNOWN_RSSI, info.getRssi());
+        assertEquals(NeighboringCellInfo.UNKNOWN_CID, info.getCid());
+        info.setRssi(RSSI);
+        info.setCid(CID);
+        assertEquals(RSSI, info.getRssi());
+        assertEquals(CID, info.getCid());
+
+        assertEquals(0, info.describeContents());
+        assertNotNull(info.toString());
+
+        p = Parcel.obtain();
+        info.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        NeighboringCellInfo target = NeighboringCellInfo.CREATOR.createFromParcel(p);
+        assertEquals(info.getRssi(), target.getRssi());
+        assertEquals(info.getCid(), target.getCid());
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberFormattingTextWatcherTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberFormattingTextWatcherTest.java
new file mode 100644
index 0000000..b96dcd9
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberFormattingTextWatcherTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.telephony.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.telephony.PhoneNumberFormattingTextWatcher;
+import android.test.AndroidTestCase;
+import android.text.Editable;
+import android.widget.TextView;
+
+@TestTargetClass(PhoneNumberFormattingTextWatcher.class)
+public class PhoneNumberFormattingTextWatcherTest extends AndroidTestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "PhoneNumberFormattingTextWatcher",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "beforeTextChanged",
+            args = {java.lang.CharSequence.class, int.class, int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "afterTextChanged",
+            args = {android.text.Editable.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "onTextChanged",
+            args = {java.lang.CharSequence.class, int.class, int.class, int.class}
+        )
+    })
+    public void testPhoneNumberFormattingTextWatcher() {
+        TextView text = new TextView(getContext());
+        text.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
+
+        text.setText("+15551212");
+        assertEquals("+1-555-1212", text.getText().toString());
+
+        // delete first dash and first 5
+        Editable edit = (Editable) text.getText();
+        edit.delete(2, 3);
+        assertEquals("+1-551-212", text.getText().toString());
+
+        // already formatted correctly
+        text.setText("+1-555-1212");
+        assertEquals("+1-555-1212", text.getText().toString());
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
new file mode 100644
index 0000000..37bb211
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
@@ -0,0 +1,487 @@
+/*
+ * 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.telephony.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.RemoteException;
+import android.provider.Contacts;
+import android.provider.Contacts.People;
+import android.telephony.PhoneNumberUtils;
+import android.telephony.TelephonyManager;
+import android.test.AndroidTestCase;
+import android.text.Editable;
+import android.text.SpannableStringBuilder;
+
+import java.util.Locale;
+
+@TestTargetClass(PhoneNumberUtils.class)
+public class PhoneNumberUtilsTest extends AndroidTestCase {
+    // mPhoneNumber ~ "+17005550020", length == 7.
+    private byte[] mPhoneNumber = { (byte) 0x91, (byte) 0x71, (byte) 0x00, (byte) 0x55,
+            (byte) 0x05, (byte) 0x20, (byte) 0xF0 };
+
+    @TestTargets({
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "extractNetworkPortion",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "extractPostDialPortion",
+        args = {String.class}
+      )
+    })
+    public void testExtractMethods() {
+
+        // Test extractNetworkPortion
+        assertNull(PhoneNumberUtils.extractNetworkPortion(null));
+        assertEquals("+17005554141", PhoneNumberUtils.extractNetworkPortion("+17005554141"));
+        assertEquals("+17005554141*#N",
+                PhoneNumberUtils.extractNetworkPortion("+1 (700).555-4141*#N"));
+        assertEquals("170055541", PhoneNumberUtils.extractNetworkPortion("1 (700).555-41,1234"));
+        assertEquals("**21**17005554141#",
+                PhoneNumberUtils.extractNetworkPortion("**21**+17005554141#"));
+
+        // Test extractPostDialPortion
+        assertNull(PhoneNumberUtils.extractPostDialPortion(null));
+        assertEquals("", PhoneNumberUtils.extractPostDialPortion("+17005554141"));
+        assertEquals(",1234", PhoneNumberUtils.extractPostDialPortion("+1 (700).555-41NN,1234"));
+        assertEquals(";1234", PhoneNumberUtils.extractPostDialPortion("+1 (700).555-41NN;1234"));
+        assertEquals(";1234,;N", PhoneNumberUtils
+                .extractPostDialPortion("+1 (700).555-41NN;1-2.34 ,;N"));
+    }
+
+    @TestTargets({
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "calledPartyBCDToString",
+        args = {byte[].class, int.class, int.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "toCallerIDMinMatch",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "networkPortionToCalledPartyBCD",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "calledPartyBCDFragmentToString",
+        args = {byte[].class, int.class, int.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "networkPortionToCalledPartyBCDWithLength",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "numberToCalledPartyBCD",
+        args = {String.class}
+      )
+    })
+    public void testCallMethods() {
+        // Test calledPartyBCDToString
+        assertEquals("+17005550020", PhoneNumberUtils.calledPartyBCDToString(mPhoneNumber, 0, 7));
+
+        // Test toCallerIDMinMatch
+        assertNull(PhoneNumberUtils.toCallerIDMinMatch(null));
+        assertEquals("14145", PhoneNumberUtils.toCallerIDMinMatch("17005554141"));
+        assertEquals("14145", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141"));
+        assertEquals("14145", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141,1234"));
+        assertEquals("14145", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141;1234"));
+        assertEquals("NN145", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-41NN"));
+        assertEquals("", PhoneNumberUtils.toCallerIDMinMatch(""));
+        assertEquals("0032", PhoneNumberUtils.toCallerIDMinMatch("2300"));
+        assertEquals("0032+", PhoneNumberUtils.toCallerIDMinMatch("+2300"));
+        assertEquals("#130#", PhoneNumberUtils.toCallerIDMinMatch("*#031#"));
+
+        // Test networkPortionToCalledPartyBCD, calledPartyBCDToString
+        byte[] bRet = PhoneNumberUtils.networkPortionToCalledPartyBCD("+17005550020");
+        assertEquals(mPhoneNumber.length, bRet.length);
+        for (int i = 0; i < mPhoneNumber.length; i++) {
+            assertEquals(mPhoneNumber[i], bRet[i]);
+        }
+        bRet = PhoneNumberUtils.networkPortionToCalledPartyBCD("7005550020");
+        assertEquals("7005550020", PhoneNumberUtils.calledPartyBCDToString(bRet, 0, bRet.length));
+
+        // Test calledPartyBCDFragmentToString
+        assertEquals("1917005550020", PhoneNumberUtils.calledPartyBCDFragmentToString(mPhoneNumber,
+                0, 7));
+
+        // Test networkPortionToCalledPartyBCDWithLength
+        bRet = PhoneNumberUtils.networkPortionToCalledPartyBCDWithLength("+17005550020");
+        assertEquals(mPhoneNumber.length + 1, bRet.length);
+        for (int i = 0; i < mPhoneNumber.length; i++) {
+            assertEquals(mPhoneNumber[i], bRet[i + 1]);
+        }
+
+        // Test numberToCalledPartyBCD
+        bRet = PhoneNumberUtils.numberToCalledPartyBCD("+17005550020");
+        assertEquals(mPhoneNumber.length, bRet.length);
+        for (int i = 0; i < mPhoneNumber.length; i++) {
+            assertEquals(mPhoneNumber[i], bRet[i]);
+        }
+    }
+
+    @TestTargetNew(
+      level = TestLevel.COMPLETE,
+      method = "compare",
+      args = {String.class, String.class}
+    )
+    public void testCompare() {
+        assertFalse(PhoneNumberUtils.compare("", ""));
+
+        assertTrue(PhoneNumberUtils.compare("911", "911"));
+        assertFalse(PhoneNumberUtils.compare("911", "18005550911"));
+
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "+17005554141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "+1 (700).555-4141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "7005554141"));
+        assertTrue(PhoneNumberUtils.compare("17005554141", "5554141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "0017005554141"));
+        assertTrue(PhoneNumberUtils.compare("+17005554141", "**31#+17005554141"));
+        assertFalse(PhoneNumberUtils.compare("+1 999 7005554141", "+1 7005554141"));
+        assertTrue(PhoneNumberUtils.compare("011 1 7005554141", "7005554141"));
+        assertFalse(PhoneNumberUtils.compare("011 11 7005554141", "+17005554141"));
+        assertTrue(PhoneNumberUtils.compare("+44 207 792 3490", "0 207 792 3490"));
+        assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "00 207 792 3490"));
+
+        // MMI header should be ignored
+        assertFalse(PhoneNumberUtils.compare("+17005554141", "**31#17005554141"));
+        assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "+44 (0) 207 792 3490"));
+        assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "010 44 207 792 3490"));
+        assertFalse(PhoneNumberUtils.compare("+44 207 792 3490", "0011 44 207 792 3490"));
+        assertFalse(PhoneNumberUtils.compare("+7(095)9100766", "8(095)9100766"));
+        assertTrue(PhoneNumberUtils.compare("+444 207 792 3490", "0 207 792 3490"));
+    }
+
+    @TestTargets({
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getStrippedReversed",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getFormatTypeForLocale",
+        args = {Locale.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.PARTIAL,
+        notes = "partial, null branch is ok, non-null has a insert fail",
+        method = "getNumberFromIntent",
+        args = {Intent.class, Context.class}
+      )
+    })
+    public void testGetMethods() throws RemoteException {
+        // Test getStrippedReversed
+        assertNull(PhoneNumberUtils.getStrippedReversed(null));
+        assertEquals("14145550071", PhoneNumberUtils.getStrippedReversed("1-700-555-4141"));
+        assertEquals("14145550071", PhoneNumberUtils.getStrippedReversed("1-700-555-4141,1234"));
+        assertEquals("14145550071", PhoneNumberUtils.getStrippedReversed("1-700-555-4141;1234"));
+        assertEquals("NN145550071", PhoneNumberUtils.getStrippedReversed("1-700-555-41NN"));
+        assertEquals("", PhoneNumberUtils.getStrippedReversed(""));
+        assertEquals("#130#*+", PhoneNumberUtils.getStrippedReversed("+*#031#"));
+
+        // Test getFormatTypeForLocale
+        int formatType = PhoneNumberUtils.getFormatTypeForLocale(Locale.CHINA);
+        assertEquals(PhoneNumberUtils.FORMAT_UNKNOWN, formatType);
+        formatType = PhoneNumberUtils.getFormatTypeForLocale(Locale.US);
+        assertEquals(PhoneNumberUtils.FORMAT_NANP, formatType);
+        formatType = PhoneNumberUtils.getFormatTypeForLocale(Locale.JAPAN);
+        assertEquals(PhoneNumberUtils.FORMAT_JAPAN, formatType);
+
+        // Test getNumberFromIntent, query nothing, return null.
+        Intent intent = new Intent();
+        intent.setData(Contacts.People.CONTENT_URI);
+        Context context = getContext();
+        assertNull(PhoneNumberUtils.getNumberFromIntent(intent, context));
+
+        intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+18005555555"));
+        assertEquals("+18005555555", PhoneNumberUtils.getNumberFromIntent(intent, getContext()));
+
+        intent = new Intent(Intent.ACTION_DIAL, Uri.parse("voicemail:"));
+        TelephonyManager tm =
+                (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
+        assertEquals(tm.getVoiceMailNumber(),
+                PhoneNumberUtils.getNumberFromIntent(intent, getContext()));
+
+        ContentResolver cr = getContext().getContentResolver();
+        Uri personRecord = null;
+        Uri phoneRecord = null;
+        try {
+            // insert a contact with phone number
+            ContentValues values = new ContentValues();
+            values.put(People.NAME, "CTS test contact");
+            personRecord = cr.insert(People.CONTENT_URI, values);
+            Uri phoneUri = Uri.withAppendedPath(personRecord, People.Phones.CONTENT_DIRECTORY);
+            values.clear();
+            values.put(People.Phones.TYPE, People.Phones.TYPE_HOME);
+            values.put(People.Phones.NUMBER, "+18005552871");
+            phoneRecord = cr.insert(phoneUri, values);
+
+            intent = new Intent(Intent.ACTION_DIAL, phoneRecord);
+            assertEquals("+18005552871",
+                    PhoneNumberUtils.getNumberFromIntent(intent, getContext()));
+        } finally {
+            if (personRecord != null) {
+                cr.delete(personRecord, null, null);
+            }
+            if (phoneRecord != null) {
+                cr.delete(phoneRecord, null, null);
+            }
+        }
+    }
+
+    @TestTargets({
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "formatNanpNumber",
+        args = {Editable.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "convertKeypadLettersToDigits",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "stringFromStringAndTOA",
+        args = {String.class, int.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "formatJapaneseNumber",
+        args = {Editable.class}
+       ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "formatNumber",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "formatNumber",
+        args = {Editable.class, int.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "stripSeparators",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "toaFromString",
+        args = {String.class}
+      )
+    })
+    public void testFormatMethods() {
+        // Test formatNanpNumber
+        SpannableStringBuilder builderNumber = new SpannableStringBuilder();
+        builderNumber.append("8005551212");
+        PhoneNumberUtils.formatNanpNumber(builderNumber);
+        assertEquals("800-555-1212", builderNumber.toString());
+        builderNumber.clear();
+        builderNumber.append("800555121");
+        PhoneNumberUtils.formatNanpNumber(builderNumber);
+        assertEquals("800-555-121", builderNumber.toString());
+        builderNumber.clear();
+        builderNumber.append("555-1212");
+        PhoneNumberUtils.formatNanpNumber(builderNumber);
+        assertEquals("555-1212", builderNumber.toString());
+        builderNumber.clear();
+        builderNumber.append("180055512");
+        PhoneNumberUtils.formatNanpNumber(builderNumber);
+        assertEquals("1-800-555-12", builderNumber.toString());
+        builderNumber.clear();
+        builderNumber.append("+180055512");
+        PhoneNumberUtils.formatNanpNumber(builderNumber);
+        assertEquals("+1-800-555-12", builderNumber.toString());
+
+        // Test convertKeypadLettersToDigits
+        assertEquals("1-800-4664-411", PhoneNumberUtils
+                .convertKeypadLettersToDigits("1-800-GOOG-411"));
+        assertEquals("1-800-466-4411", PhoneNumberUtils
+                .convertKeypadLettersToDigits("1-800-466-4411"));
+        assertEquals("222-333-444-555-666-7777-888-9999", PhoneNumberUtils
+                .convertKeypadLettersToDigits("ABC-DEF-GHI-JKL-MNO-PQRS-TUV-WXYZ"));
+        assertEquals("222-333-444-555-666-7777-888-9999", PhoneNumberUtils
+                .convertKeypadLettersToDigits("abc-def-ghi-jkl-mno-pqrs-tuv-wxyz"));
+        assertEquals("(800) 222-3334", PhoneNumberUtils
+                .convertKeypadLettersToDigits("(800) ABC-DEFG"));
+
+        // Test stringFromStringAndTOA
+        assertNull(PhoneNumberUtils.stringFromStringAndTOA(null, 1));
+        assertEquals("+888888888", PhoneNumberUtils.stringFromStringAndTOA("888888888",
+                PhoneNumberUtils.TOA_International));
+
+        // Test formatJapaneseNumber
+        Editable jpEditNumber = Editable.Factory.getInstance().newEditable("0377777777");
+        PhoneNumberUtils.formatJapaneseNumber(jpEditNumber);
+        assertEquals("03-7777-7777", jpEditNumber.toString());
+        jpEditNumber = Editable.Factory.getInstance().newEditable("09077777777");
+        PhoneNumberUtils.formatJapaneseNumber(jpEditNumber);
+        assertEquals("090-7777-7777", jpEditNumber.toString());
+        jpEditNumber = Editable.Factory.getInstance().newEditable("0120777777");
+        PhoneNumberUtils.formatJapaneseNumber(jpEditNumber);
+        assertEquals("0120-777-777", jpEditNumber.toString());
+        jpEditNumber = Editable.Factory.getInstance().newEditable("+81377777777");
+        PhoneNumberUtils.formatJapaneseNumber(jpEditNumber);
+        assertEquals("+81-3-7777-7777", jpEditNumber.toString());
+        jpEditNumber = Editable.Factory.getInstance().newEditable("+819077777777");
+        PhoneNumberUtils.formatJapaneseNumber(jpEditNumber);
+        assertEquals("+81-90-7777-7777", jpEditNumber.toString());
+
+        // Test formatNumber(String). Only numbers begin with +1 or +81 can be formatted.
+        assertEquals("+1-888-888-888", PhoneNumberUtils.formatNumber("+1888888888"));
+        // Test formatNumber(Editable, int)
+        Editable editNumber = Editable.Factory.getInstance().newEditable("0377777777");
+        PhoneNumberUtils.formatNumber(editNumber, PhoneNumberUtils.FORMAT_UNKNOWN);
+        assertEquals("0377777777", editNumber.toString());
+        editNumber = Editable.Factory.getInstance().newEditable("+177777777");
+        PhoneNumberUtils.formatNumber(editNumber, PhoneNumberUtils.FORMAT_UNKNOWN);
+        assertEquals("+1-777-777-77", editNumber.toString());
+        editNumber = Editable.Factory.getInstance().newEditable("+8177777777");
+        PhoneNumberUtils.formatNumber(editNumber, PhoneNumberUtils.FORMAT_UNKNOWN);
+        assertEquals("+81-77-777-777", editNumber.toString());
+
+        // Test stripSeparators
+        assertEquals("+188888888", PhoneNumberUtils.stripSeparators("+188-888-888"));
+
+        // Test toaFromString
+        assertEquals(PhoneNumberUtils.TOA_International, PhoneNumberUtils
+                .toaFromString("+88888888"));
+        assertEquals(PhoneNumberUtils.TOA_Unknown, PhoneNumberUtils.toaFromString("88888888"));
+    }
+
+    @TestTargets({
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "is12Key",
+        args = {char.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isDialable",
+        args = {char.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isEmergencyNumber",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isGlobalPhoneNumber",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isISODigit",
+        args = {char.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isReallyDialable",
+        args = {char.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isStartsPostDial",
+        args = {char.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isWellFormedSmsAddress",
+        args = {String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isNonSeparator",
+        args = {char.class}
+      )
+    })
+    public void testJudgeMethods() {
+        // Test is12Key, isDialable, isISODigit, isReallyDialable, isStartsPostDial
+        for (char c = '0'; c <= '9'; c++) {
+            assertTrue(PhoneNumberUtils.is12Key(c));
+            assertTrue(PhoneNumberUtils.isDialable(c));
+            assertTrue(PhoneNumberUtils.isISODigit(c));
+            assertTrue(PhoneNumberUtils.isNonSeparator(c));
+            assertTrue(PhoneNumberUtils.isReallyDialable(c));
+        }
+        char c = '*';
+        assertTrue(PhoneNumberUtils.is12Key(c));
+        assertTrue(PhoneNumberUtils.isDialable(c));
+        assertTrue(PhoneNumberUtils.isNonSeparator(c));
+        assertTrue(PhoneNumberUtils.isReallyDialable(c));
+        c = '#';
+        assertTrue(PhoneNumberUtils.is12Key(c));
+        assertTrue(PhoneNumberUtils.isDialable(c));
+        assertTrue(PhoneNumberUtils.isNonSeparator(c));
+        assertTrue(PhoneNumberUtils.isReallyDialable(c));
+        c = '$';
+        assertFalse(PhoneNumberUtils.is12Key(c));
+        assertFalse(PhoneNumberUtils.isDialable(c));
+        assertFalse(PhoneNumberUtils.isDialable(c));
+        c = '+';
+        assertTrue(PhoneNumberUtils.isDialable(c));
+        assertFalse(PhoneNumberUtils.isISODigit(c));
+        assertTrue(PhoneNumberUtils.isNonSeparator(c));
+        assertTrue(PhoneNumberUtils.isReallyDialable(c));
+        c = PhoneNumberUtils.WILD;
+        assertTrue(PhoneNumberUtils.isDialable(c));
+        assertTrue(PhoneNumberUtils.isNonSeparator(c));
+        assertFalse(PhoneNumberUtils.isReallyDialable(c));
+        c = PhoneNumberUtils.WAIT;
+        assertTrue(PhoneNumberUtils.isNonSeparator(c));
+        assertTrue(PhoneNumberUtils.isStartsPostDial(c));
+        c = PhoneNumberUtils.PAUSE;
+        assertTrue(PhoneNumberUtils.isNonSeparator(c));
+        assertTrue(PhoneNumberUtils.isStartsPostDial(c));
+        c = '8';
+        assertFalse(PhoneNumberUtils.isStartsPostDial(c));
+
+        // Test isEmergencyNumber, now only know US emergency number
+        if (Locale.getDefault().getCountry().equals("US")) {
+            assertTrue(PhoneNumberUtils.isEmergencyNumber("911"));
+            assertTrue(PhoneNumberUtils.isEmergencyNumber("112"));
+            assertFalse(PhoneNumberUtils.isEmergencyNumber("119"));
+        }
+
+        // Test isGlobalPhoneNumber
+        assertTrue(PhoneNumberUtils.isGlobalPhoneNumber("+17005554141"));
+        assertFalse(PhoneNumberUtils.isGlobalPhoneNumber("android"));
+
+        // Test isWellFormedSmsAddress
+        assertTrue(PhoneNumberUtils.isWellFormedSmsAddress("+17005554141"));
+        assertFalse(PhoneNumberUtils.isWellFormedSmsAddress("android"));
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneStateListenerTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneStateListenerTest.java
new file mode 100644
index 0000000..b6c3d2a
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneStateListenerTest.java
@@ -0,0 +1,427 @@
+/*
+ * 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.telephony.cts;
+
+import android.content.Context;
+import android.os.Looper;
+import android.os.cts.TestThread;
+import android.telephony.CellLocation;
+import android.telephony.PhoneStateListener;
+import android.telephony.ServiceState;
+import android.telephony.TelephonyManager;
+import android.test.AndroidTestCase;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+@TestTargetClass(PhoneStateListener.class)
+public class PhoneStateListenerTest extends AndroidTestCase {
+
+    public static final long WAIT_TIME = 1000;
+
+    private boolean mOnCallForwardingIndicatorChangedCalled;
+    private boolean mOnCallStateChangedCalled;
+    private boolean mOnCellLocationChangedCalled;
+    private boolean mOnDataActivityCalled;
+    private boolean mOnDataConnectionStateChangedCalled;
+    private boolean mOnMessageWaitingIndicatorChangedCalled;
+    private boolean mOnServiceStateChangedCalled;
+    private boolean mOnSignalStrengthChangedCalled;
+    private TelephonyManager mTelephonyManager;
+    private PhoneStateListener mListener;
+    private final Object mLock = new Object();
+    private Looper mLooper;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        Context context = getContext();
+        mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        if (mLooper != null) {
+            mLooper.quit();
+        }
+        if (mListener != null) {
+            // unregister the listener
+            mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_NONE);
+        }
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test constructor(s) of {@link PhoneStateListener}",
+            method = "PhoneStateListener",
+            args = {}
+        )
+    })
+    public void testPhoneStateListener() {
+        new PhoneStateListener();
+    }
+
+    /*
+     * The tests below rely on the framework to immediately call the installed listener upon
+     * registration. There is no simple way to emulate state changes for testing the listeners.
+     */
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test method: onServiceStateChanged ",
+            method = "onServiceStateChanged",
+            args = {ServiceState.class}
+        )
+    })
+    public void testOnServiceStateChanged() throws Throwable {
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onServiceStateChanged(ServiceState serviceState) {
+                        synchronized(mLock) {
+                            mOnServiceStateChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_SERVICE_STATE);
+
+                Looper.loop();
+            }
+        });
+
+        assertFalse(mOnServiceStateChangedCalled);
+        t.start();
+
+        synchronized (mLock) {
+            while(!mOnServiceStateChangedCalled){
+                mLock.wait();
+            }
+        }
+        quitLooper();
+        t.checkException();
+        assertTrue(mOnServiceStateChangedCalled);
+    }
+
+    private void quitLooper() {
+        mLooper.quit();
+        mLooper = null;
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test method: onSignalStrengthChanged ",
+            method = "onSignalStrengthChanged",
+            args = {int.class}
+        )
+    })
+    public void testOnSignalStrengthChanged() throws Throwable {
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onSignalStrengthChanged(int asu) {
+                        synchronized(mLock) {
+                            mOnSignalStrengthChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTH);
+
+                Looper.loop();
+            }
+        });
+
+        assertFalse(mOnSignalStrengthChangedCalled);
+        t.start();
+
+        synchronized (mLock) {
+            while(!mOnSignalStrengthChangedCalled){
+                mLock.wait();
+            }
+        }
+        quitLooper();
+        t.checkException();
+        assertTrue(mOnSignalStrengthChangedCalled);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test method: onMessageWaitingIndicatorChanged ",
+            method = "onMessageWaitingIndicatorChanged",
+            args = {boolean.class}
+        )
+    })
+    public void testOnMessageWaitingIndicatorChanged() throws Throwable {
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onMessageWaitingIndicatorChanged(boolean mwi) {
+                        synchronized(mLock) {
+                            mOnMessageWaitingIndicatorChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(
+                        mListener, PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR);
+
+                Looper.loop();
+            }
+        });
+
+        assertFalse(mOnMessageWaitingIndicatorChangedCalled);
+        t.start();
+
+        synchronized (mLock) {
+            while(!mOnMessageWaitingIndicatorChangedCalled){
+                mLock.wait();
+            }
+        }
+        quitLooper();
+        t.checkException();
+        assertTrue(mOnMessageWaitingIndicatorChangedCalled);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test method: onCallForwardingIndicatorChanged ",
+            method = "onCallForwardingIndicatorChanged",
+            args = {boolean.class}
+        )
+    })
+    public void testOnCallForwardingIndicatorChanged() throws Throwable {
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onCallForwardingIndicatorChanged(boolean cfi) {
+                        synchronized(mLock) {
+                            mOnCallForwardingIndicatorChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(
+                        mListener, PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR);
+
+                Looper.loop();
+            }
+        });
+
+        assertFalse(mOnCallForwardingIndicatorChangedCalled);
+        t.start();
+
+        synchronized (mLock) {
+            while(!mOnCallForwardingIndicatorChangedCalled){
+                mLock.wait();
+            }
+        }
+        quitLooper();
+        t.checkException();
+        assertTrue(mOnCallForwardingIndicatorChangedCalled);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test method: onCellLocationChanged ",
+            method = "onCellLocationChanged",
+            args = {CellLocation.class}
+        )
+    })
+    public void testOnCellLocationChanged() throws Throwable {
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onCellLocationChanged(CellLocation location) {
+                        synchronized(mLock) {
+                            mOnCellLocationChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_CELL_LOCATION);
+
+                Looper.loop();
+            }
+        });
+
+        assertFalse(mOnCellLocationChangedCalled);
+        t.start();
+
+        synchronized (mLock) {
+            while(!mOnCellLocationChangedCalled){
+                mLock.wait();
+            }
+        }
+        quitLooper();
+        t.checkException();
+        assertTrue(mOnCellLocationChangedCalled);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test method: onCallStateChanged ",
+            method = "onCallStateChanged",
+            args = {int.class, String.class}
+        )
+    })
+    public void testOnCallStateChanged() throws Throwable {
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onCallStateChanged(int state, String incomingNumber) {
+                        synchronized(mLock) {
+                            mOnCallStateChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_CALL_STATE);
+
+                Looper.loop();
+            }
+        });
+
+        assertFalse(mOnCallStateChangedCalled);
+        t.start();
+
+        synchronized (mLock) {
+            while(!mOnCallStateChangedCalled){
+                mLock.wait();
+            }
+        }
+        quitLooper();
+        t.checkException();
+        assertTrue(mOnCallStateChangedCalled);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test method: onDataConnectionStateChanged ",
+            method = "onDataConnectionStateChanged",
+            args = {int.class}
+        )
+    })
+    public void testOnDataConnectionStateChanged() throws Throwable {
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onDataConnectionStateChanged(int state) {
+                        synchronized(mLock) {
+                            mOnDataConnectionStateChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(
+                        mListener, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
+
+                Looper.loop();
+            }
+        });
+
+        assertFalse(mOnDataConnectionStateChangedCalled);
+        t.start();
+
+        synchronized (mLock) {
+            while(!mOnDataConnectionStateChangedCalled){
+                mLock.wait();
+            }
+        }
+        quitLooper();
+        t.checkException();
+        assertTrue(mOnDataConnectionStateChangedCalled);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            notes = "Test method: onDataActivity ",
+            method = "onDataActivity",
+            args = {int.class}
+        )
+    })
+    public void testOnDataActivity() throws Throwable {
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onDataActivity(int direction) {
+                        synchronized(mLock) {
+                            mOnDataActivityCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_DATA_ACTIVITY);
+
+                Looper.loop();
+            }
+        });
+
+        assertFalse(mOnDataActivityCalled);
+        t.start();
+
+        synchronized (mLock) {
+            while(!mOnDataActivityCalled){
+                mLock.wait();
+            }
+        }
+        quitLooper();
+        t.checkException();
+        assertTrue(mOnDataActivityCalled);
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/ServiceStateTest.java b/tests/tests/telephony/src/android/telephony/cts/ServiceStateTest.java
new file mode 100644
index 0000000..56188fb
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/ServiceStateTest.java
@@ -0,0 +1,202 @@
+/*
+ * 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.telephony.cts;
+
+import android.os.Parcel;
+import android.telephony.ServiceState;
+import android.test.AndroidTestCase;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+@TestTargetClass(ServiceState.class)
+public class ServiceStateTest extends AndroidTestCase {
+    private static final String OPERATOR_ALPHA_LONG = "CtsOperatorLong";
+    private static final String OPERATOR_ALPHA_SHORT = "CtsOp";
+    private static final String OPERATOR_NUMERIC = "02871";
+
+    @TestTargets({
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "describeContents",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "equals",
+        args = {Object.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getIsManualSelection",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getOperatorAlphaLong",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getOperatorAlphaShort",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getOperatorNumeric",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getRoaming",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getState",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "hashCode",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "ServiceState",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "ServiceState",
+        args = {Parcel.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "ServiceState",
+        args = {ServiceState.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "copyFrom",
+        args = {ServiceState.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setIsManualSelection",
+        args = {boolean.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setOperatorName",
+        args = {String.class, String.class, String.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setRoaming",
+        args = {boolean.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setState",
+        args = {int.class}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setStateOff",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "setStateOutOfService",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "toString",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "writeToParcel",
+        args = {Parcel.class, int.class}
+      )
+    })
+    public void testServiceState() {
+        ServiceState serviceState = new ServiceState();
+
+        assertEquals(0, serviceState.describeContents());
+
+        serviceState.setStateOff();
+        assertEquals(ServiceState.STATE_POWER_OFF, serviceState.getState());
+        checkOffStatus(serviceState);
+
+        serviceState.setStateOutOfService();
+        assertEquals(ServiceState.STATE_OUT_OF_SERVICE, serviceState.getState());
+        checkOffStatus(serviceState);
+
+        serviceState.setState(ServiceState.STATE_IN_SERVICE);
+        assertEquals(ServiceState.STATE_IN_SERVICE, serviceState.getState());
+
+        assertFalse(serviceState.getRoaming());
+        serviceState.setRoaming(true);
+        assertTrue(serviceState.getRoaming());
+
+        assertFalse(serviceState.getIsManualSelection());
+        serviceState.setIsManualSelection(true);
+        assertTrue(serviceState.getIsManualSelection());
+
+        serviceState.setOperatorName(OPERATOR_ALPHA_LONG, OPERATOR_ALPHA_SHORT, OPERATOR_NUMERIC);
+        assertEquals(OPERATOR_ALPHA_LONG, serviceState.getOperatorAlphaLong());
+        assertEquals(OPERATOR_ALPHA_SHORT, serviceState.getOperatorAlphaShort());
+        assertEquals(OPERATOR_NUMERIC, serviceState.getOperatorNumeric());
+
+        assertTrue(serviceState.hashCode() > 0);
+        assertNotNull(serviceState.toString());
+
+        ServiceState tempServiceState = new ServiceState(serviceState);
+        assertTrue(tempServiceState.equals(serviceState));
+
+        Parcel stateParcel = Parcel.obtain();
+        serviceState.writeToParcel(stateParcel, 0);
+        stateParcel.setDataPosition(0);
+        tempServiceState = new ServiceState(stateParcel);
+        assertTrue(tempServiceState.equals(serviceState));
+
+        MockServiceState mockServiceState = new MockServiceState();
+        mockServiceState.copyFrom(serviceState);
+        assertTrue(mockServiceState.equals(serviceState));
+    }
+
+    /**
+     * Check the ServiceState fields in STATE_OUT_OF_SERVICE or STATE_POWER_OFF
+     */
+    private void checkOffStatus(ServiceState s) {
+        assertFalse(s.getRoaming());
+        assertNull(s.getOperatorAlphaLong());
+        assertNull(s.getOperatorAlphaShort());
+        assertNull(s.getOperatorNumeric());
+        assertFalse(s.getIsManualSelection());
+    }
+
+    private class MockServiceState extends ServiceState {
+        @Override
+        protected void copyFrom(ServiceState s) {
+            super.copyFrom(s);
+        }
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
new file mode 100644
index 0000000..d48ea95
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
@@ -0,0 +1,268 @@
+/*
+ * 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.telephony.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.content.Context;
+import android.os.Looper;
+import android.os.cts.TestThread;
+import android.telephony.CellLocation;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
+import android.test.AndroidTestCase;
+
+@TestTargetClass(TelephonyManager.class)
+public class TelephonyManagerTest extends AndroidTestCase {
+    private TelephonyManager mTelephonyManager;
+    private boolean mOnCellLocationChangedCalled = false;
+    private final Object mLock = new Object();
+    private static final int TOLERANCE = 1000;
+    private Looper mLooper;
+    private PhoneStateListener mListener;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mTelephonyManager =
+            (TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mListener != null) {
+            // unregister the listener
+            mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_NONE);
+        }
+        super.tearDown();
+    }
+
+    @TestTargetNew(
+      level = TestLevel.COMPLETE,
+      method = "listen",
+      args = {PhoneStateListener.class, int.class}
+    )
+    public void testListen() throws Throwable {
+
+        // Test register
+        TestThread t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                mListener = new PhoneStateListener() {
+                    @Override
+                    public void onCellLocationChanged(CellLocation location) {
+                        synchronized (mLock) {
+                            mOnCellLocationChangedCalled = true;
+                            mLock.notify();
+                        }
+                    }
+                };
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_CELL_LOCATION);
+
+                Looper.loop();
+            }
+        });
+        t.start();
+
+        CellLocation.requestLocationUpdate();
+        synchronized (mLock) {
+            while (!mOnCellLocationChangedCalled) {
+                mLock.wait();
+            }
+        }
+        mLooper.quit();
+        assertTrue(mOnCellLocationChangedCalled);
+
+        // Test unregister
+        t = new TestThread(new Runnable() {
+            public void run() {
+                Looper.prepare();
+
+                mLooper = Looper.myLooper();
+                // unregister the listener
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_NONE);
+                mOnCellLocationChangedCalled = false;
+                // unregister again, to make sure doing so does not call the listener
+                mTelephonyManager.listen(mListener, PhoneStateListener.LISTEN_NONE);
+
+                Looper.loop();
+            }
+        });
+        t.start();
+
+        CellLocation.requestLocationUpdate();
+        synchronized (mLock) {
+            while (!mOnCellLocationChangedCalled) {
+                mLock.wait(TOLERANCE);
+                break;
+            }
+        }
+        mLooper.quit();
+        assertFalse(mOnCellLocationChangedCalled);
+    }
+
+    /**
+     * The getter methods here are all related to the information about the telephony.
+     * These getters are related to concrete location, phone, service provider company, so
+     * it's no need to get details of these information, just make sure they are in right
+     * condition(>0 or not null).
+     */
+    @TestTargets({
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getNetworkType",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getPhoneType",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getVoiceMailNumber",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getSimOperatorName",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getNetworkCountryIso",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getCellLocation",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getDeviceSoftwareVersion",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getSimState",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getSimSerialNumber",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getDeviceId",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getSimOperator",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getNetworkOperatorName",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getSubscriberId",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getLine1Number",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getNetworkOperator",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getSimCountryIso",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getDataActivity",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getDataState",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getCallState",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "isNetworkRoaming",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getVoiceMailAlphaTag",
+        args = {}
+      ),
+      @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getNeighboringCellInfo",
+        args = {}
+      )
+    })
+    public void testTelephonyManager() {
+        assertTrue(mTelephonyManager.getNetworkType() >= TelephonyManager.NETWORK_TYPE_UNKNOWN);
+        assertTrue(mTelephonyManager.getPhoneType() >= TelephonyManager.PHONE_TYPE_NONE);
+        assertTrue(mTelephonyManager.getSimState() >= TelephonyManager.SIM_STATE_UNKNOWN);
+        assertTrue(mTelephonyManager.getDataActivity() >= TelephonyManager.DATA_ACTIVITY_NONE);
+        assertTrue(mTelephonyManager.getDataState() >= TelephonyManager.DATA_DISCONNECTED);
+        assertTrue(mTelephonyManager.getCallState() >= TelephonyManager.CALL_STATE_IDLE);
+
+        // The following methods may return null. Simply call them to make sure they do not
+        // throw any exceptions.
+        mTelephonyManager.getVoiceMailNumber();
+        mTelephonyManager.getSimOperatorName();
+        mTelephonyManager.getNetworkCountryIso();
+        mTelephonyManager.getCellLocation();
+        mTelephonyManager.getSimSerialNumber();
+        mTelephonyManager.getSimOperator();
+        mTelephonyManager.getNetworkOperatorName();
+        mTelephonyManager.getSubscriberId();
+        mTelephonyManager.getLine1Number();
+        mTelephonyManager.getNetworkOperator();
+        mTelephonyManager.getSimCountryIso();
+        mTelephonyManager.getVoiceMailAlphaTag();
+        mTelephonyManager.getNeighboringCellInfo();
+        mTelephonyManager.isNetworkRoaming();
+        mTelephonyManager.getDeviceId();
+        mTelephonyManager.getDeviceSoftwareVersion();
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/gsm/cts/GsmCellLocationTest.java b/tests/tests/telephony/src/android/telephony/gsm/cts/GsmCellLocationTest.java
new file mode 100644
index 0000000..07eb141
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/gsm/cts/GsmCellLocationTest.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.telephony.gsm.cts;
+
+import android.os.Bundle;
+import android.telephony.gsm.GsmCellLocation;
+import android.test.AndroidTestCase;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+@TestTargetClass(GsmCellLocation.class)
+public class GsmCellLocationTest extends AndroidTestCase {
+
+    private static final int CID_VALUE = 20;
+    private static final int LAC_VALUE = 10;
+    private static final int INVALID_CID = -1;
+    private static final int INVALID_LAC = -1;
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "GsmCellLocation",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "GsmCellLocation",
+            args = {Bundle.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getCid",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getLac",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setLacAndCid",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setStateInvalid",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "hashCode",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "toString",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "fillInNotifierBundle",
+            args = {Bundle.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "equals",
+            args = {Object.class}
+        )
+    })
+    public void testGsmCellLocation() {
+        Bundle bundle = new Bundle();
+
+        GsmCellLocation gsmCellLocation = new GsmCellLocation();
+        checkLacAndCid(INVALID_LAC, INVALID_CID, gsmCellLocation);
+
+        gsmCellLocation.setLacAndCid(LAC_VALUE, CID_VALUE);
+        gsmCellLocation.fillInNotifierBundle(bundle);
+        gsmCellLocation = new GsmCellLocation(bundle);
+        checkLacAndCid(LAC_VALUE, CID_VALUE, gsmCellLocation);
+
+        gsmCellLocation.setStateInvalid();
+        checkLacAndCid(INVALID_LAC, INVALID_CID, gsmCellLocation);
+
+        gsmCellLocation.setLacAndCid(LAC_VALUE, CID_VALUE);
+        checkLacAndCid(LAC_VALUE, CID_VALUE, gsmCellLocation);
+
+        assertEquals(LAC_VALUE ^ CID_VALUE, gsmCellLocation.hashCode());
+        assertNotNull(gsmCellLocation.toString());
+
+        GsmCellLocation testGCSEquals = new GsmCellLocation();
+        assertFalse(gsmCellLocation.equals(testGCSEquals));
+        testGCSEquals.setLacAndCid(LAC_VALUE, CID_VALUE);
+        assertTrue(gsmCellLocation.equals(testGCSEquals));
+    }
+
+    private void checkLacAndCid(int expectedLac, int expectedCid, GsmCellLocation gsmCellLocation) {
+        assertEquals(expectedLac, gsmCellLocation.getLac());
+        assertEquals(expectedCid, gsmCellLocation.getCid());
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/gsm/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/gsm/cts/SmsManagerTest.java
new file mode 100644
index 0000000..ba02c35
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/gsm/cts/SmsManagerTest.java
@@ -0,0 +1,205 @@
+/*
+ * 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.telephony.gsm.cts;
+
+import java.util.ArrayList;
+
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.telephony.TelephonyManager;
+import android.telephony.gsm.SmsManager;
+import android.test.AndroidTestCase;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+@SuppressWarnings("deprecation")
+@TestTargetClass(SmsManager.class)
+public class SmsManagerTest extends AndroidTestCase {
+
+    private static final int NUM_TEXT_PARTS = 3;
+    private static final String LONG_TEXT =
+        "This is a very long text. This text should be broken into three " +
+        "separate messages.This is a very long text. This text should be broken into " +
+        "three separate messages.This is a very long text. This text should be broken " +
+        "into three separate messages.This is a very long text. This text should be " +
+        "broken into three separate messages.";;
+
+    private static final String SMS_SEND_ACTION = "CTS_SMS_SEND_ACTION";
+    private static final String SMS_DELIVERY_ACTION = "CTS_SMS_DELIVERY_ACTION";
+
+    private SmsManager mSms;
+    private String mDestAddr;
+    private String mText;
+    private SmsBroadcastReceiver mSendReceiver;
+    private SmsBroadcastReceiver mDeliveryReceiver;
+    private PendingIntent mSentIntent;
+    private PendingIntent mDeliveredIntent;
+    private Intent mSendIntent;
+    private Intent mDeliveryIntent;
+
+    private static final int TIME_OUT = 1000 * 60 * 4;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mSms = SmsManager.getDefault();
+        TelephonyManager tm =
+            (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
+        mDestAddr = tm.getLine1Number();
+        mText = "This is a test message";
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "divideMessage",
+            args = {String.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getDefault",
+            args = {}
+        )
+    })
+    public void testDivideMessage() {
+        // Test getDefault
+        assertNotNull(mSms);
+
+        // Test divideMessage
+        ArrayList<String> dividedMessages = mSms.divideMessage(LONG_TEXT);
+        assertNotNull(dividedMessages);
+        assertEquals(NUM_TEXT_PARTS, dividedMessages.size());
+        assertEquals(LONG_TEXT,
+                dividedMessages.get(0) + dividedMessages.get(1) + dividedMessages.get(2));
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "sendDataMessage",
+            args = {String.class, String.class, short.class, byte[].class,
+                    PendingIntent.class, PendingIntent.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "sendTextMessage",
+            args = {String.class, String.class, String.class, PendingIntent.class,
+                    PendingIntent.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "sendMultipartTextMessage",
+            args = {String.class, String.class, ArrayList.class, ArrayList.class, ArrayList.class}
+        )
+    })
+    public void testSendMessages() throws InterruptedException {
+
+        mSendIntent = new Intent(SMS_SEND_ACTION);
+        mDeliveryIntent = new Intent(SMS_DELIVERY_ACTION);
+
+        IntentFilter sendIntentFilter = new IntentFilter(SMS_SEND_ACTION);
+        IntentFilter deliveryIntentFilter = new IntentFilter(SMS_DELIVERY_ACTION);
+
+        mSendReceiver = new SmsBroadcastReceiver(SMS_SEND_ACTION);
+        mDeliveryReceiver = new SmsBroadcastReceiver(SMS_DELIVERY_ACTION);
+
+        getContext().registerReceiver(mSendReceiver, sendIntentFilter);
+        getContext().registerReceiver(mDeliveryReceiver, deliveryIntentFilter);
+
+        // send single text sms
+        init();
+        mSms.sendTextMessage(mDestAddr, null, mText, mSentIntent, mDeliveredIntent);
+        mSendReceiver.waitForCalls(1, TIME_OUT);
+        mDeliveryReceiver.waitForCalls(1, TIME_OUT);
+
+        // send data sms
+        byte[] data = mText.getBytes();
+        short port = 19989;
+
+        init();
+        mSms.sendDataMessage(mDestAddr, null, port, data, mSentIntent, mDeliveredIntent);
+        mSendReceiver.waitForCalls(1, TIME_OUT);
+        mDeliveryReceiver.waitForCalls(1, TIME_OUT);
+
+        // send multi parts text sms
+        init();
+        ArrayList<String> parts = mSms.divideMessage(LONG_TEXT);
+        int numParts = parts.size();
+        ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
+        ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
+        for (int i = 0; i < numParts; i++) {
+            sentIntents.add(PendingIntent.getBroadcast(getContext(), 0, mSendIntent, 0));
+            deliveryIntents.add(PendingIntent.getBroadcast(getContext(), 0, mDeliveryIntent, 0));
+        }
+        mSms.sendMultipartTextMessage(mDestAddr, null, parts, sentIntents, deliveryIntents);
+        mSendReceiver.waitForCalls(numParts, TIME_OUT);
+        mDeliveryReceiver.waitForCalls(numParts, TIME_OUT);
+    }
+
+    private void init() {
+        mSendReceiver.reset();
+        mDeliveryReceiver.reset();
+        mSentIntent = PendingIntent.getBroadcast(getContext(), 0, mSendIntent,
+                PendingIntent.FLAG_ONE_SHOT);
+        mDeliveredIntent = PendingIntent.getBroadcast(getContext(), 0, mDeliveryIntent,
+                PendingIntent.FLAG_ONE_SHOT);
+    }
+
+    private static class SmsBroadcastReceiver extends BroadcastReceiver {
+        private int mCalls;
+        private int mExpectedCalls;
+        private String mAction;
+        private Object mLock;
+
+        SmsBroadcastReceiver(String action) {
+            mAction = action;
+            reset();
+            mLock = new Object();
+        }
+
+        void reset() {
+            mExpectedCalls = Integer.MAX_VALUE;
+            mCalls = 0;
+        }
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getAction().equals(mAction)) {
+                synchronized (mLock) {
+                    mCalls += 1;
+                    if (mCalls >= mExpectedCalls) {
+                        mLock.notify();
+                    }
+                }
+            }
+        }
+
+        public void waitForCalls(int expectedCalls, long timeout) throws InterruptedException {
+            synchronized(mLock) {
+                mExpectedCalls = expectedCalls;
+                if (mCalls < mExpectedCalls) {
+                    mLock.wait(timeout);
+                }
+            }
+        }
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessageTest.java b/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessageTest.java
new file mode 100644
index 0000000..3d3aec4
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessageTest.java
@@ -0,0 +1,431 @@
+/*
+ * 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.telephony.gsm.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.telephony.gsm.SmsMessage;
+import android.test.AndroidTestCase;
+
+@SuppressWarnings("deprecation")
+@TestTargetClass(SmsMessage.class)
+public class SmsMessageTest extends AndroidTestCase{
+
+    private static final String DISPLAY_MESSAGE_BODY = "test body";
+    private static final String DMB = "{ testBody[^~\\] }";
+    private static final String EMAIL_ADD = "foo@example.com";
+    private static final String EMAIL_FROM = "foo@example.com";
+    private static final String MB = DMB;
+    private static final String MESSAGE_BODY1 = "Test";
+    private static final String MESSAGE_BODY2 = "(Subject)Test";
+    private static final String MESSAGE_BODY3 = "\u2122\u00a9\u00aehello";
+    private static final String MESSAGE_BODY4 = " ";
+    private static final String MESSAGE_BODY5 = " ";
+    private static final String OA = "foo@example.com";
+    private static final String OA1 = "+14154255486";
+    private static final String OA2 = "+15122977683";
+    private static final String OA3 = "_@";
+    private static final String OA4 = "\u0394@";
+    private static final String PSEUDO_SUBJECT = "test subject";
+    private static final String SCA1 = "+16466220020";
+    private static final String SCA2 = "+12063130012";
+    private static final String SCA3 = "+14155551212";
+    private static final String SCA4 = "+14155551212";
+    private static final int NOT_CREATE_FROM_SIM = -1;
+    private static final int PROTOCOL_IDENTIFIER = 0;
+    private static final int SMS_NUMBER1 = 1;
+    private static final int SMS_NUMBER2 = 1;
+    private static final int SMS_NUMBER3 = 1;
+    private static final int STATUS = 0;
+    private static final int STATUS_ON_SIM_DEF = -1;
+    private static final int TPLAYER_LENGTH_FOR_PDU = 23;
+    private static final long TIMESTAMP_MILLIS = 1149631383000l;
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "createFromPdu",
+            args = {byte[].class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getServiceCenterAddress",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getOriginatingAddress",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getTPLayerLengthForPDU",
+            args = {String.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getMessageBody",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "calculateLength",
+            args = {CharSequence.class, boolean.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "calculateLength",
+            args = {String.class, boolean.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getPdu",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isEmail",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isCphsMwiMessage",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isMwiDontStore",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isReplyPathPresent",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isStatusReportMessage",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getProtocolIdentifier",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getIndexOnSim",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getMessageClass",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getStatus",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getStatusOnSim",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getTimestampMillis",
+            args = {}
+        )
+    })
+    public void testCreateFromPdu() throws Exception {
+        String pdu = "07916164260220F0040B914151245584F600006060605130308A04D4F29C0E";
+        SmsMessage sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertEquals(SCA1, sms.getServiceCenterAddress());
+        assertEquals(OA1, sms.getOriginatingAddress());
+        assertEquals(MESSAGE_BODY1, sms.getMessageBody());
+        assertEquals(TPLAYER_LENGTH_FOR_PDU, SmsMessage.getTPLayerLengthForPDU(pdu));
+        int[] result = SmsMessage.calculateLength(sms.getMessageBody(), true);
+        assertEquals(SMS_NUMBER1, result[0]);
+        assertEquals(sms.getMessageBody().length(), result[1]);
+        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
+        assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
+        assertEquals(pdu, toHexString(sms.getPdu()));
+
+        assertEquals(NOT_CREATE_FROM_SIM, sms.getIndexOnSim());
+        assertEquals(PROTOCOL_IDENTIFIER, sms.getProtocolIdentifier());
+        assertFalse(sms.isEmail());
+        assertFalse(sms.isReplyPathPresent());
+        assertFalse(sms.isStatusReportMessage());
+        assertFalse(sms.isCphsMwiMessage());
+        assertEquals(SmsMessage.MessageClass.UNKNOWN, sms.getMessageClass());
+        assertEquals(STATUS, sms.getStatus());
+        assertEquals(STATUS_ON_SIM_DEF, sms.getStatusOnSim());
+        assertEquals(TIMESTAMP_MILLIS, sms.getTimestampMillis());
+
+        // Test create from null Pdu
+        sms = SmsMessage.createFromPdu(null);
+        assertNotNull(sms);
+
+        //Test create from long Pdu
+        pdu = "07912160130310F2040B915121927786F300036060924180008A0DA"
+            + "8695DAC2E8FE9296A794E07";
+        sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertEquals(SCA2, sms.getServiceCenterAddress());
+        assertEquals(OA2, sms.getOriginatingAddress());
+        assertEquals(MESSAGE_BODY2, sms.getMessageBody());
+        CharSequence msgBody = (CharSequence) sms.getMessageBody();
+        result = SmsMessage.calculateLength(msgBody, false);
+        assertEquals(SMS_NUMBER2, result[0]);
+        assertEquals(sms.getMessageBody().length(), result[1]);
+        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
+        assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
+
+        // Test createFromPdu Ucs to Sms
+        pdu = "07912160130300F4040B914151245584"
+            + "F600087010807121352B10212200A900AE00680065006C006C006F";
+        sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertEquals(MESSAGE_BODY3, sms.getMessageBody());
+        result = SmsMessage.calculateLength(sms.getMessageBody(), true);
+        assertEquals(SMS_NUMBER3, result[0]);
+        assertEquals(sms.getMessageBody().length(), result[1]);
+        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
+        assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isReplace",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isMWISetMessage",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isMWIClearMessage",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isMwiDontStore",
+            args = {}
+        )
+    })
+    public void testCPHSVoiceMail() throws Exception {
+        // "set MWI flag"
+        String pdu = "07912160130310F20404D0110041006060627171118A0120";
+        SmsMessage sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertTrue(sms.isReplace());
+        assertEquals(OA3, sms.getOriginatingAddress());
+        assertEquals(MESSAGE_BODY4, sms.getMessageBody());
+        assertTrue(sms.isMWISetMessage());
+
+        // "clear mwi flag"
+        pdu = "07912160130310F20404D0100041006021924193352B0120";
+        sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertTrue(sms.isMWIClearMessage());
+
+        // "clear MWI flag"
+        pdu = "07912160130310F20404D0100041006060627161058A0120";
+        sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertTrue(sms.isReplace());
+        assertEquals(OA4, sms.getOriginatingAddress());
+        assertEquals(MESSAGE_BODY5, sms.getMessageBody());
+        assertTrue(sms.isMWIClearMessage());
+
+        // "set MWI flag"
+        pdu = "07912180958750F84401800500C87020026195702B06040102000200";
+        sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertTrue(sms.isMWISetMessage());
+        assertTrue(sms.isMwiDontStore());
+
+        // "clear mwi flag"
+        pdu = "07912180958750F84401800500C07020027160112B06040102000000";
+        sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+
+        assertTrue(sms.isMWIClearMessage());
+        assertTrue(sms.isMwiDontStore());
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getUserData",
+            args = {}
+        )
+    })
+    public void testGetUserData() throws Exception {
+        String pdu = "07914140279510F6440A8111110301003BF56080207130138A8C0B05040B8423F"
+            + "000032A02010106276170706C69636174696F6E2F766E642E7761702E6D6D732D"
+            + "6D65737361676500AF848D0185B4848C8298524E453955304A6D7135514141426"
+            + "66C414141414D7741414236514141414141008D908918802B3135313232393737"
+            + "3638332F545950453D504C4D4E008A808E022B918805810306977F83687474703"
+            + "A2F2F36";
+        SmsMessage sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        byte[] userData = sms.getUserData();
+        assertNotNull(userData);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getSubmitPdu",
+            args = {String.class, String.class, String.class, boolean.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getSubmitPdu",
+            args = {String.class, String.class, short.class, byte[].class, boolean.class}
+        )
+    })
+    public void testGetSubmitPdu() throws Exception {
+        String scAddress = null, destinationAddress = null;
+        String message = null;
+        boolean statusReportRequested = false;
+
+        try {
+            // null message, null destination
+            SmsMessage.getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException expected) {
+            // expected
+        }
+
+        message = "This is a test message";
+        try {
+            // non-null message
+            SmsMessage.getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested);
+            fail("Should throw NullPointerException");
+        } catch (NullPointerException expected) {
+            // expected
+        }
+
+        scAddress = "1650253000";
+        destinationAddress = "18004664411";
+        message = "This is a test message";
+        statusReportRequested = false;
+        SmsMessage.SubmitPdu smsPdu =
+            SmsMessage.getSubmitPdu(scAddress, destinationAddress, message, statusReportRequested);
+        assertNotNull(smsPdu);
+
+        smsPdu = SmsMessage.getSubmitPdu(scAddress, destinationAddress, (short)80,
+                message.getBytes(), statusReportRequested);
+        assertNotNull(smsPdu);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getEmailBody",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getEmailFrom",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getDisplayMessageBody",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getPseudoSubject",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getDisplayOriginatingAddress",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isEmail",
+            args = {}
+        )
+    })
+    public void testEmailGateway() throws Exception {
+        String pdu = "07914151551512f204038105f300007011103164638a28e6f71b50c687db" +
+                         "7076d9357eb7412f7a794e07cdeb6275794c07bde8e5391d247e93f3";
+
+        SmsMessage sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertEquals(SCA4, sms.getServiceCenterAddress());
+        assertTrue(sms.isEmail());
+        assertEquals(EMAIL_ADD, sms.getEmailFrom());
+        assertEquals(EMAIL_ADD, sms.getDisplayOriginatingAddress());
+        assertEquals(PSEUDO_SUBJECT, sms.getPseudoSubject());
+
+        assertEquals(DISPLAY_MESSAGE_BODY, sms.getDisplayMessageBody());
+        assertEquals(DISPLAY_MESSAGE_BODY, sms.getEmailBody());
+
+        pdu = "07914151551512f204038105f400007011103105458a29e6f71b50c687db" +
+                        "7076d9357eb741af0d0a442fcfe9c23739bfe16d289bdee6b5f1813629";
+        sms = SmsMessage.createFromPdu(hexStringToByteArray(pdu));
+        assertEquals(SCA3, sms.getServiceCenterAddress());
+        assertTrue(sms.isEmail());
+        assertEquals(OA, sms.getDisplayOriginatingAddress());
+        assertEquals(EMAIL_FROM, sms.getEmailFrom());
+        assertEquals(DMB, sms.getDisplayMessageBody());
+        assertEquals(MB, sms.getEmailBody());
+    }
+
+    private final static char[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+            'A', 'B', 'C', 'D', 'E', 'F' };
+
+    public static String toHexString(byte[] array) {
+        int length = array.length;
+        char[] buf = new char[length * 2];
+
+        int bufIndex = 0;
+        for (int i = 0 ; i < length; i++)
+        {
+            byte b = array[i];
+            buf[bufIndex++] = HEX_DIGITS[(b >>> 4) & 0x0F];
+            buf[bufIndex++] = HEX_DIGITS[b & 0x0F];
+        }
+
+        return new String(buf);
+    }
+
+    private static int toByte(char c) {
+        if (c >= '0' && c <= '9') return (c - '0');
+        if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
+        if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
+
+        throw new RuntimeException ("Invalid hex char '" + c + "'");
+    }
+
+    private static byte[] hexStringToByteArray(String hexString) {
+        int length = hexString.length();
+        byte[] buffer = new byte[length / 2];
+
+        for (int i = 0 ; i < length ; i += 2) {
+            buffer[i / 2] =
+                (byte)((toByte(hexString.charAt(i)) << 4) | toByte(hexString.charAt(i+1)));
+        }
+
+        return buffer;
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessage_MessageClassTest.java b/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessage_MessageClassTest.java
new file mode 100644
index 0000000..bfa53ef
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessage_MessageClassTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.telephony.gsm.cts;
+
+import junit.framework.TestCase;
+import android.telephony.gsm.SmsMessage;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+@TestTargetClass(SmsMessage.MessageClass.class)
+public class SmsMessage_MessageClassTest extends TestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.NOT_NECESSARY,
+            method = "valueOf",
+            args = {String.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.NOT_NECESSARY,
+            method = "values",
+            args = {}
+        )
+    })
+    public void testMessageClass() {
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessage_SubmitPduTest.java b/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessage_SubmitPduTest.java
new file mode 100644
index 0000000..e40a7fd
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/gsm/cts/SmsMessage_SubmitPduTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.telephony.gsm.cts;
+
+import android.telephony.gsm.SmsMessage;
+import android.test.AndroidTestCase;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+@TestTargetClass(SmsMessage.SubmitPdu.class)
+public class SmsMessage_SubmitPduTest extends AndroidTestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "toString",
+            args = {}
+        )
+    })
+    public void testToString() {
+        SmsMessage.SubmitPdu sp = new SmsMessage.SubmitPdu();
+        assertNotNull(sp.toString());
+    }
+}
diff --git a/tests/tests/text/src/android/text/cts/AlteredCharSequenceTest.java b/tests/tests/text/src/android/text/cts/AlteredCharSequenceTest.java
index 393e7d1..7aad01d 100644
--- a/tests/tests/text/src/android/text/cts/AlteredCharSequenceTest.java
+++ b/tests/tests/text/src/android/text/cts/AlteredCharSequenceTest.java
@@ -31,7 +31,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test charAt(int off)",
         method = "charAt",
         args = {int.class}
     )
@@ -64,7 +63,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test getChars(int start, int end, char[] dest, int off)",
         method = "getChars",
         args = {int.class, int.class, char[].class, int.class}
     )
@@ -102,7 +100,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test length()",
         method = "length",
         args = {}
     )
@@ -119,7 +116,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test make method",
         method = "make",
         args = {java.lang.CharSequence.class, char[].class, int.class, int.class}
     )
@@ -143,7 +139,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test subSequence(int start, int end)",
         method = "subSequence",
         args = {int.class, int.class}
     )
@@ -165,7 +160,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test toString()",
         method = "toString",
         args = {}
     )
diff --git a/tests/tests/text/src/android/text/cts/AnnotationTest.java b/tests/tests/text/src/android/text/cts/AnnotationTest.java
index 4521963..2e412b3 100644
--- a/tests/tests/text/src/android/text/cts/AnnotationTest.java
+++ b/tests/tests/text/src/android/text/cts/AnnotationTest.java
@@ -43,7 +43,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test constructor",
         method = "Annotation",
         args = {java.lang.String.class, java.lang.String.class}
     )
@@ -54,7 +53,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test getValue()",
         method = "getValue",
         args = {}
     )
@@ -68,7 +66,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test getKey()",
         method = "getKey",
         args = {}
     )
@@ -82,7 +79,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test getSpanTypeId()",
         method = "getSpanTypeId",
         args = {}
     )
@@ -95,15 +91,18 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test writeToParcel",
             method = "writeToParcel",
             args = {Parcel.class, int.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor create from parcel",
             method = "Annotation",
             args = {Parcel.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
         )
     })
     public void testWriteToParcel() {
@@ -114,5 +113,7 @@
         Annotation out = new Annotation(dest);
         assertEquals(out.getKey(), mAnnotation.getKey());
         assertEquals(out.getValue(), mAnnotation.getValue());
+
+        assertEquals(0, out.describeContents());
     }
 }
diff --git a/tests/tests/text/src/android/text/cts/AutoTextTest.java b/tests/tests/text/src/android/text/cts/AutoTextTest.java
index dbc8618..3ab301d 100644
--- a/tests/tests/text/src/android/text/cts/AutoTextTest.java
+++ b/tests/tests/text/src/android/text/cts/AutoTextTest.java
@@ -29,8 +29,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test {@link AutoText#get(CharSequence, int, int, View)}"
-            + ".It simply get a word value according to the word key.",
         method = "get",
         args = {java.lang.CharSequence.class, int.class, int.class, android.view.View.class}
     )
@@ -79,5 +77,17 @@
         assertNotNull(actual);
         assertEquals("can", actual);
     }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getSize",
+        args = {android.view.View.class}
+    )
+    public void testGetSize() {
+        Locale.setDefault(Locale.ENGLISH);
+        View view = new View(getContext());
+        // Returns the size of the auto text dictionary. Just make sure it is bigger than 0.
+        assertTrue(AutoText.getSize(view) > 0);
+    }
 }
 
diff --git a/tests/tests/text/src/android/text/cts/BoringLayoutTest.java b/tests/tests/text/src/android/text/cts/BoringLayoutTest.java
index e0aac11..01da716 100644
--- a/tests/tests/text/src/android/text/cts/BoringLayoutTest.java
+++ b/tests/tests/text/src/android/text/cts/BoringLayoutTest.java
@@ -65,7 +65,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor",
             method = "BoringLayout",
             args = {java.lang.CharSequence.class, android.text.TextPaint.class, int.class,
                     android.text.Layout.Alignment.class, float.class, float.class,
@@ -73,7 +72,6 @@
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor",
             method = "BoringLayout",
             args = {java.lang.CharSequence.class, android.text.TextPaint.class, int.class,
                     android.text.Layout.Alignment.class, float.class, float.class,
@@ -82,7 +80,7 @@
         )
     })
     public void testConstructors() {
-        BoringLayout boringLayout = new BoringLayout(DEFAULT_CHAR_SEQUENCE,
+        new BoringLayout(DEFAULT_CHAR_SEQUENCE,
                 DEFAULT_PAINT,
                 DEFAULT_OUTER_WIDTH,
                 DEFAULT_ALIGN,
@@ -90,7 +88,8 @@
                 SPACING_ADD_NO_SCALE,
                 DEFAULT_METRICS,
                 true);
-        boringLayout = new BoringLayout(DEFAULT_CHAR_SEQUENCE,
+
+        new BoringLayout(DEFAULT_CHAR_SEQUENCE,
                 DEFAULT_PAINT,
                 DEFAULT_OUTER_WIDTH,
                 DEFAULT_ALIGN,
@@ -385,13 +384,11 @@
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test getBottomPadding",
             method = "getBottomPadding",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test getLineDescent",
             method = "getLineDescent",
             args = {int.class}
         )
@@ -432,7 +429,6 @@
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test isBoring",
             method = "isBoring",
             args = {java.lang.CharSequence.class, android.text.TextPaint.class,
                     android.text.BoringLayout.Metrics.class}
@@ -456,7 +452,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test getLineDirections(int line)",
         method = "getLineDirections",
         args = {int.class}
     )
@@ -468,7 +463,6 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test make",
             method = "make",
             args = {java.lang.CharSequence.class, android.text.TextPaint.class, int.class,
                     android.text.Layout.Alignment.class, float.class, float.class,
@@ -476,7 +470,6 @@
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test make",
             method = "make",
             args = {java.lang.CharSequence.class, android.text.TextPaint.class, int.class,
                     android.text.Layout.Alignment.class, float.class, float.class,
@@ -511,7 +504,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test draw",
         method = "draw",
         args = {android.graphics.Canvas.class, android.graphics.Path.class,
                 android.graphics.Paint.class, int.class}
diff --git a/tests/tests/text/src/android/text/cts/BoringLayout_MetricsTest.java b/tests/tests/text/src/android/text/cts/BoringLayout_MetricsTest.java
index 62cb162..acb723f 100644
--- a/tests/tests/text/src/android/text/cts/BoringLayout_MetricsTest.java
+++ b/tests/tests/text/src/android/text/cts/BoringLayout_MetricsTest.java
@@ -29,13 +29,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test toString()",
             method = "toString",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor",
             method = "BoringLayout.Metrics",
             args = {}
         )
diff --git a/tests/tests/text/src/android/text/cts/ClipboardManagerTest.java b/tests/tests/text/src/android/text/cts/ClipboardManagerTest.java
new file mode 100644
index 0000000..336f0ce
--- /dev/null
+++ b/tests/tests/text/src/android/text/cts/ClipboardManagerTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.content.Context;
+import android.test.AndroidTestCase;
+import android.text.ClipboardManager;
+
+/**
+ * Test {@link ClipboardManager}.
+ */
+@TestTargetClass(ClipboardManager.class)
+public class ClipboardManagerTest extends AndroidTestCase {
+    private ClipboardManager mClipboardManager;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mClipboardManager = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setText",
+            args = {CharSequence.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getText",
+            args = {}
+        )
+    })
+    public void testAccessText() {
+        // set the expected value
+        CharSequence expected = "test";
+        mClipboardManager.setText(expected);
+        assertEquals(expected, mClipboardManager.getText());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "hasText",
+        args = {}
+    )
+    public void testHasText() {
+        mClipboardManager.setText("");
+        assertFalse(mClipboardManager.hasText());
+
+        mClipboardManager.setText("test");
+        assertTrue(mClipboardManager.hasText());
+
+        mClipboardManager.setText(null);
+        assertFalse(mClipboardManager.hasText());
+    }
+}
diff --git a/tests/tests/text/src/android/text/cts/Editable_FactoryTest.java b/tests/tests/text/src/android/text/cts/Editable_FactoryTest.java
index bb6e020..3e73150 100644
--- a/tests/tests/text/src/android/text/cts/Editable_FactoryTest.java
+++ b/tests/tests/text/src/android/text/cts/Editable_FactoryTest.java
@@ -20,10 +20,9 @@
 import android.text.Editable;
 import android.text.SpannableStringBuilder;
 import android.text.Editable.Factory;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
 
 @TestTargetClass(Editable.Factory.class)
 public class Editable_FactoryTest extends AndroidTestCase {
diff --git a/tests/tests/text/src/android/text/cts/HtmlTest.java b/tests/tests/text/src/android/text/cts/HtmlTest.java
index e8fed3c..7f86914 100644
--- a/tests/tests/text/src/android/text/cts/HtmlTest.java
+++ b/tests/tests/text/src/android/text/cts/HtmlTest.java
@@ -45,13 +45,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.PARTIAL_COMPLETE,
-            notes = "Test method: fromHtml",
             method = "fromHtml",
             args = {String.class}
         ),
         @TestTargetNew(
             level = TestLevel.PARTIAL_COMPLETE,
-            notes = "Test method: fromHtml",
             method = "fromHtml",
             args = {String.class, ImageGetter.class, TagHandler.class}
         )
@@ -81,13 +79,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.PARTIAL_COMPLETE,
-            notes = "Test method: fromHtml",
             method = "fromHtml",
             args = {String.class}
         ),
         @TestTargetNew(
             level = TestLevel.PARTIAL_COMPLETE,
-            notes = "Test method: fromHtml",
             method = "fromHtml",
             args = {String.class, ImageGetter.class, TagHandler.class}
         )
@@ -113,13 +109,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.PARTIAL_COMPLETE,
-            notes = "Test method: fromHtml",
             method = "fromHtml",
             args = {String.class}
         ),
         @TestTargetNew(
             level = TestLevel.PARTIAL_COMPLETE,
-            notes = "Test method: fromHtml",
             method = "fromHtml",
             args = {String.class, ImageGetter.class, TagHandler.class}
         )
@@ -137,13 +131,11 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.PARTIAL_COMPLETE,
-            notes = "Test method: fromHtml",
             method = "fromHtml",
             args = {String.class}
         ),
         @TestTargetNew(
             level = TestLevel.PARTIAL_COMPLETE,
-            notes = "Test method: fromHtml",
             method = "fromHtml",
             args = {String.class, ImageGetter.class, TagHandler.class}
         )
@@ -173,7 +165,6 @@
 
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
-        notes = "Test method: toHtml",
         method = "toHtml",
         args = {Spanned.class}
     )
@@ -193,7 +184,6 @@
 
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
-        notes = "Test method: toHtml",
         method = "toHtml",
         args = {Spanned.class}
     )
@@ -213,7 +203,6 @@
 
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
-        notes = "Test method: toHtml",
         method = "toHtml",
         args = {Spanned.class}
     )
@@ -230,7 +219,6 @@
 
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
-        notes = "Test method: toHtml",
         method = "toHtml",
         args = {Spanned.class}
     )
@@ -281,7 +269,6 @@
 
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
-        notes = "Test method: toHtml",
         method = "toHtml",
         args = {Spanned.class}
     )
diff --git a/tests/tests/text/src/android/text/cts/InputFilter_LengthFilterTest.java b/tests/tests/text/src/android/text/cts/InputFilter_LengthFilterTest.java
index 60660ce..df77e60 100644
--- a/tests/tests/text/src/android/text/cts/InputFilter_LengthFilterTest.java
+++ b/tests/tests/text/src/android/text/cts/InputFilter_LengthFilterTest.java
@@ -31,14 +31,12 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test filter",
             method = "filter",
             args = {java.lang.CharSequence.class, int.class, int.class, android.text.Spanned.class,
                     int.class, int.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor",
             method = "InputFilter.LengthFilter",
             args = {int.class}
         )
diff --git a/tests/tests/text/src/android/text/cts/LoginFilterTest.java b/tests/tests/text/src/android/text/cts/LoginFilterTest.java
index d5028d9..b436ec7 100644
--- a/tests/tests/text/src/android/text/cts/LoginFilterTest.java
+++ b/tests/tests/text/src/android/text/cts/LoginFilterTest.java
@@ -21,14 +21,14 @@
 import android.text.SpannableString;
 import android.text.Spanned;
 import android.text.SpannedString;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.ToBeFixed;
 
 @TestTargetClass(LoginFilter.class)
 public class LoginFilterTest extends TestCase {
+
     @ToBeFixed(bug="1448885", explanation="LoginFilter is an abstract class and its" +
             " constructors are all package private, we can not extends it directly" +
             " to test. So, we try to extends its subclass UsernameFilterGeneric to test")
@@ -40,7 +40,7 @@
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         method = "filter",
-        args = {java.lang.CharSequence.class, int.class, int.class, android.text.Spanned.class, 
+        args = {java.lang.CharSequence.class, int.class, int.class, android.text.Spanned.class,
                 int.class, int.class}
     )
     @ToBeFixed(bug="1417734", explanation="should add @throws clause into javadoc " +
@@ -135,37 +135,37 @@
         loginFilter.filter(source1, 0, source1.length(), dest1, dest1.length(),  0);
     }
 
+    // This method does nothing. we only test onInvalidCharacter function here,
+    // the callback should be tested in testFilter()
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         method = "onInvalidCharacter",
         args = {char.class}
     )
-    // This method does nothing. we only test onInvalidCharacter function here, 
-    // the callback should be tested in testFilter()
     public void testOnInvalidCharacter() {
         LoginFilter loginFilter = new MockLoginFilter();
         loginFilter.onInvalidCharacter('a');
     }
 
+    // This method does nothing. we only test onStop function here,
+    // the callback should be tested in testFilter()
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         method = "onStop",
         args = {}
     )
-    // This method does nothing. we only test onStop function here, 
-    // the callback should be tested in testFilter()
     public void testOnStop() {
         LoginFilter loginFilter = new MockLoginFilter();
         loginFilter.onStop();
     }
 
+    // This method does nothing. we only test onStart function here,
+    // the callback should be tested in testFilter()
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         method = "onStart",
         args = {}
     )
-    // This method does nothing. we only test onStart function here, 
-    // the callback should be tested in testFilter()
     public void testOnStart() {
         LoginFilter loginFilter = new LoginFilter.UsernameFilterGeneric();
         loginFilter.onStart();
diff --git a/tests/tests/text/src/android/text/cts/LoginFilter_PasswordFilterGMailTest.java b/tests/tests/text/src/android/text/cts/LoginFilter_PasswordFilterGMailTest.java
index 59fed16..fa4ed6e 100644
--- a/tests/tests/text/src/android/text/cts/LoginFilter_PasswordFilterGMailTest.java
+++ b/tests/tests/text/src/android/text/cts/LoginFilter_PasswordFilterGMailTest.java
@@ -28,16 +28,15 @@
 
 @TestTargetClass(PasswordFilterGMail.class)
 public class LoginFilter_PasswordFilterGMailTest extends TestCase {
-    @TestTargets({
+
+@TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of PasswordFilterGMail.",
             method = "LoginFilter.PasswordFilterGMail",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of PasswordFilterGMail.",
             method = "LoginFilter.PasswordFilterGMail",
             args = {boolean.class}
         )
@@ -51,7 +50,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test isAllowed(char c).",
         method = "isAllowed",
         args = {char.class}
     )
diff --git a/tests/tests/text/src/android/text/cts/LoginFilter_UsernameFilterGenericTest.java b/tests/tests/text/src/android/text/cts/LoginFilter_UsernameFilterGenericTest.java
index d57f969..2421855 100644
--- a/tests/tests/text/src/android/text/cts/LoginFilter_UsernameFilterGenericTest.java
+++ b/tests/tests/text/src/android/text/cts/LoginFilter_UsernameFilterGenericTest.java
@@ -28,16 +28,15 @@
 
 @TestTargetClass(UsernameFilterGeneric.class)
 public class LoginFilter_UsernameFilterGenericTest extends TestCase {
+
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of UsernameFilterGeneric.",
             method = "LoginFilter.UsernameFilterGeneric",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of UsernameFilterGeneric.",
             method = "LoginFilter.UsernameFilterGeneric",
             args = {boolean.class}
         )
diff --git a/tests/tests/text/src/android/text/cts/SelectionTest.java b/tests/tests/text/src/android/text/cts/SelectionTest.java
index 4270b0c..11ba854 100644
--- a/tests/tests/text/src/android/text/cts/SelectionTest.java
+++ b/tests/tests/text/src/android/text/cts/SelectionTest.java
@@ -17,23 +17,19 @@
 package android.text.cts;
 
 import android.test.AndroidTestCase;
-import android.text.Layout;
 import android.text.Selection;
-import android.text.Spannable;
 import android.text.SpannableStringBuilder;
 import android.text.StaticLayout;
 import android.text.TextPaint;
-import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.ToBeFixed;
 
 @TestTargetClass(Selection.class)
 public class SelectionTest extends AndroidTestCase {
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test getSelectionStart(CharSequence text).",
         method = "getSelectionStart",
         args = {java.lang.CharSequence.class}
     )
@@ -56,7 +52,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test getSelectionEnd(CharSequence text).",
         method = "getSelectionEnd",
         args = {java.lang.CharSequence.class}
     )
@@ -79,7 +74,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test setSelection(Spannable text, int start, int stop).",
         method = "setSelection",
         args = {android.text.Spannable.class, int.class, int.class}
     )
@@ -122,7 +116,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test setSelection(Spannable text, int index).",
         method = "setSelection",
         args = {android.text.Spannable.class, int.class}
     )
@@ -162,7 +155,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test removeSelection(Spannable text).",
         method = "removeSelection",
         args = {android.text.Spannable.class}
     )
@@ -194,7 +186,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test selectAll(Spannable text).",
         method = "selectAll",
         args = {android.text.Spannable.class}
     )
@@ -233,7 +224,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test moveLeft(Spannable text, Layout layout).",
         method = "moveLeft",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -292,7 +282,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test moveRight(Spannable text, Layout layout).",
         method = "moveRight",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -355,7 +344,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test moveUp(Spannable text, Layout layout).",
         method = "moveUp",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -404,7 +392,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test moveDown(Spannable text, Layout layout).",
         method = "moveDown",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -462,7 +449,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test extendSelection(Spannable text, int index).",
         method = "extendSelection",
         args = {android.text.Spannable.class, int.class}
     )
@@ -516,7 +502,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test extendLeft(Spannable text, Layout layout).",
         method = "extendLeft",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -574,7 +559,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test extendRight(Spannable text, Layout layout).",
         method = "extendRight",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -628,7 +612,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test extendUp(Spannable text, Layout layout).",
         method = "extendUp",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -677,7 +660,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test extendDown(Spannable text, Layout layout).",
         method = "extendDown",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -730,7 +712,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test extendToLeftEdge(Spannable text, Layout layout).",
         method = "extendToLeftEdge",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -784,7 +765,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test extendToRightEdge(Spannable text, Layout layout).",
         method = "extendToRightEdge",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -836,7 +816,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test moveToLeftEdge(Spannable text, Layout layout).",
         method = "moveToLeftEdge",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
@@ -886,7 +865,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test moveToRightEdge(Spannable text, Layout layout).",
         method = "moveToRightEdge",
         args = {android.text.Spannable.class, android.text.Layout.class}
     )
diff --git a/tests/tests/text/src/android/text/cts/TextPaintTest.java b/tests/tests/text/src/android/text/cts/TextPaintTest.java
index 8987ad0..175a130 100644
--- a/tests/tests/text/src/android/text/cts/TextPaintTest.java
+++ b/tests/tests/text/src/android/text/cts/TextPaintTest.java
@@ -37,19 +37,16 @@
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of {@link TextPaint}",
             method = "TextPaint",
             args = {}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of {@link TextPaint}",
             method = "TextPaint",
             args = {int.class}
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            notes = "Test constructor(s) of {@link TextPaint}",
             method = "TextPaint",
             args = {android.graphics.Paint.class}
         )
@@ -86,7 +83,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "Test {@link TextPaint#set(TextPaint)}",
         method = "set",
         args = {android.text.TextPaint.class}
     )