public static void removeFromInstallQueue(
     Context context, ArrayList<String> packageNames, UserHandleCompat user) {
   if (packageNames.isEmpty()) {
     return;
   }
   String spKey = LauncherAppState.getSharedPreferencesKey();
   SharedPreferences sp = context.getSharedPreferences(spKey, Context.MODE_PRIVATE);
   synchronized (sLock) {
     Set<String> strings = sp.getStringSet(APPS_PENDING_INSTALL, null);
     if (DBG) {
       Log.d(TAG, "APPS_PENDING_INSTALL: " + strings + ", removing packages: " + packageNames);
     }
     if (strings != null) {
       Set<String> newStrings = new HashSet<String>(strings);
       Iterator<String> newStringsIter = newStrings.iterator();
       while (newStringsIter.hasNext()) {
         String encoded = newStringsIter.next();
         PendingInstallShortcutInfo info = decode(encoded, context);
         if (info == null
             || (packageNames.contains(info.getTargetPackage()) && user.equals(info.user))) {
           newStringsIter.remove();
         }
       }
       sp.edit().putStringSet(APPS_PENDING_INSTALL, newStrings).commit();
     }
   }
 }
    /** Initializes a PendingInstallShortcutInfo received from a different app. */
    public PendingInstallShortcutInfo(Intent data, Context context) {
      this.data = data;
      mContext = context;

      launchIntent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
      label = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
      user = UserHandleCompat.myUserHandle();
      activityInfo = null;
    }
  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);
      }
    }
  }