summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-11-22 16:42:47 -0800
committerAdam Cohen <adamcohen@google.com>2011-11-22 16:51:26 -0800
commitd919882006a457d16dea46bd546472e6534b5c19 (patch)
tree0a207d19e6b9f57beb53d4bb65f5471eb39974b5 /src/com
parentd016015c2396b885a7ba30f3678d5c50830c20bd (diff)
downloadandroid_packages_apps_Trebuchet-d919882006a457d16dea46bd546472e6534b5c19.tar.gz
android_packages_apps_Trebuchet-d919882006a457d16dea46bd546472e6534b5c19.tar.bz2
android_packages_apps_Trebuchet-d919882006a457d16dea46bd546472e6534b5c19.zip
Prevent the creation of Shorcuts with null intents (issue 5629292)
Change-Id: I54fbad2d4af27c6d8fc0d79c33e890298a3db4dc
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher2/InstallShortcutReceiver.java10
-rw-r--r--src/com/android/launcher2/Launcher.java3
-rw-r--r--src/com/android/launcher2/LauncherModel.java9
-rw-r--r--src/com/android/launcher2/Workspace.java4
4 files changed, 22 insertions, 4 deletions
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java
index 9d7054cf4..ed8f29942 100644
--- a/src/com/android/launcher2/InstallShortcutReceiver.java
+++ b/src/com/android/launcher2/InstallShortcutReceiver.java
@@ -65,11 +65,15 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);
if (duplicate || !LauncherModel.shortcutExists(context, name, intent)) {
LauncherApplication app = (LauncherApplication) context.getApplicationContext();
- app.getModel().addShortcut(context, data,
+ ShortcutInfo info = app.getModel().addShortcut(context, data,
LauncherSettings.Favorites.CONTAINER_DESKTOP, screen, mCoordinates[0],
mCoordinates[1], true);
- Toast.makeText(context, context.getString(R.string.shortcut_installed, name),
- Toast.LENGTH_SHORT).show();
+ if (info != null) {
+ Toast.makeText(context, context.getString(R.string.shortcut_installed, name),
+ Toast.LENGTH_SHORT).show();
+ } else {
+ return false;
+ }
} else {
Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name),
Toast.LENGTH_SHORT).show();
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 6ea14db41..e489e4640 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -873,6 +873,9 @@ public final class Launcher extends Activity
boolean foundCellSpan = false;
ShortcutInfo info = mModel.infoFromShortcutIntent(this, data, null);
+ if (info == null) {
+ return;
+ }
final View view = createShortcut(info);
// First we check if we already know the exact location where we want to add this item.
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 1755903ec..50a36a5b7 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1772,6 +1772,9 @@ public class LauncherModel extends BroadcastReceiver {
ShortcutInfo addShortcut(Context context, Intent data, long container, int screen,
int cellX, int cellY, boolean notify) {
final ShortcutInfo info = infoFromShortcutIntent(context, data, null);
+ if (info == null) {
+ return null;
+ }
addItemToDatabase(context, info, container, screen, cellX, cellY, notify);
return info;
@@ -1835,6 +1838,12 @@ public class LauncherModel extends BroadcastReceiver {
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
+ if (intent == null) {
+ // If the intent is null, we can't construct a valid ShortcutInfo, so we return null
+ Log.e(TAG, "Can't construct ShorcutInfo with null intent");
+ return null;
+ }
+
Bitmap icon = null;
boolean customIcon = false;
ShortcutIconResource iconResource = null;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 79e994203..3f74fd938 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -2455,7 +2455,9 @@ public class Workspace extends SmoothPagedView
if (isShortcut) {
final Intent intent = data.getItemAt(index).getIntent();
Object info = model.infoFromShortcutIntent(mContext, intent, data.getIcon());
- onDropExternal(new int[] { x, y }, info, layout, false);
+ if (info != null) {
+ onDropExternal(new int[] { x, y }, info, layout, false);
+ }
} else {
if (widgets.size() == 1) {
// If there is only one item, then go ahead and add and configure