Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a4670ee authored by Steven Ng's avatar Steven Ng
Browse files

Only clear widgets list upon all widgets & shortcuts update

Test: Install BBC News. Then, quickly go to all widgets tray.
      BBC News widgets is added to the all widgets tray without
      removing other widgets.

Bug: 182897740
Change-Id: I17b50f5128e24c346354b8fb7817a318a94efb62
parent a79c7e42
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ public class WidgetsModel {
                widgetsAndShortcuts.add(new WidgetItem(info, app.getIconCache(), pm));
                updatedItems.add(info);
            }
            setWidgetsAndShortcuts(widgetsAndShortcuts, app);
            setWidgetsAndShortcuts(widgetsAndShortcuts, app, packageUser);
        } catch (Exception e) {
            if (!FeatureFlags.IS_STUDIO_BUILD && Utilities.isBinderSizeError(e)) {
                // the returned value may be incomplete and will not be refreshed until the next
@@ -149,7 +149,7 @@ public class WidgetsModel {
    }

    private synchronized void setWidgetsAndShortcuts(ArrayList<WidgetItem> rawWidgetsShortcuts,
            LauncherAppState app) {
            LauncherAppState app, @Nullable PackageUserKey packageUser) {
        if (DEBUG) {
            Log.d(TAG, "addWidgetsAndShortcuts, widgetsShortcuts#=" + rawWidgetsShortcuts.size());
        }
@@ -158,8 +158,12 @@ public class WidgetsModel {
        // {@link mPackageItemInfos} to locate the key to be used for {@link #mWidgetsList}
        HashMap<PackageUserKey, PackageItemInfo> tmpPackageItemInfos = new HashMap<>();

        // clear the lists.
        // Clear the lists only if this is an update on all widgets and shortcuts. If packageUser
        // isn't null, only updates the shortcuts and widgets for the app represented in
        // packageUser.
        if (packageUser == null) {
            mWidgetsList.clear();
        }
        // add and update.
        mWidgetsList.putAll(rawWidgetsShortcuts.stream()
                .filter(new WidgetValidityCheck(app))