diff options
author | Tyler Gunn <tgunn@google.com> | 2021-03-02 22:11:20 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-03-02 22:11:20 +0000 |
commit | 50bbecff3f884e1564101ef1f34b8144f06a586c (patch) | |
tree | f59db9f656a4e60f1129ea45f5f34d1ee1683793 | |
parent | 702be0dfdde31c7718dd114f76d9bf6adbe9ea3a (diff) | |
parent | 09123202edab3a2baa806828ede8495fcd46d6bb (diff) | |
download | cts-temp_RQ2A.210305.007.tar.gz |
Merge "Add CTS test suite for CallDiagnosticService API." am: 09123202edtemp_RQ2A.210305.007
Original change: https://android-review.googlesource.com/c/platform/cts/+/1602495
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I3eea8665253cd946b11d492b4534aefccd68e064
5 files changed, 562 insertions, 0 deletions
diff --git a/tests/tests/permission2/res/raw/android_manifest.xml b/tests/tests/permission2/res/raw/android_manifest.xml index 1d83543d9e8..e382870e99f 100644 --- a/tests/tests/permission2/res/raw/android_manifest.xml +++ b/tests/tests/permission2/res/raw/android_manifest.xml @@ -2239,6 +2239,15 @@ <permission android:name="android.permission.BIND_PHONE_ACCOUNT_SUGGESTION_SERVICE" android:protectionLevel="signature" /> + <!-- Must be required by a {@link android.telecom.CallDiagnosticService}, + to ensure that only the system can bind to it. + <p>Protection level: signature + @SystemApi + @hide + --> + <permission android:name="android.permission.BIND_CALL_DIAGNOSTIC_SERVICE" + android:protectionLevel="signature" /> + <!-- Must be required by a {@link android.telecom.CallRedirectionService}, to ensure that only the system can bind to it. <p>Protection level: signature|privileged diff --git a/tests/tests/telecom/AndroidManifest.xml b/tests/tests/telecom/AndroidManifest.xml index e71a878c3b8..964775c2794 100644 --- a/tests/tests/telecom/AndroidManifest.xml +++ b/tests/tests/telecom/AndroidManifest.xml @@ -38,10 +38,18 @@ <uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" /> <uses-permission android:name="android.permission.MANAGE_ROLE_HOLDERS" /> <uses-permission android:name="android.permission.MANAGE_USERS" /> + <uses-permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION" /> <application> <uses-library android:name="android.test.runner" /> + <service android:name="android.telecom.cts.CtsCallDiagnosticService" + android:permission="android.permission.BIND_CALL_DIAGNOSTIC_SERVICE" > + <intent-filter> + <action android:name="android.telecom.CallDiagnosticService" /> + </intent-filter> + </service> + <service android:name="android.telecom.cts.CtsRemoteConnectionService" android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE" > <intent-filter> diff --git a/tests/tests/telecom/src/android/telecom/cts/CallDiagnosticServiceTest.java b/tests/tests/telecom/src/android/telecom/cts/CallDiagnosticServiceTest.java new file mode 100644 index 00000000000..e1c27833831 --- /dev/null +++ b/tests/tests/telecom/src/android/telecom/cts/CallDiagnosticServiceTest.java @@ -0,0 +1,318 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecom.cts; + +import static android.telecom.cts.TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS; +import static android.telecom.cts.TestUtils.shouldTestTelecom; + +import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity; + +import android.content.Context; +import android.os.Bundle; +import android.telecom.BluetoothCallQualityReport; +import android.telecom.Call; +import android.telecom.CallAudioState; +import android.telecom.Connection; +import android.telecom.DiagnosticCall; +import android.telecom.TelecomManager; + +import java.util.concurrent.TimeUnit; + +public class CallDiagnosticServiceTest extends BaseTelecomTestWithMockServices { + private static final String POOR_CALL_MESSAGE = "Can you hear me?"; + private static final int POOR_MESSAGE_ID = 90210; + private TelecomManager mTelecomManager; + private MockConnection mConnection; + private android.telecom.Call mCall; + private CtsCallDiagnosticService mService; + + @Override + protected void setUp() throws Exception { + super.setUp(); + if (!shouldTestTelecom(mContext)) { + return; + } + mTelecomManager = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); + + setupConnectionService(null, FLAG_REGISTER | FLAG_ENABLE); + runWithShellPermissionIdentity(() -> { + // Make sure there is a sim account registered. + mTelecomManager.registerPhoneAccount(TestUtils.TEST_SIM_PHONE_ACCOUNT); + }); + TestUtils.enablePhoneAccount( + getInstrumentation(), TestUtils.TEST_SIM_PHONE_ACCOUNT_HANDLE); + TestUtils.setCallDiagnosticService(getInstrumentation(), TestUtils.PACKAGE); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + + TestUtils.setCallDiagnosticService(getInstrumentation(), "default"); + } + + /** + * Test adding a call binds to the call diagnostic service. + * @throws InterruptedException + */ + public void testAddCallAndPassValues() throws InterruptedException { + if (!shouldTestTelecom(mContext)) { + return; + } + setupCall(); + + assertEquals(1, mService.getCalls().size()); + final CtsCallDiagnosticService.CtsDiagnosticCall diagnosticCall = + mService.getCalls().get(0); + + // Add an extra to the connection and verify CDS gets it. + Bundle connectionExtras = new Bundle(); + connectionExtras.putInt(Connection.EXTRA_AUDIO_CODEC, Connection.AUDIO_CODEC_AMR_WB); + mConnection.putExtras(connectionExtras); + waitUntilConditionIsTrueOrTimeout(new Condition() { + @Override + public Object expected() { + return true; + } + + @Override + public Object actual() { + return diagnosticCall.getCallDetails().getExtras().containsKey( + Connection.EXTRA_AUDIO_CODEC) + && diagnosticCall.getCallDetails().getExtras().getInt( + Connection.EXTRA_AUDIO_CODEC) == Connection.AUDIO_CODEC_AMR_WB; + } + }, TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, "Extras propagation"); + + mConnection.onDisconnect(); + } + + /** + * Test adding multiple calls to the Call Diagnostic Service. + * @throws InterruptedException + */ + public void testAddMultipleCalls() throws InterruptedException { + if (!shouldTestTelecom(mContext)) { + return; + } + setupCall(); + + final Bundle extras = new Bundle(); + extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, + TestUtils.TEST_SIM_PHONE_ACCOUNT_HANDLE); + + // Add a second call. + placeAndVerifyCall(extras); + MockConnection connection = verifyConnectionForOutgoingCall(1); + MockInCallService inCallService = mInCallCallbacks.getService(); + Call call = inCallService.getLastCall(); + assertEquals(TestUtils.TEST_SIM_PHONE_ACCOUNT_HANDLE, connection.getPhoneAccountHandle()); + + mService.getCallChangeLatch().await(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, + TimeUnit.MILLISECONDS); + assertEquals(2, mService.getCalls().size()); + + // Disconnect the first call. + mConnection.onDisconnect(); + mConnection.destroy(); + + mService.getCallChangeLatch().await(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, + TimeUnit.MILLISECONDS); + assertEquals(1, mService.getCalls().size()); + } + + + /** + * Test passing of BT call quality report to CDS. + * @throws InterruptedException + */ + public void testBluetoothCallQualityReport() throws InterruptedException { + if (!shouldTestTelecom(mContext)) { + return; + } + setupCall(); + + // Add an extra to the connection and verify CDS gets it. + BluetoothCallQualityReport report = new BluetoothCallQualityReport.Builder() + .setChoppyVoice(true) + .setNegativeAcknowledgementCount(10) + .setRetransmittedPacketsCount(10) + .build(); + Bundle eventExtras = new Bundle(); + eventExtras.putParcelable(BluetoothCallQualityReport.EXTRA_BLUETOOTH_CALL_QUALITY_REPORT, + report); + mCall.sendCallEvent(BluetoothCallQualityReport.EVENT_BLUETOOTH_CALL_QUALITY_REPORT, + eventExtras); + + mService.getBluetoothCallQualityReportLatch().await( + TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, TimeUnit.MILLISECONDS); + assertEquals(report, mService.getBluetoothCallQualityReport()); + + mConnection.onDisconnect(); + } + + /** + * Test passing of call audio route to CDS. + * @throws InterruptedException + */ + public void testCallAudioRoute() throws InterruptedException { + if (!shouldTestTelecom(mContext)) { + return; + } + setupCall(); + + mInCallCallbacks.getService().setAudioRoute(CallAudioState.ROUTE_SPEAKER); + assertAudioRoute(mInCallCallbacks.getService(), CallAudioState.ROUTE_SPEAKER); + + mService.getCallAudioStateLatch().await(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, + TimeUnit.MILLISECONDS); + assertEquals(CallAudioState.ROUTE_SPEAKER, mService.getCallAudioState().getRoute()); + } + + /** + * Test incoming D2D message + * @throws InterruptedException + */ + public void testReceiveD2DMessage() throws InterruptedException { + if (!shouldTestTelecom(mContext)) { + return; + } + setupCall(); + + Bundle message = new Bundle(); + message.putInt(Connection.EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE, + DiagnosticCall.MESSAGE_CALL_NETWORK_TYPE); + message.putInt(Connection.EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE, + DiagnosticCall.NETWORK_TYPE_NR); + mConnection.sendConnectionEvent(Connection.EVENT_DEVICE_TO_DEVICE_MESSAGE, message); + + CtsCallDiagnosticService.CtsDiagnosticCall diagnosticCall = mService.getCalls().get(0); + diagnosticCall.getReceivedMessageLatch().await(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, + TimeUnit.MILLISECONDS); + assertEquals(DiagnosticCall.MESSAGE_CALL_NETWORK_TYPE, + diagnosticCall.getMessageType()); + assertEquals(DiagnosticCall.NETWORK_TYPE_NR, + diagnosticCall.getMessageValue()); + } + + /** + * Test sending D2D message + * @throws InterruptedException + */ + public void testSendD2DMessage() throws InterruptedException { + if (!shouldTestTelecom(mContext)) { + return; + } + setupCall(); + + CtsCallDiagnosticService.CtsDiagnosticCall diagnosticCall = mService.getCalls().get(0); + diagnosticCall.sendDeviceToDeviceMessage(DiagnosticCall.MESSAGE_DEVICE_BATTERY_STATE, + DiagnosticCall.BATTERY_STATE_LOW); + + final TestUtils.InvokeCounter counter = mConnection.getInvokeCounter( + MockConnection.ON_CALL_EVENT); + counter.waitForCount(1, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS); + + String event = (String) (counter.getArgs(0)[0]); + Bundle extras = (Bundle) (counter.getArgs(0)[1]); + assertEquals(Connection.EVENT_DEVICE_TO_DEVICE_MESSAGE, event); + assertNotNull(extras); + int messageType = extras.getInt(Connection.EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE); + int messageValue = extras.getInt(Connection.EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE); + assertEquals(DiagnosticCall.MESSAGE_DEVICE_BATTERY_STATE, messageType); + assertEquals(DiagnosticCall.BATTERY_STATE_LOW, messageValue); + } + + /** + * Test routing of a diagnostic message from the CallDiagnosticService to the dialer. + * @throws InterruptedException + */ + public void testDisplayDiagnosticMessage() throws InterruptedException { + if (!shouldTestTelecom(mContext)) { + return; + } + setupCall(); + + CtsCallDiagnosticService.CtsDiagnosticCall diagnosticCall = mService.getCalls().get(0); + diagnosticCall.displayDiagnosticMessage(POOR_MESSAGE_ID, POOR_CALL_MESSAGE); + + mOnConnectionEventCounter.waitForCount(1, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS); + String event = (String) (mOnConnectionEventCounter.getArgs(0)[1]); + Bundle extras = (Bundle) (mOnConnectionEventCounter.getArgs(0)[2]); + assertEquals(Call.EVENT_DISPLAY_DIAGNOSTIC_MESSAGE, event); + assertNotNull(extras); + CharSequence message = extras.getCharSequence(Call.EXTRA_DIAGNOSTIC_MESSAGE); + int messageId = extras.getInt(Call.EXTRA_DIAGNOSTIC_MESSAGE_ID); + assertEquals(POOR_MESSAGE_ID, messageId); + assertEquals(POOR_CALL_MESSAGE, message); + } + + /** + * Test routing of a clear diagnostic message from the CallDiagnosticService to the dialer. + * @throws InterruptedException + */ + public void testClearDisplayDiagnosticMessage() throws InterruptedException { + if (!shouldTestTelecom(mContext)) { + return; + } + setupCall(); + + CtsCallDiagnosticService.CtsDiagnosticCall diagnosticCall = mService.getCalls().get(0); + diagnosticCall.clearDiagnosticMessage(POOR_MESSAGE_ID); + + mOnConnectionEventCounter.waitForCount(1, WAIT_FOR_STATE_CHANGE_TIMEOUT_MS); + String event = (String) (mOnConnectionEventCounter.getArgs(0)[1]); + Bundle extras = (Bundle) (mOnConnectionEventCounter.getArgs(0)[2]); + assertEquals(Call.EVENT_CLEAR_DIAGNOSTIC_MESSAGE, event); + assertNotNull(extras); + int messageId = extras.getInt(Call.EXTRA_DIAGNOSTIC_MESSAGE_ID); + assertEquals(POOR_MESSAGE_ID, messageId); + } + + /** + * Starts a fake SIM call and verifies binding to the CDS. + * @throws InterruptedException + */ + private void setupCall() throws InterruptedException { + final Bundle extras = new Bundle(); + extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, + TestUtils.TEST_SIM_PHONE_ACCOUNT_HANDLE); + + // Add a call. + placeAndVerifyCall(extras); + mConnection = verifyConnectionForOutgoingCall(); + MockInCallService inCallService = mInCallCallbacks.getService(); + mCall = inCallService.getLastCall(); + + assertEquals(TestUtils.TEST_SIM_PHONE_ACCOUNT_HANDLE, mConnection.getPhoneAccountHandle()); + + // Make sure we bound to the CTS call diagnostic service and told it there is a call. + CtsCallDiagnosticService.getBindLatch().await(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, + TimeUnit.MILLISECONDS); + mService = CtsCallDiagnosticService.getInstance(); + assertNotNull(mService); + mService.getCallChangeLatch().await(TestUtils.WAIT_FOR_STATE_CHANGE_TIMEOUT_MS, + TimeUnit.MILLISECONDS); + assertEquals(1, mService.getCalls().size()); + + // Make the call active. + mConnection.setActive(); + + // Make sure UI knows. + assertCallState(mCall, Call.STATE_ACTIVE); + } +} diff --git a/tests/tests/telecom/src/android/telecom/cts/CtsCallDiagnosticService.java b/tests/tests/telecom/src/android/telecom/cts/CtsCallDiagnosticService.java new file mode 100644 index 00000000000..b90f5a722dd --- /dev/null +++ b/tests/tests/telecom/src/android/telecom/cts/CtsCallDiagnosticService.java @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecom.cts; + +import android.content.Intent; +import android.telecom.BluetoothCallQualityReport; +import android.telecom.Call; +import android.telecom.CallAudioState; +import android.telecom.CallDiagnosticService; +import android.telecom.DiagnosticCall; +import android.telephony.CallQuality; +import android.telephony.ims.ImsReasonInfo; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +public class CtsCallDiagnosticService extends CallDiagnosticService { + private static final String LOG_TAG = "CtsCallDiagnosticService"; + private static CtsCallDiagnosticService sCtsCallDiagnosticService; + private CallAudioState mCallAudioState; + private BluetoothCallQualityReport mBluetoothCallQualityReport; + private static CountDownLatch sBindLatch = new CountDownLatch(1); + private CountDownLatch mChangeLatch = new CountDownLatch(1); + private CountDownLatch mBluetoothCallQualityReportLatch = new CountDownLatch(1); + private CountDownLatch mCallAudioStateLatch = new CountDownLatch(1); + private List<CtsDiagnosticCall> mCalls = new ArrayList<>(); + + public static class CtsDiagnosticCall extends DiagnosticCall { + private Call.Details mCallDetails; + private int mMessageType; + private int mMessageValue; + private CallQuality mCallQuality; + private CountDownLatch mCallQualityReceivedLatch = new CountDownLatch(1); + private CountDownLatch mReceivedMessageLatch = new CountDownLatch(1); + private CountDownLatch mCallDetailsReceivedLatch = new CountDownLatch(1); + + @Override + public void onCallDetailsChanged(@NonNull Call.Details details) { + mCallDetails = details; + mCallDetailsReceivedLatch.countDown(); + } + + @Override + public void onReceiveDeviceToDeviceMessage(int message, int value) { + mMessageType = message; + mMessageValue = value; + mReceivedMessageLatch.countDown(); + } + + @Nullable + @Override + public CharSequence onCallDisconnected(int disconnectCause, int preciseDisconnectCause) { + return null; + } + + @Nullable + @Override + public CharSequence onCallDisconnected(@NonNull ImsReasonInfo disconnectReason) { + return null; + } + + @Override + public void onCallQualityReceived(@NonNull CallQuality callQuality) { + mCallQuality = callQuality; + mReceivedMessageLatch.countDown(); + } + + @NonNull + @Override + public Call.Details getCallDetails() { + return mCallDetails; + } + + public int getMessageType() { + return mMessageType; + } + + public void setMessageType(int messageType) { + this.mMessageType = messageType; + } + + public int getMessageValue() { + return mMessageValue; + } + + public CountDownLatch getCallQualityReceivedLatch() { + return mCallQualityReceivedLatch; + } + + public CountDownLatch getReceivedMessageLatch() { + return mReceivedMessageLatch; + } + + public CallQuality getCallQuality() { + return mCallQuality; + } + + public CountDownLatch getCallDetailsReceivedLatch() { + return mCallDetailsReceivedLatch; + } + } + + @Override + public android.os.IBinder onBind(android.content.Intent intent) { + Log.i(LOG_TAG, "Service bound."); + sCtsCallDiagnosticService = this; + android.os.IBinder binder = super.onBind(intent); + sBindLatch.countDown(); + return binder; + } + + @Override + public boolean onUnbind(Intent intent) { + Log.i(LOG_TAG, "Service unbound"); + sCtsCallDiagnosticService = null; + return super.onUnbind(intent); + } + + @NonNull + @Override + public DiagnosticCall onInitializeDiagnosticCall(@NonNull Call.Details call) { + CtsDiagnosticCall diagCall = new CtsDiagnosticCall(); + diagCall.mCallDetails = call; + mCalls.add(diagCall); + mChangeLatch.countDown(); + return diagCall; + } + + @Override + public void onRemoveDiagnosticCall(@NonNull DiagnosticCall call) { + Log.i(LOG_TAG, "onRemoveDiagnosticCall: " + call); + mCalls.remove(call); + mChangeLatch.countDown(); + } + + @Override + public void onCallAudioStateChanged(@NonNull CallAudioState audioState) { + mCallAudioState = audioState; + mCallAudioStateLatch.countDown(); + } + + @Override + public void onBluetoothCallQualityReportReceived( + @NonNull BluetoothCallQualityReport qualityReport) { + mBluetoothCallQualityReport = qualityReport; + mBluetoothCallQualityReportLatch.countDown(); + } + + public static CtsCallDiagnosticService getInstance() { + return sCtsCallDiagnosticService; + } + + public static CountDownLatch getBindLatch() { + return sBindLatch; + } + + public CallAudioState getCallAudioState() { + return mCallAudioState; + } + + public CountDownLatch getCallAudioStateLatch() { + return mCallAudioStateLatch; + } + + public BluetoothCallQualityReport getBluetoothCallQualityReport() { + return mBluetoothCallQualityReport; + } + + public CountDownLatch getCallChangeLatch() { + CountDownLatch latch = mChangeLatch; + mChangeLatch = new CountDownLatch(1); + return latch; + } + + public CountDownLatch getBluetoothCallQualityReportLatch() { + return mBluetoothCallQualityReportLatch; + } + + public List<CtsDiagnosticCall> getCalls() { + return mCalls; + } +} diff --git a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java index 30466173b26..c226fb0469a 100644 --- a/tests/tests/telecom/src/android/telecom/cts/TestUtils.java +++ b/tests/tests/telecom/src/android/telecom/cts/TestUtils.java @@ -76,10 +76,13 @@ public class TestUtils { public static final String REMOTE_COMPONENT = "android.telecom.cts.CtsRemoteConnectionService"; public static final String ACCOUNT_ID_1 = "xtstest_CALL_PROVIDER_ID_1"; public static final String ACCOUNT_ID_2 = "xtstest_CALL_PROVIDER_ID_2"; + public static final String ACCOUNT_ID_SIM = "sim_acct"; public static final String ACCOUNT_ID_EMERGENCY = "xtstest_CALL_PROVIDER_EMERGENCY"; public static final String EXTRA_PHONE_NUMBER = "android.telecom.cts.extra.PHONE_NUMBER"; public static final PhoneAccountHandle TEST_PHONE_ACCOUNT_HANDLE = new PhoneAccountHandle(new ComponentName(PACKAGE, COMPONENT), ACCOUNT_ID_1); + public static final PhoneAccountHandle TEST_SIM_PHONE_ACCOUNT_HANDLE = + new PhoneAccountHandle(new ComponentName(PACKAGE, COMPONENT), ACCOUNT_ID_SIM); public static final PhoneAccountHandle TEST_PHONE_ACCOUNT_HANDLE_2 = new PhoneAccountHandle(new ComponentName(PACKAGE, COMPONENT), ACCOUNT_ID_2); public static final PhoneAccountHandle TEST_EMERGENCY_PHONE_ACCOUNT_HANDLE = @@ -116,6 +119,7 @@ public class TestUtils { SELF_MANAGED_ACCOUNT_ID_4); public static final String ACCOUNT_LABEL = "CTSConnectionService"; + public static final String SIM_ACCOUNT_LABEL = "CTSConnectionServiceSim"; public static final PhoneAccount TEST_PHONE_ACCOUNT = PhoneAccount.builder( TEST_PHONE_ACCOUNT_HANDLE, ACCOUNT_LABEL) .setAddress(Uri.parse("tel:555-TEST")) @@ -132,6 +136,18 @@ public class TestUtils { .addSupportedUriScheme(PhoneAccount.SCHEME_VOICEMAIL) .build(); + public static final PhoneAccount TEST_SIM_PHONE_ACCOUNT = PhoneAccount.builder( + TEST_SIM_PHONE_ACCOUNT_HANDLE, SIM_ACCOUNT_LABEL) + .setAddress(Uri.parse("tel:555-TEST")) + .setSubscriptionAddress(Uri.parse("tel:555-TEST")) + .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER | + PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) + .setHighlightColor(Color.RED) + .setShortDescription(SIM_ACCOUNT_LABEL) + .addSupportedUriScheme(PhoneAccount.SCHEME_TEL) + .addSupportedUriScheme(PhoneAccount.SCHEME_VOICEMAIL) + .build(); + public static final PhoneAccount TEST_PHONE_ACCOUNT_2 = PhoneAccount.builder( TEST_PHONE_ACCOUNT_HANDLE_2, ACCOUNT_LABEL + "2") .setAddress(Uri.parse("tel:555-TEST2")) @@ -254,6 +270,9 @@ public class TestUtils { .setExtras(SELF_MANAGED_ACCOUNT_4_EXTRAS) .build(); + private static final String COMMAND_SET_CALL_DIAGNOSTIC_SERVICE = + "telecom set-call-diagnostic-service "; + private static final String COMMAND_SET_DEFAULT_DIALER = "telecom set-default-dialer "; private static final String COMMAND_GET_DEFAULT_DIALER = "telecom get-default-dialer"; @@ -298,6 +317,13 @@ public class TestUtils { pm.hasSystemFeature(PackageManager.FEATURE_CONNECTION_SERVICE); } + public static String setCallDiagnosticService(Instrumentation instrumentation, + String packageName) + throws Exception { + return executeShellCommand(instrumentation, COMMAND_SET_CALL_DIAGNOSTIC_SERVICE + + packageName); + } + public static String setDefaultDialer(Instrumentation instrumentation, String packageName) throws Exception { return executeShellCommand(instrumentation, COMMAND_SET_DEFAULT_DIALER + packageName); |