Merge "Add the archiving sysprop check to launcher3." into main

This commit is contained in:
Jakob Schneider authored and Android (Google) Code Review committed 2024-02-06 16:34:53 +00:00
commit fb2bb9425c
11 files changed
+26 -23

No files matched your search

@@ -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);
+6
View File
@@ -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");
}
}
@@ -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) {
@@ -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<PackageUserKey, SessionInfo> 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;
@@ -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()) {
@@ -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()
@@ -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
@@ -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;
@@ -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;
}
@@ -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));
@@ -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();