summaryrefslogtreecommitdiffstats
path: root/telecomm/java/android/telecom/DefaultDialerManager.java
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2015-04-28 15:45:42 -0700
committerYorke Lee <yorkelee@google.com>2015-04-28 17:05:00 -0700
commit856a5ac70474e9f57f71699ad934c701b01c1c7b (patch)
treeb2af03e319bacc7a3baa8184e1417e2ad90f397f /telecomm/java/android/telecom/DefaultDialerManager.java
parentff623a5ab3b26cd98790e355e316a65d76197cbd (diff)
downloadframeworks_base-856a5ac70474e9f57f71699ad934c701b01c1c7b.zip
frameworks_base-856a5ac70474e9f57f71699ad934c701b01c1c7b.tar.gz
frameworks_base-856a5ac70474e9f57f71699ad934c701b01c1c7b.tar.bz2
Filter list of possible default dialers
Make sure they handle the ACTION_DIAL intent with the tel scheme Bug: 20304411 Change-Id: I1822eff8bc014d4679352165ebe2bc819b82f75b
Diffstat (limited to 'telecomm/java/android/telecom/DefaultDialerManager.java')
-rw-r--r--telecomm/java/android/telecom/DefaultDialerManager.java41
1 files changed, 36 insertions, 5 deletions
diff --git a/telecomm/java/android/telecom/DefaultDialerManager.java b/telecomm/java/android/telecom/DefaultDialerManager.java
index b5d566a..e649637 100644
--- a/telecomm/java/android/telecom/DefaultDialerManager.java
+++ b/telecomm/java/android/telecom/DefaultDialerManager.java
@@ -19,6 +19,7 @@ import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.net.Uri;
import android.provider.Settings;
import android.text.TextUtils;
@@ -120,14 +121,14 @@ public class DefaultDialerManager {
for (ResolveInfo resolveInfo : resolveInfoList) {
final ActivityInfo activityInfo = resolveInfo.activityInfo;
- if (activityInfo == null) {
- continue;
+ if (activityInfo != null && !packageNames.contains(activityInfo.packageName)) {
+ packageNames.add(activityInfo.packageName);
}
- packageNames.add(activityInfo.packageName);
}
- // TODO: Filter for apps that don't handle DIAL intent with tel scheme
- return packageNames;
+ final Intent dialIntentWithTelScheme = new Intent(Intent.ACTION_DIAL);
+ dialIntentWithTelScheme.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, "", null));
+ return filterByIntent(context, packageNames, dialIntentWithTelScheme);
}
/**
@@ -151,6 +152,36 @@ public class DefaultDialerManager {
|| packageName.equals(tm.getSystemDialerPackage());
}
+ /**
+ * Filter a given list of package names for those packages that contain an activity that has
+ * an intent filter for a given intent.
+ *
+ * @param context A valid context
+ * @param packageNames List of package names to filter.
+ * @return The filtered list.
+ */
+ private static List<String> filterByIntent(Context context, List<String> packageNames,
+ Intent intent) {
+ if (packageNames == null || packageNames.isEmpty()) {
+ return new ArrayList<>();
+ }
+
+ final List<String> result = new ArrayList<>();
+ final List<ResolveInfo> resolveInfoList =
+ context.getPackageManager().queryIntentActivities(intent, 0);
+ final int length = resolveInfoList.size();
+ for (int i = 0; i < length; i++) {
+ final ActivityInfo info = resolveInfoList.get(i).activityInfo;
+ if (info != null && packageNames.contains(info.packageName)
+ && !result.contains(info.packageName)) {
+ result.add(info.packageName);
+ }
+ }
+
+ return result;
+ }
+
+
private static TelecomManager getTelecomManager(Context context) {
return (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
}