static void flushInstallQueue(Context context) {
    String spKey = LauncherAppState.getSharedPreferencesKey();
    SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
    ArrayList<PendingInstallShortcutInfo> installQueue = getAndClearInstallQueue(sp, context);
    if (!installQueue.isEmpty()) {
      Iterator<PendingInstallShortcutInfo> iter = installQueue.iterator();
      ArrayList<ItemInfo> addShortcuts = new ArrayList<ItemInfo>();
      while (iter.hasNext()) {
        final PendingInstallShortcutInfo pendingInfo = iter.next();
        final Intent intent = pendingInfo.launchIntent;

        if (LauncherAppState.isDisableAllApps() && !isValidShortcutLaunchIntent(intent)) {
          if (DBG) Log.d(TAG, "Ignoring shortcut with launchIntent:" + intent);
          continue;
        }

        // If the intent specifies a package, make sure the package exists
        String packageName = pendingInfo.getTargetPackage();
        if (!TextUtils.isEmpty(packageName)) {
          UserHandleCompat myUserHandle = UserHandleCompat.myUserHandle();
          if (!LauncherModel.isValidPackage(context, packageName, myUserHandle)) {
            if (DBG) Log.d(TAG, "Ignoring shortcut for absent package:" + intent);
            continue;
          }
        }

        final boolean exists =
            LauncherModel.shortcutExists(context, pendingInfo.label, intent, pendingInfo.user);
        if (!exists) {
          // Generate a shortcut info to add into the model
          addShortcuts.add(pendingInfo.getShortcutInfo());
        }
      }

      // Add the new apps to the model and bind them
      if (!addShortcuts.isEmpty()) {
        LauncherAppState app = LauncherAppState.getInstance();
        app.getModel().addAndBindAddedWorkspaceApps(context, addShortcuts);
      }
    }
  }