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

Commit 3459089b authored by Tyler Gunn's avatar Tyler Gunn Committed by Android Git Automerger
Browse files

am 595787d0: Merge "Fix issue where GSM conference is held in...

am 595787d0: Merge "Fix issue where GSM conference is held in makeRoomForOutgoingCall." into mnc-dev

* commit '595787d0':
  Fix issue where GSM conference is held in makeRoomForOutgoingCall.
parents b213354c 595787d0
Loading
Loading
Loading
Loading
+35 −1
Original line number Original line Diff line number Diff line
@@ -1504,10 +1504,27 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx


            // We have room for at least one more holding call at this point.
            // We have room for at least one more holding call at this point.


            // TODO: Remove once b/23035408 has been corrected.
            // If the live call is a conference, it will not have a target phone account set.  This
            // means the check to see if the live call has the same target phone account as the new
            // call will not cause us to bail early.  As a result, we'll end up holding the
            // ongoing conference call.  However, the ConnectionService is already doing that.  This
            // has caused problems with some carriers.  As a workaround until b/23035408 is
            // corrected, we will try and get the target phone account for one of the conference's
            // children and use that instead.
            PhoneAccountHandle liveCallPhoneAccount = liveCall.getTargetPhoneAccount();
            if (liveCallPhoneAccount == null && liveCall.isConference() &&
                    !liveCall.getChildCalls().isEmpty()) {
                liveCallPhoneAccount = getFirstChildPhoneAccount(liveCall);
                Log.i(this, "makeRoomForOutgoingCall: using child call PhoneAccount = " +
                        liveCallPhoneAccount);
            }

            // First thing, if we are trying to make a call with the same phone account as the live
            // First thing, if we are trying to make a call with the same phone account as the live
            // call, then allow it so that the connection service can make its own decision about
            // call, then allow it so that the connection service can make its own decision about
            // how to handle the new call relative to the current one.
            // how to handle the new call relative to the current one.
            if (Objects.equals(liveCall.getTargetPhoneAccount(), call.getTargetPhoneAccount())) {
            if (Objects.equals(liveCallPhoneAccount, call.getTargetPhoneAccount())) {
                Log.i(this, "makeRoomForOutgoingCall: phoneAccount matches.");
                return true;
                return true;
            } else if (call.getTargetPhoneAccount() == null) {
            } else if (call.getTargetPhoneAccount() == null) {
                // Without a phone account, we can't say reliably that the call will fail.
                // Without a phone account, we can't say reliably that the call will fail.
@@ -1521,6 +1538,7 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx


            // Try to hold the live call before attempting the new outgoing call.
            // Try to hold the live call before attempting the new outgoing call.
            if (liveCall.can(Connection.CAPABILITY_HOLD)) {
            if (liveCall.can(Connection.CAPABILITY_HOLD)) {
                Log.i(this, "makeRoomForOutgoingCall: holding live call.");
                liveCall.hold();
                liveCall.hold();
                return true;
                return true;
            }
            }
@@ -1531,6 +1549,22 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx
        return true;
        return true;
    }
    }


    /**
     * Given a call, find the first non-null phone account handle of its children.
     *
     * @param parentCall The parent call.
     * @return The first non-null phone account handle of the children, or {@code null} if none.
     */
    private PhoneAccountHandle getFirstChildPhoneAccount(Call parentCall) {
        for (Call childCall : parentCall.getChildCalls()) {
            PhoneAccountHandle childPhoneAccount = childCall.getTargetPhoneAccount();
            if (childPhoneAccount != null) {
                return childPhoneAccount;
            }
        }
        return null;
    }

    /**
    /**
     * Checks to see if the call should be on speakerphone and if so, set it.
     * Checks to see if the call should be on speakerphone and if so, set it.
     */
     */