Search in sources :

Example 76 with LauncherAppState

use of com.android.launcher3.LauncherAppState in project android_packages_apps_404Launcher by P-404.

the class Utilities method loadFullDrawableWithoutTheme.

private static Drawable loadFullDrawableWithoutTheme(Context context, ItemInfo info, int width, int height, Object[] outObj) {
    ActivityContext activity = ActivityContext.lookupContext(context);
    LauncherAppState appState = LauncherAppState.getInstance(context);
    if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
        LauncherActivityInfo activityInfo = context.getSystemService(LauncherApps.class).resolveActivity(info.getIntent(), info.user);
        outObj[0] = activityInfo;
        return activityInfo == null ? null : IconProvider.INSTANCE.get(context).getIcon(activityInfo, activity.getDeviceProfile().inv.fillResIconDpi);
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
        if (info instanceof PendingAddShortcutInfo) {
            ShortcutConfigActivityInfo activityInfo = ((PendingAddShortcutInfo) info).activityInfo;
            outObj[0] = activityInfo;
            return activityInfo.getFullResIcon(appState.getIconCache());
        }
        List<ShortcutInfo> si = ShortcutKey.fromItemInfo(info).buildRequest(context).query(ShortcutRequest.ALL);
        if (si.isEmpty()) {
            return null;
        } else {
            outObj[0] = si.get(0);
            return ShortcutCachingLogic.getIcon(context, si.get(0), appState.getInvariantDeviceProfile().fillResIconDpi);
        }
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
        FolderAdaptiveIcon icon = FolderAdaptiveIcon.createFolderAdaptiveIcon(activity, info.id, new Point(width, height));
        if (icon == null) {
            return null;
        }
        outObj[0] = icon;
        return icon;
    } else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_SEARCH_ACTION && info instanceof SearchActionItemInfo) {
        return new AdaptiveIconDrawable(new FastBitmapDrawable(((SearchActionItemInfo) info).bitmap), null);
    } else {
        return null;
    }
}
Also used : ActivityContext(com.android.launcher3.views.ActivityContext) FolderAdaptiveIcon(com.android.launcher3.dragndrop.FolderAdaptiveIcon) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) PendingAddShortcutInfo(com.android.launcher3.widget.PendingAddShortcutInfo) ShortcutConfigActivityInfo(com.android.launcher3.pm.ShortcutConfigActivityInfo) LauncherApps(android.content.pm.LauncherApps) List(java.util.List) SearchActionItemInfo(com.android.launcher3.model.data.SearchActionItemInfo) Point(android.graphics.Point) AdaptiveIconDrawable(android.graphics.drawable.AdaptiveIconDrawable)

Example 77 with LauncherAppState

use of com.android.launcher3.LauncherAppState in project android_packages_apps_Launcher3 by crdroidandroid.

the class PredictionUpdateTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    Context context = app.getContext();
    // TODO: remove this
    Utilities.getDevicePrefs(context).edit().putBoolean(LAST_PREDICTION_ENABLED_STATE, !mTargets.isEmpty()).apply();
    FixedContainerItems fci = mPredictorState.items;
    Set<UserHandle> usersForChangedShortcuts = new HashSet<>(fci.items.stream().filter(info -> info.itemType == ITEM_TYPE_DEEP_SHORTCUT).map(info -> info.user).collect(Collectors.toSet()));
    fci.items.clear();
    for (AppTarget target : mTargets) {
        WorkspaceItemInfo itemInfo;
        ShortcutInfo si = target.getShortcutInfo();
        if (si != null) {
            usersForChangedShortcuts.add(si.getUserHandle());
            itemInfo = new WorkspaceItemInfo(si, context);
            app.getIconCache().getShortcutIcon(itemInfo, si);
        } else {
            String className = target.getClassName();
            if (COMPONENT_CLASS_MARKER.equals(className)) {
                // TODO: Implement this
                continue;
            }
            ComponentName cn = new ComponentName(target.getPackageName(), className);
            UserHandle user = target.getUser();
            itemInfo = apps.data.stream().filter(info -> user.equals(info.user) && cn.equals(info.componentName)).map(ai -> {
                app.getIconCache().getTitleAndIcon(ai, false);
                return ai.makeWorkspaceItem();
            }).findAny().orElseGet(() -> {
                LauncherActivityInfo lai = context.getSystemService(LauncherApps.class).resolveActivity(AppInfo.makeLaunchIntent(cn), user);
                if (lai == null) {
                    return null;
                }
                AppInfo ai = new AppInfo(context, lai, user);
                app.getIconCache().getTitleAndIcon(ai, lai, false);
                return ai.makeWorkspaceItem();
            });
            if (itemInfo == null) {
                continue;
            }
        }
        itemInfo.container = fci.containerId;
        fci.items.add(itemInfo);
    }
    bindExtraContainerItems(fci);
    usersForChangedShortcuts.forEach(u -> dataModel.updateShortcutPinnedState(app.getContext(), u));
    // Save to disk
    mPredictorState.storage.write(context, fci.items);
}
Also used : Context(android.content.Context) Utilities(com.android.launcher3.Utilities) Context(android.content.Context) AppInfo(com.android.launcher3.model.data.AppInfo) ComponentName(android.content.ComponentName) ShortcutInfo(android.content.pm.ShortcutInfo) ITEM_TYPE_DEEP_SHORTCUT(com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) LauncherAppState(com.android.launcher3.LauncherAppState) Set(java.util.Set) Collectors(java.util.stream.Collectors) AppTarget(android.app.prediction.AppTarget) LauncherApps(android.content.pm.LauncherApps) HashSet(java.util.HashSet) List(java.util.List) COMPONENT_CLASS_MARKER(com.android.quickstep.InstantAppResolverImpl.COMPONENT_CLASS_MARKER) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) LAST_PREDICTION_ENABLED_STATE(com.android.launcher3.model.QuickstepModelDelegate.LAST_PREDICTION_ENABLED_STATE) PredictorState(com.android.launcher3.model.QuickstepModelDelegate.PredictorState) ShortcutInfo(android.content.pm.ShortcutInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) AppInfo(com.android.launcher3.model.data.AppInfo) AppTarget(android.app.prediction.AppTarget) UserHandle(android.os.UserHandle) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 78 with LauncherAppState

use of com.android.launcher3.LauncherAppState in project android_packages_apps_Launcher3 by crdroidandroid.

the class PackageIncrementalDownloadUpdatedTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) {
    PackageInstallInfo downloadInfo = new PackageInstallInfo(mPackageName, PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING, mProgress, mUser);
    synchronized (appsList) {
        List<AppInfo> updatedAppInfos = appsList.updatePromiseInstallInfo(downloadInfo);
        if (!updatedAppInfos.isEmpty()) {
            for (AppInfo appInfo : updatedAppInfos) {
                appInfo.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
                scheduleCallbackTask(c -> c.bindIncrementalDownloadProgressUpdated(appInfo));
            }
        }
        bindApplicationsIfNeeded();
    }
    final ArrayList<WorkspaceItemInfo> updatedWorkspaceItems = new ArrayList<>();
    synchronized (dataModel) {
        dataModel.forAllWorkspaceItemInfos(mUser, si -> {
            if (mPackageName.equals(si.getTargetPackage())) {
                si.runtimeStatusFlags &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
                si.setProgressLevel(downloadInfo);
                updatedWorkspaceItems.add(si);
            }
        });
    }
    bindUpdatedWorkspaceItems(updatedWorkspaceItems);
}
Also used : PackageInstallInfo(com.android.launcher3.pm.PackageInstallInfo) ArrayList(java.util.ArrayList) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 79 with LauncherAppState

use of com.android.launcher3.LauncherAppState in project android_packages_apps_Launcher3 by crdroidandroid.

the class PackageUpdatedTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) {
    final Context context = app.getContext();
    final IconCache iconCache = app.getIconCache();
    final String[] packages = mPackages;
    final int N = packages.length;
    final FlagOp flagOp;
    final HashSet<String> packageSet = new HashSet<>(Arrays.asList(packages));
    final ItemInfoMatcher matcher = mOp == OP_USER_AVAILABILITY_CHANGE ? // We want to update all packages for this user
    ItemInfoMatcher.ofUser(mUser) : ItemInfoMatcher.ofPackages(packageSet, mUser);
    final HashSet<ComponentName> removedComponents = new HashSet<>();
    final HashMap<String, List<LauncherActivityInfo>> activitiesLists = new HashMap<>();
    boolean needsRestart = false;
    switch(mOp) {
        case OP_ADD:
            {
                for (int i = 0; i < N; i++) {
                    if (DEBUG)
                        Log.d(TAG, "mAllAppsList.addPackage " + packages[i]);
                    if (isTargetPackage(packages[i])) {
                        needsRestart = true;
                    }
                    iconCache.updateIconsForPkg(packages[i], mUser);
                    if (FeatureFlags.PROMISE_APPS_IN_ALL_APPS.get()) {
                        appsList.removePackage(packages[i], mUser);
                    }
                    activitiesLists.put(packages[i], appsList.addPackage(context, packages[i], mUser));
                }
                flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
                break;
            }
        case OP_UPDATE:
            try (SafeCloseable t = appsList.trackRemoves(a -> removedComponents.add(a.componentName))) {
                for (int i = 0; i < N; i++) {
                    if (DEBUG)
                        Log.d(TAG, "mAllAppsList.updatePackage " + packages[i]);
                    iconCache.updateIconsForPkg(packages[i], mUser);
                    activitiesLists.put(packages[i], appsList.updatePackage(context, packages[i], mUser));
                    app.getWidgetCache().removePackage(packages[i], mUser);
                    // The update may have changed which shortcuts/widgets are available.
                    // Refresh the widgets for the package if we have an activity running.
                    Launcher launcher = Launcher.ACTIVITY_TRACKER.getCreatedActivity();
                    if (launcher != null) {
                        launcher.refreshAndBindWidgetsForPackageUser(new PackageUserKey(packages[i], mUser));
                    }
                }
            }
            // Since package was just updated, the target must be available now.
            flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
            break;
        case OP_REMOVE:
            {
                for (int i = 0; i < N; i++) {
                    FileLog.d(TAG, "Removing app icon" + packages[i]);
                    iconCache.removeIconsForPkg(packages[i], mUser);
                    if (isTargetPackage(packages[i])) {
                        needsRestart = true;
                    }
                }
            // Fall through
            }
        case OP_UNAVAILABLE:
            for (int i = 0; i < N; i++) {
                if (DEBUG)
                    Log.d(TAG, "mAllAppsList.removePackage " + packages[i]);
                appsList.removePackage(packages[i], mUser);
                app.getWidgetCache().removePackage(packages[i], mUser);
            }
            flagOp = FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
            break;
        case OP_SUSPEND:
        case OP_UNSUSPEND:
            flagOp = mOp == OP_SUSPEND ? FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED) : FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED);
            if (DEBUG)
                Log.d(TAG, "mAllAppsList.(un)suspend " + N);
            appsList.updateDisabledFlags(matcher, flagOp);
            for (int i = 0; i < N; i++) {
                if (isTargetPackage(packages[i])) {
                    needsRestart = true;
                }
            }
            break;
        case OP_USER_AVAILABILITY_CHANGE:
            {
                UserManagerState ums = new UserManagerState();
                ums.init(UserCache.INSTANCE.get(context), context.getSystemService(UserManager.class));
                flagOp = ums.isUserQuiet(mUser) ? FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER) : FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER);
                appsList.updateDisabledFlags(matcher, flagOp);
                // We are not synchronizing here, as int operations are atomic
                appsList.setFlags(FLAG_QUIET_MODE_ENABLED, ums.isAnyProfileQuietModeEnabled());
                break;
            }
        default:
            flagOp = FlagOp.NO_OP;
            break;
    }
    bindApplicationsIfNeeded();
    final IntSet removedShortcuts = new IntSet();
    // Shortcuts to keep even if the corresponding app was removed
    final IntSet forceKeepShortcuts = new IntSet();
    // Update shortcut infos
    if (mOp == OP_ADD || flagOp != FlagOp.NO_OP) {
        final ArrayList<WorkspaceItemInfo> updatedWorkspaceItems = new ArrayList<>();
        final ArrayList<LauncherAppWidgetInfo> widgets = new ArrayList<>();
        // For system apps, package manager send OP_UPDATE when an app is enabled.
        final boolean isNewApkAvailable = mOp == OP_ADD || mOp == OP_UPDATE;
        synchronized (dataModel) {
            dataModel.forAllWorkspaceItemInfos(mUser, si -> {
                boolean infoUpdated = false;
                boolean shortcutUpdated = false;
                // Update shortcuts which use iconResource.
                if ((si.iconResource != null) && packageSet.contains(si.iconResource.packageName)) {
                    LauncherIcons li = LauncherIcons.obtain(context);
                    BitmapInfo iconInfo = li.createIconBitmap(si.iconResource);
                    li.recycle();
                    if (iconInfo != null) {
                        si.bitmap = iconInfo;
                        infoUpdated = true;
                    }
                }
                ComponentName cn = si.getTargetComponent();
                if (cn != null && matcher.matches(si, cn)) {
                    String packageName = cn.getPackageName();
                    if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI)) {
                        forceKeepShortcuts.add(si.id);
                        if (mOp == OP_REMOVE) {
                            return;
                        }
                    }
                    if (si.isPromise() && isNewApkAvailable) {
                        boolean isTargetValid = !cn.getClassName().equals(IconCache.EMPTY_CLASS_NAME);
                        if (si.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
                            List<ShortcutInfo> shortcut = new ShortcutRequest(context, mUser).forPackage(cn.getPackageName(), si.getDeepShortcutId()).query(ShortcutRequest.PINNED);
                            if (shortcut.isEmpty()) {
                                isTargetValid = false;
                            } else {
                                si.updateFromDeepShortcutInfo(shortcut.get(0), context);
                                infoUpdated = true;
                            }
                        } else if (isTargetValid) {
                            isTargetValid = context.getSystemService(LauncherApps.class).isActivityEnabled(cn, mUser);
                        }
                        if (!isTargetValid && si.hasStatusFlag(FLAG_RESTORED_ICON | FLAG_AUTOINSTALL_ICON)) {
                            if (updateWorkspaceItemIntent(context, si, packageName)) {
                                infoUpdated = true;
                            } else if (si.hasPromiseIconUi()) {
                                removedShortcuts.add(si.id);
                                return;
                            }
                        } else if (!isTargetValid) {
                            removedShortcuts.add(si.id);
                            FileLog.e(TAG, "Restored shortcut no longer valid " + si.getIntent());
                            return;
                        } else {
                            si.status = WorkspaceItemInfo.DEFAULT;
                            infoUpdated = true;
                        }
                    } else if (isNewApkAvailable && removedComponents.contains(cn)) {
                        if (updateWorkspaceItemIntent(context, si, packageName)) {
                            infoUpdated = true;
                        }
                    }
                    if (isNewApkAvailable) {
                        List<LauncherActivityInfo> activities = activitiesLists.get(packageName);
                        si.setProgressLevel(activities == null || activities.isEmpty() ? 100 : PackageManagerHelper.getLoadingProgress(activities.get(0)), PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
                        if (si.itemType == Favorites.ITEM_TYPE_APPLICATION) {
                            iconCache.getTitleAndIcon(si, si.usingLowResIcon());
                            infoUpdated = true;
                        }
                    }
                    int oldRuntimeFlags = si.runtimeStatusFlags;
                    si.runtimeStatusFlags = flagOp.apply(si.runtimeStatusFlags);
                    if (si.runtimeStatusFlags != oldRuntimeFlags) {
                        shortcutUpdated = true;
                    }
                }
                if (infoUpdated || shortcutUpdated) {
                    updatedWorkspaceItems.add(si);
                }
                if (infoUpdated && si.id != ItemInfo.NO_ID) {
                    getModelWriter().updateItemInDatabase(si);
                }
            });
            for (LauncherAppWidgetInfo widgetInfo : dataModel.appWidgets) {
                if (mUser.equals(widgetInfo.user) && widgetInfo.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY) && packageSet.contains(widgetInfo.providerName.getPackageName())) {
                    widgetInfo.restoreStatus &= ~LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY & ~LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
                    // adding this flag ensures that launcher shows 'click to setup'
                    // if the widget has a config activity. In case there is no config
                    // activity, it will be marked as 'restored' during bind.
                    widgetInfo.restoreStatus |= LauncherAppWidgetInfo.FLAG_UI_NOT_READY;
                    widgets.add(widgetInfo);
                    getModelWriter().updateItemInDatabase(widgetInfo);
                }
            }
        }
        bindUpdatedWorkspaceItems(updatedWorkspaceItems);
        if (!removedShortcuts.isEmpty()) {
            deleteAndBindComponentsRemoved(ItemInfoMatcher.ofItemIds(removedShortcuts));
        }
        if (!widgets.isEmpty()) {
            scheduleCallbackTask(c -> c.bindWidgetsRestored(widgets));
        }
    }
    final HashSet<String> removedPackages = new HashSet<>();
    if (mOp == OP_REMOVE) {
        // Mark all packages in the broadcast to be removed
        Collections.addAll(removedPackages, packages);
    // No need to update the removedComponents as
    // removedPackages is a super-set of removedComponents
    } else if (mOp == OP_UPDATE) {
        // Mark disabled packages in the broadcast to be removed
        final LauncherApps launcherApps = context.getSystemService(LauncherApps.class);
        for (int i = 0; i < N; i++) {
            if (!launcherApps.isPackageEnabled(packages[i], mUser)) {
                removedPackages.add(packages[i]);
            }
        }
    }
    if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) {
        ItemInfoMatcher removeMatch = ItemInfoMatcher.ofPackages(removedPackages, mUser).or(ItemInfoMatcher.ofComponents(removedComponents, mUser)).and(ItemInfoMatcher.ofItemIds(forceKeepShortcuts).negate());
        deleteAndBindComponentsRemoved(removeMatch);
        // Remove any queued items from the install queue
        ItemInstallQueue.INSTANCE.get(context).removeFromInstallQueue(removedPackages, mUser);
    }
    if (mOp == OP_ADD) {
        // AppWidgetHost events, this is just to initialize the long-press options.
        for (int i = 0; i < N; i++) {
            dataModel.widgetsModel.update(app, new PackageUserKey(packages[i], mUser));
        }
        bindUpdatedWidgets(dataModel);
    }
    if (needsRestart) {
        Utilities.restart(context);
    }
}
Also used : HashMap(java.util.HashMap) IntSet(com.android.launcher3.util.IntSet) ArrayList(java.util.ArrayList) ShortcutRequest(com.android.launcher3.shortcuts.ShortcutRequest) IconCache(com.android.launcher3.icons.IconCache) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) ComponentName(android.content.ComponentName) ArrayList(java.util.ArrayList) List(java.util.List) FlagOp(com.android.launcher3.util.FlagOp) HashSet(java.util.HashSet) Context(android.content.Context) ShortcutInfo(android.content.pm.ShortcutInfo) PackageUserKey(com.android.launcher3.util.PackageUserKey) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) LauncherApps(android.content.pm.LauncherApps) LauncherIcons(com.android.launcher3.icons.LauncherIcons) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) Launcher(com.android.launcher3.Launcher) SafeCloseable(com.android.launcher3.util.SafeCloseable) BitmapInfo(com.android.launcher3.icons.BitmapInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 80 with LauncherAppState

use of com.android.launcher3.LauncherAppState in project android_packages_apps_Launcher3 by crdroidandroid.

the class ShortcutsChangedTask method execute.

@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
    final Context context = app.getContext();
    // Find WorkspaceItemInfo's that have changed on the workspace.
    ArrayList<WorkspaceItemInfo> matchingWorkspaceItems = new ArrayList<>();
    synchronized (dataModel) {
        dataModel.forAllWorkspaceItemInfos(mUser, si -> {
            if ((si.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) && mPackageName.equals(si.getIntent().getPackage())) {
                matchingWorkspaceItems.add(si);
            }
        });
    }
    if (!matchingWorkspaceItems.isEmpty()) {
        if (mShortcuts.isEmpty()) {
            // Verify that the app is indeed installed.
            if (!new PackageManagerHelper(app.getContext()).isAppInstalled(mPackageName, mUser)) {
                // App is not installed, ignoring package events
                return;
            }
        }
        // Update the workspace to reflect the changes to updated shortcuts residing on it.
        List<String> allLauncherKnownIds = matchingWorkspaceItems.stream().map(WorkspaceItemInfo::getDeepShortcutId).distinct().collect(Collectors.toList());
        List<ShortcutInfo> shortcuts = new ShortcutRequest(context, mUser).forPackage(mPackageName, allLauncherKnownIds).query(ShortcutRequest.ALL);
        Set<String> nonPinnedIds = new HashSet<>(allLauncherKnownIds);
        ArrayList<WorkspaceItemInfo> updatedWorkspaceItemInfos = new ArrayList<>();
        for (ShortcutInfo fullDetails : shortcuts) {
            if (!fullDetails.isPinned()) {
                continue;
            }
            String sid = fullDetails.getId();
            nonPinnedIds.remove(sid);
            matchingWorkspaceItems.stream().filter(itemInfo -> sid.equals(itemInfo.getDeepShortcutId())).forEach(workspaceItemInfo -> {
                workspaceItemInfo.updateFromDeepShortcutInfo(fullDetails, context);
                app.getIconCache().getShortcutIcon(workspaceItemInfo, fullDetails);
                updatedWorkspaceItemInfos.add(workspaceItemInfo);
            });
        }
        bindUpdatedWorkspaceItems(updatedWorkspaceItemInfos);
        if (!nonPinnedIds.isEmpty()) {
            deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(nonPinnedIds.stream().map(id -> new ShortcutKey(mPackageName, mUser, id)).collect(Collectors.toSet())));
        }
    }
    if (mUpdateIdMap) {
        // Update the deep shortcut map if the list of ids has changed for an activity.
        dataModel.updateDeepShortcutCounts(mPackageName, mUser, mShortcuts);
        bindDeepShortcuts(dataModel);
    }
}
Also used : Context(android.content.Context) Context(android.content.Context) ShortcutInfo(android.content.pm.ShortcutInfo) LauncherAppState(com.android.launcher3.LauncherAppState) Set(java.util.Set) LauncherSettings(com.android.launcher3.LauncherSettings) Collectors(java.util.stream.Collectors) ShortcutKey(com.android.launcher3.shortcuts.ShortcutKey) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) UserHandle(android.os.UserHandle) ShortcutRequest(com.android.launcher3.shortcuts.ShortcutRequest) ItemInfoMatcher(com.android.launcher3.util.ItemInfoMatcher) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) ShortcutInfo(android.content.pm.ShortcutInfo) ArrayList(java.util.ArrayList) ShortcutRequest(com.android.launcher3.shortcuts.ShortcutRequest) ShortcutKey(com.android.launcher3.shortcuts.ShortcutKey) PackageManagerHelper(com.android.launcher3.util.PackageManagerHelper) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)62 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)56 Context (android.content.Context)39 LauncherAppState (com.android.launcher3.LauncherAppState)38 HashSet (java.util.HashSet)37 ShortcutInfo (android.content.pm.ShortcutInfo)33 List (java.util.List)33 ComponentName (android.content.ComponentName)32 ItemInfo (com.android.launcher3.model.data.ItemInfo)30 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)24 Point (android.graphics.Point)24 LauncherApps (android.content.pm.LauncherApps)23 IconCache (com.android.launcher3.icons.IconCache)23 LauncherIcons (com.android.launcher3.icons.LauncherIcons)23 AppInfo (com.android.launcher3.model.data.AppInfo)22 PackageManager (android.content.pm.PackageManager)20 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)20 HashMap (java.util.HashMap)20 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)19 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)19