Add a CTS test to make sure a SecurityException isn't thrown when accessing the APN table in Telephony provider
Bug 11469154
Change-Id: I974e0b5c907db96241f78664821485aac391440d
diff --git a/tests/tests/provider/Android.mk b/tests/tests/provider/Android.mk
index edc078d..4c5875b 100644
--- a/tests/tests/provider/Android.mk
+++ b/tests/tests/provider/Android.mk
@@ -21,7 +21,7 @@
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
-LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common
LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
diff --git a/tests/tests/provider/src/android/provider/cts/TelephonyProviderTest.java b/tests/tests/provider/src/android/provider/cts/TelephonyProviderTest.java
index a37ef4b..962e3aa 100644
--- a/tests/tests/provider/src/android/provider/cts/TelephonyProviderTest.java
+++ b/tests/tests/provider/src/android/provider/cts/TelephonyProviderTest.java
@@ -18,8 +18,10 @@
import android.content.ContentResolver;
import android.content.ContentValues;
+import android.database.Cursor;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
+import android.provider.Telephony.Carriers;
import android.test.InstrumentationTestCase;
import java.lang.reflect.Field;
@@ -33,6 +35,12 @@
public class TelephonyProviderTest extends InstrumentationTestCase {
private ContentResolver mContentResolver;
+ private static final String[] APN_PROJECTION = {
+ Carriers.TYPE, // 0
+ Carriers.MMSC, // 1
+ Carriers.MMSPROXY, // 2
+ Carriers.MMSPORT // 3
+ };
@Override
protected void setUp() throws Exception {
@@ -68,4 +76,18 @@
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
+ // can access the APN info the carriers table, after JB MR1.
+ public void testAccessToApns() {
+ try {
+ String selection = Carriers.CURRENT + " IS NOT NULL";
+ String[] selectionArgs = null;
+ Cursor cursor = mContentResolver.query(Carriers.CONTENT_URI,
+ APN_PROJECTION, selection, selectionArgs, null);
+ } catch (SecurityException e) {
+ fail("No access to current APN");
+ }
+ }
}