Merge "Improving CTS test stability." into jb-mr2-dev
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index afbf97e..46963a0 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -172,6 +172,14 @@
             new Feature(PackageManager.FEATURE_TELEVISION, false),
     };
 
+    public static final Feature[] ALL_JELLY_BEAN_MR2_FEATURES = {
+            new Feature("android.software.app_widgets", false),
+            new Feature("android.software.input_methods", false),
+            new Feature("android.software.home_screen", false),
+            new Feature("android.hardware.bluetooth_le", false),
+            new Feature("android.hardware.camera.any", false),
+    };
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -202,6 +210,9 @@
 
         // add features from latest to last so that the latest requirements are put in the set first
         int apiVersion = Build.VERSION.SDK_INT;
+        if (apiVersion >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+            Collections.addAll(features, ALL_JELLY_BEAN_MR2_FEATURES);
+        }
         if (apiVersion >= Build.VERSION_CODES.JELLY_BEAN) {
             Collections.addAll(features, ALL_JELLY_BEAN_FEATURES);
         }
diff --git a/build/test_package.mk b/build/test_package.mk
index aa9a4dd..46718a8 100644
--- a/build/test_package.mk
+++ b/build/test_package.mk
@@ -21,6 +21,7 @@
 
 # Disable by default so "m cts" will work in emulator builds
 LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
 
 include $(BUILD_PACKAGE)
 
diff --git a/tests/deviceadmin/AndroidManifest.xml b/tests/deviceadmin/AndroidManifest.xml
index 69bc74d..2395d99 100644
--- a/tests/deviceadmin/AndroidManifest.xml
+++ b/tests/deviceadmin/AndroidManifest.xml
@@ -40,6 +40,17 @@
             </intent-filter>
         </receiver>
 
+        <!-- Device Admin that needs to be in the deactivated state in order
+             for tests to pass. -->
+        <receiver android:name="android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver"
+                android:permission="android.permission.BIND_DEVICE_ADMIN">
+            <meta-data android:name="android.app.device_admin"
+                    android:resource="@xml/device_admin" />
+            <intent-filter>
+                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
+            </intent-filter>
+        </receiver>
+
         <!-- Helper Activity used by Device Admin activation tests -->
         <activity android:name="android.deviceadmin.cts.CtsDeviceAdminActivationTestActivity"
                 android:label="Device Admin activation test" />
diff --git a/tests/deviceadmin/src/android/deviceadmin/cts/CtsDeviceAdminDeactivatedReceiver.java b/tests/deviceadmin/src/android/deviceadmin/cts/CtsDeviceAdminDeactivatedReceiver.java
new file mode 100644
index 0000000..ec59f63
--- /dev/null
+++ b/tests/deviceadmin/src/android/deviceadmin/cts/CtsDeviceAdminDeactivatedReceiver.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.deviceadmin.cts;
+
+import android.app.admin.DeviceAdminReceiver;
+
+public class CtsDeviceAdminDeactivatedReceiver extends DeviceAdminReceiver {
+}
diff --git a/tests/tests/admin/src/android/admin/cts/DeviceAdminActivationTest.java b/tests/tests/admin/src/android/admin/cts/DeviceAdminActivationTest.java
index 7e09989..cb0425a 100644
--- a/tests/tests/admin/src/android/admin/cts/DeviceAdminActivationTest.java
+++ b/tests/tests/admin/src/android/admin/cts/DeviceAdminActivationTest.java
@@ -19,13 +19,14 @@
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
 import android.content.ComponentName;
+import android.content.Context;
 import android.content.Intent;
 import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver;
 import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver2;
 import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver3;
 import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver4;
 import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver5;
-import android.deviceadmin.cts.CtsDeviceAdminReceiver;
+import android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver;
 import android.deviceadmin.cts.CtsDeviceAdminActivationTestActivity;
 import android.deviceadmin.cts.CtsDeviceAdminActivationTestActivity.OnActivityResultListener;
 import android.os.SystemClock;
@@ -98,37 +99,49 @@
     }
 
     public void testActivateGoodReceiverDisplaysActivationUi() throws Exception {
-        startAddDeviceAdminActivityForResult(CtsDeviceAdminReceiver.class);
+        assertDeviceAdminDeactivated(CtsDeviceAdminDeactivatedReceiver.class);
+        startAddDeviceAdminActivityForResult(CtsDeviceAdminDeactivatedReceiver.class);
         assertWithTimeoutOnActivityResultNotInvoked();
         // The UI is up and running. Assert that dismissing the UI returns the corresponding result
         // to the test activity.
         finishActivateDeviceAdminActivity();
         assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+        assertDeviceAdminDeactivated(CtsDeviceAdminDeactivatedReceiver.class);
     }
 
     public void testActivateBrokenReceiverFails() throws Exception {
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver.class);
         startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver.class);
         assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver.class);
     }
 
     public void testActivateBrokenReceiver2Fails() throws Exception {
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver2.class);
         startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver2.class);
         assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver2.class);
     }
 
     public void testActivateBrokenReceiver3Fails() throws Exception {
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver3.class);
         startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver3.class);
         assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver3.class);
     }
 
     public void testActivateBrokenReceiver4Fails() throws Exception {
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver4.class);
         startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver4.class);
         assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver4.class);
     }
 
     public void testActivateBrokenReceiver5Fails() throws Exception {
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver5.class);
         startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver5.class);
         assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+        assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver5.class);
     }
 
     private void startAddDeviceAdminActivityForResult(Class<?> receiverClass) {
@@ -179,4 +192,12 @@
     private void finishActivateDeviceAdminActivity() {
         getActivity().finishActivity(REQUEST_CODE_ACTIVATE_ADMIN);
     }
+
+    private void assertDeviceAdminDeactivated(Class<?> receiverClass) {
+        DevicePolicyManager devicePolicyManager =
+                (DevicePolicyManager) getActivity().getSystemService(
+                        Context.DEVICE_POLICY_SERVICE);
+        assertFalse(devicePolicyManager.isAdminActive(
+                new ComponentName(getInstrumentation().getTargetContext(), receiverClass)));
+    }
 }
diff --git a/tests/tests/media/res/raw/monotestm4a.m4a b/tests/tests/media/res/raw/monotestm4a.m4a
new file mode 100644
index 0000000..9ef6651
--- /dev/null
+++ b/tests/tests/media/res/raw/monotestm4a.m4a
Binary files differ
diff --git a/tests/tests/media/res/raw/monotestmp3.mp3 b/tests/tests/media/res/raw/monotestmp3.mp3
new file mode 100644
index 0000000..43a8ac3
--- /dev/null
+++ b/tests/tests/media/res/raw/monotestmp3.mp3
Binary files differ
diff --git a/tests/tests/media/res/raw/monotestogg.ogg b/tests/tests/media/res/raw/monotestogg.ogg
new file mode 100644
index 0000000..3dc5644
--- /dev/null
+++ b/tests/tests/media/res/raw/monotestogg.ogg
Binary files differ
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index 077c9f3..8fbee93 100644
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -87,6 +87,38 @@
         decode(R.raw.sinesweepflac, 0.0f, true);
     }
 
+    public void testDecodeMonoMp3() throws Exception {
+        monoTest(R.raw.monotestmp3);
+    }
+
+    public void testDecodeMonoM4a() throws Exception {
+        monoTest(R.raw.monotestm4a);
+    }
+
+    public void testDecodeMonoOgg() throws Exception {
+        monoTest(R.raw.monotestogg);
+    }
+
+    private void monoTest(int res) throws Exception {
+        short [] mono = decodeToMemory(res, false);
+        if (mono.length == 44100) {
+            // expected
+            return;
+        } else if (mono.length == 88200) {
+            // the decoder output 2 channels instead of 1, check that the left and right channel
+            // are identical
+            for (int i = 0; i < mono.length; i += 2) {
+                assertEquals("mismatched samples at " + i, mono[i], mono[i+1]);
+            }
+        } else {
+            fail("wrong number of samples: " + mono.length);
+        }
+
+        // we should get the same data when reconfiguring the codec
+        short [] mono2 = decodeToMemory(res, true);
+        Arrays.equals(mono, mono2);
+    }
+
     /**
      * @param testinput the file to decode
      * @param maxerror the maximum allowed root mean squared error
@@ -874,6 +906,6 @@
         }
         return maxvalue; 
     }
-    
+
 }
 
diff --git a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
index a3c9454..1d78967 100644
--- a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
@@ -96,7 +96,7 @@
                 + "&sparams=ip,ipbits,expire,id,itag,source"
                 + "&signature=3CFCAFB87EB9FC943FACDC54FEC8C725A801642C."
                 + "7D77ACBC4CAF40349BF093E302B635757E45F345"
-                + "&key=test_key1&user=android-device-test", 480, 270);
+                + "&key=test_key1&user=android-device-test", 640, 360);
     }
     public void testHTTP_H264Base_AAC_Video2() throws Exception {
         playVideoTest("http://redirector.c.youtube.com/videoplayback?id=c80658495af60617"
@@ -104,7 +104,7 @@
                 + "&sparams=ip,ipbits,expire,id,itag,source"
                 + "&signature=A11D8BA0AA67A27F1409BE0C0B96B756625DB88B."
                 + "9BF4C93A130583ADBDF2B953AD5A8A58F518B012"
-                + "&key=test_key1&user=android-device-test", 480, 270);
+                + "&key=test_key1&user=android-device-test", 640, 360);
     }
 
     // Streaming HLS video from YouTube
diff --git a/tests/tests/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java b/tests/tests/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
index 70ab54d..ceb74d1 100644
--- a/tests/tests/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
+++ b/tests/tests/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
@@ -86,9 +86,9 @@
     }
 
     // a host and port that are expected to be available but have
-    // a cert with a different CN, in this case CN=mtalk.google.com
-    private static String TEST_CREATE_SOCKET_HOST = "mobile-gtalk.l.google.com";
-    private static int TEST_CREATE_SOCKET_PORT = 5228;
+    // a cert with a different CN, in this case CN=mail.google.com
+    private static String TEST_CREATE_SOCKET_HOST = "googlemail.com";
+    private static int TEST_CREATE_SOCKET_PORT = 443;
 
     /**
      * b/2807618 Make sure that hostname verifcation in cases were it
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index 48c03b9..3f37249 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -704,7 +704,9 @@
                 new File("/dev/tty"),
                 new File("/dev/urandom"),
                 new File("/dev/xt_qtaguid"),  // b/9088251
-                new File("/dev/zero")
+                new File("/dev/zero"),
+                new File("/dev/fimg2d"),      // b/10428016
+                new File("/dev/mobicore-user") // b/10428016
             ));
 
     public void testAllCharacterDevicesAreSecure() throws Exception {
@@ -716,6 +718,24 @@
                 insecure.isEmpty());
     }
 
+    public void testDevRandomWorldReadableAndWritable() throws Exception {
+        FileUtils.FileStatus status = new FileUtils.FileStatus();
+        assertTrue(FileUtils.getFileStatus("/dev/random", status, false));
+        assertTrue(
+                "/dev/random not world-readable/writable. Actual mode: 0"
+                        + Integer.toString(status.mode, 8),
+                (status.mode & 0666) == 0666);
+    }
+
+    public void testDevUrandomWorldReadableAndWritable() throws Exception {
+        FileUtils.FileStatus status = new FileUtils.FileStatus();
+        assertTrue(FileUtils.getFileStatus("/dev/urandom", status, false));
+        assertTrue(
+                "/dev/urandom not world-readable/writable. Actual mode: 0"
+                        + Integer.toString(status.mode, 8),
+                (status.mode & 0666) == 0666);
+    }
+
     private static Set<File>
     getAllInsecureDevicesInDirAndSubdir(File dir, int type) throws Exception {
         assertTrue(dir.isDirectory());
diff --git a/tests/tests/provider/src/android/provider/cts/CalendarTest.java b/tests/tests/provider/src/android/provider/cts/CalendarTest.java
index 3c10d0c..bd8e06d 100644
--- a/tests/tests/provider/src/android/provider/cts/CalendarTest.java
+++ b/tests/tests/provider/src/android/provider/cts/CalendarTest.java
@@ -1965,6 +1965,10 @@
         assertTrue(eventId >= 0);
         return eventValues;
       }
+
+      public long getCalendarId() {
+        return mCalendarId;
+      }
     }
 
     /**
@@ -2000,7 +2004,8 @@
           CalendarContract.Instances.CONTENT_BY_DAY_URI, julianStart + "/" + julianEnd);
 
       // Query the range, sorting by event start time
-      Cursor c = mContentResolver.query(uri, null, null, null, Events.DTSTART);
+      Cursor c = mContentResolver.query(uri, null, Instances.CALENDAR_ID + "="
+              + helper.getCalendarId(), null, Events.DTSTART);
 
       // Assert that two events are returned
       assertEquals(c.getCount(), 2);
diff --git a/tests/tests/provider/src/android/provider/cts/MediaStore_FilesTest.java b/tests/tests/provider/src/android/provider/cts/MediaStore_FilesTest.java
index 79b2e57..70d6f58 100644
--- a/tests/tests/provider/src/android/provider/cts/MediaStore_FilesTest.java
+++ b/tests/tests/provider/src/android/provider/cts/MediaStore_FilesTest.java
@@ -21,6 +21,7 @@
 import android.content.ContentResolver;
 import android.content.ContentUris;
 import android.content.ContentValues;
+import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
 import android.os.Environment;
@@ -30,6 +31,8 @@
 import android.test.AndroidTestCase;
 
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
 import java.io.IOException;
 
 public class MediaStore_FilesTest extends AndroidTestCase {
@@ -150,6 +153,133 @@
         }
     }
 
+    public void testAccess() throws IOException {
+        // clean up from previous run
+        mResolver.delete(MediaStore.Images.Media.INTERNAL_CONTENT_URI,
+                "_data NOT LIKE ?", new String[] { "/system/%" } );
+
+        // insert some dummy starter data into the provider
+        ContentValues values = new ContentValues();
+        values.put(MediaStore.Images.Media.DISPLAY_NAME, "My Bitmap");
+        values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
+        values.put(MediaStore.Images.Media.DATA, "/mnt/sdcard/dummy.jpg");
+        Uri uri = mResolver.insert(MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
+
+        // point _data at directory and try to get an fd for it
+        values = new ContentValues();
+        values.put("_data", "/data/media");
+        mResolver.update(uri, values, null, null);
+        ParcelFileDescriptor pfd = null;
+        try {
+            pfd = mResolver.openFileDescriptor(uri, "r");
+            pfd.close();
+            fail("shouldn't be here");
+        } catch (FileNotFoundException e) {
+            // expected
+        }
+
+        // try to create a file in a place we don't have access to
+        values = new ContentValues();
+        values.put("_data", "/data/media/test.dat");
+        mResolver.update(uri, values, null, null);
+        try {
+            pfd = mResolver.openFileDescriptor(uri, "w");
+            pfd.close();
+            fail("shouldn't be here");
+        } catch (FileNotFoundException e) {
+            // expected
+        }
+        // read file back
+        try {
+            pfd = mResolver.openFileDescriptor(uri, "r");
+            pfd.close();
+            fail("shouldn't be here");
+        } catch (FileNotFoundException e) {
+            // expected
+        }
+
+        // point _data at media database and read it
+        values = new ContentValues();
+        values.put("_data", "/data/data/com.android.providers.media/databases/internal.db");
+        mResolver.update(uri, values, null, null);
+        try {
+            pfd = mResolver.openFileDescriptor(uri, "r");
+            pfd.close();
+            fail("shouldn't be here");
+        } catch (FileNotFoundException e) {
+            // expected
+        }
+
+        // Insert a private file into the database. Since it's private, the media provider won't
+        // be able to open it
+        FileOutputStream fos = mContext.openFileOutput("dummy.dat", Context.MODE_PRIVATE);
+        fos.write(0);
+        fos.close();
+        File path = mContext.getFileStreamPath("dummy.dat");
+        values = new ContentValues();
+        values.put("_data", path.getAbsolutePath());
+
+        mResolver.update(uri, values, null, null);
+        try {
+            pfd = mResolver.openFileDescriptor(uri, "r");
+            pfd.close();
+            fail("shouldn't be here");
+        } catch (FileNotFoundException e) {
+            // expected
+        }
+        // now make the file world-readable
+        fos = mContext.openFileOutput("dummy.dat", Context.MODE_WORLD_READABLE);
+        fos.write(0);
+        fos.close();
+        try {
+            pfd = mResolver.openFileDescriptor(uri, "r");
+            pfd.close();
+        } catch (FileNotFoundException e) {
+            fail("failed to open file");
+        }
+        path.delete();
+
+        File sdfile = null;
+        if (Environment.isExternalStorageEmulated()) {
+            // create file on sdcard and check access via real path
+            String fileDir = Environment.getExternalStorageDirectory() +
+                    "/" + getClass().getCanonicalName() + "/test.mp3";
+            sdfile = new File(fileDir);
+            writeFile(R.raw.testmp3, sdfile.getCanonicalPath());
+            assertTrue(sdfile.exists());
+            values = new ContentValues();
+            values.put("_data", sdfile.getCanonicalPath());
+            mResolver.update(uri, values, null, null);
+            try {
+                pfd = mResolver.openFileDescriptor(uri, "r");
+
+                // get the real path from the file descriptor
+                File real = new File("/proc/self/fd/" + pfd.getFd());
+                values = new ContentValues();
+                values.put("_data", real.getCanonicalPath());
+                mResolver.update(uri, values, null, null);
+                pfd.close();
+
+                // we shouldn't be able to access this
+                try {
+                    pfd = mResolver.openFileDescriptor(uri, "r");
+                    pfd.close();
+                    fail("shouldn't be here");
+                } catch (FileNotFoundException e) {
+                    // expected
+                }
+            } catch (FileNotFoundException e) {
+                fail("couldn't open file");
+            }
+        }
+
+        // clean up
+        assertEquals(1, mResolver.delete(uri, null, null));
+        if (sdfile != null) {
+            sdfile.delete();
+        }
+    }
+
     private void writeFile(int resid, String path) throws IOException {
         File out = new File(path);
         File dir = out.getParentFile();
diff --git a/tests/tests/provider/src/android/provider/cts/VoicemailContractTest.java b/tests/tests/provider/src/android/provider/cts/VoicemailContractTest.java
index ffb60f4..34a546e 100644
--- a/tests/tests/provider/src/android/provider/cts/VoicemailContractTest.java
+++ b/tests/tests/provider/src/android/provider/cts/VoicemailContractTest.java
@@ -21,6 +21,7 @@
 import android.content.ContentValues;
 import android.database.Cursor;
 import android.net.Uri;
+import android.os.RemoteException;
 import android.provider.VoicemailContract;
 import android.provider.VoicemailContract.Status;
 import android.provider.VoicemailContract.Voicemails;
@@ -140,6 +141,66 @@
         cursor.close();
     }
 
+    // Data column should be automatically generated during insert.
+    public void testInsert_doesNotUpdateDataColumn() throws Exception {
+
+        final String newFilePath = "my/new/file/path";
+        final ContentValues value = buildContentValuesForNewVoicemail();
+        value.put(Voicemails._DATA, newFilePath);
+        mVoicemailProvider.insert(mVoicemailContentUri, value);
+
+        assertDataNotEquals(newFilePath);
+    }
+
+    public void testDataColumnUpdate_throwsIllegalArgumentException() throws Exception {
+
+        final ContentValues value = buildContentValuesForNewVoicemail();
+        final Uri uri = mVoicemailProvider.insert(mVoicemailContentUri, value);
+
+        // Test: update
+        final String newFilePath = "another/file/path";
+
+        value.clear();
+        value.put(Voicemails._DATA, newFilePath);
+        try {
+            mVoicemailProvider.update(uri, value, null, null);
+            fail("IllegalArgumentException expected but not thrown.");
+        } catch (IllegalArgumentException e) {
+            // pass
+        }
+
+        assertDataNotEquals(newFilePath);
+    }
+
+    private void assertDataNotEquals(String newFilePath) throws RemoteException {
+        // Make sure data value is not actually updated.
+        final Cursor cursor = mVoicemailProvider.query(mVoicemailContentUri,
+                new String[]{Voicemails._DATA}, null, null, null);
+        cursor.moveToNext();
+        final String data = cursor.getString(0);
+        assertFalse(data.equals(newFilePath));
+    }
+
+    private ContentValues buildContentValuesForNewVoicemail() {
+        final String insertCallsNumber = "0123456789";
+        final long insertCallsDuration = 120;
+        final String insertSourceData = "internal_id";
+        final String insertMimeType = "audio/mp3";
+        final long insertDate = 1324478862000L;
+
+        ContentValues value = new ContentValues();
+        value.put(Voicemails.NUMBER, insertCallsNumber);
+        value.put(Voicemails.DATE, insertDate);
+        value.put(Voicemails.DURATION, insertCallsDuration);
+        // Source package is expected to be inserted by the provider, if not set.
+        value.put(Voicemails.SOURCE_DATA, insertSourceData);
+        value.put(Voicemails.MIME_TYPE, insertMimeType);
+        value.put(Voicemails.IS_READ, false);
+        value.put(Voicemails.HAS_CONTENT, true);
+
+        return value;
+    }
+
     public void testStatusTable() throws Exception {
         final String[] STATUS_PROJECTION = new String[] {
                 Status._ID, Status.SOURCE_PACKAGE, Status.CONFIGURATION_STATE,
diff --git a/tests/tests/security/Android.mk b/tests/tests/security/Android.mk
index f36be9d..43b615f 100644
--- a/tests/tests/security/Android.mk
+++ b/tests/tests/security/Android.mk
@@ -24,7 +24,8 @@
 
 LOCAL_JNI_SHARED_LIBRARIES := libctssecurity_jni
 
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+    src/android/security/cts/activity/ISecureRandomService.aidl
 
 LOCAL_PACKAGE_NAME := CtsSecurityTestCases
 
diff --git a/tests/tests/security/AndroidManifest.xml b/tests/tests/security/AndroidManifest.xml
index 6c2c87a..2048de9 100644
--- a/tests/tests/security/AndroidManifest.xml
+++ b/tests/tests/security/AndroidManifest.xml
@@ -19,12 +19,17 @@
     package="com.android.cts.security">
 
     <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
+
     <application>
         <uses-library android:name="android.test.runner" />
+
+        <service android:name="android.security.cts.activity.SecureRandomService"
+                 android:process=":secureRandom"/>
     </application>
 
     <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
-                     android:targetPackage="com.android.cts.stub"
+                     android:targetPackage="com.android.cts.security"
                      android:label="CTS tests of com.android.cts.security"/>
 
 </manifest>
diff --git a/tests/tests/security/jni/Android.mk b/tests/tests/security/jni/Android.mk
index 5821ec0..06172c5 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -24,7 +24,8 @@
 LOCAL_SRC_FILES := \
 		CtsSecurityJniOnLoad.cpp \
 		android_security_cts_CharDeviceTest.cpp \
-		android_security_cts_NativeCodeTest.cpp
+		android_security_cts_LinuxRngTest.cpp \
+		android_security_cts_NativeCodeTest.cpp \
 
 LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
 
diff --git a/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp b/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
index 7244fc2..7577eef 100644
--- a/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
+++ b/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
@@ -18,6 +18,7 @@
 #include <stdio.h>
 
 extern int register_android_security_cts_CharDeviceTest(JNIEnv*);
+extern int register_android_security_cts_LinuxRngTest(JNIEnv*);
 extern int register_android_security_cts_NativeCodeTest(JNIEnv*);
 
 jint JNI_OnLoad(JavaVM *vm, void *reserved) {
@@ -31,6 +32,10 @@
         return JNI_ERR;
     }
 
+    if (register_android_security_cts_LinuxRngTest(env)) {
+        return JNI_ERR;
+    }
+
     if (register_android_security_cts_NativeCodeTest(env)) {
         return JNI_ERR;
     }
diff --git a/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp b/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
new file mode 100644
index 0000000..671226b
--- /dev/null
+++ b/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <errno.h>
+#include <jni.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+/*
+ * Native methods used by
+ * cts/tests/tests/permission/src/android/security/cts/LinuxRngTest.java
+ */
+
+static void throwIOException(JNIEnv* env, const char *format, ...) {
+    va_list ap;
+    va_start(ap, format);
+
+    char *message;
+    vasprintf(&message, format, ap);
+
+    va_end(ap);
+
+    jclass cls = env->FindClass("java/io/IOException");
+    env->ThrowNew(cls, message);
+
+    free(message);
+}
+
+jint android_security_cts_LinuxRngTest_getCharDeviceMajor(JNIEnv* env,
+        jobject thiz, jstring name)
+{
+    const char* nameStr = env->GetStringUTFChars(name, NULL);
+
+    jint result = -1;
+    struct stat st;
+    if (stat(nameStr, &st) == -1) {
+        throwIOException(env, "Failed to stat %s: %s", nameStr, strerror(errno));
+        goto ret;
+    }
+
+    if (!S_ISCHR(st.st_mode)) {
+        throwIOException(env, "%s is not a character device: mode is 0%o", nameStr, st.st_mode);
+        goto ret;
+    }
+
+    result = major(st.st_rdev);
+
+ret:
+    if (nameStr != NULL) {
+        env->ReleaseStringUTFChars(name, nameStr);
+    }
+    return result;
+}
+
+jint android_security_cts_LinuxRngTest_getCharDeviceMinor(JNIEnv* env,
+        jobject thiz, jstring name)
+{
+    const char* nameStr = env->GetStringUTFChars(name, NULL);
+
+    jint result = -1;
+    struct stat st;
+    if (stat(nameStr, &st) == -1) {
+        throwIOException(env, "Failed to stat %s: %s", nameStr, strerror(errno));
+        goto ret;
+    }
+
+    if (!S_ISCHR(st.st_mode)) {
+        throwIOException(env, "%s is not a character device: mode is 0%o", nameStr, st.st_mode);
+        goto ret;
+    }
+
+    result = minor(st.st_rdev);
+
+ret:
+    if (nameStr != NULL) {
+        env->ReleaseStringUTFChars(name, nameStr);
+    }
+    return result;
+}
+
+static JNINativeMethod gMethods[] = {
+    {  "getCharDeviceMajor", "(Ljava/lang/String;)I",
+            (void *) android_security_cts_LinuxRngTest_getCharDeviceMajor },
+    {  "getCharDeviceMinor", "(Ljava/lang/String;)I",
+            (void *) android_security_cts_LinuxRngTest_getCharDeviceMinor },
+};
+
+int register_android_security_cts_LinuxRngTest(JNIEnv* env)
+{
+    jclass clazz = env->FindClass("android/security/cts/LinuxRngTest");
+    return env->RegisterNatives(clazz, gMethods,
+            sizeof(gMethods) / sizeof(JNINativeMethod));
+}
diff --git a/tests/tests/security/src/android/security/cts/ClonedSecureRandomTest.java b/tests/tests/security/src/android/security/cts/ClonedSecureRandomTest.java
new file mode 100644
index 0000000..e51b11c
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/ClonedSecureRandomTest.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import android.app.ActivityManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+import android.security.cts.activity.ISecureRandomService;
+import android.security.cts.activity.SecureRandomService;
+import android.test.AndroidTestCase;
+
+import java.io.BufferedReader;
+import java.io.EOFException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class ClonedSecureRandomTest extends AndroidTestCase {
+    private static final int ANSWER_TIMEOUT_SECONDS = 60;
+
+    private static final String SEPARATE_PROCESS_NAME = ":secureRandom";
+
+    private static final int MAX_PID = 32768;
+
+    /**
+     * Attempt to burn through PIDs faster after this many iterations to reach a
+     * wrap-around point faster.
+     */
+    private static final int PRIMING_ITERATIONS = 128;
+
+    private static final int RANDOM_BYTES_PER_PID = 8;
+
+    private static final int MAX_PIDS_WASTED = 1024;
+
+    private static final int PID_WASTING_SKIP_LOWER = 64;
+
+    private static final int PID_WASTING_SKIP_UPPER = 2048;
+
+    private volatile CountDownLatch mLatch;
+
+    private Intent mSeparateIntent;
+
+    private ISecureRandomService mSecureRandomService;
+
+    private ServiceConnection mServiceConnection = new ServiceConnection() {
+        public void onServiceConnected(ComponentName className, IBinder service) {
+            mSecureRandomService = ISecureRandomService.Stub.asInterface(service);
+            mLatch.countDown();
+        }
+
+        public void onServiceDisconnected(ComponentName className) {
+        }
+    };
+
+    private boolean mHasDisconnected;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mSeparateIntent = new Intent(getContext(), SecureRandomService.class);
+    }
+
+    /**
+     * This test spawns a Service in a new process to check the initial state of
+     * SecureRandom. It then attempts to make the PID number wrap around so it
+     * sees a new process with the same PID twice. The test completes when it
+     * sees two newly started processes with the same PID and compares their
+     * output.
+     */
+    public void testCheckForDuplicateOutput() throws Exception {
+        assertEquals("Only supports up to " + MAX_PID + " because of memory requirements",
+                Integer.toString(MAX_PID), getFirstLineFromFile("/proc/sys/kernel/pid_max"));
+
+        final String packageName = getContext().getPackageName();
+        String separateProcessName = packageName + SEPARATE_PROCESS_NAME;
+
+        /*
+         * Using a byte[][] and BitSet gives us a fixed upper bound for the
+         * memory cost of this test. One could possibly use a SparseArray if the
+         * upper bound becomes too large (for instance, if PID_MAX is large),
+         * only keep track of a smaller number of outputs, and just cause a
+         * wrap-around of PIDs to keep the test working.
+         */
+        byte[][] outputs = new byte[MAX_PID][RANDOM_BYTES_PER_PID];
+        BitSet seenPids = new BitSet(MAX_PID);
+
+        ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+
+        int myPid = android.os.Process.myPid();
+
+        /*
+         * We're guaranteed to see at least one duplicate if we iterate MAX_PID
+         * number of times because of the pigeonhole principle. In an attempt to
+         * hit a collision faster, first get a closely-spaced sampling of PIDs
+         * then spin up a bunch of threads locally to get us closer to wrapping
+         * around to the first PID.
+         */
+        int firstPid = -1;
+        int previousPid = -1;
+        for (int i = 0; i < MAX_PID; i++) {
+            byte[] output = new byte[RANDOM_BYTES_PER_PID];
+            int pid;
+
+            mLatch = new CountDownLatch(1);
+            getContext().startService(mSeparateIntent);
+            getContext().bindService(mSeparateIntent, mServiceConnection, 0);
+            if (!mLatch.await(ANSWER_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
+                fail("Timeout waiting for answer from SecureRandomService; cannot complete test");
+            }
+
+            pid = mSecureRandomService.getRandomBytesAndPid(output);
+
+            getContext().unbindService(mServiceConnection);
+            getContext().stopService(mSeparateIntent);
+            am.killBackgroundProcesses(packageName);
+
+            /*
+             * Make sure the AndroidManifest.xml wasn't altered in a way that
+             * breaks the test.
+             */
+            assertFalse("SecureRandomService must run in a different process. Check "
+                    + "AndroidManifest.xml to ensure it has a unique android:process=\"...\"",
+                    myPid == pid);
+
+            // We didn't get a new process for some reason. Try again.
+            if (previousPid == pid) {
+                i--;
+                continue;
+            } else if (previousPid == -1 && firstPid == -1) {
+                /*
+                 * The first time around, we'll discard the output. This is
+                 * needed because we don't know if the SecureRandomService instance
+                 * has been running before or not. To be consistent, we only
+                 * want the first outputs from SecureRandom for this test.
+                 */
+                i--;
+                previousPid = pid;
+                continue;
+            } else {
+                previousPid = pid;
+            }
+
+            if (seenPids.get(pid)) {
+                assertFalse("SecureRandom should not output the same value twice (pid=" + pid
+                                + ", output=" + Arrays.toString(output) + ", outputs[pid]="
+                                + Arrays.toString(outputs[pid]) + ")",
+                        Arrays.equals(output, outputs[pid]));
+                return;
+            }
+
+            seenPids.set(pid);
+            System.arraycopy(output, 0, outputs[pid], 0, output.length);
+
+            if (firstPid == -1) {
+                firstPid = pid;
+            }
+
+            if (i > PRIMING_ITERATIONS) {
+                wastePids(firstPid, previousPid);
+            }
+        }
+
+        /*
+         * This should never be reached unless the test was altered to break it.
+         * Since we're looping until we see PID_MAX unique answers, we must have
+         * seen a duplicate by the pigeonhole principle.
+         */
+        fail("Must see a duplicate PID");
+    }
+
+    /**
+     * This is an attempt to get the PIDs to roll over faster. Threads use up
+     * PIDs on Android and spawning a new thread is much faster than having
+     * another service spawned as we are doing in this test.
+     */
+    private static void wastePids(int firstPid, int previousPid) {
+        int distance = (firstPid - previousPid + MAX_PID) % MAX_PID;
+
+        // Don't waste PIDs if we're close to wrap-around to improve odds of
+        // collision.
+        if ((distance < PID_WASTING_SKIP_LOWER) || (MAX_PID - distance < PID_WASTING_SKIP_UPPER)) {
+            return;
+        }
+
+        for (int i = 0; i < distance; i++) {
+            Thread t = new Thread();
+            t.start();
+        }
+    }
+
+    private static String getFirstLineFromFile(String filename) throws IOException {
+        BufferedReader in = null;
+        try {
+            in = new BufferedReader(new FileReader(filename));
+            final String line = in.readLine();
+            if (line == null) {
+                throw new EOFException("EOF encountered before reading first line of " + filename);
+            }
+            return line.trim();
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+    }
+}
diff --git a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
index f8ee283..bc60a65 100644
--- a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
+++ b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
@@ -31,6 +31,17 @@
 public class KernelSettingsTest extends TestCase {
 
     /**
+     * Ensure that SELinux is not in enforcing mode.
+     */
+    public void testSELinuxEnforcing() throws IOException {
+        try {
+            assertEquals("0", getFile("/sys/fs/selinux/enforce"));
+        } catch (FileNotFoundException e) {
+            // SELinux is not compiled into the kernel. Ignore exception.
+        }
+    }
+
+    /**
      * Protect against kernel based NULL pointer attacks by enforcing a
      * minimum (and maximum!) value of mmap_min_addr.
      *
@@ -88,27 +99,6 @@
     }
 
     /**
-     * Assert that support for loadable modules is not compiled into the
-     * kernel.
-     *
-     * Loadable modules are often used to implement rootkit like functionality.
-     * In addition, loadable modules enable support for /proc/sys/kernel/modprobe,
-     * which is commonly used by exploit writers to gain root access.
-     *
-     * Support for loadable modules can be removed by editing the Linux kernel
-     * config and removing the CONFIG_MODULES option.
-     */
-    public void testNoLoadableModules() throws IOException {
-        assertFalse(
-            "Support for loadable modules is compiled into the kernel. "
-                + "Loadable modules are often used by rootkits and other "
-                + "exploits and should be disabled. Please remove "
-                + "CONFIG_MODULES from your kernel config and compile "
-                + "all modules directly into the kernel.",
-            new File("/proc/sys/kernel/modprobe").exists());
-    }
-
-    /**
      * Assert that the kernel config file is not compiled into the kernel.
      *
      * Compiling the config file into the kernel leaks the kernel base address
diff --git a/tests/tests/security/src/android/security/cts/LinuxRngTest.java b/tests/tests/security/src/android/security/cts/LinuxRngTest.java
new file mode 100644
index 0000000..6bc5fd3
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/LinuxRngTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+
+public class LinuxRngTest extends TestCase {
+    static {
+        System.loadLibrary("ctssecurity_jni");
+    }
+
+    public void testDevRandomMajorMinor() throws Exception {
+        // Based on Linux kernel's drivers/char/random.c
+        assertEquals("/dev/random major", 1, getCharDeviceMajor("/dev/random"));
+        assertEquals("/dev/random minor", 8, getCharDeviceMinor("/dev/random"));
+    }
+
+    public void testDevUrandomMajorMinor() throws Exception {
+        // Based on Linux kernel's drivers/char/random.c
+        assertEquals("/dev/urandom major", 1, getCharDeviceMajor("/dev/urandom"));
+        assertEquals("/dev/urandom minor", 9, getCharDeviceMinor("/dev/urandom"));
+    }
+
+    public static native int getCharDeviceMajor(String file) throws IOException;
+    public static native int getCharDeviceMinor(String file) throws IOException;
+}
diff --git a/tests/tests/security/src/android/security/cts/activity/ISecureRandomService.aidl b/tests/tests/security/src/android/security/cts/activity/ISecureRandomService.aidl
new file mode 100644
index 0000000..af264c9
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/activity/ISecureRandomService.aidl
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts.activity;
+
+interface ISecureRandomService {
+    int getRandomBytesAndPid(inout byte[] randomBytes);
+}
diff --git a/tests/tests/security/src/android/security/cts/activity/SecureRandomService.java b/tests/tests/security/src/android/security/cts/activity/SecureRandomService.java
new file mode 100644
index 0000000..2d425b3
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/activity/SecureRandomService.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.security.cts.activity;
+
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.security.cts.activity.ISecureRandomService;
+
+import android.app.Service;
+import android.content.Intent;
+
+import java.security.SecureRandom;
+
+public class SecureRandomService extends Service {
+    /**
+     * This helps the process shut down a little faster and get us a new
+     * PID earlier than calling stopService.
+     */
+    private Handler mShutdownHandler = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            stopSelf();
+        }
+    };
+
+    private final ISecureRandomService.Stub mBinder = new ISecureRandomService.Stub() {
+
+        /**
+         * Returns output from SecureRandom and the current process PID. Note
+         * that this should only be called once. To ensure that it's only called
+         * once, this will throw an error if it's called twice in a row.
+         */
+        public int getRandomBytesAndPid(byte[] randomBytes) {
+            mShutdownHandler.sendEmptyMessage(-1);
+
+            SecureRandom sr = new SecureRandom();
+            sr.nextBytes(randomBytes);
+            return android.os.Process.myPid();
+        }
+    };
+
+    @Override
+    public IBinder onBind(Intent intent) {
+        return mBinder;
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
old mode 100755
new mode 100644
index 8acd0f4..17a109b
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -126,6 +126,7 @@
                     "45008",    // KT
                     "45005",    // SKT Mobility
                     "45002",     // SKT Mobility
+                    "45006",    // LGT
                     // Verizon
                     "310004",
                     "310012",
@@ -160,6 +161,7 @@
                     "30272",    // Rogers
                     "302370",   // Fido
                     "30237",    // Fido
+                    "45006",    // LGT
                     "45008"     // KT
             );
 
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index 08fca45..afb0700 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
     @Option(name="cts-install-path", description="the path to the cts installation to use")
     private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
 
-    public static final String CTS_BUILD_VERSION = "4.3_r1";
+    public static final String CTS_BUILD_VERSION = "4.3_r2";
 
     /**
      * {@inheritDoc}