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

Commit 6e6f6d1f authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Support for third-party emergency calls.

Modified CreateConnectionProcessor to get the PhoneAccount with
CAPABILITY_CONNECTION_MANAGER and add it to the mAttemptRecords so that
it will be tried after the PSTN phone account.

Bug: 16846053
Change-Id: Ib8df2c6f1a717bccff57d0354b7d4a4fb661d0f3
parent d0a8d8be
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -57,6 +57,24 @@ final class CreateConnectionProcessor {
                    + Objects.toString(connectionManagerPhoneAccount) + ","
                    + Objects.toString(targetPhoneAccount) + ")";
        }

        /**
         * Determines if this instance of {@code CallAttemptRecord} has the same underlying
         * {@code PhoneAccountHandle}s as another instance.
         *
         * @param obj The other instance to compare against.
         * @return {@code True} if the {@code CallAttemptRecord}s are equal.
         */
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof CallAttemptRecord) {
                CallAttemptRecord other = (CallAttemptRecord) obj;
                return Objects.equals(connectionManagerPhoneAccount,
                        other.connectionManagerPhoneAccount) &&
                        Objects.equals(targetPhoneAccount, other.targetPhoneAccount);
            }
            return false;
        }
    }

    private final Call mCall;
@@ -189,6 +207,7 @@ final class CreateConnectionProcessor {
            mAttemptRecords.clear();
            List<PhoneAccountHandle> allAccountHandles = TelecommApp.getInstance()
                    .getPhoneAccountRegistrar().getOutgoingPhoneAccounts();
            // First, add the PSTN phone account
            for (int i = 0; i < allAccountHandles.size(); i++) {
                if (TelephonyUtil.isPstnComponentName(
                        allAccountHandles.get(i).getComponentName())) {
@@ -199,6 +218,19 @@ final class CreateConnectionProcessor {
                                    allAccountHandles.get(i)));
                }
            }

            // Next, add the connection manager account as a backup.
            PhoneAccountHandle callManager = TelecommApp.getInstance()
                    .getPhoneAccountRegistrar().getSimCallManager();
            CallAttemptRecord callAttemptRecord = new CallAttemptRecord(callManager,
                    TelecommApp.getInstance().getPhoneAccountRegistrar().
                            getDefaultOutgoingPhoneAccount());

            if (callManager != null && !mAttemptRecords.contains(callAttemptRecord)) {
                Log.i(this, "Will try Connection Manager account %s for emergency",
                        callManager);
                mAttemptRecords.add(callAttemptRecord);
            }
        }
    }