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

Commit 4a834cf6 authored by Deqiang Chen's avatar Deqiang Chen
Browse files

In the case that no SIM phone account is available for emergency, pick the...

In the case that no SIM phone account is available for emergency, pick the non-sim phone account for emergency

Bug:123505743
Test: adb shell setprop ril.ecclist 911,122,*911,#911,411
And then manual test when there is no-sim subscription phone account, the
phone account indicating emergency capability is chosen for 411 ecall.

Change-Id: I087e98d0948714d2d06435de604901d18af1b912
(cherry picked from commit 385c8bc69655f8370e773f7b485233790e661459)
parent 4d47bcb4
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -311,6 +311,38 @@ public class CreateConnectionProcessor implements CreateConnectionResponse {
        }
    }

    // This function is used after previous attempts to find emergency PSTN connections
    // do not find any SIM phone accounts with emergency capability.
    // It attempts to add any accounts with CAPABILITY_PLACE_EMERGENCY_CALLS even if
    // accounts are not SIM accounts.
    private void adjustAttemptsForEmergencyNoSimRequired(
            PhoneAccountHandle preferredPAH,
            List<PhoneAccount> allAccounts) {
        // First, possibly add the phone account that the user prefers.
        PhoneAccount preferredPA = mPhoneAccountRegistrar.getPhoneAccountUnchecked(preferredPAH);
        if (preferredPA != null
                && preferredPA.hasCapabilities(PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS)) {
            Log.i(this, "Will try account %s for emergency", preferredPA.getAccountHandle());
            mAttemptRecords.add(new CallAttemptRecord(preferredPAH, preferredPAH));
        }

        // Next, add all phone accounts which can place emergency calls.
        // If preferredPA already has an emergency PhoneAccount, do not add others since the
        // emergency call be redialed in Telephony.
        if (mAttemptRecords.isEmpty()) {
            for (PhoneAccount phoneAccount : allAccounts) {
                if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS)) {
                    PhoneAccountHandle phoneAccountHandle = phoneAccount.getAccountHandle();
                    Log.i(this, "Will try account %s for emergency", phoneAccountHandle);
                    mAttemptRecords.add(
                            new CallAttemptRecord(phoneAccountHandle, phoneAccountHandle));
                    // Add only one emergency PhoneAccount to the attempt list.
                    break;
                }
            }
        }
    }

    // If we are possibly attempting to call a local emergency number, ensure that the
    // plain PSTN connection services are listed, and nothing else.
    private void adjustAttemptsForEmergency(PhoneAccountHandle preferredPAH) {
@@ -383,6 +415,12 @@ public class CreateConnectionProcessor implements CreateConnectionResponse {
                    }
                }
            }

            if (mAttemptRecords.isEmpty()) {
                // Last best-effort attempt: choose any account with emergency capability even without
                // sim capability.
                adjustAttemptsForEmergencyNoSimRequired(preferredPAH, allAccounts);
            }
        }
    }