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
diff --git a/src/com/android/telecomm/CreateConnectionProcessor.java b/src/com/android/telecomm/CreateConnectionProcessor.java
index 3e6e544..ac8974c 100644
--- a/src/com/android/telecomm/CreateConnectionProcessor.java
+++ b/src/com/android/telecomm/CreateConnectionProcessor.java
@@ -57,6 +57,24 @@
+ 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 @@
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 @@
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);
+ }
}
}