diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 598b8ce20c..6e1aa2a4db 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -170,6 +170,9 @@ public class LauncherModel extends BroadcastReceiver // sBgWidgetProviders is the set of widget providers including custom internal widgets public static HashMap sBgWidgetProviders; + // sBgShortcutProviders is the set of custom shortcut providers + public static List sBgShortcutProviders; + // sPendingPackages is a set of packages which could be on sdcard and are not available yet static final HashMap> sPendingPackages = new HashMap>(); @@ -3431,8 +3434,29 @@ public class LauncherModel extends BroadcastReceiver PackageManager packageManager = mApp.getContext().getPackageManager(); final ArrayList widgetsAndShortcuts = new ArrayList(); widgetsAndShortcuts.addAll(getWidgetProviders(mApp.getContext(), refresh)); - Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT); - widgetsAndShortcuts.addAll(packageManager.queryIntentActivities(shortcutsIntent, 0)); + + // Update shortcut providers + synchronized (sBgLock) { + try { + Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT); + List providers = packageManager.queryIntentActivities(shortcutsIntent, 0); + sBgShortcutProviders = providers; + } catch (RuntimeException e) { + if (!LauncherAppState.isDogfoodBuild() && + (e.getCause() instanceof TransactionTooLargeException || + e.getCause() instanceof DeadObjectException)) { + /** + * Ignore exception and use the cached list if available. + * Refer to {@link #getWidgetProviders(Context, boolean}} for more info. + */ + } else { + throw e; + } + } + if (sBgShortcutProviders != null) { + widgetsAndShortcuts.addAll(sBgShortcutProviders); + } + } mBgWidgetsModel.setWidgetsAndShortcuts(widgetsAndShortcuts); }