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

Commit 6b67a65a authored by Ravindra's avatar Ravindra Committed by Gerrit - the friendly Code Review server
Browse files

Fix to fetch conversation sub correctly and prevent NPE

If the sub is not in LCH and it has a active call then it should
be considered as the conversation sub.
Add null check to avoid NPE due to phone account being null
when there is no sim card.

Change-Id: I5f1b5a978bb2b0f84dfbedb9e4984ba734963496
CRs-Fixed: 764545,764581
parent b8bd1ff6
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -903,13 +903,15 @@ public final class CallsManager extends Call.ListenerBase {
                 getPhoneAccountRegistrar().getPhoneAccount(call.getTargetPhoneAccount());
        if ((call.getTargetPhoneAccount() != null &&
                    call.getTargetPhoneAccount().getId().equals(getActiveSubscription())) &&
                    (phAcc.isSet(PhoneAccount.LCH)) && (getConversationSub() != null) &&
                    (phAcc != null) && (phAcc.isSet(PhoneAccount.LCH)) &&
                    (getConversationSub() != null) &&
                    (!getConversationSub().equals(getActiveSubscription()))) {
            Log.d(this,"Set active sub to conversation sub");
            setActiveSubscription(getConversationSub());
        }

        if ((call.getTargetPhoneAccount() != null) && (phAcc.isSet(PhoneAccount.LCH))) {
        if ((call.getTargetPhoneAccount() != null) && (phAcc != null) &&
                (phAcc.isSet(PhoneAccount.LCH))) {
            Call activecall = getFirstCallWithStateUsingSubId(call.getTargetPhoneAccount().getId(),
                    CallState.RINGING, CallState.DIALING, CallState.ACTIVE, CallState.ON_HOLD);
            Log.d(this,"activecall: " + activecall);
@@ -1682,7 +1684,7 @@ public final class CallsManager extends Call.ListenerBase {

    private String getConversationSub() {
        for (PhoneAccountHandle ph : getPhoneAccountRegistrar().getCallCapablePhoneAccounts()) {
            if (!getPhoneAccountRegistrar().getPhoneAccount(ph).isSet(PhoneAccount.ACTIVE) &&
            if (!getPhoneAccountRegistrar().getPhoneAccount(ph).isSet(PhoneAccount.LCH) &&
                    (getFirstCallWithStateUsingSubId(ph.getId(), CallState.ACTIVE, CallState.DIALING,
                        CallState.ON_HOLD) != null)) {
                Log.d(this, "getConversationSub: " + ph.getId());