Loading src/com/android/server/telecom/CallsManager.java +13 −0 Original line number Diff line number Diff line Loading @@ -3655,6 +3655,19 @@ public class CallsManager extends Call.ListenerBase } mPendingAccountSelection.remove(callId); } /** * Derived from the disconnectCallOld logic to ensure that the registered listeners are notified * of the disconnecting state once the call is disconnected. This is used for call sequencing. * @param call The call to notify the state change for. * @param previousState The previous call state before the disconnect. */ public void notifyCallStateChangeForDisconnect(Call call, int previousState) { for (CallsManagerListener listener : mListeners) { listener.onCallStateChanged(call, previousState, call.getState()); } } /** * Disconnects calls for any other {@link PhoneAccountHandle} but the one specified. * Note: As a protective measure, will NEVER disconnect an emergency call. Although that Loading src/com/android/server/telecom/callsequencing/CallSequencingController.java +7 −0 Original line number Diff line number Diff line Loading @@ -863,12 +863,19 @@ public class CallSequencingController { */ public void disconnectCall(Call call, int previousState) { CompletableFuture<Boolean> disconnectFuture = call.disconnect(); int newState = call.getState(); mCallsManager.notifyCallStateChangeForDisconnect(call, previousState); disconnectFuture.thenComposeAsync((result) -> { if (result) { Log.i(this, "disconnectCall: Disconnect call transaction succeeded. " + "Processing associated cleanup."); mCallsManager.processDisconnectCallAndCleanup(call, previousState); } else { // Revert the disconnecting state that was set as a result of invoking // Call#disconnect and make sure the reverted state is notified to the registered // listeners. call.setLocallyDisconnecting(false); mCallsManager.notifyCallStateChangeForDisconnect(call, newState); Log.i(this, "disconnectCall: Disconnect call transaction failed. " + "Aborting associated cleanup."); } Loading tests/src/com/android/server/telecom/tests/CallSequencingTests.java +5 −0 Original line number Diff line number Diff line Loading @@ -620,6 +620,7 @@ public class CallSequencingTests extends TelecomTestCase { when(mActiveCall.disconnect()).thenReturn(CompletableFuture.completedFuture(true)); int previousState = CallState.ACTIVE; mController.disconnectCall(mActiveCall, previousState); verify(mCallsManager).notifyCallStateChangeForDisconnect(any(Call.class), anyInt()); verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS)) .processDisconnectCallAndCleanup(eq(mActiveCall), eq(previousState)); } Loading @@ -630,8 +631,12 @@ public class CallSequencingTests extends TelecomTestCase { when(mActiveCall.disconnect()).thenReturn(CompletableFuture.completedFuture(false)); int previousState = CallState.ACTIVE; mController.disconnectCall(mActiveCall, previousState); verify(mCallsManager).notifyCallStateChangeForDisconnect(any(Call.class), anyInt()); verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS).times(0)) .processDisconnectCallAndCleanup(eq(mActiveCall), eq(previousState)); verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS).times(2)) .notifyCallStateChangeForDisconnect(any(Call.class), anyInt()); verify(mActiveCall, timeout(SEQUENCING_TIMEOUT_MS)).setLocallyDisconnecting(eq(false)); } @Test Loading Loading
src/com/android/server/telecom/CallsManager.java +13 −0 Original line number Diff line number Diff line Loading @@ -3655,6 +3655,19 @@ public class CallsManager extends Call.ListenerBase } mPendingAccountSelection.remove(callId); } /** * Derived from the disconnectCallOld logic to ensure that the registered listeners are notified * of the disconnecting state once the call is disconnected. This is used for call sequencing. * @param call The call to notify the state change for. * @param previousState The previous call state before the disconnect. */ public void notifyCallStateChangeForDisconnect(Call call, int previousState) { for (CallsManagerListener listener : mListeners) { listener.onCallStateChanged(call, previousState, call.getState()); } } /** * Disconnects calls for any other {@link PhoneAccountHandle} but the one specified. * Note: As a protective measure, will NEVER disconnect an emergency call. Although that Loading
src/com/android/server/telecom/callsequencing/CallSequencingController.java +7 −0 Original line number Diff line number Diff line Loading @@ -863,12 +863,19 @@ public class CallSequencingController { */ public void disconnectCall(Call call, int previousState) { CompletableFuture<Boolean> disconnectFuture = call.disconnect(); int newState = call.getState(); mCallsManager.notifyCallStateChangeForDisconnect(call, previousState); disconnectFuture.thenComposeAsync((result) -> { if (result) { Log.i(this, "disconnectCall: Disconnect call transaction succeeded. " + "Processing associated cleanup."); mCallsManager.processDisconnectCallAndCleanup(call, previousState); } else { // Revert the disconnecting state that was set as a result of invoking // Call#disconnect and make sure the reverted state is notified to the registered // listeners. call.setLocallyDisconnecting(false); mCallsManager.notifyCallStateChangeForDisconnect(call, newState); Log.i(this, "disconnectCall: Disconnect call transaction failed. " + "Aborting associated cleanup."); } Loading
tests/src/com/android/server/telecom/tests/CallSequencingTests.java +5 −0 Original line number Diff line number Diff line Loading @@ -620,6 +620,7 @@ public class CallSequencingTests extends TelecomTestCase { when(mActiveCall.disconnect()).thenReturn(CompletableFuture.completedFuture(true)); int previousState = CallState.ACTIVE; mController.disconnectCall(mActiveCall, previousState); verify(mCallsManager).notifyCallStateChangeForDisconnect(any(Call.class), anyInt()); verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS)) .processDisconnectCallAndCleanup(eq(mActiveCall), eq(previousState)); } Loading @@ -630,8 +631,12 @@ public class CallSequencingTests extends TelecomTestCase { when(mActiveCall.disconnect()).thenReturn(CompletableFuture.completedFuture(false)); int previousState = CallState.ACTIVE; mController.disconnectCall(mActiveCall, previousState); verify(mCallsManager).notifyCallStateChangeForDisconnect(any(Call.class), anyInt()); verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS).times(0)) .processDisconnectCallAndCleanup(eq(mActiveCall), eq(previousState)); verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS).times(2)) .notifyCallStateChangeForDisconnect(any(Call.class), anyInt()); verify(mActiveCall, timeout(SEQUENCING_TIMEOUT_MS)).setLocallyDisconnecting(eq(false)); } @Test Loading