From f6b384045db92e1a47fa1135405e5618f4bf8d24 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Wed, 11 Nov 2009 15:22:37 -0800 Subject: [PATCH] Fix for NPE in #2248683 Also fix a problem in type-to-filter. It was looking for substring match instead of searching on word boundaries. It will now search by word boundaries (separated by space). --- src/com/android/settings/ManageApplications.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/ManageApplications.java b/src/com/android/settings/ManageApplications.java index a71d17bb0aa..9cd6e23ce3a 100644 --- a/src/com/android/settings/ManageApplications.java +++ b/src/com/android/settings/ManageApplications.java @@ -1403,13 +1403,17 @@ public class ManageApplications extends ListActivity implements } } else { final String prefixString = prefix.toString().toLowerCase(); + final String spacePrefixString = " " + prefixString; Map newMap = new HashMap(); synchronized (mFilterLock) { Map localMap = mFilterMap; Set keys = mFilterMap.keySet(); for (String key : keys) { String label = localMap.get(key); - if (label.indexOf(prefixString) != -1) { + if (label == null) continue; + label = label.toLowerCase(); + if (label.startsWith(prefixString) + || label.indexOf(spacePrefixString) != -1) { newMap.put(key, label); } } @@ -1895,6 +1899,9 @@ public class ManageApplications extends ListActivity implements public final int compare(ApplicationInfo a, ApplicationInfo b) { AppInfo ainfo = mCache.getEntry(a.packageName); AppInfo binfo = mCache.getEntry(b.packageName); + // Check for null app names, to avoid NPE in rare cases + if (ainfo == null || ainfo.appName == null) return -1; + if (binfo == null || binfo.appName == null) return 1; return sCollator.compare(ainfo.appName.toString(), binfo.appName.toString()); } }