FileDocCategorySizeDatePackage
SmsManagerPermissionTest.javaAPI DocAndroid 5.1 API2983Thu Mar 12 22:22:44 GMT 2015com.android.framework.permission.tests

SmsManagerPermissionTest

public class SmsManagerPermissionTest extends android.test.AndroidTestCase
Verify that SmsManager apis cannot be called without required permissions.

Fields Summary
private static final String
MSG_CONTENTS
private static final short
DEST_PORT
private static final String
DEST_NUMBER
private static final String
SRC_NUMBER
Constructors Summary
Methods Summary
public voidtestSendDataMessage()
Verify that SmsManager.sendDataMessage requires permissions.

Tests Permission: {@link android.Manifest.permission#SEND_SMS}.

        try {
            SmsManager.getDefault().sendDataMessage(SRC_NUMBER, DEST_NUMBER, DEST_PORT,
                    MSG_CONTENTS.getBytes(), null, null);
            fail("SmsManager.sendDataMessage did not throw SecurityException as expected");
        } catch (SecurityException e) {
            // expected
        }
    
public voidtestSendMultipartMessage()
Verify that SmsManager.sendMultipartMessage requires permissions.

Tests Permission: {@link android.Manifest.permission#SEND_MMS}.

        try {
            ArrayList<String> msgParts = new ArrayList<String>(2);
            msgParts.add(MSG_CONTENTS);
            msgParts.add("foo");
            SmsManager.getDefault().sendMultipartTextMessage(SRC_NUMBER, DEST_NUMBER, msgParts,
                    null, null);
            fail("SmsManager.sendMultipartTextMessage did not throw SecurityException as expected");
        } catch (SecurityException e) {
            // expected
        }
    
public voidtestSendTextMessage()
Verify that SmsManager.sendTextMessage requires permissions.

Tests Permission: {@link android.Manifest.permission#SEND_SMS}.


                    
    
       
        try {
            SmsManager.getDefault().sendTextMessage(SRC_NUMBER, DEST_NUMBER, MSG_CONTENTS, null,
                    null);
            fail("SmsManager.sendTextMessage did not throw SecurityException as expected");
        } catch (SecurityException e) {
            // expected
        }