Allowing enable/disable of phone accounts. (2/3)
- Change broadcast listener to listen to PACKAGE_FULLY_REMOVED instead
of PACKAGE_REMOVED. This ensures re-installing an app will not
remove all PhoneAccounts, losing the enabled states.
- Changed some method names.
- Added PhoneAccountRegistrar methods to enable/disable PhoneAccounts.
- Changed PhoneAccountRegistrar register method to copy over the
previous enabled state for phone accounts.
- Added some TelecomService methods.
Bug: 17306514
Bug: 17408536
Change-Id: Ie8c5e9f3ddec988b42bee682c91671cec904076b
diff --git a/src/com/android/telecomm/CreateConnectionProcessor.java b/src/com/android/telecomm/CreateConnectionProcessor.java
index fcf94cc..023f43e 100644
--- a/src/com/android/telecomm/CreateConnectionProcessor.java
+++ b/src/com/android/telecomm/CreateConnectionProcessor.java
@@ -235,31 +235,39 @@
if (TelephonyUtil.shouldProcessAsEmergency(TelecommApp.getInstance(), mCall.getHandle())) {
Log.i(this, "Emergency number detected");
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())) {
- Log.i(this, "Will try PSTN account %s for emergency", allAccountHandles.get(i));
+ List<PhoneAccount> allAccounts = TelecommApp.getInstance()
+ .getPhoneAccountRegistrar().getAllPhoneAccounts();
+ // First, add SIM phone accounts which can place emergency calls.
+ for (PhoneAccount phoneAccount : allAccounts) {
+ if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS) &&
+ phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
+ Log.i(this, "Will try PSTN account %s for emergency",
+ phoneAccount.getAccountHandle());
mAttemptRecords.add(
new CallAttemptRecord(
- allAccountHandles.get(i),
- allAccountHandles.get(i)));
+ phoneAccount.getAccountHandle(),
+ phoneAccount.getAccountHandle()));
}
}
- // Next, add the connection manager account as a backup.
- PhoneAccountHandle callManager = TelecommApp.getInstance()
+ // Next, add the connection manager account as a backup if it can place emergency calls.
+ PhoneAccountHandle callManagerHandle = TelecommApp.getInstance()
.getPhoneAccountRegistrar().getSimCallManager();
- CallAttemptRecord callAttemptRecord = new CallAttemptRecord(callManager,
- TelecommApp.getInstance().getPhoneAccountRegistrar().
- getDefaultOutgoingPhoneAccount(mCall.getHandle().getScheme()));
+ if (callManagerHandle != null) {
+ PhoneAccount callManager = TelecommApp.getInstance()
+ .getPhoneAccountRegistrar().getPhoneAccount(callManagerHandle);
+ if (callManager.hasCapabilities(PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS)) {
+ CallAttemptRecord callAttemptRecord = new CallAttemptRecord(callManagerHandle,
+ TelecommApp.getInstance().getPhoneAccountRegistrar().
+ getDefaultOutgoingPhoneAccount(mCall.getHandle().getScheme())
+ );
- if (callManager != null && !mAttemptRecords.contains(callAttemptRecord)) {
- Log.i(this, "Will try Connection Manager account %s for emergency",
- callManager);
- mAttemptRecords.add(callAttemptRecord);
+ if (!mAttemptRecords.contains(callAttemptRecord)) {
+ Log.i(this, "Will try Connection Manager account %s for emergency",
+ callManager);
+ mAttemptRecords.add(callAttemptRecord);
+ }
+ }
}
}
}