summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Miranda <jonmiranda@google.com>2019-10-29 19:03:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-10-29 19:03:25 +0000
commitdafd8d92255cc1dbb4d810ab244bcdc66415ab50 (patch)
tree797a15b7bda14d64f5c1ee8ce32da2b48f4fadd7 /src
parent329fca4550172c3075dc3437c1d9ba2a2491ef6e (diff)
parent4459e3f6f91fdd917850f9d37c1a4a734fa55ed7 (diff)
downloadandroid_packages_apps_Trebuchet-dafd8d92255cc1dbb4d810ab244bcdc66415ab50.tar.gz
android_packages_apps_Trebuchet-dafd8d92255cc1dbb4d810ab244bcdc66415ab50.tar.bz2
android_packages_apps_Trebuchet-dafd8d92255cc1dbb4d810ab244bcdc66415ab50.zip
Merge "Fix NPE caused by an install flow where we decode the LauncherActivityInfo but we don't fill in the data Intent." into ub-launcher3-qt-future-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/InstallShortcutReceiver.java35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index f6ed70ed0..fe916028b 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -21,6 +21,7 @@ import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -38,6 +39,7 @@ import android.util.Base64;
import android.util.Log;
import android.util.Pair;
+import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import com.android.launcher3.compat.LauncherAppsCompat;
@@ -239,11 +241,6 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
return info == null ? null : (WorkspaceItemInfo) info.getItemInfo().first;
}
- public static WorkspaceItemInfo fromActivityInfo(LauncherActivityInfo info, Context context) {
- return (WorkspaceItemInfo)
- new PendingInstallShortcutInfo(info, context).getItemInfo().first;
- }
-
public static void queueShortcut(ShortcutInfo info, Context context) {
queuePendingShortcutInfo(new PendingInstallShortcutInfo(info, context), context);
}
@@ -319,10 +316,10 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
private static class PendingInstallShortcutInfo {
final boolean isActivity;
- final ShortcutInfo shortcutInfo;
- final AppWidgetProviderInfo providerInfo;
+ @Nullable final ShortcutInfo shortcutInfo;
+ @Nullable final AppWidgetProviderInfo providerInfo;
- final Intent data;
+ @Nullable final Intent data;
final Context mContext;
final Intent launchIntent;
final String label;
@@ -352,7 +349,12 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
shortcutInfo = null;
providerInfo = null;
- data = null;
+ String packageName = info.getComponentName().getPackageName();
+ data = new Intent();
+ data.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent().setComponent(
+ new ComponentName(packageName, "")).setPackage(packageName));
+ data.putExtra(Intent.EXTRA_SHORTCUT_NAME, info.getLabel());
+
user = info.getUser();
mContext = context;
@@ -446,9 +448,10 @@ 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 = ensureValidName(mContext, launchIntent, label).toString();
- Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
- Intent.ShortcutIconResource iconResource =
- data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
+ Bitmap icon = data == null ? null
+ : data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
+ Intent.ShortcutIconResource iconResource = data == null ? null
+ : data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
// Only encode the parameters which are supported by the API.
JSONStringer json = new JSONStringer()
@@ -460,9 +463,11 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
.key(APP_SHORTCUT_TYPE_KEY).value(isActivity);
if (icon != null) {
byte[] iconByteArray = GraphicsUtils.flattenBitmap(icon);
- json = json.key(ICON_KEY).value(
- Base64.encodeToString(
- iconByteArray, 0, iconByteArray.length, Base64.DEFAULT));
+ if (iconByteArray != null) {
+ json = json.key(ICON_KEY).value(
+ Base64.encodeToString(
+ iconByteArray, 0, iconByteArray.length, Base64.DEFAULT));
+ }
}
if (iconResource != null) {
json = json.key(ICON_RESOURCE_NAME_KEY).value(iconResource.resourceName);