Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit de70f555 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Fix crash during outgoing call + incoming SM call

When an outgoing call is in SELECT_PHONE_ACCOUNT state and an
incoming Self-Managed call is received, it will cause a crash
because we assume that the target PhoneAccount is set.

Instead, only count unholdable calls using Calls that have had
their target PhoneAccount set. This convention is set because
calls are not considered "active focus" until they have had their
PhoneAccount set. Otherwise, we could show UX to end the outgoing
call to accept the incoming  call, which will put Telecom in a
bad state because it does not properly end the call in
SELECT_PHONE_ACCOUNT state.

Bug: 285161098
Test: place outgoing managed call and put into SELECT_PHONE_ACCOUNT
and then create incoming Self-Managed call.
Test: atest TelecomUnitTests

Change-Id: Ica350292275a75936a3b529111ee0c3527d9dd8a
parent 2d6380b9
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -4738,14 +4738,20 @@ public class CallsManager extends Call.ListenerBase


    /**
    /**
     * Determines the number of unholdable calls present in a connection service other than the one
     * Determines the number of unholdable calls present in a connection service other than the one
     * the passed phone account belonds to.
     * the passed phone account belongs to. If a ConnectionService has not been associated with an
     * outgoing call yet (for example, it is in the SELECT_PHONE_ACCOUNT state), then we do not
     * count that call because it is not tracked as an active call yet.
     * @param phoneAccountHandle The handle of the PhoneAccount.
     * @param phoneAccountHandle The handle of the PhoneAccount.
     * @return Number of unholdable calls owned by other connection service.
     * @return Number of unholdable calls owned by other connection service.
     */
     */
    public int getNumUnholdableCallsForOtherConnectionService(
    public int getNumUnholdableCallsForOtherConnectionService(
            PhoneAccountHandle phoneAccountHandle) {
            PhoneAccountHandle phoneAccountHandle) {
        return (int) mCalls.stream().filter(call ->
        return (int) mCalls.stream().filter(call ->
                !phoneAccountHandle.getComponentName().equals(
                // If this convention needs to be changed, answerCall will need to be modified to
                // change what an "active call" is so that the call in SELECT_PHONE_ACCOUNT state
                // will be properly cancelled.
                call.getTargetPhoneAccount() != null
                        && !phoneAccountHandle.getComponentName().equals(
                                call.getTargetPhoneAccount().getComponentName())
                                call.getTargetPhoneAccount().getComponentName())
                        && call.getParentCall() == null
                        && call.getParentCall() == null
                        && !call.isExternalCall()
                        && !call.isExternalCall()