Handle emergency only phone accounts.
Do not expose the emergency only phone account (only marked for wear)
unless we are explicitly querying for accounts that can place emergency
calls.
Bug: 24756957
Change-Id: I195bf25fdaced8ee0be411281d32e422a2987138
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java
index a795d6f..aab193e 100644
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java
@@ -479,7 +479,9 @@
public List<PhoneAccountHandle> getCallCapablePhoneAccounts(
String uriScheme, boolean includeDisabledAccounts) {
return getPhoneAccountHandles(
- PhoneAccount.CAPABILITY_CALL_PROVIDER, uriScheme, null, includeDisabledAccounts);
+ PhoneAccount.CAPABILITY_CALL_PROVIDER,
+ PhoneAccount.CAPABILITY_EMERGENCY_CALLS_ONLY /*excludedCapabilities*/,
+ uriScheme, null, includeDisabledAccounts);
}
/**
@@ -716,35 +718,58 @@
return null;
}
+ private List<PhoneAccountHandle> getPhoneAccountHandles(
+ int capabilities,
+ String uriScheme,
+ String packageName,
+ boolean includeDisabledAccounts) {
+ return getPhoneAccountHandles(capabilities, 0 /*excludedCapabilities*/, uriScheme,
+ packageName, includeDisabledAccounts);
+ }
+
/**
* Returns a list of phone account handles with the specified capabilities, uri scheme,
* and package name.
*/
private List<PhoneAccountHandle> getPhoneAccountHandles(
int capabilities,
+ int excludedCapabilities,
String uriScheme,
String packageName,
boolean includeDisabledAccounts) {
List<PhoneAccountHandle> handles = new ArrayList<>();
for (PhoneAccount account : getPhoneAccounts(
- capabilities, uriScheme, packageName, includeDisabledAccounts)) {
+ capabilities, excludedCapabilities, uriScheme, packageName,
+ includeDisabledAccounts)) {
handles.add(account.getAccountHandle());
}
return handles;
}
+ private List<PhoneAccount> getPhoneAccounts(
+ int capabilities,
+ String uriScheme,
+ String packageName,
+ boolean includeDisabledAccounts) {
+ return getPhoneAccounts(capabilities, 0 /*excludedCapabilities*/, uriScheme, packageName,
+ includeDisabledAccounts);
+ }
+
/**
* Returns a list of phone account handles with the specified flag, supporting the specified
* URI scheme, within the specified package name.
*
* @param capabilities Capabilities which the {@code PhoneAccount} must have. Ignored if 0.
+ * @param excludedCapabilities Capabilities which the {@code PhoneAccount} must not have.
+ * Ignored if 0.
* @param uriScheme URI schemes the PhoneAccount must handle. {@code null} bypasses the
* URI scheme check.
* @param packageName Package name of the PhoneAccount. {@code null} bypasses packageName check.
*/
private List<PhoneAccount> getPhoneAccounts(
int capabilities,
+ int excludedCapabilities,
String uriScheme,
String packageName,
boolean includeDisabledAccounts) {
@@ -755,6 +780,11 @@
continue;
}
+ if ((m.getCapabilities() & excludedCapabilities) != 0) {
+ // If an excluded capability is present, skip.
+ continue;
+ }
+
if (capabilities != 0 && !m.hasCapabilities(capabilities)) {
// Account doesn't have the right capabilities; skip this one.
continue;