summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-09-18 08:38:57 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-09-18 09:15:22 -0700
commit31860581536b3fee0221456a2dcc5d6d6f2b7e15 (patch)
tree3d1347266bb103ed33a68d9b9552cb83819736bc
parent0f196e6939ee9f23ea24d046e74fd1d1d3fc953f (diff)
downloadandroid_packages_apps_Trebuchet-31860581536b3fee0221456a2dcc5d6d6f2b7e15.tar.gz
android_packages_apps_Trebuchet-31860581536b3fee0221456a2dcc5d6d6f2b7e15.tar.bz2
android_packages_apps_Trebuchet-31860581536b3fee0221456a2dcc5d6d6f2b7e15.zip
Catching RemoteExceptions when calling packagemanager to get list of shortcuts
Bug: 23796963 Change-Id: I5486c2916e981e7135edd5df360536a362bc2795
-rw-r--r--src/com/android/launcher3/LauncherModel.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 598b8ce20..6e1aa2a4d 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<ComponentKey, LauncherAppWidgetProviderInfo> sBgWidgetProviders;
+ // sBgShortcutProviders is the set of custom shortcut providers
+ public static List<ResolveInfo> sBgShortcutProviders;
+
// sPendingPackages is a set of packages which could be on sdcard and are not available yet
static final HashMap<UserHandleCompat, HashSet<String>> sPendingPackages =
new HashMap<UserHandleCompat, HashSet<String>>();
@@ -3431,8 +3434,29 @@ public class LauncherModel extends BroadcastReceiver
PackageManager packageManager = mApp.getContext().getPackageManager();
final ArrayList<Object> widgetsAndShortcuts = new ArrayList<Object>();
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<ResolveInfo> 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);
}