summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHall Liu <hallliu@google.com>2021-01-07 11:53:43 -0800
committerChen Chen <cncn@google.com>2021-01-08 01:37:02 +0000
commitc1a1dbf18e869b6c2ac8f1abe740d7582c046b7c (patch)
tree7cfb0cadb731d59c077d1b35b6d038448156dfab /tests
parentdf68d921e880ac70b55bbd322cdb5679a252200c (diff)
downloadplatform_packages_services_Telecomm-c1a1dbf18e869b6c2ac8f1abe740d7582c046b7c.tar.gz
platform_packages_services_Telecomm-c1a1dbf18e869b6c2ac8f1abe740d7582c046b7c.tar.bz2
platform_packages_services_Telecomm-c1a1dbf18e869b6c2ac8f1abe740d7582c046b7c.zip
Bind to non-ui incall services for self-mgd calls
Bind to non-ui incall services that support self managed calls for a self-managed call, even if the main ui incall service doesn't get bound. Bug: 176883407 Test: atest InCallControllerTests, manual Merged-In: I02745189954e4453ce43e5900d4787513f030084 Change-Id: Ida3889b5be4c0ca98d11890afa5984a106b64c5a (cherry picked from 6c3e04a9b1cfc614365890721fb221784a7f9c03)
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/server/telecom/tests/InCallControllerTests.java51
1 files changed, 49 insertions, 2 deletions
diff --git a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
index 6a6b9f341..df1119847 100644
--- a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
+++ b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
@@ -876,6 +876,36 @@ public class InCallControllerTests extends TelecomTestCase {
verifyBinding(bindIntentCaptor, 1, APPOP_NONUI_PKG, APPOP_NONUI_CLASS);
}
+ /**
+ * Ensures that the {@link InCallController} will bind to a non-ui service even if no ui service
+ * is bound if the call is self managed.
+ */
+ @MediumTest
+ @Test
+ public void testBindToService_NonUiSelfManaged() throws Exception {
+ setupMocks(false /* isExternalCall */, true);
+ setupMockPackageManager(false /* default */, true/* nonui */, true /* appop_nonui */,
+ true /* system */, false /* external calls */, false /* self mgd in default */,
+ false /* self mgd in car*/, true /* self managed in nonui */);
+
+ // we should bind to only the non ui app.
+ mInCallController.bindToServices(mMockCall);
+
+ // Bind InCallServices
+ ArgumentCaptor<Intent> bindIntentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mMockContext, times(1)).bindServiceAsUser(
+ bindIntentCaptor.capture(),
+ any(ServiceConnection.class),
+ eq(Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE
+ | Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS),
+ eq(UserHandle.CURRENT));
+
+ // Verify bind
+ assertEquals(1, bindIntentCaptor.getAllValues().size());
+
+ // Should have bound to the third party non ui app.
+ verifyBinding(bindIntentCaptor, 0, NONUI_PKG, NONUI_CLASS);
+ }
@MediumTest
@Test
@@ -1238,7 +1268,7 @@ public class InCallControllerTests extends TelecomTestCase {
}};
}
- private ResolveInfo getNonUiResolveinfo() {
+ private ResolveInfo getNonUiResolveinfo(boolean supportsSelfManaged) {
return new ResolveInfo() {{
serviceInfo = new ServiceInfo();
serviceInfo.packageName = NONUI_PKG;
@@ -1247,6 +1277,11 @@ public class InCallControllerTests extends TelecomTestCase {
serviceInfo.applicationInfo.uid = NONUI_UID;
serviceInfo.enabled = true;
serviceInfo.permission = Manifest.permission.BIND_INCALL_SERVICE;
+ serviceInfo.metaData = new Bundle();
+ if (supportsSelfManaged) {
+ serviceInfo.metaData.putBoolean(
+ TelecomManager.METADATA_INCLUDE_SELF_MANAGED_CALLS, true);
+ }
}};
}
@@ -1282,6 +1317,18 @@ public class InCallControllerTests extends TelecomTestCase {
final boolean useSystemDialer, final boolean includeExternalCalls,
final boolean includeSelfManagedCallsInDefaultDialer,
final boolean includeSelfManagedCallsInCarModeDialer) {
+ setupMockPackageManager(useDefaultDialer, useNonUiInCalls/* nonui */,
+ useAppOpNonUiInCalls/* appop_nonui */,
+ useSystemDialer, includeExternalCalls, includeSelfManagedCallsInDefaultDialer,
+ includeSelfManagedCallsInCarModeDialer, false);
+ }
+
+ private void setupMockPackageManager(final boolean useDefaultDialer,
+ final boolean useNonUiInCalls, final boolean useAppOpNonUiInCalls,
+ final boolean useSystemDialer, final boolean includeExternalCalls,
+ final boolean includeSelfManagedCallsInDefaultDialer,
+ final boolean includeSelfManagedCallsInCarModeDialer,
+ final boolean includeSelfManagedCallsInNonUi) {
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
@@ -1319,7 +1366,7 @@ public class InCallControllerTests extends TelecomTestCase {
} else {
// InCallController uses a blank package name when querying for non-ui incalls
if (useNonUiInCalls) {
- resolveInfo.add(getNonUiResolveinfo());
+ resolveInfo.add(getNonUiResolveinfo(includeSelfManagedCallsInNonUi));
}
// InCallController uses a blank package name when querying for App Op non-ui incalls
if (useAppOpNonUiInCalls) {