Fix SMSSendConfirmationCheck so that it doesnt fail on tablets or tv's
Skip the test for any device that doesn't have telephony service.
Bug: 31684410
Change-Id: If9bc5c2e2db5d6ca05593736c8d2eb6fc2fedc47
diff --git a/tests/tests/smssendconfirmationcheck/src/android/smssendconfirmationcheck/cts/SMSSendConfirmationCheck.java b/tests/tests/smssendconfirmationcheck/src/android/smssendconfirmationcheck/cts/SMSSendConfirmationCheck.java
index c776050..7d928bd 100755
--- a/tests/tests/smssendconfirmationcheck/src/android/smssendconfirmationcheck/cts/SMSSendConfirmationCheck.java
+++ b/tests/tests/smssendconfirmationcheck/src/android/smssendconfirmationcheck/cts/SMSSendConfirmationCheck.java
@@ -17,10 +17,12 @@
package android.smssendconfirmationcheck.cts;
import android.content.ContentResolver;
+import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.SystemClock;
import android.telephony.SmsManager;
+import android.telephony.TelephonyManager;
import android.test.AndroidTestCase;
public class SMSSendConfirmationCheck extends AndroidTestCase {
@@ -28,10 +30,16 @@
/*
* The following method tries to send a short code SMS via default SMS API (silently). If
* the message is sent (no confirmation displayed to user), the SMS db size will not
- * match the previous db size.
+ * match the previous db size. If SMS is not capable on the device (i.e. a tablet or tv)
+ * this test will always pass.
*/
public void testSMSSendingExploit() throws Exception {
+ TelephonyManager telephonyManager =
+ (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
+ if(!telephonyManager.isSmsCapable()) {
+ return;
+ }
int inboxSizeBeforeExploit = getSMSInboxSize();
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage("25578", null, "STOP", null, null);