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

Commit 28849dfa authored by Muhammed Siju's avatar Muhammed Siju
Browse files

Fix issue during swapping of SIP and CS calls.

Since SIP phone account id is different from Telephone account id
hold/unhold was not issued correctly during swapping of sip and cs
calls. To fix this, avoid comparing the account ids if one of the
calls is a sip call.
Also make sure that there is no LCH update during active/hold sip
calls.

Change-Id: I46955d1b750cf6336c59fddb03fa1e996d768c28
CRs-Fixed: 738816
parent b71a0810
Loading
Loading
Loading
Loading
+26 −8
Original line number Diff line number Diff line
@@ -793,7 +793,7 @@ public final class CallsManager extends Call.ListenerBase {

                // if 'c' is not for same subscription as call, then don't disturb 'c'
                if (c != null && c.isAlive() && c != call && (ph != null
                        && ph1 != null && ph.getId().equals(ph1.getId()))) {
                        && ph1 != null && isSameIdOrSipId(ph.getId(), ph1.getId()))) {
                    c.hold();
                }
            }
@@ -801,6 +801,16 @@ public final class CallsManager extends Call.ListenerBase {
        }
    }

    /**
     *  Returns true if the ids are same or one of the ids is sip id.
     */
    private boolean isSameIdOrSipId(String id1, String id2) {
        boolean ret = ((id1 != null && id2 != null) &&
                (id1.equals(id2) || id1.contains("sip") || id2.contains("sip")));
        Log.d(this, "isSameIdOrSipId: id1 = " + id1 + " id2 = " + id2 + " ret = " + ret);
        return ret;
    }

    /** Called by the in-call UI to change the mute state. */
    void mute(boolean shouldMute) {
        mCallAudioManager.mute(shouldMute);
@@ -1028,7 +1038,7 @@ public final class CallsManager extends Call.ListenerBase {
            PhoneAccountHandle otherCallPh = otherCall.getTargetPhoneAccount();
            // if 'otherCall' is not for same subscription as 'call', then don't consider it
            if (call != otherCall && otherCall.getParentCall() == null && ph != null
                    && otherCallPh != null && ph.getId().equals(otherCallPh.getId())) {
                    && otherCallPh != null && isSameIdOrSipId(ph.getId(), otherCallPh.getId())) {
                return false;
            }
        }
@@ -1126,7 +1136,7 @@ public final class CallsManager extends Call.ListenerBase {
            // check the foreground first
            if (mForegroundCall != null && mForegroundCall.getState() == currentState
                    && mForegroundCall.getTargetPhoneAccount() != null
                    && mForegroundCall.getTargetPhoneAccount().getId().equals(subId)) {
                    && isSameIdOrSipId(mForegroundCall.getTargetPhoneAccount().getId(), subId)) {
                return mForegroundCall;
            }

@@ -1143,13 +1153,13 @@ public final class CallsManager extends Call.ListenerBase {
                if ((call.getTargetPhoneAccount() == null) && (call.getChildCalls().size() > 1)) {
                    Call child = call.getChildCalls().get(0);
                    PhoneAccountHandle childph = child.getTargetPhoneAccount();
                    if (childph.getId().equals(subId)) {
                    if (childph != null && isSameIdOrSipId(childph.getId(), subId)) {
                        return call;
                    }
                }

                if (currentState == call.getState() && call.getTargetPhoneAccount() != null
                        && call.getTargetPhoneAccount().equals(subId)) {
                        && isSameIdOrSipId(call.getTargetPhoneAccount().getId(), subId)) {
                    return call;
                }
            }
@@ -1434,7 +1444,7 @@ public final class CallsManager extends Call.ListenerBase {
        for (int state : states) {
            for (Call call : mCalls) {
                if (call.getState() == state && call.getTargetPhoneAccount() != null
                        && call.getTargetPhoneAccount().getId().equals(subId)) {
                        && isSameIdOrSipId(call.getTargetPhoneAccount().getId(), subId)) {
                    count++;
                }
            }
@@ -1736,14 +1746,15 @@ public final class CallsManager extends Call.ListenerBase {
            // check the foreground first
            if (mForegroundCall != null && mForegroundCall.getState() == currentState
                    && (mForegroundCall.getTargetPhoneAccount() != null)
                    && mForegroundCall.getTargetPhoneAccount().getId().equals(sub)) {
                    && isSameIdOrSipId(mForegroundCall.getTargetPhoneAccount().getId(),
                    sub)) {
                return mForegroundCall;
            }

            for (Call call : mCalls) {
                if ((currentState == call.getState()) &&
                        (call.getTargetPhoneAccount() != null) &&
                        (call.getTargetPhoneAccount().getId().equals(sub))) {
                        (isSameIdOrSipId(call.getTargetPhoneAccount().getId(), sub))) {
                    return call;
                }
            }
@@ -1858,8 +1869,15 @@ public final class CallsManager extends Call.ListenerBase {
     */
    private void updateLchStatus(String subInConversation) {
        Log.i(this, "updateLchStatus subInConversation: " + subInConversation);
        if (subInConversation != null && subInConversation.contains("sip")) {
            return;
        }
        for (PhoneAccountHandle ph : getPhoneAccountRegistrar().getCallCapablePhoneAccounts()) {
            String sub = ph.getId();
            if (sub != null && sub.contains("sip")) {
                Log.d(this, "update lch. Skipping account: " + sub);
                continue;
            }
            PhoneAccount phAcc = getPhoneAccountRegistrar().getPhoneAccount(ph);
            boolean lchState = false;
            if (subInConversation != null && hasActiveOrHoldingCall(sub) &&