From 328c32235ee537f7d6033f2e9b9234f8ae7b3c84 Mon Sep 17 00:00:00 2001 From: Jakob Schneider Date: Thu, 1 Feb 2024 15:39:11 +0000 Subject: [PATCH] Add the archiving sysprop check to launcher3. This system property will be used to test the feature in DVT. This is required because the new device is built on U QPR3, not V. See https://docs.google.com/document/d/1h8sLlnnhwGP4uZssglBqTShMoQcEq5dvR7jsJmmp0Cw/edit?resourcekey=0-KTFHkPKTdtMN-5kQYBWJig&tab=t.0#heading=h.x9snb54sjlu9 for more details. Test: tested manually Flag: ACONFIG com.android.launcher3.enable_support_for_archiving TEAMFOOD Change-Id: Ie64a40ba799c81057258dd7de3872a0494cff2d8 --- src/com/android/launcher3/LauncherAppState.java | 3 ++- src/com/android/launcher3/Utilities.java | 6 ++++++ src/com/android/launcher3/model/AllAppsList.java | 4 ++-- src/com/android/launcher3/model/LoaderTask.java | 5 ++--- src/com/android/launcher3/model/PackageUpdatedTask.java | 4 ++-- src/com/android/launcher3/model/WorkspaceItemProcessor.kt | 5 ++--- src/com/android/launcher3/model/data/AppInfo.java | 3 +-- src/com/android/launcher3/model/data/ItemInfoWithIcon.java | 5 ++--- src/com/android/launcher3/pm/InstallSessionHelper.java | 6 +++--- src/com/android/launcher3/pm/InstallSessionTracker.java | 5 +++-- src/com/android/launcher3/touch/ItemClickHandler.java | 3 +-- 11 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java index c3cbd2b064..60a6be6c9e 100644 --- a/src/com/android/launcher3/LauncherAppState.java +++ b/src/com/android/launcher3/LauncherAppState.java @@ -109,7 +109,8 @@ public class LauncherAppState implements SafeCloseable { launcherApps.registerCallback(callbacks); mOnTerminateCallback.add(() -> mContext.getSystemService(LauncherApps.class).unregisterCallback(callbacks)); - if (Flags.enableSupportForArchiving()) { + + if (Utilities.enableSupportForArchiving()) { ArchiveCompatibilityParams params = new ArchiveCompatibilityParams(); params.setEnableUnarchivalConfirmation(false); launcherApps.setArchiveCompatibility(params); diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 2b886e4570..d44438f5bc 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -830,4 +830,10 @@ public final class Utilities { // No-Op } } + + /** Encapsulates two flag checks into a single one. */ + public static boolean enableSupportForArchiving() { + return Flags.enableSupportForArchiving() + || getSystemProperty("pm.archiving.enabled", "false").equals("true"); + } } diff --git a/src/com/android/launcher3/model/AllAppsList.java b/src/com/android/launcher3/model/AllAppsList.java index b41f01118f..8659471d27 100644 --- a/src/com/android/launcher3/model/AllAppsList.java +++ b/src/com/android/launcher3/model/AllAppsList.java @@ -16,7 +16,6 @@ package com.android.launcher3.model; -import static com.android.launcher3.Flags.enableSupportForArchiving; import static com.android.launcher3.model.data.AppInfo.COMPONENT_KEY_COMPARATOR; import static com.android.launcher3.model.data.AppInfo.EMPTY_ARRAY; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_ARCHIVED; @@ -34,6 +33,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.AppFilter; +import com.android.launcher3.Utilities; import com.android.launcher3.compat.AlphabeticIndexCompat; import com.android.launcher3.icons.IconCache; import com.android.launcher3.model.BgDataModel.Callbacks; @@ -330,7 +330,7 @@ public class AllAppsList { PackageManagerHelper.getLoadingProgress(info), PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING); applicationInfo.intent = launchIntent; - if (enableSupportForArchiving()) { + if (Utilities.enableSupportForArchiving()) { // In case an app is archived, the respective item flag corresponding to // archiving should also be applied during package updates if (info.getActivityInfo().isArchived) { diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index 736b80a900..71ab51cc17 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -18,7 +18,6 @@ package com.android.launcher3.model; import static com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN; import static com.android.launcher3.Flags.enableLauncherBrMetricsFixed; -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; @@ -421,7 +420,7 @@ public class LoaderTask implements Runnable { final HashMap installingPkgs = mSessionHelper.getActiveSessions(); - if (enableSupportForArchiving()) { + if (Utilities.enableSupportForArchiving()) { mInstallingPkgsCached = installingPkgs; } installingPkgs.forEach(mApp.getIconCache()::updateSessionCache); @@ -656,7 +655,7 @@ public class LoaderTask implements Runnable { for (int i = 0; i < apps.size(); i++) { LauncherActivityInfo app = apps.get(i); AppInfo appInfo = new AppInfo(app, mUserCache.getUserInfo(user), quietMode); - if (enableSupportForArchiving() && app.getApplicationInfo().isArchived) { + if (Utilities.enableSupportForArchiving() && app.getApplicationInfo().isArchived) { // For archived apps, include progress info in case there is a pending // install session post restart of device. String appPackageName = app.getApplicationInfo().packageName; diff --git a/src/com/android/launcher3/model/PackageUpdatedTask.java b/src/com/android/launcher3/model/PackageUpdatedTask.java index 529a8f9fac..a41b663432 100644 --- a/src/com/android/launcher3/model/PackageUpdatedTask.java +++ b/src/com/android/launcher3/model/PackageUpdatedTask.java @@ -15,7 +15,6 @@ */ 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; @@ -39,6 +38,7 @@ import com.android.launcher3.Flags; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; import com.android.launcher3.LauncherSettings.Favorites; +import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.icons.IconCache; import com.android.launcher3.logging.FileLog; @@ -274,7 +274,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask { 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()) { + if (Utilities.enableSupportForArchiving() && !activities.isEmpty()) { boolean newArchivalState = activities.get( 0).getActivityInfo().isArchived; if (newArchivalState != si.isArchived()) { diff --git a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt index 44c41c1770..31ae7c2e50 100644 --- a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt +++ b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt @@ -26,7 +26,6 @@ import android.graphics.Point import android.text.TextUtils import android.util.Log import android.util.LongSparseArray -import com.android.launcher3.Flags import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.LauncherAppState import com.android.launcher3.LauncherSettings.Favorites @@ -323,7 +322,7 @@ class WorkspaceItemProcessor( } if ( (c.restoreFlag != 0 || - Flags.enableSupportForArchiving() && + Utilities.enableSupportForArchiving() && activityInfo != null && activityInfo.applicationInfo.isArchived) && !TextUtils.isEmpty(targetPkg) ) { @@ -338,7 +337,7 @@ class WorkspaceItemProcessor( null // For archived apps, include progress info in case there is // a pending install session post restart of device. || - (Flags.enableSupportForArchiving() && + (Utilities.enableSupportForArchiving() && activityInfo.applicationInfo.isArchived) ) { val installProgress = (si.getProgress() * 100).toInt() diff --git a/src/com/android/launcher3/model/data/AppInfo.java b/src/com/android/launcher3/model/data/AppInfo.java index 72eda6c79f..b213fe306e 100644 --- a/src/com/android/launcher3/model/data/AppInfo.java +++ b/src/com/android/launcher3/model/data/AppInfo.java @@ -16,7 +16,6 @@ package com.android.launcher3.model.data; -import static com.android.launcher3.Flags.enableSupportForArchiving; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_ALL_APPS; import android.content.ComponentName; @@ -179,7 +178,7 @@ public class AppInfo extends ItemInfoWithIcon implements WorkspaceItemFactory { if (PackageManagerHelper.isAppSuspended(appInfo)) { info.runtimeStatusFlags |= FLAG_DISABLED_SUSPENDED; } - if (enableSupportForArchiving() && lai.getActivityInfo().isArchived) { + if (Utilities.enableSupportForArchiving() && lai.getActivityInfo().isArchived) { info.runtimeStatusFlags |= FLAG_ARCHIVED; } info.runtimeStatusFlags |= (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0 diff --git a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java index c8ab09ca6a..e46c502a51 100644 --- a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java +++ b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java @@ -16,14 +16,13 @@ package com.android.launcher3.model.data; -import static com.android.launcher3.Flags.enableSupportForArchiving; - import android.content.Context; import android.content.Intent; import android.os.Process; import androidx.annotation.Nullable; +import com.android.launcher3.Utilities; import com.android.launcher3.icons.BitmapInfo; import com.android.launcher3.icons.BitmapInfo.DrawableCreationFlags; import com.android.launcher3.icons.FastBitmapDrawable; @@ -158,7 +157,7 @@ public abstract class ItemInfoWithIcon extends ItemInfo { /** * Returns true if the app corresponding to the item is archived. */ public boolean isArchived() { - if (!enableSupportForArchiving()) { + if (!Utilities.enableSupportForArchiving()) { return false; } return (runtimeStatusFlags & FLAG_ARCHIVED) != 0; diff --git a/src/com/android/launcher3/pm/InstallSessionHelper.java b/src/com/android/launcher3/pm/InstallSessionHelper.java index 0d474628b2..605ef165b3 100644 --- a/src/com/android/launcher3/pm/InstallSessionHelper.java +++ b/src/com/android/launcher3/pm/InstallSessionHelper.java @@ -16,8 +16,6 @@ package com.android.launcher3.pm; -import static com.android.launcher3.Flags.enableSupportForArchiving; - import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.LauncherApps; @@ -33,6 +31,7 @@ import androidx.annotation.WorkerThread; import com.android.launcher3.LauncherPrefs; import com.android.launcher3.SessionCommitReceiver; +import com.android.launcher3.Utilities; import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.ItemInstallQueue; import com.android.launcher3.util.IntArray; @@ -228,7 +227,8 @@ public class InstallSessionHelper { public boolean verifySessionInfo(@Nullable final PackageInstaller.SessionInfo sessionInfo) { // For archived apps we always want to show promise icons and the checks below don't apply. - if (enableSupportForArchiving() && sessionInfo != null && sessionInfo.isUnarchival()) { + if (Utilities.enableSupportForArchiving() && sessionInfo != null + && sessionInfo.isUnarchival()) { return true; } diff --git a/src/com/android/launcher3/pm/InstallSessionTracker.java b/src/com/android/launcher3/pm/InstallSessionTracker.java index e4a2045af3..eacbc11821 100644 --- a/src/com/android/launcher3/pm/InstallSessionTracker.java +++ b/src/com/android/launcher3/pm/InstallSessionTracker.java @@ -15,7 +15,6 @@ */ package com.android.launcher3.pm; -import static com.android.launcher3.Flags.enableSupportForArchiving; import static com.android.launcher3.pm.InstallSessionHelper.getUserHandle; import static com.android.launcher3.pm.PackageInstallInfo.STATUS_FAILED; import static com.android.launcher3.pm.PackageInstallInfo.STATUS_INSTALLED; @@ -32,6 +31,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.WorkerThread; +import com.android.launcher3.Utilities; import com.android.launcher3.util.PackageUserKey; import java.lang.ref.WeakReference; @@ -80,7 +80,8 @@ public class InstallSessionTracker extends PackageInstaller.SessionCallback { helper.tryQueuePromiseAppIcon(sessionInfo); - if (enableSupportForArchiving() && sessionInfo != null && sessionInfo.isUnarchival()) { + if (Utilities.enableSupportForArchiving() && sessionInfo != null + && sessionInfo.isUnarchival()) { // For archived apps, icon could already be present on the workspace. To make sure // the icon state is updated, we send a change event. callback.onPackageStateChanged(PackageInstallInfo.fromInstallingState(sessionInfo)); diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index f47ab90822..ded4da6bbe 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -15,7 +15,6 @@ */ package com.android.launcher3.touch; -import static com.android.launcher3.Flags.enableSupportForArchiving; import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_BIND_PENDING_APPWIDGET; import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN; @@ -331,7 +330,7 @@ public class ItemClickHandler { // Check for abandoned promise if ((v instanceof BubbleTextView) && shortcut.hasPromiseIconUi() - && (!enableSupportForArchiving() || !shortcut.isArchived())) { + && (!Utilities.enableSupportForArchiving() || !shortcut.isArchived())) { String packageName = shortcut.getIntent().getComponent() != null ? shortcut.getIntent().getComponent().getPackageName() : shortcut.getIntent().getPackage();