Fill in missing telephony/sms CTS tests.
Test: Add some tests.
Fixes: 154867896
Change-Id: Id3d3160497a22af4354799a20a0820db6a304e3e
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/SmsManagerTest.java
index 474fc72..bc085e8 100755
--- a/tests/tests/telephony/current/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/SmsManagerTest.java
@@ -668,6 +668,27 @@
}
}
+ @Test
+ public void testGetSmsCapacityOnIcc() {
+ try {
+ getSmsManager().getSmsCapacityOnIcc();
+ fail("Caller without READ_PRIVILEGED_PHONE_STATE should NOT be able to call API");
+ } catch (SecurityException se) {
+ // all good
+ }
+
+ InstrumentationRegistry.getInstrumentation().getUiAutomation()
+ .adoptShellPermissionIdentity("android.permission.READ_PRIVILEGED_PHONE_STATE");
+ try {
+ getSmsManager().getSmsCapacityOnIcc();
+ } catch (SecurityException se) {
+ fail("Caller with READ_PRIVILEGED_PHONE_STATE should be able to call API");
+ } finally {
+ InstrumentationRegistry.getInstrumentation().getUiAutomation()
+ .dropShellPermissionIdentity();
+ }
+ }
+
protected ArrayList<String> divideMessage(String text) {
return getSmsManager().divideMessage(text);
}
diff --git a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
index 686f793..97e6f35 100644
--- a/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/current/src/android/telephony/cts/TelephonyManagerTest.java
@@ -2696,6 +2696,32 @@
}
@Test
+ public void testIsApplicationOnUicc() {
+ if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
+ return;
+ }
+
+ // Expect a security exception without permission.
+ try {
+ mTelephonyManager.isApplicationOnUicc(TelephonyManager.APPTYPE_SIM);
+ fail("Expected security exception");
+ } catch (SecurityException se1) {
+ // Expected
+ }
+
+ InstrumentationRegistry.getInstrumentation().getUiAutomation()
+ .adoptShellPermissionIdentity("android.permission.READ_PRIVILEGED_PHONE_STATE");
+ try {
+ mTelephonyManager.isApplicationOnUicc(TelephonyManager.APPTYPE_SIM);
+ } catch (SecurityException se) {
+ fail("Caller with READ_PRIVILEGED_PHONE_STATE should be able to call API");
+ } finally {
+ InstrumentationRegistry.getInstrumentation().getUiAutomation()
+ .dropShellPermissionIdentity();
+ }
+ }
+
+ @Test
public void testGetSupportedModemCount() {
if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) {
return;