Merge "Make sure to skip Telecom CTS tests on unsupported devices" into mnc-dev
diff --git a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
index 323190c..bf063f7 100644
--- a/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
+++ b/tests/tests/telecom/src/android/telecom/cts/BaseTelecomTestWithMockServices.java
@@ -86,13 +86,16 @@
     String mPreviousDefaultDialer = null;
     MockConnectionService connectionService = null;
 
+    boolean mShouldTestTelecom = true;
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         mContext = getInstrumentation().getContext();
         mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
 
-        if (shouldTestTelecom(mContext)) {
+        mShouldTestTelecom = shouldTestTelecom(mContext);
+        if (mShouldTestTelecom) {
             mPreviousDefaultDialer = TestUtils.getDefaultDialer(getInstrumentation());
             TestUtils.setDefaultDialer(getInstrumentation(), PACKAGE);
             setupCallbacks();
@@ -101,7 +104,7 @@
 
     @Override
     protected void tearDown() throws Exception {
-        if (shouldTestTelecom(mContext)) {
+        if (mShouldTestTelecom) {
             cleanupCalls();
             if (!TextUtils.isEmpty(mPreviousDefaultDialer)) {
                 TestUtils.setDefaultDialer(getInstrumentation(), mPreviousDefaultDialer);
diff --git a/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java b/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
index dd93573..879c995 100644
--- a/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/CallDetailsTest.java
@@ -65,7 +65,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        if (TestUtils.shouldTestTelecom(mContext)) {
+        if (mShouldTestTelecom) {
             PhoneAccount account = setupConnectionService(
                     new MockConnectionService() {
                         @Override
@@ -93,23 +93,27 @@
                         }
                     }, FLAG_REGISTER | FLAG_ENABLE);
 
+            /** Place a call as a part of the setup before we test the various
+             *  Call details.
+             */
+            placeAndVerifyCall();
+            verifyConnectionForOutgoingCall();
+
+            mInCallService = mInCallCallbacks.getService();
+            mCall = mInCallService.getLastCall();
+
+            assertCallState(mCall, Call.STATE_DIALING);
         }
-        /** Place a call as a part of the setup before we test the various
-         *  Call details.
-         */
-        placeAndVerifyCall();
-        verifyConnectionForOutgoingCall();
-
-        mInCallService = mInCallCallbacks.getService();
-        mCall = mInCallService.getLastCall();
-
-        assertCallState(mCall, Call.STATE_DIALING);
     }
 
     /**
      * Tests whether the getAccountHandle() getter returns the correct object.
      */
     public void testAccountHandle() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getAccountHandle(), is(PhoneAccountHandle.class));
         assertEquals(TEST_PHONE_ACCOUNT_HANDLE, mCall.getDetails().getAccountHandle());
     }
@@ -118,6 +122,10 @@
      * Tests whether the getCallCapabilities() getter returns the correct object.
      */
     public void testCallCapabilities() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getCallCapabilities(), is(Integer.class));
         assertEquals(CALL_CAPABILITIES, mCall.getDetails().getCallCapabilities());
         assertTrue(mCall.getDetails().can(Call.Details.CAPABILITY_HOLD));
@@ -130,6 +138,10 @@
      * Tests whether the getCallerDisplayName() getter returns the correct object.
      */
     public void testCallerDisplayName() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getCallerDisplayName(), is(String.class));
         assertEquals(CALLER_DISPLAY_NAME, mCall.getDetails().getCallerDisplayName());
     }
@@ -138,6 +150,10 @@
      * Tests whether the getCallerDisplayNamePresentation() getter returns the correct object.
      */
     public void testCallerDisplayNamePresentation() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getCallerDisplayNamePresentation(), is(Integer.class));
         assertEquals(CALLER_DISPLAY_NAME_PRESENTATION, mCall.getDetails().getCallerDisplayNamePresentation());
     }
@@ -146,6 +162,10 @@
      * Tests whether the getCallProperties() getter returns the correct object.
      */
     public void testCallProperties() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getCallProperties(), is(Integer.class));
         assertEquals(CALL_PROPERTIES, mCall.getDetails().getCallProperties());
     }
@@ -154,6 +174,10 @@
      * Tests whether the getConnectTimeMillis() getter returns the correct object.
      */
     public void testConnectTimeMillis() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getConnectTimeMillis(), is(Long.class));
     }
 
@@ -161,6 +185,10 @@
      * Tests whether the getDisconnectCause() getter returns the correct object.
      */
     public void testDisconnectCause() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getDisconnectCause(), is(DisconnectCause.class));
     }
 
@@ -168,6 +196,10 @@
      * Tests whether the getExtras() getter returns the correct object.
      */
     public void testExtras() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         if (mCall.getDetails().getExtras() != null) {
             assertThat(mCall.getDetails().getExtras(), is(Bundle.class));
         }
@@ -177,6 +209,10 @@
      * Tests whether the getIntentExtras() getter returns the correct object.
      */
     public void testIntentExtras() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getIntentExtras(), is(Bundle.class));
     }
 
@@ -184,6 +220,10 @@
      * Tests whether the getGatewayInfo() getter returns the correct object.
      */
     public void testGatewayInfo() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         if (mCall.getDetails().getGatewayInfo() != null) {
             assertThat(mCall.getDetails().getGatewayInfo(), is(GatewayInfo.class));
         }
@@ -193,6 +233,10 @@
      * Tests whether the getHandle() getter returns the correct object.
      */
     public void testHandle() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getHandle(), is(Uri.class));
         assertEquals(getTestNumber(), mCall.getDetails().getHandle());
     }
@@ -201,6 +245,10 @@
      * Tests whether the getHandlePresentation() getter returns the correct object.
      */
     public void testHandlePresentation() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getHandlePresentation(), is(Integer.class));
         assertEquals(MockConnectionService.CONNECTION_PRESENTATION, mCall.getDetails().getHandlePresentation());
     }
@@ -209,6 +257,10 @@
      * Tests whether the getStatusHints() getter returns the correct object.
      */
     public void testStatusHints() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getStatusHints(), is(StatusHints.class));
         assertEquals(mStatusHints.getLabel(), mCall.getDetails().getStatusHints().getLabel());
         assertEquals(
@@ -221,6 +273,10 @@
      * Tests whether the getVideoState() getter returns the correct object.
      */
     public void testVideoState() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         assertThat(mCall.getDetails().getVideoState(), is(Integer.class));
     }
 }
diff --git a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
index 989045c..121d559 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ConferenceTest.java
@@ -51,17 +51,17 @@
     protected void setUp() throws Exception {
         super.setUp();
         mContext = getInstrumentation().getContext();
-        if (shouldTestTelecom(mContext)) {
+        if (mShouldTestTelecom) {
             addOutgoingCalls();
             addConferenceCall(mCall1, mCall2);
             // Use vanilla conference object so that the CTS coverage tool detects the useage.
-            mConferenceObject = (Conference)verifyConferenceForOutgoingCall();
+            mConferenceObject = verifyConferenceForOutgoingCall();
             verifyConferenceObject(mConferenceObject, mConnection1, mConnection2);
         }
     }
 
     public void testConferenceCreate() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call conf = mInCallService.getLastConferenceCall();
@@ -81,7 +81,7 @@
     }
 
     public void testConferenceSplit() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call conf = mInCallService.getLastConferenceCall();
@@ -101,7 +101,7 @@
     }
 
     public void testConferenceHoldAndUnhold() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call conf = mInCallService.getLastConferenceCall();
@@ -119,7 +119,7 @@
     }
 
     public void testConferenceMergeAndSwap() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call conf = mInCallService.getLastConferenceCall();
@@ -144,7 +144,7 @@
     }
 
     public void testConferenceSetters() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call conf = mInCallService.getLastConferenceCall();
@@ -215,7 +215,7 @@
     }
 
     public void testConferenceAddAndRemoveConnection() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call conf = mInCallService.getLastConferenceCall();
@@ -240,7 +240,7 @@
     }
 
     public void testConferenceDTMFTone() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call conf = mInCallService.getLastConferenceCall();
diff --git a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
index b56db06..216ba97 100644
--- a/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/ExtendedInCallServiceTest.java
@@ -36,13 +36,13 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        if (TestUtils.shouldTestTelecom(mContext)) {
+        if (mShouldTestTelecom) {
             setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
         }
     }
 
     public void testAddNewOutgoingCallAndThenDisconnect() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -56,7 +56,7 @@
     }
 
     public void testMuteAndUnmutePhone() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -83,7 +83,7 @@
     }
 
     public void testSwitchAudioRoutes() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -122,7 +122,7 @@
      * @see {@link Call#stopDtmfTone()}
      */
     public void testPlayAndStopDtmfTones() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -155,7 +155,7 @@
     }
 
     public void testHoldAndUnholdCall() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -182,6 +182,10 @@
     }
 
     public void testAnswerIncomingCallAudioOnly() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         addAndVerifyNewIncomingCall(getTestNumber(), null);
         final MockConnection connection = verifyConnectionForIncomingCall();
 
@@ -199,6 +203,10 @@
     }
 
     public void testAnswerIncomingCallAsVideo_SendsCorrectVideoState() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         addAndVerifyNewIncomingCall(getTestNumber(), null);
         final MockConnection connection = verifyConnectionForIncomingCall();
 
@@ -218,6 +226,10 @@
     }
 
     public void testRejectIncomingCall() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         addAndVerifyNewIncomingCall(getTestNumber(), null);
         final MockConnection connection = verifyConnectionForIncomingCall();
 
@@ -235,7 +247,7 @@
     }
 
     public void testCanAddCall_CannotAddForExistingDialingCall() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -252,7 +264,7 @@
     }
 
     public void testCanAddCall_CanAddForExistingActiveCall() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -273,7 +285,7 @@
     }
 
     public void testCanAddCall_CannotAddIfTooManyCalls() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -308,7 +320,7 @@
     }
 
     public void testOnBringToForeground() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -340,7 +352,7 @@
     }
 
     public void testOnPostDialWaitAndContinue() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -372,7 +384,7 @@
     }
 
     public void testOnCannedTextResponsesLoaded() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
diff --git a/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java b/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
index 8d6d114..8ffcf48 100644
--- a/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/NumberDialingTest.java
@@ -35,7 +35,7 @@
     private static final int CS_WAIT_MILLIS = 2000;
 
     public void testEndInPound() throws Exception {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
diff --git a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
index b1c77fd..f2422c9 100644
--- a/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/OutgoingCallTest.java
@@ -30,7 +30,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        if (TestUtils.shouldTestTelecom(mContext)) {
+        if (mShouldTestTelecom) {
             setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
         }
     }
@@ -52,6 +52,10 @@
      * @see {@link TelecomManager#EXTRA_START_CALL_WITH_SPEAKERPHONE}
      */
     public void testStartCallWithSpeakerphoneTrue_SpeakerphoneOnInCall() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         final Bundle extras = new Bundle();
         extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, true);
         placeAndVerifyCall(extras);
@@ -60,6 +64,10 @@
     }
 
     public void testStartCallWithSpeakerphoneFalse_SpeakerphoneOffInCall() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         final Bundle extras = new Bundle();
         extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_SPEAKERPHONE, false);
         placeAndVerifyCall(extras);
@@ -68,6 +76,10 @@
     }
 
     public void testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall();
         verifyConnectionForOutgoingCall();
         assertAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_EARPIECE);
diff --git a/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java b/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
index 27c8cf4..cfa8e9f 100644
--- a/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/PhoneAccountOperationsTest.java
@@ -74,6 +74,9 @@
 
     @Override
     protected void tearDown() throws Exception {
+        if (!TestUtils.shouldTestTelecom(mContext)) {
+            return;
+        }
         mTelecomManager.unregisterPhoneAccount(TEST_PHONE_ACCOUNT_HANDLE);
         PhoneAccount retrievedPhoneAccount = mTelecomManager.getPhoneAccount(
                 TEST_PHONE_ACCOUNT_HANDLE);
diff --git a/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java b/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
index d14372e..3fc65ea 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RemoteConferenceTest.java
@@ -62,14 +62,14 @@
     protected void setUp() throws Exception {
         super.setUp();
         mContext = getInstrumentation().getContext();
-        if (shouldTestTelecom(mContext)) {
+        if (mShouldTestTelecom) {
             addRemoteConferenceCall();
             verifyRemoteConferenceObject(mRemoteConferenceObject, mRemoteConference, mConference);
         }
     }
 
     public void testRemoteConferenceCreate() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -92,7 +92,7 @@
     }
 
     public void testRemoteConferenceSplit() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -114,7 +114,7 @@
     }
 
     public void testRemoteConferenceHoldAndUnhold() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -146,7 +146,7 @@
     }
 
     public void testRemoteConferenceMergeAndSwap() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -178,7 +178,7 @@
     }
 
     public void testRemoteConferenceDTMFTone() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         final Call confCall = mInCallCallbacks.getService().getLastConferenceCall();
@@ -201,7 +201,7 @@
     }
 
     public void testRemoteConferenceCallbacks_StateChange() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         Handler handler = setupRemoteConferenceCallbacksTest();
@@ -227,7 +227,7 @@
     }
 
     public void testRemoteConferenceCallbacks_Disconnect() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         Handler handler = setupRemoteConferenceCallbacksTest();
@@ -254,7 +254,7 @@
     }
 
     public void testRemoteConferenceCallbacks_ConnectionAdd() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         Handler handler = setupRemoteConferenceCallbacksTest();
@@ -285,7 +285,7 @@
     }
 
     public void testRemoteConferenceCallbacks_ConnectionRemove() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         Handler handler = setupRemoteConferenceCallbacksTest();
@@ -317,7 +317,7 @@
     }
 
     public void testRemoteConferenceCallbacks_ConnectionCapabilities() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         Handler handler = setupRemoteConferenceCallbacksTest();
@@ -345,7 +345,7 @@
     }
 
     public void testRemoteConferenceCallbacks_ConferenceableConnections() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         Handler handler = setupRemoteConferenceCallbacksTest();
@@ -380,7 +380,7 @@
     }
 
     public void testRemoteConferenceCallbacks_Destroy() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         Handler handler = setupRemoteConferenceCallbacksTest();
@@ -404,7 +404,7 @@
     }
 
     public void testRemoteConferenceCallbacks_Extras() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         Handler handler = setupRemoteConferenceCallbacksTest();
diff --git a/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java b/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
index b4237ab..79fb592 100644
--- a/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/RemoteConnectionTest.java
@@ -55,7 +55,7 @@
     RemoteConnection mRemoteConnectionObject;
 
     public void testRemoteConnectionOutgoingCall() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         addRemoteConnectionOutgoingCall();
@@ -92,7 +92,7 @@
     }
 
     public void testRemoteConnectionIncomingCallAccept() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         addRemoteConnectionIncomingCall();
@@ -113,7 +113,7 @@
     }
 
     public void testRemoteConnectionIncomingCallReject() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         addRemoteConnectionIncomingCall();
@@ -134,7 +134,7 @@
     }
 
     public void testRemoteConnectionDTMFTone() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
         addRemoteConnectionIncomingCall();
@@ -160,7 +160,7 @@
     }
 
     public void testRemoteConnectionCallbacks_StateChange() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -186,7 +186,7 @@
     }
 
     public void testRemoteConnectionCallbacks_RingbackRequest() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -212,7 +212,7 @@
     }
 
     public void testRemoteConnectionCallbacks_ConnectionCapabilities() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -242,7 +242,7 @@
     }
 
     public void testRemoteConnectionCallbacks_PostDialWait() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -270,7 +270,7 @@
     }
 
     public void testRemoteConnectionCallbacks_PostDialChar() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -297,7 +297,7 @@
     }
 
     public void testRemoteConnectionCallbacks_VoipAudio() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -323,7 +323,7 @@
     }
 
     public void testRemoteConnectionCallbacks_StatusHints() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -350,7 +350,7 @@
     }
 
     public void testRemoteConnectionCallbacks_AddressChange() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -379,7 +379,7 @@
     }
 
     public void testRemoteConnectionCallbacks_CallerDisplayName() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -408,7 +408,7 @@
     }
 
     public void testRemoteConnectionCallbacks_VideoState() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -434,7 +434,7 @@
     }
 
     public void testRemoteConnectionCallbacks_ConferenceableConnections() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -474,7 +474,7 @@
     }
 
     public void testRemoteConnectionCallbacks_VideoProvider() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -502,7 +502,7 @@
     }
 
     public void testRemoteConnectionCallbacks_Extras() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -531,7 +531,7 @@
     }
 
     public void testRemoteConnectionCallbacks_Disconnect() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -560,7 +560,7 @@
     }
 
     public void testRemoteConnectionCallbacks_Destroy() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -585,7 +585,7 @@
     }
 
     public void testRemoteConnectionVideoCallbacks_SessionModify() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -627,7 +627,7 @@
     }
 
     public void testRemoteConnectionVideoCallbacks_SessionEvent() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -655,7 +655,7 @@
     }
 
     public void testRemoteConnectionVideoCallbacks_PeerDimensions() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -686,7 +686,7 @@
     }
 
     public void testRemoteConnectionVideoCallbacks_CallDataUsage() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -715,7 +715,7 @@
     }
 
     public void testRemoteConnectionVideoCallbacks_CameraCapabilities() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -746,7 +746,7 @@
     }
 
     public void testRemoteConnectionVideoCallbacks_VideoQuality() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -775,7 +775,7 @@
     }
 
     public void testRemoteConnectionVideo_RequestCallDataUsage() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -810,7 +810,7 @@
     }
 
     public void testRemoteConnectionVideo_RequestCameraCapabilities() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -848,7 +848,7 @@
     }
 
     public void testRemoteConnectionVideo_SendSessionModifyRequest() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -889,7 +889,7 @@
     }
 
     public void testRemoteConnectionVideo_SendSessionModifyResponse() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -935,7 +935,7 @@
     }
 
     public void testRemoteConnectionVideo_SetCamera() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -975,7 +975,7 @@
     }
 
     public void testRemoteConnectionVideo_SetDeviceOrientation() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -998,7 +998,7 @@
     }
 
     public void testRemoteConnectionVideo_SetDisplaySurface() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -1021,7 +1021,7 @@
     }
 
     public void testRemoteConnectionVideo_SetPauseImage() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -1044,7 +1044,7 @@
     }
 
     public void testRemoteConnectionVideo_SetPreviewSurface() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
@@ -1067,7 +1067,7 @@
     }
 
     public void testRemoteConnectionVideo_SetZoom() {
-        if (!shouldTestTelecom(mContext)) {
+        if (!mShouldTestTelecom) {
             return;
         }
 
diff --git a/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java b/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
index e3ba6ef..fbfa998 100644
--- a/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/VideoCallTest.java
@@ -47,7 +47,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        if (TestUtils.shouldTestTelecom(mContext)) {
+        if (mShouldTestTelecom) {
             setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
         }
     }
@@ -56,6 +56,9 @@
      * Tests ability to start a 2-way video call and retrieve its video state.
      */
     public void testMakeTwoWayVideoCall() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
 
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         final MockConnection connection = verifyConnectionForOutgoingCall();
@@ -75,6 +78,10 @@
      * Tests ability to start a 1-way video call and retrieve its video state.
      */
     public void testMakeOneWayVideoCall() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_TX_ENABLED);
         verifyConnectionForOutgoingCall();
 
@@ -89,6 +96,10 @@
      * Tests ability to upgrade an audio-only call to a video call.
      */
     public void testUpgradeToVideo() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_AUDIO_ONLY);
         verifyConnectionForOutgoingCall();
 
@@ -109,6 +120,10 @@
      * Tests ability to receive a session modification request.
      */
     public void testReceiveSessionModifyRequest() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_AUDIO_ONLY);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -134,6 +149,10 @@
      * Tests ability to send a session modification response.
      */
     public void testSendSessionModifyResponse() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_AUDIO_ONLY);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -156,6 +175,10 @@
      * the call.
      */
     public void testVideoCallDelayProvider() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         // Don't create video provider when call is created initially; we will do this later.
         try {
             connectionService.setCreateVideoProvider(false);
@@ -187,6 +210,10 @@
      * back in response.
      */
     public void testChangeCamera() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         verifyConnectionForOutgoingCall();
 
@@ -208,6 +235,10 @@
      * Tests ability to request the camera capabilities from the video provider.
      */
     public void testRequestCameraCapabilities() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         verifyConnectionForOutgoingCall();
 
@@ -232,6 +263,10 @@
      * Tests ability to request data usage from the video provider.
      */
     public void testRequestDataUsage() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         verifyConnectionForOutgoingCall();
 
@@ -249,6 +284,10 @@
      * Tests ability to receive changes to the video quality from the video provider.
      */
     public void testReceiveVideoQuality() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -281,6 +320,10 @@
      * Tests ability to receive call session events from the video provider.
      */
     public void testReceiveCallSessionEvent() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -303,6 +346,10 @@
      * Tests ability to receive changes to the peer dimensions from the video provider.
      */
     public void testReceivePeerDimensionChange() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -324,6 +371,10 @@
      * Tests ability to set the device orientation via the provider.
      */
     public void testSetDeviceOrientation() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -342,6 +393,10 @@
      * Tests ability to set the preview surface via the provider.
      */
     public void testSetPreviewSurface() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -365,6 +420,10 @@
      * Tests ability to set the display surface via the provider.
      */
     public void testSetDisplaySurface() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -388,6 +447,10 @@
      * Tests ability to set the camera zoom via the provider.
      */
     public void testSetZoom() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall(VideoProfile.STATE_BIDIRECTIONAL);
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
diff --git a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
index 697b191..466a90b 100644
--- a/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
+++ b/tests/tests/telecom/src/android/telecom/cts/WiredHeadsetTest.java
@@ -30,7 +30,7 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        if (TestUtils.shouldTestTelecom(mContext)) {
+        if (mShouldTestTelecom) {
             setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE);
         }
     }
@@ -45,6 +45,10 @@
     }
 
     public void testIncomingCallShortPress_acceptsCall() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         addAndVerifyNewIncomingCall(getTestNumber(), null);
         final MockConnection connection = verifyConnectionForIncomingCall();
 
@@ -58,6 +62,10 @@
     }
 
     public void testIncomingCallLongPress_rejectsCall() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         addAndVerifyNewIncomingCall(getTestNumber(), null);
         final MockConnection connection = verifyConnectionForIncomingCall();
 
@@ -71,6 +79,10 @@
     }
 
     public void testInCallShortPress_togglesMute() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall();
         final MockConnection connection = verifyConnectionForOutgoingCall();
         final MockInCallService incallService = mInCallCallbacks.getService();
@@ -89,6 +101,10 @@
     }
 
     public void testInCallLongPress_hangupCall() throws Exception {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall();
         final MockConnection connection = verifyConnectionForOutgoingCall();
 
@@ -104,6 +120,10 @@
     }
 
     public void testStartCallWithSpeakerphoneNotProvided_SpeakerphoneOffByDefault() {
+        if (!mShouldTestTelecom) {
+            return;
+        }
+
         placeAndVerifyCall();
         verifyConnectionForOutgoingCall();
         assertAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_EARPIECE);