Revert^2 "Restore Archived Pinned Shortcuts instead of removing them."
This reverts commit f5cb1b664b.
Reason for revert: adding test fix and reverting
Change-Id: I2fc8dc83259b2ee7992ac2291df6ee4246a2e9d5
This commit is contained in:
1 parent
126566a096
commit
ceb401c3e7
7 files changed
+252
-71
No files matched your search
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3.model;
|
||||
|
||||
import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT;
|
||||
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,7 +40,6 @@ import androidx.annotation.NonNull;
|
||||
import com.android.launcher3.Flags;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherModel.ModelUpdateTask;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
@@ -238,19 +238,22 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
if (itemInfo.isPromise() && isNewApkAvailable) {
|
||||
boolean isTargetValid = !cn.getClassName().equals(
|
||||
IconCache.EMPTY_CLASS_NAME);
|
||||
if (itemInfo.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
if (itemInfo.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
List<ShortcutInfo> shortcut =
|
||||
new ShortcutRequest(context, mUser)
|
||||
.forPackage(cn.getPackageName(),
|
||||
itemInfo.getDeepShortcutId())
|
||||
.query(ShortcutRequest.PINNED);
|
||||
if (shortcut.isEmpty()) {
|
||||
if (shortcut.isEmpty()
|
||||
&& !(Flags.restoreArchivedShortcuts()
|
||||
&& !itemInfo.isArchived())
|
||||
) {
|
||||
isTargetValid = false;
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Pinned Shortcut not found for updated"
|
||||
+ " package=" + itemInfo.getTargetPackage());
|
||||
}
|
||||
} else {
|
||||
} else if (!shortcut.isEmpty()) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Found pinned shortcut for updated"
|
||||
+ " package=" + itemInfo.getTargetPackage()
|
||||
@@ -269,7 +272,7 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
|| itemInfo.isArchived())) {
|
||||
if (updateWorkspaceItemIntent(context, itemInfo, packageName)) {
|
||||
infoUpdated = true;
|
||||
} else if (itemInfo.hasPromiseIconUi()) {
|
||||
} else if (shouldRemoveRestoredShortcut(itemInfo)) {
|
||||
removedShortcuts.add(itemInfo.id);
|
||||
if (DEBUG) {
|
||||
FileLog.w(TAG, "Removing restored shortcut promise icon"
|
||||
@@ -436,7 +439,7 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
*/
|
||||
private boolean updateWorkspaceItemIntent(Context context,
|
||||
WorkspaceItemInfo si, String packageName) {
|
||||
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
if (si.itemType == ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
// Do not update intent for deep shortcuts as they contain additional information
|
||||
// about the shortcut.
|
||||
return false;
|
||||
@@ -452,6 +455,15 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean shouldRemoveRestoredShortcut(WorkspaceItemInfo itemInfo) {
|
||||
if (itemInfo.hasPromiseIconUi() && !Flags.restoreArchivedShortcuts()) {
|
||||
return true;
|
||||
}
|
||||
return Flags.restoreArchivedShortcuts()
|
||||
&& !itemInfo.isArchived()
|
||||
&& itemInfo.itemType == ITEM_TYPE_DEEP_SHORTCUT;
|
||||
}
|
||||
|
||||
private String getOpString() {
|
||||
return switch (mOp) {
|
||||
case OP_NONE -> "NONE";
|
||||
|
||||
Reference in new issue
Block a user