diff options
author | Winson Chung <winsonc@google.com> | 2011-01-27 15:21:41 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2011-01-27 15:25:44 -0800 |
commit | b3781d934ffb55a282a2567de55a23fb92b71856 (patch) | |
tree | e844246e2a3c9bdc02aa83f028be761847ed42fb /src/com/android/launcher2/InstallShortcutReceiver.java | |
parent | 27b3721bf904d2a1789938a77d3344b8792a41e2 (diff) | |
download | android_packages_apps_Trebuchet-b3781d934ffb55a282a2567de55a23fb92b71856.tar.gz android_packages_apps_Trebuchet-b3781d934ffb55a282a2567de55a23fb92b71856.tar.bz2 android_packages_apps_Trebuchet-b3781d934ffb55a282a2567de55a23fb92b71856.zip |
Adding check to prevent NPE when we get a badly encoded install-shortcut intent. (3398526)
Change-Id: I49c00ff290b126539247f4345e638460040c6ac5
Diffstat (limited to 'src/com/android/launcher2/InstallShortcutReceiver.java')
-rw-r--r-- | src/com/android/launcher2/InstallShortcutReceiver.java | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java index ac50f6605..c67e90ecf 100644 --- a/src/com/android/launcher2/InstallShortcutReceiver.java +++ b/src/com/android/launcher2/InstallShortcutReceiver.java @@ -55,25 +55,27 @@ public class InstallShortcutReceiver extends BroadcastReceiver { if (findEmptyCell(context, mCoordinates, screen)) { Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); + if (intent != null) { + if (intent.getAction() == null) { + intent.setAction(Intent.ACTION_VIEW); + } - if (intent.getAction() == null) { - intent.setAction(Intent.ACTION_VIEW); - } + // By default, we allow for duplicate entries (located in + // different places) + 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, screen, mCoordinates[0], + mCoordinates[1], true); + Toast.makeText(context, context.getString(R.string.shortcut_installed, name), + Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name), + Toast.LENGTH_SHORT).show(); + } - // By default, we allow for duplicate entries (located in - // different places) - boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true); - if (duplicate || !LauncherModel.shortcutExists(context, name, intent)) { - ((LauncherApplication)context.getApplicationContext()).getModel() - .addShortcut(context, data, screen, mCoordinates[0], mCoordinates[1], true); - Toast.makeText(context, context.getString(R.string.shortcut_installed, name), - Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name), - Toast.LENGTH_SHORT).show(); + return true; } - - return true; } else { Toast.makeText(context, context.getString(R.string.out_of_space), Toast.LENGTH_SHORT).show(); |