From da4093923903a53273c7ba86daaa5af0d1cf3d97 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Queru Date: Fri, 27 Feb 2009 16:53:12 -0800 Subject: Optimize call to queryIntentActivities() Replace a call to queryIntentActivities() with a calls to resolveActivity(). This is done since the only purpose of the call is to check if the returned list is empty or non-empty. It's inefficient to move an entire list across the process boundary, only to discard it. --- src/com/android/providers/downloads/Helpers.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java index 0226eba4..866cddcb 100644 --- a/src/com/android/providers/downloads/Helpers.java +++ b/src/com/android/providers/downloads/Helpers.java @@ -38,7 +38,6 @@ import android.webkit.MimeTypeMap; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.util.List; import java.util.Random; import java.util.Set; import java.util.regex.Matcher; @@ -115,11 +114,10 @@ public class Helpers { PackageManager pm = context.getPackageManager(); intent.setDataAndType(Uri.fromParts("file", "", null), mimeType); - List list = pm.queryIntentActivities(intent, - PackageManager.MATCH_DEFAULT_ONLY); + ResolveInfo ri = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); //Log.i(Constants.TAG, "*** FILENAME QUERY " + intent + ": " + list); - if (list.size() == 0) { + if (ri == null) { if (Config.LOGD) { Log.d(Constants.TAG, "no handler found for type " + mimeType); } -- cgit v1.2.3