Merge "Prevent the creation of Shorcuts with null intents (issue 5629292)" into ics-mr1
This commit is contained in:
@@ -65,11 +65,15 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
|||||||
boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);
|
boolean duplicate = data.getBooleanExtra(Launcher.EXTRA_SHORTCUT_DUPLICATE, true);
|
||||||
if (duplicate || !LauncherModel.shortcutExists(context, name, intent)) {
|
if (duplicate || !LauncherModel.shortcutExists(context, name, intent)) {
|
||||||
LauncherApplication app = (LauncherApplication) context.getApplicationContext();
|
LauncherApplication app = (LauncherApplication) context.getApplicationContext();
|
||||||
app.getModel().addShortcut(context, data,
|
ShortcutInfo info = app.getModel().addShortcut(context, data,
|
||||||
LauncherSettings.Favorites.CONTAINER_DESKTOP, screen, mCoordinates[0],
|
LauncherSettings.Favorites.CONTAINER_DESKTOP, screen, mCoordinates[0],
|
||||||
mCoordinates[1], true);
|
mCoordinates[1], true);
|
||||||
Toast.makeText(context, context.getString(R.string.shortcut_installed, name),
|
if (info != null) {
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, context.getString(R.string.shortcut_installed, name),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name),
|
Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
|||||||
@@ -875,6 +875,9 @@ public final class Launcher extends Activity
|
|||||||
boolean foundCellSpan = false;
|
boolean foundCellSpan = false;
|
||||||
|
|
||||||
ShortcutInfo info = mModel.infoFromShortcutIntent(this, data, null);
|
ShortcutInfo info = mModel.infoFromShortcutIntent(this, data, null);
|
||||||
|
if (info == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
final View view = createShortcut(info);
|
final View view = createShortcut(info);
|
||||||
|
|
||||||
// First we check if we already know the exact location where we want to add this item.
|
// First we check if we already know the exact location where we want to add this item.
|
||||||
|
|||||||
@@ -1772,6 +1772,9 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
ShortcutInfo addShortcut(Context context, Intent data, long container, int screen,
|
ShortcutInfo addShortcut(Context context, Intent data, long container, int screen,
|
||||||
int cellX, int cellY, boolean notify) {
|
int cellX, int cellY, boolean notify) {
|
||||||
final ShortcutInfo info = infoFromShortcutIntent(context, data, null);
|
final ShortcutInfo info = infoFromShortcutIntent(context, data, null);
|
||||||
|
if (info == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
addItemToDatabase(context, info, container, screen, cellX, cellY, notify);
|
addItemToDatabase(context, info, container, screen, cellX, cellY, notify);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
@@ -1835,6 +1838,12 @@ public class LauncherModel extends BroadcastReceiver {
|
|||||||
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
|
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
|
||||||
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
|
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;
|
Bitmap icon = null;
|
||||||
boolean customIcon = false;
|
boolean customIcon = false;
|
||||||
ShortcutIconResource iconResource = null;
|
ShortcutIconResource iconResource = null;
|
||||||
|
|||||||
@@ -2472,7 +2472,9 @@ public class Workspace extends SmoothPagedView
|
|||||||
if (isShortcut) {
|
if (isShortcut) {
|
||||||
final Intent intent = data.getItemAt(index).getIntent();
|
final Intent intent = data.getItemAt(index).getIntent();
|
||||||
Object info = model.infoFromShortcutIntent(mContext, intent, data.getIcon());
|
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 {
|
} else {
|
||||||
if (widgets.size() == 1) {
|
if (widgets.size() == 1) {
|
||||||
// If there is only one item, then go ahead and add and configure
|
// If there is only one item, then go ahead and add and configure
|
||||||
|
|||||||
Reference in New Issue
Block a user