1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package android.telecom.cts; 18 19 import android.content.Context; 20 import android.telecom.TelecomManager; 21 import android.test.InstrumentationTestCase; 22 import android.text.TextUtils; 23 24 /** 25 * Verifies correct operation of TelecomManager APIs when the correct permissions have not been 26 * granted. 27 */ 28 public class TelecomManagerNoPermissionsTest extends InstrumentationTestCase { 29 private Context mContext; 30 private TelecomManager mTelecomManager; 31 32 @Override 33 protected void setUp() throws Exception { 34 super.setUp(); 35 mContext = getInstrumentation().getContext(); 36 if (!TestUtils.shouldTestTelecom(mContext)) { 37 return; 38 } 39 mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); 40 } 41 42 @Override 43 protected void tearDown() throws Exception { 44 super.tearDown(); 45 } 46 47 public void testCannotEndCall() throws Exception { 48 if (!TestUtils.shouldTestTelecom(mContext)) { 49 return; 50 } 51 try { 52 mTelecomManager.endCall(); 53 fail("Shouldn't be able to call endCall without permission grant."); 54 } catch (SecurityException se) { 55 } 56 } 57 } 58