summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/InstallShortcutReceiver.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2013-10-17 20:44:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-17 20:44:10 +0000
commit1fa05179eb4ccbe264c67b6acb3abf2793b03197 (patch)
treee1d2a1ecb78e2324c9125c4b57a69446de367abc /src/com/android/launcher3/InstallShortcutReceiver.java
parent681a4aced8e3b5029aafdc3f45d3f47b96d26f9c (diff)
parent2c1afde5cd60eb13f05aeae0c170e697493ef307 (diff)
downloadandroid_packages_apps_Trebuchet-1fa05179eb4ccbe264c67b6acb3abf2793b03197.tar.gz
android_packages_apps_Trebuchet-1fa05179eb4ccbe264c67b6acb3abf2793b03197.tar.bz2
android_packages_apps_Trebuchet-1fa05179eb4ccbe264c67b6acb3abf2793b03197.zip
Merge "Ensuring that we have a valid name for installed shortcuts. (Bug 11266005)" into jb-ub-now-jetsonic
Diffstat (limited to 'src/com/android/launcher3/InstallShortcutReceiver.java')
-rw-r--r--src/com/android/launcher3/InstallShortcutReceiver.java33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index a9d237a2d..835c472d4 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -223,16 +223,8 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
}
// This name is only used for comparisons and notifications, so fall back to activity name
// if not supplied
- String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
- if (name == null) {
- try {
- PackageManager pm = context.getPackageManager();
- ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0);
- name = info.loadLabel(pm).toString();
- } catch (PackageManager.NameNotFoundException nnfe) {
- return;
- }
- }
+ String name = ensureValidName(context, intent,
+ data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME)).toString();
Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
Intent.ShortcutIconResource iconResource =
data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
@@ -318,6 +310,25 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
}
LauncherAppState app = LauncherAppState.getInstance();
- return app.getModel().infoFromShortcutIntent(context, data, null);
+ ShortcutInfo info = app.getModel().infoFromShortcutIntent(context, data, null);
+ info.title = ensureValidName(context, launchIntent, info.title);
+ return info;
+ }
+
+ /**
+ * Ensures that we have a valid, non-null name. If the provided name is null, we will return
+ * the application name instead.
+ */
+ private static CharSequence ensureValidName(Context context, Intent intent, CharSequence name) {
+ if (name == null) {
+ try {
+ PackageManager pm = context.getPackageManager();
+ ActivityInfo info = pm.getActivityInfo(intent.getComponent(), 0);
+ name = info.loadLabel(pm).toString();
+ } catch (PackageManager.NameNotFoundException nnfe) {
+ return "";
+ }
+ }
+ return name;
}
}