From 83dba19a8e9d5be6f18a4c9e2e254386c25c66fe Mon Sep 17 00:00:00 2001 From: Bjorn Bringert Date: Thu, 30 Jul 2009 13:58:23 +0100 Subject: [PATCH] Fix in-app search shortcut icons When the suggstion provider is in a different package from the searchable activity, the icons stored for shortcuts used the package of the activity instead of the provider. Fixes http://b/issue?id=2023993 --- core/java/android/app/SearchDialog.java | 9 ++++----- core/java/android/server/search/SearchableInfo.java | 8 ++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 4dd2433e20c41..ea3d762a90252 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -1238,11 +1238,11 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // ensure the icons will work for global search cv.put(SearchManager.SUGGEST_COLUMN_ICON_1, wrapIconForPackage( - source, + mSearchable.getSuggestPackage(), getColumnString(c, SearchManager.SUGGEST_COLUMN_ICON_1))); cv.put(SearchManager.SUGGEST_COLUMN_ICON_2, wrapIconForPackage( - source, + mSearchable.getSuggestPackage(), getColumnString(c, SearchManager.SUGGEST_COLUMN_ICON_2))); // the rest can be passed through directly @@ -1281,11 +1281,11 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS * Wraps an icon for a particular package. If the icon is a resource id, it is converted into * an android.resource:// URI. * - * @param source The source of the icon + * @param packageName The source of the icon * @param icon The icon retrieved from a suggestion column * @return An icon string appropriate for the package. */ - private String wrapIconForPackage(ComponentName source, String icon) { + private String wrapIconForPackage(String packageName, String icon) { if (icon == null || icon.length() == 0 || "0".equals(icon)) { // SearchManager specifies that null or zero can be returned to indicate // no icon. We also allow empty string. @@ -1293,7 +1293,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS } else if (!Character.isDigit(icon.charAt(0))){ return icon; } else { - String packageName = source.getPackageName(); return new Uri.Builder() .scheme(ContentResolver.SCHEME_ANDROID_RESOURCE) .authority(packageName) diff --git a/core/java/android/server/search/SearchableInfo.java b/core/java/android/server/search/SearchableInfo.java index 045b0c2f0874f..69ef98c0c3ce8 100644 --- a/core/java/android/server/search/SearchableInfo.java +++ b/core/java/android/server/search/SearchableInfo.java @@ -102,6 +102,14 @@ public final class SearchableInfo implements Parcelable { return mSuggestAuthority; } + /** + * Gets the name of the package where the suggestion provider lives, + * or {@code null}. + */ + public String getSuggestPackage() { + return mSuggestProviderPackage; + } + /** * Gets the component name of the searchable activity. */