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

Commit b4f6f73b authored by Sandeep Gutta's avatar Sandeep Gutta Committed by Lukasz Nowicki
Browse files

MSIM: Phone account related changes

- Do not set "always ask" if only one account present
- Use voice subId from SIM Settings as default outgoing account

Change-Id: I9e7b16f20c357f8d3ceedfba781bc893d11c39ea
parent b1fb89c9
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -221,9 +221,39 @@ public final class PhoneAccountRegistrar {
        if (account != null) {
            return mState.defaultOutgoing;
        }
        if (TelephonyManager.getDefault().getPhoneCount() > 1 &&
                   mSubscriptionManager.getActiveSubscriptionInfoCount() == 1) {
            return getUserSelectedVoicePhoneAccount();
        }
        return null;
    }

    PhoneAccountHandle getUserSelectedVoicePhoneAccount() {
        long voiceSubId = SubscriptionManager.getDefaultVoiceSubId();
        PhoneAccountHandle prefPhoneAccount = null;

        Log.i(this, "getUserSelVoicePhoneAccount, voice subId = " + voiceSubId);
        for (int i = 0; i < mState.accounts.size(); i++) {
            String id = mState.accounts.get(i).getAccountHandle().getId();

            // emergency account present return it
            if (id.equals("E")) {
                Log.i(this, "getUserSelVoicePhoneAccount, emergency account ");
                return mState.accounts.get(i).getAccountHandle();
            }

            long subId = Long.parseLong(id);
            Log.i(this, "getUserSelectedVoicePhoneAccount, voice subId = "
                         + voiceSubId + " subId = " + subId + " mId = " + id);
            if (subId == voiceSubId) {
                prefPhoneAccount = mState.accounts.get(i).getAccountHandle();
                break;
            }
        }

        return prefPhoneAccount;
    }

    /**
     * Sets the phone account with which to place all calls by default. Set by the user
     * within phone settings.