Add IconCache support for deep shortcuts, loads deepshortcut on

background thread.  Added a feature flag to toggle on/off this
feature.

Bug: 140242324
Test:
  1. (Custom Shortcut) Long click on google maps -> widgets -> drag
     driving mode to workspace.

  2. Open chrome -> add to home screen -> add -> add automatically.

  3. InstallShortcutReceiver
     In Launcher.completeAddShortcut, commend out the code that
     calls PinRequestHelper.createWorkspaceItemFromPinItemRequest,
     then open chrome -> add to home screen -> add -> add
     automatically.

  4. ShortcutDragPreviewProvider
     qdb -> long press on suggested app that has deep shortcut
     -> drag to workspace.

Change-Id: If7babe4eddf5434909bf686b4e9bde15e444d9fd
This commit is contained in:
Pinyao Ting committed 2019-11-05 11:27:28 -08:00
1 parent 5d3dc9c76d
commit c1a1ced33a
11 files changed
+248 -21

No files matched your search

@@ -17,6 +17,7 @@
package com.android.launcher3;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import static com.android.launcher3.util.ShortcutUtil.fetchAndUpdateShortcutIconAsync;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
@@ -44,6 +45,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.icons.BitmapInfo;
import com.android.launcher3.icons.GraphicsUtils;
import com.android.launcher3.icons.LauncherIcons;
@@ -489,9 +491,13 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
return Pair.create(si, null);
} else if (shortcutInfo != null) {
WorkspaceItemInfo itemInfo = new WorkspaceItemInfo(shortcutInfo, mContext);
LauncherIcons li = LauncherIcons.obtain(mContext);
itemInfo.bitmap = li.createShortcutIcon(shortcutInfo);
li.recycle();
if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
fetchAndUpdateShortcutIconAsync(mContext, itemInfo, shortcutInfo, true);
} else {
LauncherIcons li = LauncherIcons.obtain(mContext);
itemInfo.bitmap = li.createShortcutIcon(shortcutInfo);
li.recycle();
}
return Pair.create(itemInfo, shortcutInfo);
} else if (providerInfo != null) {
LauncherAppWidgetProviderInfo info = LauncherAppWidgetProviderInfo