summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2014-10-20 10:02:53 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-20 10:02:53 +0000
commit6e96068a334053e641db6d20fff263c5cb7647d6 (patch)
treec5c528eb6f8fd4b6fc664b1c79e08f37cf83b94e
parent5e50d7b55e8f5914f883b32c52c6f891e578e333 (diff)
parent1e76f8882ec9b0505baf8350f000b97bddc90578 (diff)
downloadandroid_packages_apps_Trebuchet-6e96068a334053e641db6d20fff263c5cb7647d6.tar.gz
android_packages_apps_Trebuchet-6e96068a334053e641db6d20fff263c5cb7647d6.tar.bz2
android_packages_apps_Trebuchet-6e96068a334053e641db6d20fff263c5cb7647d6.zip
am 1e76f888: Merge "Adding NPE check in InstallShortcutReceiver" into ub-now-queens
* commit '1e76f8882ec9b0505baf8350f000b97bddc90578': Adding NPE check in InstallShortcutReceiver
-rw-r--r--src/com/android/launcher3/InstallShortcutReceiver.java28
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/LauncherModel.java21
3 files changed, 17 insertions, 34 deletions
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 2edde4fae..e9fb499ad 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -17,7 +17,6 @@
package com.android.launcher3;
import android.content.BroadcastReceiver;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -45,17 +44,17 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
private static final String TAG = "InstallShortcutReceiver";
private static final boolean DBG = false;
- public static final String ACTION_INSTALL_SHORTCUT =
+ private static final String ACTION_INSTALL_SHORTCUT =
"com.android.launcher.action.INSTALL_SHORTCUT";
- public static final String DATA_INTENT_KEY = "intent.data";
- public static final String LAUNCH_INTENT_KEY = "intent.launch";
- public static final String NAME_KEY = "name";
- public static final String ICON_KEY = "icon";
- public static final String ICON_RESOURCE_NAME_KEY = "iconResource";
- public static final String ICON_RESOURCE_PACKAGE_NAME_KEY = "iconResourcePackage";
+ private static final String DATA_INTENT_KEY = "intent.data";
+ private static final String LAUNCH_INTENT_KEY = "intent.launch";
+ private static final String NAME_KEY = "name";
+ private static final String ICON_KEY = "icon";
+ private static final String ICON_RESOURCE_NAME_KEY = "iconResource";
+ private static final String ICON_RESOURCE_PACKAGE_NAME_KEY = "iconResourcePackage";
// The set of shortcuts that are pending install
- public static final String APPS_PENDING_INSTALL = "apps_to_install";
+ private static final String APPS_PENDING_INSTALL = "apps_to_install";
public static final int NEW_SHORTCUT_BOUNCE_DURATION = 450;
public static final int NEW_SHORTCUT_STAGGER_DELAY = 85;
@@ -63,17 +62,13 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
private static final int INSTALL_SHORTCUT_SUCCESSFUL = 0;
private static final int INSTALL_SHORTCUT_IS_DUPLICATE = -1;
- // A mime-type representing shortcut data
- public static final String SHORTCUT_MIMETYPE =
- "com.android.launcher3/shortcut";
-
private static Object sLock = new Object();
private static void addToStringSet(SharedPreferences sharedPrefs,
SharedPreferences.Editor editor, String key, String value) {
Set<String> strings = sharedPrefs.getStringSet(key, null);
if (strings == null) {
- strings = new HashSet<String>(0);
+ strings = new HashSet<String>(1);
} else {
strings = new HashSet<String>(strings);
}
@@ -133,6 +128,9 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
Intent launchIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0);
String pn = launchIntent.getPackage();
if (pn == null) {
+ if (launchIntent.getComponent() == null) {
+ continue;
+ }
pn = launchIntent.getComponent().getPackageName();
}
if (packageNames.contains(pn)) {
@@ -355,7 +353,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
}
LauncherAppState app = LauncherAppState.getInstance();
- ShortcutInfo info = app.getModel().infoFromShortcutIntent(context, data, null);
+ ShortcutInfo info = app.getModel().infoFromShortcutIntent(context, data);
info.title = ensureValidName(context, launchIntent, info.title);
return info;
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ec1c0aa67..dfbef31bd 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1434,7 +1434,7 @@ public class Launcher extends Activity
boolean foundCellSpan = false;
- ShortcutInfo info = mModel.infoFromShortcutIntent(this, data, null);
+ ShortcutInfo info = mModel.infoFromShortcutIntent(this, data);
if (info == null) {
return;
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 0b7ee2e1f..f747423e6 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -3499,17 +3499,6 @@ 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;
- }
-
/**
* Attempts to find an AppWidgetProviderInfo that matches the given component.
*/
@@ -3525,7 +3514,7 @@ public class LauncherModel extends BroadcastReceiver
return null;
}
- ShortcutInfo infoFromShortcutIntent(Context context, Intent data, Bitmap fallbackIcon) {
+ ShortcutInfo infoFromShortcutIntent(Context context, Intent data) {
Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
@@ -3558,12 +3547,8 @@ public class LauncherModel extends BroadcastReceiver
// users wouldn't get here without intent forwarding anyway.
info.user = UserHandleCompat.myUserHandle();
if (icon == null) {
- if (fallbackIcon != null) {
- icon = fallbackIcon;
- } else {
- icon = mIconCache.getDefaultIcon(info.user);
- info.usingFallbackIcon = true;
- }
+ icon = mIconCache.getDefaultIcon(info.user);
+ info.usingFallbackIcon = true;
}
info.setIcon(icon);