CTS: TelephonyProviderTest failing

Bug 21207615

The test doesn't run in the context of being the default SMS app. As
a result, the TelephonyProvider code is never actually executed. The
insert call returns a "fake" result and the test interprets that as
failure. The test is commented out for now, until we figure out a way
to run the test as the default SMS app.

Change-Id: I50e2b006f1ff8950247b7fc3cf41d6356414e21b
diff --git a/tests/tests/provider/src/android/provider/cts/TelephonyProviderTest.java b/tests/tests/provider/src/android/provider/cts/TelephonyProviderTest.java
index 0eba9f2..b06ddfa 100644
--- a/tests/tests/provider/src/android/provider/cts/TelephonyProviderTest.java
+++ b/tests/tests/provider/src/android/provider/cts/TelephonyProviderTest.java
@@ -52,32 +52,35 @@
 
     // Test that the TelephonyProvider doesn't allow clients to update _data column data and
     // if they can, that they can't abuse the provider to open an arbitrary file.
-    public void testOpeningAnyFile() {
-        Uri uri = Uri.parse("content://mms/100/part");
-        try {
-            ContentValues values2 = new ContentValues();
-            values2.put("_data", "/dev/urandom");
-            Uri uri2 = mContentResolver.insert(uri, values2);
-            assertEquals("The code was able to insert the _data column", null, uri2);
-            if (uri2 == null) {
-                return;
-            }
-            ContentValues values = new ContentValues();
-            values.put("_data", "/dev/urandom");
-            int rowCnt = mContentResolver.update(uri2, values, null, null);
-            assertEquals("Was able to update the _data column", 0, rowCnt);
-
-            ParcelFileDescriptor pfd = mContentResolver.openFileDescriptor(uri2, "rw");
-            pfd.getFileDescriptor();
-            FileDescriptor fd = pfd.getFileDescriptor();
-            Field fld = fd.getClass().getDeclaredField("descriptor");
-            fld.setAccessible(true);
-            int fint  = fld.getInt(fd);
-            fail("The code was able to abuse the MmsProvider to open any file");
-        } catch(Exception e){
-            e.printStackTrace();
-        }
-    }
+    // --- This test is commented out for now because the test needs to run as if it were
+    // the default SMS app. Until we have a way to do that in the test framework, the test will
+    // fail (i.e. the insert will appear to have succeeded when it really hasn't).
+//    public void testOpeningAnyFile() {
+//        Uri uri = Uri.parse("content://mms/100/part");
+//        try {
+//            ContentValues values2 = new ContentValues();
+//            values2.put("_data", "/dev/urandom");
+//            Uri uri2 = mContentResolver.insert(uri, values2);
+//            assertNull("The code was able to insert the _data column", uri2);
+//            if (uri2 == null) {
+//                return;
+//            }
+//            ContentValues values = new ContentValues();
+//            values.put("_data", "/dev/urandom");
+//            int rowCnt = mContentResolver.update(uri2, values, null, null);
+//            assertEquals("Was able to update the _data column", 0, rowCnt);
+//
+//            ParcelFileDescriptor pfd = mContentResolver.openFileDescriptor(uri2, "rw");
+//            pfd.getFileDescriptor();
+//            FileDescriptor fd = pfd.getFileDescriptor();
+//            Field fld = fd.getClass().getDeclaredField("descriptor");
+//            fld.setAccessible(true);
+//            int fint  = fld.getInt(fd);
+//            fail("The code was able to abuse the MmsProvider to open any file");
+//        } catch(Exception e){
+//            e.printStackTrace();
+//        }
+//    }
 
     // In JB MR1 access to the TelephonyProvider's Carriers table was clamped down and would
     // throw a SecurityException when queried. That was fixed in JB MR2. Verify that 3rd parties