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

Commit 2e6010c4 authored by Rohit Goyal's avatar Rohit Goyal
Browse files

Add support for progress bar during unarchival of app.

* With this change, progress bar should appear whenever app update for archived app reaches non-zero progress.
* Once the update is cancelled, the progress bar should also disappear.

Test: PromiseIconUiTest and manually tested the progress bar using Play Store
Bug: 302115555
Flag: ACONFIG com.android.launcher3.enable_support_for_archiving DEVELOPMENT
Change-Id: Iacf7a0fd865dba34915fa09f59c63a1da6e47315
parent 97eee72e
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -97,3 +97,10 @@ flag {
    description: "Enables full width two pane widget picker for tablets in landscape and portrait"
    bug: "315055849"
}

flag {
    name: "enable_support_for_archiving"
    namespace: "launcher"
    description: "Enables support for archived apps in Launcher3, such as empty progress bar etc."
    bug: "210590852"
}
+3 −0
Original line number Diff line number Diff line
@@ -923,6 +923,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
            if (mIcon instanceof PreloadIconDrawable) {
                preloadIconDrawable = (PreloadIconDrawable) mIcon;
                preloadIconDrawable.setLevel(progressLevel);
                // TODO(b/302115555): For archived apps, show icon as disabled if active session
                //  exists.
                preloadIconDrawable.setIsDisabled(info.getProgressLevel() == 0);
            } else {
                preloadIconDrawable = makePreloadIcon();
@@ -948,6 +950,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        final PreloadIconDrawable preloadDrawable = newPendingIcon(getContext(), info);

        preloadDrawable.setLevel(progressLevel);
        // TODO(b/302115555): For archived apps, show icon as disabled if active session exists.
        preloadDrawable.setIsDisabled(info.getProgressLevel() == 0);
        return preloadDrawable;
    }
+2 −0
Original line number Diff line number Diff line
@@ -205,6 +205,8 @@ public class AllAppsList {
                            && installInfo.state == PackageInstallInfo.STATUS_INSTALLING) {
                        continue;
                    }
                    // TODO(b/302115555): Handle the case when archived apps are to be updated
                    //  during unarchival start.
                    appInfo.setProgressLevel(installInfo);

                    updatedAppInfos.add(appInfo);
+14 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.launcher3.model;

import static com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN;
import static com.android.launcher3.Flags.enableSupportForArchiving;
import static com.android.launcher3.LauncherPrefs.IS_FIRST_LOAD_AFTER_RESTORE;
import static com.android.launcher3.LauncherPrefs.SHOULD_SHOW_SMARTSPACE;
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APP_PAIR;
@@ -131,6 +132,7 @@ import java.util.concurrent.CancellationException;
 *   - all apps icons
 *   - deep shortcuts within apps
 */
@SuppressWarnings("NewApi")
public class LoaderTask implements Runnable {
    private static final String TAG = "LoaderTask";
    public static final String SMARTSPACE_ON_HOME_SCREEN = "pref_smartspace_home_screen";
@@ -772,13 +774,21 @@ public class LoaderTask implements Runnable {
                                    PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
                        }

                        if (c.restoreFlag != 0 && !TextUtils.isEmpty(targetPkg)) {
                        if ((c.restoreFlag != 0
                                || (enableSupportForArchiving()
                                && activityInfo != null
                                && activityInfo.getApplicationInfo().isArchived))
                                && !TextUtils.isEmpty(targetPkg)) {
                            tempPackageKey.update(targetPkg, c.user);
                            SessionInfo si = installingPkgs.get(tempPackageKey);
                            if (si == null) {
                                info.runtimeStatusFlags
                                        &= ~ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE;
                            } else if (activityInfo == null) {
                            } else if (activityInfo == null
                                    // For archived apps, include progress info in case there is
                                    // a pending install session post restart of device.
                                    || (enableSupportForArchiving()
                                    && activityInfo.getApplicationInfo().isArchived)) {
                                int installProgress = (int) (si.getProgress() * 100);

                                info.setProgressLevel(installProgress,
@@ -1095,6 +1105,8 @@ public class LoaderTask implements Runnable {
            for (int i = 0; i < apps.size(); i++) {
                LauncherActivityInfo app = apps.get(i);
                AppInfo appInfo = new AppInfo(app, user, quietMode);
                // TODO(b/302115555): Handle the case when archived apps with active sessions are
                //  loaded.

                iconRequestInfos.add(new IconRequestInfo<>(
                        appInfo, app, /* useLowResIcon= */ false));
+13 −0
Original line number Diff line number Diff line
@@ -15,9 +15,11 @@
 */
package com.android.launcher3.model;

import static com.android.launcher3.Flags.enableSupportForArchiving;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_PRIVATE_PROFILE_QUIET_MODE_ENABLED;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_WORK_PROFILE_QUIET_MODE_ENABLED;
import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_ARCHIVED;
import static com.android.launcher3.model.data.WorkspaceItemInfo.FLAG_AUTOINSTALL_ICON;
import static com.android.launcher3.model.data.WorkspaceItemInfo.FLAG_RESTORED_ICON;

@@ -67,6 +69,7 @@ import java.util.stream.Collectors;
 * Handles updates due to changes in package manager (app installed/updated/removed)
 * or when a user availability changes.
 */
@SuppressWarnings("NewApi")
public class PackageUpdatedTask extends BaseModelUpdateTask {

    // TODO(b/290090023): Set to false after root causing is done.
@@ -269,6 +272,16 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
                                            : PackageManagerHelper.getLoadingProgress(
                                                    activities.get(0)),
                                    PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
                            // In case an app is archived, we need to make sure that archived state
                            // in WorkspaceItemInfo is refreshed.
                            if (enableSupportForArchiving() && !activities.isEmpty()) {
                                boolean newArchivalState = activities.get(
                                        0).getActivityInfo().isArchived;
                                if (newArchivalState != si.isArchived()) {
                                    si.runtimeStatusFlags ^= FLAG_ARCHIVED;
                                    infoUpdated = true;
                                }
                            }
                            if (si.itemType == Favorites.ITEM_TYPE_APPLICATION) {
                                iconCache.getTitleAndIcon(si, si.usingLowResIcon());
                                infoUpdated = true;
Loading