Search in sources :

Example 6 with IconCacheUpdateHandler

use of com.android.launcher3.icons.cache.IconCacheUpdateHandler in project Neo-Launcher by NeoApplications.

the class LoaderTask method run.

public void run() {
    synchronized (this) {
        // Skip fast if we are already stopped.
        if (mStopped) {
            return;
        }
    }
    TraceHelper.beginSection(TAG);
    try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
        TraceHelper.partitionSection(TAG, "step 1.1: loading workspace");
        loadWorkspace();
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 1.2: bind workspace workspace");
        mResults.bindWorkspace();
        // Notify the installer packages of packages with active installs on the first screen.
        TraceHelper.partitionSection(TAG, "step 1.3: send first screen broadcast");
        sendFirstScreenActiveInstallsBroadcast();
        // Take a break
        TraceHelper.partitionSection(TAG, "step 1 completed, wait for idle");
        waitForIdle();
        verifyNotStopped();
        // second step
        TraceHelper.partitionSection(TAG, "step 2.1: loading all apps");
        List<LauncherActivityInfo> allActivityList = loadAllApps();
        TraceHelper.partitionSection(TAG, "step 2.2: Binding all apps");
        verifyNotStopped();
        mResults.bindAllApps();
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 2.3: Update icon cache");
        IconCacheUpdateHandler updateHandler = mIconCache.getUpdateHandler();
        setIgnorePackages(updateHandler);
        updateHandler.updateIcons(allActivityList, LauncherActivityCachingLogic.newInstance(mApp.getContext()), mApp.getModel()::onPackageIconsUpdated);
        // Take a break
        TraceHelper.partitionSection(TAG, "step 2 completed, wait for idle");
        waitForIdle();
        verifyNotStopped();
        // third step
        TraceHelper.partitionSection(TAG, "step 3.1: loading deep shortcuts");
        loadDeepShortcuts();
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 3.2: bind deep shortcuts");
        mResults.bindDeepShortcuts();
        // Take a break
        TraceHelper.partitionSection(TAG, "step 3 completed, wait for idle");
        waitForIdle();
        verifyNotStopped();
        // fourth step
        TraceHelper.partitionSection(TAG, "step 4.1: loading widgets");
        List<ComponentWithLabel> allWidgetsList = mBgDataModel.widgetsModel.update(mApp, null);
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 4.2: Binding widgets");
        mResults.bindWidgets();
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 4.3: save widgets in icon cache");
        updateHandler.updateIcons(allWidgetsList, new ComponentCachingLogic(mApp.getContext(), true), mApp.getModel()::onWidgetLabelsUpdated);
        verifyNotStopped();
        TraceHelper.partitionSection(TAG, "step 5: Finish icon cache update");
        updateHandler.finish();
        transaction.commit();
    } catch (CancellationException e) {
        // Loader stopped, ignore
        TraceHelper.partitionSection(TAG, "Cancelled");
    }
    TraceHelper.endSection(TAG);
}
Also used : LauncherModel(com.android.launcher3.LauncherModel) ComponentCachingLogic(com.android.launcher3.icons.ComponentWithLabel.ComponentCachingLogic) CancellationException(java.util.concurrent.CancellationException) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) IconCacheUpdateHandler(com.android.launcher3.icons.cache.IconCacheUpdateHandler) ComponentWithLabel(com.android.launcher3.icons.ComponentWithLabel)

Example 7 with IconCacheUpdateHandler

use of com.android.launcher3.icons.cache.IconCacheUpdateHandler in project Neo-Launcher by NeoApplications.

the class LoaderTask method setIgnorePackages.

private void setIgnorePackages(IconCacheUpdateHandler updateHandler) {
    // Ignore packages which have a promise icon.
    HashSet<String> packagesToIgnore = new HashSet<>();
    synchronized (mBgDataModel) {
        for (ItemInfo info : mBgDataModel.itemsIdMap) {
            if (info instanceof WorkspaceItemInfo) {
                WorkspaceItemInfo si = (WorkspaceItemInfo) info;
                if (si.isPromise() && si.getTargetComponent() != null) {
                    packagesToIgnore.add(si.getTargetComponent().getPackageName());
                }
            } else if (info instanceof LauncherAppWidgetInfo) {
                LauncherAppWidgetInfo lawi = (LauncherAppWidgetInfo) info;
                if (lawi.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)) {
                    packagesToIgnore.add(lawi.providerName.getPackageName());
                }
            }
        }
    }
    updateHandler.setPackagesToIgnore(Process.myUserHandle(), packagesToIgnore);
}
Also used : WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo) ItemInfo(com.android.launcher3.ItemInfo) LauncherAppWidgetInfo(com.android.launcher3.LauncherAppWidgetInfo) HashSet(java.util.HashSet) WorkspaceItemInfo(com.android.launcher3.WorkspaceItemInfo)

Example 8 with IconCacheUpdateHandler

use of com.android.launcher3.icons.cache.IconCacheUpdateHandler in project android_packages_apps_Trebuchet by LineageOS.

the class LoaderTask method run.

public void run() {
    synchronized (this) {
        // Skip fast if we are already stopped.
        if (mStopped) {
            return;
        }
    }
    Object traceToken = TraceHelper.INSTANCE.beginSection(TAG);
    TimingLogger logger = new TimingLogger(TAG, "run");
    try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
        List<ShortcutInfo> allShortcuts = new ArrayList<>();
        loadWorkspace(allShortcuts);
        loadCachedPredictions();
        logger.addSplit("loadWorkspace");
        verifyNotStopped();
        mResults.bindWorkspace();
        logger.addSplit("bindWorkspace");
        // Notify the installer packages of packages with active installs on the first screen.
        sendFirstScreenActiveInstallsBroadcast();
        logger.addSplit("sendFirstScreenActiveInstallsBroadcast");
        // Take a break
        waitForIdle();
        logger.addSplit("step 1 complete");
        verifyNotStopped();
        // second step
        List<LauncherActivityInfo> allActivityList = loadAllApps();
        logger.addSplit("loadAllApps");
        verifyNotStopped();
        mResults.bindAllApps();
        logger.addSplit("bindAllApps");
        verifyNotStopped();
        IconCacheUpdateHandler updateHandler = mIconCache.getUpdateHandler();
        setIgnorePackages(updateHandler);
        updateHandler.updateIcons(allActivityList, LauncherActivityCachingLogic.newInstance(mApp.getContext()), mApp.getModel()::onPackageIconsUpdated);
        logger.addSplit("update icon cache");
        if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
            verifyNotStopped();
            logger.addSplit("save shortcuts in icon cache");
            updateHandler.updateIcons(allShortcuts, new ShortcutCachingLogic(), mApp.getModel()::onPackageIconsUpdated);
        }
        // Take a break
        waitForIdle();
        logger.addSplit("step 2 complete");
        verifyNotStopped();
        // third step
        List<ShortcutInfo> allDeepShortcuts = loadDeepShortcuts();
        logger.addSplit("loadDeepShortcuts");
        verifyNotStopped();
        mResults.bindDeepShortcuts();
        logger.addSplit("bindDeepShortcuts");
        if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
            verifyNotStopped();
            logger.addSplit("save deep shortcuts in icon cache");
            updateHandler.updateIcons(allDeepShortcuts, new ShortcutCachingLogic(), (pkgs, user) -> {
            });
        }
        // Take a break
        waitForIdle();
        logger.addSplit("step 3 complete");
        verifyNotStopped();
        // fourth step
        List<ComponentWithLabelAndIcon> allWidgetsList = mBgDataModel.widgetsModel.update(mApp, null);
        logger.addSplit("load widgets");
        verifyNotStopped();
        mResults.bindWidgets();
        logger.addSplit("bindWidgets");
        verifyNotStopped();
        updateHandler.updateIcons(allWidgetsList, new ComponentWithIconCachingLogic(mApp.getContext(), true), mApp.getModel()::onWidgetLabelsUpdated);
        logger.addSplit("save widgets in icon cache");
        // fifth step
        if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
            loadFolderNames();
        }
        verifyNotStopped();
        updateHandler.finish();
        logger.addSplit("finish icon update");
        transaction.commit();
    } catch (CancellationException e) {
        // Loader stopped, ignore
        logger.addSplit("Cancelled");
    } finally {
        logger.dumpToLog();
    }
    TraceHelper.INSTANCE.endSection(traceToken);
}
Also used : LauncherModel(com.android.launcher3.LauncherModel) ShortcutInfo(android.content.pm.ShortcutInfo) ArrayList(java.util.ArrayList) ShortcutCachingLogic(com.android.launcher3.icons.ShortcutCachingLogic) ComponentWithIconCachingLogic(com.android.launcher3.icons.ComponentWithLabelAndIcon.ComponentWithIconCachingLogic) TimingLogger(android.util.TimingLogger) CancellationException(java.util.concurrent.CancellationException) LauncherActivityInfo(android.content.pm.LauncherActivityInfo) ComponentWithLabelAndIcon(com.android.launcher3.icons.ComponentWithLabelAndIcon) IconCacheUpdateHandler(com.android.launcher3.icons.cache.IconCacheUpdateHandler)

Aggregations

LauncherActivityInfo (android.content.pm.LauncherActivityInfo)7 LauncherModel (com.android.launcher3.LauncherModel)7 IconCacheUpdateHandler (com.android.launcher3.icons.cache.IconCacheUpdateHandler)7 CancellationException (java.util.concurrent.CancellationException)7 ShortcutInfo (android.content.pm.ShortcutInfo)6 TimingLogger (android.util.TimingLogger)6 ComponentWithLabelAndIcon (com.android.launcher3.icons.ComponentWithLabelAndIcon)6 ComponentWithIconCachingLogic (com.android.launcher3.icons.ComponentWithLabelAndIcon.ComponentWithIconCachingLogic)6 ShortcutCachingLogic (com.android.launcher3.icons.ShortcutCachingLogic)6 ArrayList (java.util.ArrayList)6 ItemInfo (com.android.launcher3.ItemInfo)1 LauncherAppWidgetInfo (com.android.launcher3.LauncherAppWidgetInfo)1 WorkspaceItemInfo (com.android.launcher3.WorkspaceItemInfo)1 ComponentWithLabel (com.android.launcher3.icons.ComponentWithLabel)1 ComponentCachingLogic (com.android.launcher3.icons.ComponentWithLabel.ComponentCachingLogic)1 HashSet (java.util.HashSet)1