Merge branch 'aosp-13' into 13-wip

This commit is contained in:
MrSluffy committed 2023-10-21 09:52:01 +08:00
commit 19bf26dd5a
1558 files changed
+103731 -36693

No files matched your search

@@ -33,6 +33,8 @@ import android.os.UserManager;
import android.util.Log;
import android.content.pm.PackageManager;
import androidx.annotation.NonNull;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherSettings;
@@ -62,6 +64,9 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import app.lawnchair.preferences.PreferenceManager;
@@ -84,17 +89,23 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
public static final int OP_USER_AVAILABILITY_CHANGE = 7; // user available/unavailable
private final int mOp;
@NonNull
private final UserHandle mUser;
@NonNull
private final String[] mPackages;
public PackageUpdatedTask(int op, UserHandle user, String... packages) {
public PackageUpdatedTask(final int op, @NonNull final UserHandle user,
@NonNull final String... packages) {
mOp = op;
mUser = user;
mPackages = packages;
}
@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList appsList) {
public void execute(@NonNull final LauncherAppState app, @NonNull final BgDataModel dataModel,
@NonNull final AllAppsList appsList) {
final Context context = app.getContext();
final IconCache iconCache = app.getIconCache();
@@ -102,7 +113,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
final int N = packages.length;
final FlagOp flagOp;
final HashSet<String> packageSet = new HashSet<>(Arrays.asList(packages));
final ItemInfoMatcher matcher = mOp == OP_USER_AVAILABILITY_CHANGE
final Predicate<ItemInfo> matcher = mOp == OP_USER_AVAILABILITY_CHANGE
? ItemInfoMatcher.ofUser(mUser) // We want to update all packages for this user
: ItemInfoMatcher.ofPackages(packageSet, mUser);
final HashSet<ComponentName> removedComponents = new HashSet<>();
@@ -177,9 +188,8 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
break;
case OP_SUSPEND:
case OP_UNSUSPEND:
flagOp = mOp == OP_SUSPEND ?
FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED) :
FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED);
flagOp = FlagOp.NO_OP.setFlag(
WorkspaceItemInfo.FLAG_DISABLED_SUSPENDED, mOp == OP_SUSPEND);
if (DEBUG) Log.d(TAG, "mAllAppsList.(un)suspend " + N);
appsList.updateDisabledFlags(matcher, flagOp);
break;
@@ -187,9 +197,8 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
UserManagerState ums = new UserManagerState();
ums.init(UserCache.INSTANCE.get(context),
context.getSystemService(UserManager.class));
flagOp = ums.isUserQuiet(mUser)
? FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER)
: FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER);
flagOp = FlagOp.NO_OP.setFlag(
WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER, ums.isUserQuiet(mUser));
appsList.updateDisabledFlags(matcher, flagOp);
// We are not synchronizing here, as int operations are atomic
@@ -233,7 +242,7 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
}
ComponentName cn = si.getTargetComponent();
if (cn != null && matcher.matches(si, cn)) {
if (cn != null && matcher.test(si)) {
String packageName = cn.getPackageName();
if (si.hasStatusFlag(WorkspaceItemInfo.FLAG_SUPPORTS_WEB_UI)) {
@@ -337,7 +346,9 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
bindUpdatedWorkspaceItems(updatedWorkspaceItems);
if (!removedShortcuts.isEmpty()) {
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofItemIds(removedShortcuts));
deleteAndBindComponentsRemoved(
ItemInfoMatcher.ofItemIds(removedShortcuts),
"removed because the target component is invalid");
}
if (!widgets.isEmpty()) {
@@ -363,10 +374,16 @@ public class PackageUpdatedTask extends BaseModelUpdateTask {
}
if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) {
ItemInfoMatcher removeMatch = ItemInfoMatcher.ofPackages(removedPackages, mUser)
Predicate<ItemInfo> removeMatch = ItemInfoMatcher.ofPackages(removedPackages, mUser)
.or(ItemInfoMatcher.ofComponents(removedComponents, mUser))
.and(ItemInfoMatcher.ofItemIds(forceKeepShortcuts).negate());
deleteAndBindComponentsRemoved(removeMatch);
deleteAndBindComponentsRemoved(removeMatch,
"removed because the corresponding package or component is removed. "
+ "mOp=" + mOp + " removedPackages=" + removedPackages.stream().collect(
Collectors.joining(",", "[", "]"))
+ " removedComponents=" + removedComponents.stream()
.filter(Objects::nonNull).map(ComponentName::toShortString)
.collect(Collectors.joining(",", "[", "]")));
// Remove any queued items from the install queue
ItemInstallQueue.INSTANCE.get(context)