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

Commit 858d82b8 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias Committed by Android (Google) Code Review
Browse files

Merge "Improve all apps loading times." into sc-v2-dev

parents d1ad84c6 dccfe04a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -147,6 +147,11 @@ public final class FeatureFlags {
            false,
            false,
            "Enable loading workspace icons in bulk.");
            "Enable loading workspace icons in bulk.");


    public static final BooleanFlag ENABLE_BULK_ALL_APPS_ICON_LOADING = getDebugFlag(
            "ENABLE_BULK_ALL_APPS_ICON_LOADING",
            false,
            "Enable loading all apps icons in bulk.");

    // Keep as DeviceFlag for remote disable in emergency.
    // Keep as DeviceFlag for remote disable in emergency.
    public static final BooleanFlag ENABLE_OVERVIEW_SELECTIONS = new DeviceFlag(
    public static final BooleanFlag ENABLE_OVERVIEW_SELECTIONS = new DeviceFlag(
            "ENABLE_OVERVIEW_SELECTIONS", true, "Show Select Mode button in Overview Actions");
            "ENABLE_OVERVIEW_SELECTIONS", true, "Show Select Mode button in Overview Actions");
+33 −9
Original line number Original line Diff line number Diff line
@@ -130,30 +130,54 @@ public class AllAppsList {
     * If the app is already in the list, doesn't add it.
     * If the app is already in the list, doesn't add it.
     */
     */
    public void add(AppInfo info, LauncherActivityInfo activityInfo) {
    public void add(AppInfo info, LauncherActivityInfo activityInfo) {
        add(info, activityInfo, true);
    }

    public void add(AppInfo info, LauncherActivityInfo activityInfo, boolean loadIcon) {
        if (!mAppFilter.shouldShowApp(info.componentName)) {
        if (!mAppFilter.shouldShowApp(info.componentName)) {
            return;
            return;
        }
        }
        if (findAppInfo(info.componentName, info.user) != null) {
        if (findAppInfo(info.componentName, info.user) != null) {
            return;
            return;
        }
        }
        if (loadIcon) {
            mIconCache.getTitleAndIcon(info, activityInfo, false /* useLowResIcon */);
            mIconCache.getTitleAndIcon(info, activityInfo, false /* useLowResIcon */);
            info.sectionName = mIndex.computeSectionName(info.title);
            info.sectionName = mIndex.computeSectionName(info.title);
        }


        data.add(info);
        data.add(info);
        mDataChanged = true;
        mDataChanged = true;
    }
    }


    public void addPromiseApp(Context context, PackageInstallInfo installInfo) {
    @Nullable
    public AppInfo addPromiseApp(Context context, PackageInstallInfo installInfo) {
        return addPromiseApp(context, installInfo, true);
    }

    @Nullable
    public AppInfo addPromiseApp(
            Context context, PackageInstallInfo installInfo, boolean loadIcon) {
        // only if not yet installed
        // only if not yet installed
        if (!new PackageManagerHelper(context)
        if (new PackageManagerHelper(context)
                .isAppInstalled(installInfo.packageName, installInfo.user)) {
                .isAppInstalled(installInfo.packageName, installInfo.user)) {
            AppInfo info = new AppInfo(installInfo);
            return null;
            mIconCache.getTitleAndIcon(info, info.usingLowResIcon());
        }
            info.sectionName = mIndex.computeSectionName(info.title);
        AppInfo promiseAppInfo = new AppInfo(installInfo);


            data.add(info);
        if (loadIcon) {
            mIconCache.getTitleAndIcon(promiseAppInfo, promiseAppInfo.usingLowResIcon());
            promiseAppInfo.sectionName = mIndex.computeSectionName(promiseAppInfo.title);
        }

        data.add(promiseAppInfo);
        mDataChanged = true;
        mDataChanged = true;

        return promiseAppInfo;
    }
    }

    public void updateSectionName(AppInfo appInfo) {
        appInfo.sectionName = mIndex.computeSectionName(appInfo.title);

    }
    }


    /** Updates the given PackageInstallInfo's associated AppInfo's installation info. */
    /** Updates the given PackageInstallInfo's associated AppInfo's installation info. */
+31 −4
Original line number Original line Diff line number Diff line
@@ -936,6 +936,8 @@ public class LoaderTask implements Runnable {
        List<LauncherActivityInfo> allActivityList = new ArrayList<>();
        List<LauncherActivityInfo> allActivityList = new ArrayList<>();
        // Clear the list of apps
        // Clear the list of apps
        mBgAllAppsList.clear();
        mBgAllAppsList.clear();

        List<IconRequestInfo<AppInfo>> iconRequestInfos = new ArrayList<>();
        for (UserHandle user : profiles) {
        for (UserHandle user : profiles) {
            // Query for the set of apps
            // Query for the set of apps
            final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
            final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
@@ -948,18 +950,43 @@ public class LoaderTask implements Runnable {
            // Create the ApplicationInfos
            // Create the ApplicationInfos
            for (int i = 0; i < apps.size(); i++) {
            for (int i = 0; i < apps.size(); i++) {
                LauncherActivityInfo app = apps.get(i);
                LauncherActivityInfo app = apps.get(i);
                // This builds the icon bitmaps.
                AppInfo appInfo = new AppInfo(app, user, quietMode);
                mBgAllAppsList.add(new AppInfo(app, user, quietMode), app);

                iconRequestInfos.add(new IconRequestInfo<>(
                        appInfo, app, /* useLowResIcon= */ false));
                mBgAllAppsList.add(
                        appInfo, app, !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());
            }
            }
            allActivityList.addAll(apps);
            allActivityList.addAll(apps);
        }
        }



        if (FeatureFlags.PROMISE_APPS_IN_ALL_APPS.get()) {
        if (FeatureFlags.PROMISE_APPS_IN_ALL_APPS.get()) {
            // get all active sessions and add them to the all apps list
            // get all active sessions and add them to the all apps list
            for (PackageInstaller.SessionInfo info :
            for (PackageInstaller.SessionInfo info :
                    mSessionHelper.getAllVerifiedSessions()) {
                    mSessionHelper.getAllVerifiedSessions()) {
                mBgAllAppsList.addPromiseApp(mApp.getContext(),
                AppInfo promiseAppInfo = mBgAllAppsList.addPromiseApp(
                        PackageInstallInfo.fromInstallingState(info));
                        mApp.getContext(),
                        PackageInstallInfo.fromInstallingState(info),
                        !FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get());

                if (promiseAppInfo != null) {
                    iconRequestInfos.add(new IconRequestInfo<>(
                            promiseAppInfo,
                            /* launcherActivityInfo= */ null,
                            promiseAppInfo.usingLowResIcon()));
                }
            }
        }

        if (FeatureFlags.ENABLE_BULK_ALL_APPS_ICON_LOADING.get()) {
            Trace.beginSection("LoadAllAppsIconsInBulk");
            try {
                mIconCache.getTitlesAndIconsInBulk(iconRequestInfos);
                iconRequestInfos.forEach(iconRequestInfo ->
                        mBgAllAppsList.updateSectionName(iconRequestInfo.itemInfo));
            } finally {
                Trace.endSection();
            }
            }
        }
        }


+13 −0
Original line number Original line Diff line number Diff line
@@ -47,6 +47,19 @@ public class IconRequestInfo<T extends ItemInfoWithIcon> {
    @Nullable public final byte[] iconBlob;
    @Nullable public final byte[] iconBlob;
    public final boolean useLowResIcon;
    public final boolean useLowResIcon;


    public IconRequestInfo(
            @NonNull T itemInfo,
            @Nullable LauncherActivityInfo launcherActivityInfo,
            boolean useLowResIcon) {
        this(
                itemInfo,
                launcherActivityInfo,
                /* packageName= */ null,
                /* resourceName= */ null,
                /* iconBlob= */ null,
                useLowResIcon);
    }

    public IconRequestInfo(
    public IconRequestInfo(
            @NonNull T itemInfo,
            @NonNull T itemInfo,
            @Nullable LauncherActivityInfo launcherActivityInfo,
            @Nullable LauncherActivityInfo launcherActivityInfo,