fixed build
This commit is contained in:
1 parent
5081f7e92d
commit
65c4fe9b32
173 files changed
+7558
-4492
No files matched your search
@@ -12,8 +12,6 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Modifications copyright 2021, Lawnchair
|
||||
*/
|
||||
package com.android.launcher3.model;
|
||||
|
||||
@@ -29,11 +27,11 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.util.Log;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -42,6 +40,7 @@ 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.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.icons.IconCache;
|
||||
import com.android.launcher3.logging.FileLog;
|
||||
@@ -58,7 +57,6 @@ import com.android.launcher3.util.ItemInfoMatcher;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.PackageUserKey;
|
||||
import com.android.launcher3.util.SafeCloseable;
|
||||
import com.android.launcher3.icons.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -73,8 +71,7 @@ import java.util.stream.Collectors;
|
||||
import app.lawnchair.preferences.PreferenceManager;
|
||||
|
||||
/**
|
||||
* Handles updates due to changes in package manager (app
|
||||
* installed/updated/removed)
|
||||
* Handles updates due to changes in package manager (app installed/updated/removed)
|
||||
* or when a user availability changes.
|
||||
*/
|
||||
@SuppressWarnings("NewApi")
|
||||
@@ -102,20 +99,15 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
private final String[] mPackages;
|
||||
|
||||
public PackageUpdatedTask(final int op, @NonNull final UserHandle user,
|
||||
@NonNull final String... packages) {
|
||||
@NonNull final String... packages) {
|
||||
mOp = op;
|
||||
mUser = user;
|
||||
mPackages = packages;
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.WORK_TAB_MISSING, "PackageUpdatedTask mOp: " + mOp +
|
||||
" packageCount: " + mPackages.length + " user: " + user);
|
||||
DEBUG = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(@NonNull ModelTaskController taskController, @NonNull BgDataModel dataModel,
|
||||
@NonNull AllAppsList appsList) {
|
||||
@NonNull AllAppsList appsList) {
|
||||
final LauncherAppState app = taskController.getApp();
|
||||
final Context context = app.getContext();
|
||||
final IconCache iconCache = app.getIconCache();
|
||||
@@ -129,6 +121,8 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
: ItemInfoMatcher.ofPackages(packageSet, mUser);
|
||||
final HashSet<ComponentName> removedComponents = new HashSet<>();
|
||||
final HashMap<String, List<LauncherActivityInfo>> activitiesLists = new HashMap<>();
|
||||
final PackageManagerHelper packageManagerHelper = new PackageManagerHelper(context);
|
||||
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Package updated: mOp=" + getOpString()
|
||||
+ " packages=" + Arrays.toString(packages));
|
||||
@@ -147,7 +141,7 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
activitiesLists.put(packages[i],
|
||||
appsList.addPackage(context, packages[i], mUser));
|
||||
}
|
||||
flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||
flagOp = FlagOp.NO_OP.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||
break;
|
||||
}
|
||||
case OP_UPDATE:
|
||||
@@ -165,7 +159,7 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
}
|
||||
}
|
||||
// Since package was just updated, the target must be available now.
|
||||
flagOp = FlagOp.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||
flagOp = FlagOp.NO_OP.removeFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||
break;
|
||||
case OP_REMOVE: {
|
||||
for (int i = 0; i < N; i++) {
|
||||
@@ -174,11 +168,9 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
if (packages[i].equals(pm.getIconPackPackage().get())) {
|
||||
pm.getIconPackPackage().set("");
|
||||
}
|
||||
;
|
||||
if (packages[i].equals(pm.getThemedIconPackPackage().get())) {
|
||||
pm.getThemedIconPackPackage().set("");
|
||||
}
|
||||
;
|
||||
final boolean isThemedIconsAvailable = context.getPackageManager()
|
||||
.queryIntentActivityOptions(
|
||||
new ComponentName(context.getApplicationInfo().packageName,
|
||||
@@ -201,7 +193,7 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
}
|
||||
appsList.removePackage(packages[i], mUser);
|
||||
}
|
||||
flagOp = FlagOp.addFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||
flagOp = FlagOp.NO_OP.addFlag(WorkspaceItemInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||
break;
|
||||
case OP_SUSPEND:
|
||||
case OP_UNSUSPEND:
|
||||
@@ -213,7 +205,7 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
UserManagerState ums = new UserManagerState();
|
||||
UserManager userManager = context.getSystemService(UserManager.class);
|
||||
ums.init(UserCache.INSTANCE.get(context), userManager);
|
||||
boolean isUserQuiet = ums.isUserQuiet(mUser);
|
||||
boolean isUserQuiet = ums.isUserQuiet(mUser);
|
||||
flagOp = FlagOp.NO_OP.setFlag(
|
||||
WorkspaceItemInfo.FLAG_DISABLED_QUIET_USER, isUserQuiet);
|
||||
appsList.updateDisabledFlags(matcher, flagOp);
|
||||
@@ -270,10 +262,11 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
boolean isTargetValid = !cn.getClassName().equals(
|
||||
IconCache.EMPTY_CLASS_NAME);
|
||||
if (si.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
List<ShortcutInfo> shortcut = new ShortcutRequest(context, mUser)
|
||||
.forPackage(cn.getPackageName(),
|
||||
si.getDeepShortcutId())
|
||||
.query(ShortcutRequest.PINNED);
|
||||
List<ShortcutInfo> shortcut =
|
||||
new ShortcutRequest(context, mUser)
|
||||
.forPackage(cn.getPackageName(),
|
||||
si.getDeepShortcutId())
|
||||
.query(ShortcutRequest.PINNED);
|
||||
if (shortcut.isEmpty()) {
|
||||
isTargetValid = false;
|
||||
if (DEBUG) {
|
||||
@@ -335,12 +328,12 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
List<LauncherActivityInfo> activities = activitiesLists.get(
|
||||
packageName);
|
||||
// TODO: See if we can migrate this to
|
||||
// AppInfo#updateRuntimeFlagsForActivityTarget
|
||||
// AppInfo#updateRuntimeFlagsForActivityTarget
|
||||
si.setProgressLevel(
|
||||
activities == null || activities.isEmpty()
|
||||
? 100
|
||||
: PackageManagerHelper.getLoadingProgress(
|
||||
activities.get(0)),
|
||||
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.
|
||||
@@ -380,10 +373,11 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
for (LauncherAppWidgetInfo widgetInfo : dataModel.appWidgets) {
|
||||
if (mUser.equals(widgetInfo.user)
|
||||
&& widgetInfo.hasRestoreFlag(
|
||||
LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)
|
||||
LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)
|
||||
&& packageSet.contains(widgetInfo.providerName.getPackageName())) {
|
||||
widgetInfo.restoreStatus &= ~LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY
|
||||
& ~LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
|
||||
widgetInfo.restoreStatus &=
|
||||
~LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY
|
||||
& ~LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
|
||||
|
||||
// adding this flag ensures that launcher shows 'click to setup'
|
||||
// if the widget has a config activity. In case there is no config
|
||||
@@ -422,7 +416,7 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
} else if (mOp == OP_UPDATE) {
|
||||
// Mark disabled packages in the broadcast to be removed
|
||||
final LauncherApps launcherApps = context.getSystemService(LauncherApps.class);
|
||||
for (int i = 0; i < N; i++) {
|
||||
for (int i=0; i<N; i++) {
|
||||
if (!launcherApps.isPackageEnabled(packages[i], mUser)) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "OP_UPDATE:"
|
||||
@@ -434,16 +428,17 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
}
|
||||
|
||||
if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) {
|
||||
Predicate<ItemInfo> removeMatch = ItemInfoMatcher.ofPackages(removedPackages, mUser)
|
||||
.or(ItemInfoMatcher.ofComponents(removedComponents, mUser))
|
||||
.and(ItemInfoMatcher.ofItemIds(forceKeepShortcuts).negate());
|
||||
Predicate<ItemInfo> removeMatch =
|
||||
ItemInfoMatcher.ofPackages(removedPackages, mUser)
|
||||
.or(ItemInfoMatcher.ofComponents(removedComponents, mUser))
|
||||
.and(ItemInfoMatcher.ofItemIds(forceKeepShortcuts).negate());
|
||||
taskController.deleteAndBindComponentsRemoved(removeMatch,
|
||||
"removed because the corresponding package or component is removed. "
|
||||
+ "mOp=" + mOp + " removedPackages=" + removedPackages.stream().collect(
|
||||
Collectors.joining(",", "[", "]"))
|
||||
Collectors.joining(",", "[", "]"))
|
||||
+ " removedComponents=" + removedComponents.stream()
|
||||
.filter(Objects::nonNull).map(ComponentName::toShortString)
|
||||
.collect(Collectors.joining(",", "[", "]")));
|
||||
.filter(Objects::nonNull).map(ComponentName::toShortString)
|
||||
.collect(Collectors.joining(",", "[", "]")));
|
||||
|
||||
// Remove any queued items from the install queue
|
||||
ItemInstallQueue.INSTANCE.get(context)
|
||||
@@ -451,8 +446,7 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
}
|
||||
|
||||
if (mOp == OP_ADD) {
|
||||
// Load widgets for the new package. Changes due to app updates are handled
|
||||
// through
|
||||
// Load widgets for the new package. Changes due to app updates are handled through
|
||||
// AppWidgetHost events, this is just to initialize the long-press options.
|
||||
for (int i = 0; i < N; i++) {
|
||||
dataModel.widgetsModel.update(app, new PackageUserKey(packages[i], mUser));
|
||||
@@ -463,14 +457,12 @@ public class PackageUpdatedTask implements ModelUpdateTask {
|
||||
|
||||
/**
|
||||
* Updates {@param si}'s intent to point to a new ComponentName.
|
||||
*
|
||||
* @return Whether the shortcut intent was changed.
|
||||
*/
|
||||
private boolean updateWorkspaceItemIntent(Context context,
|
||||
WorkspaceItemInfo si, String packageName) {
|
||||
WorkspaceItemInfo si, String packageName) {
|
||||
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
// Do not update intent for deep shortcuts as they contain additional
|
||||
// information
|
||||
// Do not update intent for deep shortcuts as they contain additional information
|
||||
// about the shortcut.
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user