Loading src/com/android/server/telecom/Call.java +12 −0 Original line number Diff line number Diff line Loading @@ -802,6 +802,18 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, return mState; } /** * Determines if this {@link Call} can receive call focus via the * {@link ConnectionServiceFocusManager}. * Only top-level calls and non-external calls are eligible. * @return {@code true} if this call is focusable, {@code false} otherwise. */ @Override public boolean isFocusable() { boolean isChild = getParentCall() != null; return !isChild && !isExternalCall(); } private boolean shouldContinueProcessingAfterDisconnect() { // Stop processing once the call is active. if (!CreateConnectionTimeout.isCallBeingPlaced(this)) { Loading src/com/android/server/telecom/CallsManager.java +2 −15 Original line number Diff line number Diff line Loading @@ -1423,11 +1423,8 @@ public class CallsManager extends Call.ListenerBase notifyCreateConnectionFailed(call.getTargetPhoneAccount(), call); } else { if (call.isEmergencyCall()) { // Disconnect calls from other ConnectionServices other than the one the // emergency call targets. // Except, do not disconnect calls from the Connection Manager's // ConnectionService. disconnectCallsHaveDifferentConnectionService(call); // Drop any ongoing self-managed calls to make way for an emergency call. disconnectSelfManagedCalls("place emerg call" /* reason */); } call.startCreateConnection(mPhoneAccountRegistrar); Loading Loading @@ -3274,16 +3271,6 @@ public class CallsManager extends Call.ListenerBase mCallAudioManager.switchBaseline(); } private void disconnectCallsHaveDifferentConnectionService(Call exceptCall) { String csPackage = exceptCall.getConnectionService() != null ? exceptCall.getConnectionService().getComponentName().toShortString() : "null"; mCalls.stream().filter(c -> c.getConnectionService() != exceptCall.getConnectionService() && c.getConnectionManagerPhoneAccount() != exceptCall.getConnectionManagerPhoneAccount()) .forEach(c -> c.disconnect("CS not " + csPackage)); } /** * Dumps the state of the {@link CallsManager}. * Loading src/com/android/server/telecom/ConnectionServiceFocusManager.java +7 −1 Original line number Diff line number Diff line Loading @@ -112,6 +112,11 @@ public class ConnectionServiceFocusManager { * @see {@link CallState} */ int getState(); /** * @return {@code True} if this call can receive focus, {@code false} otherwise. */ boolean isFocusable(); } /** Interface define a call back for focus request event. */ Loading Loading @@ -330,7 +335,8 @@ public class ConnectionServiceFocusManager { List<CallFocus> calls = mCalls .stream() .filter(call -> mCurrentFocus.equals(call.getConnectionServiceWrapper())) .filter(call -> mCurrentFocus.equals(call.getConnectionServiceWrapper()) && call.isFocusable()) .collect(Collectors.toList()); for (int i = 0; i < PRIORITY_FOCUS_CALL_STATE.length; i++) { Loading tests/Android.mk +20 −15 Original line number Diff line number Diff line Loading @@ -19,12 +19,17 @@ include $(CLEAR_VARS) LOCAL_STATIC_JAVA_LIBRARIES := \ android-ex-camera2 \ android-support-v4 \ android-support-test \ guava \ mockito-target \ android-support-test \ platform-test-annotations LOCAL_STATIC_ANDROID_LIBRARIES := \ android-support-core-ui \ android-support-core-utils \ android-support-compat \ android-support-fragment LOCAL_SRC_FILES := \ $(call all-java-files-under, src) \ $(call all-java-files-under, ../src) \ Loading @@ -36,7 +41,7 @@ LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors LOCAL_RESOURCE_DIR := \ $(LOCAL_PATH)/res \ $(LOCAL_PATH)/../res \ $(LOCAL_PATH)/../res LOCAL_JAVA_LIBRARIES := \ android.test.mock \ Loading @@ -48,7 +53,7 @@ LOCAL_USE_AAPT2 := true LOCAL_AAPT_FLAGS := \ --auto-add-overlay \ --extra-packages com.android.server.telecom:android.support.compat --extra-packages com.android.server.telecom LOCAL_JACK_FLAGS := --multi-dex native Loading tests/src/com/android/server/telecom/tests/ConnectionServiceFocusManagerTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -307,6 +307,20 @@ public class ConnectionServiceFocusManagerTest extends TelecomTestCase { assertTrue(mFocusManagerUT.getAllCall().contains(mActiveCall)); } @SmallTest @Test public void testNonFocusableDoesntChangeFocus() { // GIVEN the ConnectionServiceFocusManager with the focus ConnectionService requestFocus(mActiveCall, null); // WHEN a new non-focusable call is added. when(mNewCall.isFocusable()).thenReturn(false); mCallsManagerListener.onCallAdded((Call) mNewCall); // THEN the call focus isn't changed. assertEquals(mActiveCall, mFocusManagerUT.getCurrentFocusCall()); } private void requestFocus(CallFocus call, RequestFocusCallback callback) { mCallsManagerListener.onCallAdded((Call) call); mFocusManagerUT.requestFocus(call, callback); Loading Loading @@ -344,6 +358,7 @@ public class ConnectionServiceFocusManagerTest extends TelecomTestCase { Call call = Mockito.mock(Call.class); when(call.getConnectionServiceWrapper()).thenReturn(connSvr); when(call.getState()).thenReturn(state); when(call.isFocusable()).thenReturn(true); return call; } } Loading
src/com/android/server/telecom/Call.java +12 −0 Original line number Diff line number Diff line Loading @@ -802,6 +802,18 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable, return mState; } /** * Determines if this {@link Call} can receive call focus via the * {@link ConnectionServiceFocusManager}. * Only top-level calls and non-external calls are eligible. * @return {@code true} if this call is focusable, {@code false} otherwise. */ @Override public boolean isFocusable() { boolean isChild = getParentCall() != null; return !isChild && !isExternalCall(); } private boolean shouldContinueProcessingAfterDisconnect() { // Stop processing once the call is active. if (!CreateConnectionTimeout.isCallBeingPlaced(this)) { Loading
src/com/android/server/telecom/CallsManager.java +2 −15 Original line number Diff line number Diff line Loading @@ -1423,11 +1423,8 @@ public class CallsManager extends Call.ListenerBase notifyCreateConnectionFailed(call.getTargetPhoneAccount(), call); } else { if (call.isEmergencyCall()) { // Disconnect calls from other ConnectionServices other than the one the // emergency call targets. // Except, do not disconnect calls from the Connection Manager's // ConnectionService. disconnectCallsHaveDifferentConnectionService(call); // Drop any ongoing self-managed calls to make way for an emergency call. disconnectSelfManagedCalls("place emerg call" /* reason */); } call.startCreateConnection(mPhoneAccountRegistrar); Loading Loading @@ -3274,16 +3271,6 @@ public class CallsManager extends Call.ListenerBase mCallAudioManager.switchBaseline(); } private void disconnectCallsHaveDifferentConnectionService(Call exceptCall) { String csPackage = exceptCall.getConnectionService() != null ? exceptCall.getConnectionService().getComponentName().toShortString() : "null"; mCalls.stream().filter(c -> c.getConnectionService() != exceptCall.getConnectionService() && c.getConnectionManagerPhoneAccount() != exceptCall.getConnectionManagerPhoneAccount()) .forEach(c -> c.disconnect("CS not " + csPackage)); } /** * Dumps the state of the {@link CallsManager}. * Loading
src/com/android/server/telecom/ConnectionServiceFocusManager.java +7 −1 Original line number Diff line number Diff line Loading @@ -112,6 +112,11 @@ public class ConnectionServiceFocusManager { * @see {@link CallState} */ int getState(); /** * @return {@code True} if this call can receive focus, {@code false} otherwise. */ boolean isFocusable(); } /** Interface define a call back for focus request event. */ Loading Loading @@ -330,7 +335,8 @@ public class ConnectionServiceFocusManager { List<CallFocus> calls = mCalls .stream() .filter(call -> mCurrentFocus.equals(call.getConnectionServiceWrapper())) .filter(call -> mCurrentFocus.equals(call.getConnectionServiceWrapper()) && call.isFocusable()) .collect(Collectors.toList()); for (int i = 0; i < PRIORITY_FOCUS_CALL_STATE.length; i++) { Loading
tests/Android.mk +20 −15 Original line number Diff line number Diff line Loading @@ -19,12 +19,17 @@ include $(CLEAR_VARS) LOCAL_STATIC_JAVA_LIBRARIES := \ android-ex-camera2 \ android-support-v4 \ android-support-test \ guava \ mockito-target \ android-support-test \ platform-test-annotations LOCAL_STATIC_ANDROID_LIBRARIES := \ android-support-core-ui \ android-support-core-utils \ android-support-compat \ android-support-fragment LOCAL_SRC_FILES := \ $(call all-java-files-under, src) \ $(call all-java-files-under, ../src) \ Loading @@ -36,7 +41,7 @@ LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors LOCAL_RESOURCE_DIR := \ $(LOCAL_PATH)/res \ $(LOCAL_PATH)/../res \ $(LOCAL_PATH)/../res LOCAL_JAVA_LIBRARIES := \ android.test.mock \ Loading @@ -48,7 +53,7 @@ LOCAL_USE_AAPT2 := true LOCAL_AAPT_FLAGS := \ --auto-add-overlay \ --extra-packages com.android.server.telecom:android.support.compat --extra-packages com.android.server.telecom LOCAL_JACK_FLAGS := --multi-dex native Loading
tests/src/com/android/server/telecom/tests/ConnectionServiceFocusManagerTest.java +15 −0 Original line number Diff line number Diff line Loading @@ -307,6 +307,20 @@ public class ConnectionServiceFocusManagerTest extends TelecomTestCase { assertTrue(mFocusManagerUT.getAllCall().contains(mActiveCall)); } @SmallTest @Test public void testNonFocusableDoesntChangeFocus() { // GIVEN the ConnectionServiceFocusManager with the focus ConnectionService requestFocus(mActiveCall, null); // WHEN a new non-focusable call is added. when(mNewCall.isFocusable()).thenReturn(false); mCallsManagerListener.onCallAdded((Call) mNewCall); // THEN the call focus isn't changed. assertEquals(mActiveCall, mFocusManagerUT.getCurrentFocusCall()); } private void requestFocus(CallFocus call, RequestFocusCallback callback) { mCallsManagerListener.onCallAdded((Call) call); mFocusManagerUT.requestFocus(call, callback); Loading Loading @@ -344,6 +358,7 @@ public class ConnectionServiceFocusManagerTest extends TelecomTestCase { Call call = Mockito.mock(Call.class); when(call.getConnectionServiceWrapper()).thenReturn(connSvr); when(call.getState()).thenReturn(state); when(call.isFocusable()).thenReturn(true); return call; } }