Loading src/com/android/server/telecom/InCallController.java +4 −3 Original line number Diff line number Diff line Loading @@ -1393,11 +1393,12 @@ public class InCallController extends CallsManagerListenerBase { mInCallServiceConnection.chooseInitialInCallService(shouldUseCarModeUI()); // Actually try binding to the UI InCallService. If the response // Actually try binding to the UI InCallService. if (mInCallServiceConnection.connect(call) == InCallServiceConnection.CONNECTION_SUCCEEDED) { InCallServiceConnection.CONNECTION_SUCCEEDED || call.isSelfManaged()) { // Only connect to the non-ui InCallServices if we actually connected to the main UI // one. // one, or if the call is self-managed (in which case we'd still want to keep Wear, BT, // etc. informed. connectToNonUiInCallServices(call); mBindingFuture = new CompletableFuture<Boolean>().completeOnTimeout(false, mTimeoutsAdapter.getCallRemoveUnbindInCallServicesDelay( Loading tests/src/com/android/server/telecom/tests/InCallControllerTests.java +49 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading @@ -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); } }}; } Loading Loading @@ -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 { Loading Loading @@ -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) { Loading Loading
src/com/android/server/telecom/InCallController.java +4 −3 Original line number Diff line number Diff line Loading @@ -1393,11 +1393,12 @@ public class InCallController extends CallsManagerListenerBase { mInCallServiceConnection.chooseInitialInCallService(shouldUseCarModeUI()); // Actually try binding to the UI InCallService. If the response // Actually try binding to the UI InCallService. if (mInCallServiceConnection.connect(call) == InCallServiceConnection.CONNECTION_SUCCEEDED) { InCallServiceConnection.CONNECTION_SUCCEEDED || call.isSelfManaged()) { // Only connect to the non-ui InCallServices if we actually connected to the main UI // one. // one, or if the call is self-managed (in which case we'd still want to keep Wear, BT, // etc. informed. connectToNonUiInCallServices(call); mBindingFuture = new CompletableFuture<Boolean>().completeOnTimeout(false, mTimeoutsAdapter.getCallRemoveUnbindInCallServicesDelay( Loading
tests/src/com/android/server/telecom/tests/InCallControllerTests.java +49 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading @@ -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); } }}; } Loading Loading @@ -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 { Loading Loading @@ -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) { Loading