Fixing model being updated on UI thread
> When package gets unavailable or suspended, the disabled flag was getting updated on the UI thread. This could lead to inconsistent model if launcher activity didn't exist. > Fixing: When unsuspending one work profile apps, all work profile apps get unsuspended Bug: 27673573,27673373,27403236 Change-Id: I7fde3f79c36204e73ca66ccf8431fa0f0cce3d08
This commit is contained in:
@@ -22,6 +22,7 @@ import android.content.Context;
|
|||||||
import com.android.launcher3.compat.LauncherActivityInfoCompat;
|
import com.android.launcher3.compat.LauncherActivityInfoCompat;
|
||||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||||
import com.android.launcher3.compat.UserHandleCompat;
|
import com.android.launcher3.compat.UserHandleCompat;
|
||||||
|
import com.android.launcher3.util.FlagOp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -119,19 +120,15 @@ class AllAppsList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Suspend the apps for the given apk identified by packageName.
|
* Updates the apps for the given packageName and user based on {@param op}.
|
||||||
*/
|
*/
|
||||||
public void suspendPackage(String packageName, UserHandleCompat user, boolean suspend) {
|
public void updatePackageFlags(String packageName, UserHandleCompat user, FlagOp op) {
|
||||||
final List<AppInfo> data = this.data;
|
final List<AppInfo> data = this.data;
|
||||||
for (int i = data.size() - 1; i >= 0; i--) {
|
for (int i = data.size() - 1; i >= 0; i--) {
|
||||||
AppInfo info = data.get(i);
|
AppInfo info = data.get(i);
|
||||||
final ComponentName component = info.intent.getComponent();
|
final ComponentName component = info.intent.getComponent();
|
||||||
if (info.user.equals(user) && packageName.equals(component.getPackageName())) {
|
if (info.user.equals(user) && packageName.equals(component.getPackageName())) {
|
||||||
if (suspend) {
|
info.isDisabled = op.apply(info.isDisabled);
|
||||||
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SUSPENDED;
|
|
||||||
} else {
|
|
||||||
info.isDisabled &= ~ShortcutInfo.FLAG_DISABLED_SUSPENDED;
|
|
||||||
}
|
|
||||||
modified.add(info);
|
modified.add(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeFromInstallQueue(Context context, ArrayList<String> packageNames,
|
public static void removeFromInstallQueue(Context context, HashSet<String> packageNames,
|
||||||
UserHandleCompat user) {
|
UserHandleCompat user) {
|
||||||
if (packageNames.isEmpty()) {
|
if (packageNames.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -4322,7 +4322,7 @@ public class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
mWorkspace.removeItemsByComponentName(removedComponents, user);
|
mWorkspace.removeItemsByComponentName(removedComponents, user);
|
||||||
// Notify the drag controller
|
// Notify the drag controller
|
||||||
mDragController.onAppsRemoved(new ArrayList<String>(), removedComponents);
|
mDragController.onAppsRemoved(new HashSet<String>(), removedComponents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4346,43 +4346,44 @@ public class Launcher extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A package was uninstalled. We take both the super set of packageNames
|
* A package was uninstalled/updated. We take both the super set of packageNames
|
||||||
* in addition to specific applications to remove, the reason being that
|
* in addition to specific applications to remove, the reason being that
|
||||||
* this can be called when a package is updated as well. In that scenario,
|
* this can be called when a package is updated as well. In that scenario,
|
||||||
* we only remove specific components from the workspace, where as
|
* we only remove specific components from the workspace and hotseat, where as
|
||||||
* package-removal should clear all items by package name.
|
* package-removal should clear all items by package name.
|
||||||
*
|
|
||||||
* @param reason if non-zero, the icons are not permanently removed, rather marked as disabled.
|
|
||||||
* Implementation of the method from LauncherModel.Callbacks.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void bindComponentsRemoved(final ArrayList<String> packageNames,
|
public void bindWorkspaceComponentsRemoved(
|
||||||
final ArrayList<AppInfo> appInfos, final UserHandleCompat user, final int reason) {
|
final HashSet<String> packageNames, final HashSet<ComponentName> components,
|
||||||
|
final UserHandleCompat user) {
|
||||||
Runnable r = new Runnable() {
|
Runnable r = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
bindComponentsRemoved(packageNames, appInfos, user, reason);
|
bindWorkspaceComponentsRemoved(packageNames, components, user);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (waitUntilResume(r)) {
|
if (waitUntilResume(r)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!packageNames.isEmpty()) {
|
||||||
|
mWorkspace.removeItemsByPackageName(packageNames, user);
|
||||||
|
}
|
||||||
|
if (!components.isEmpty()) {
|
||||||
|
mWorkspace.removeItemsByComponentName(components, user);
|
||||||
|
}
|
||||||
|
// Notify the drag controller
|
||||||
|
mDragController.onAppsRemoved(packageNames, components);
|
||||||
|
|
||||||
if (reason == 0) {
|
}
|
||||||
HashSet<ComponentName> removedComponents = new HashSet<ComponentName>();
|
|
||||||
for (AppInfo info : appInfos) {
|
|
||||||
removedComponents.add(info.componentName);
|
|
||||||
}
|
|
||||||
if (!packageNames.isEmpty()) {
|
|
||||||
mWorkspace.removeItemsByPackageName(packageNames, user);
|
|
||||||
}
|
|
||||||
if (!removedComponents.isEmpty()) {
|
|
||||||
mWorkspace.removeItemsByComponentName(removedComponents, user);
|
|
||||||
}
|
|
||||||
// Notify the drag controller
|
|
||||||
mDragController.onAppsRemoved(packageNames, removedComponents);
|
|
||||||
|
|
||||||
} else {
|
@Override
|
||||||
mWorkspace.disableShortcutsByPackageName(packageNames, user, reason);
|
public void bindAppInfosRemoved(final ArrayList<AppInfo> appInfos) {
|
||||||
|
Runnable r = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
bindAppInfosRemoved(appInfos);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (waitUntilResume(r)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update AllApps
|
// Update AllApps
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import com.android.launcher3.model.GridSizeMigrationTask;
|
|||||||
import com.android.launcher3.model.WidgetsModel;
|
import com.android.launcher3.model.WidgetsModel;
|
||||||
import com.android.launcher3.util.ComponentKey;
|
import com.android.launcher3.util.ComponentKey;
|
||||||
import com.android.launcher3.util.CursorIconInfo;
|
import com.android.launcher3.util.CursorIconInfo;
|
||||||
|
import com.android.launcher3.util.FlagOp;
|
||||||
import com.android.launcher3.util.LongArrayMap;
|
import com.android.launcher3.util.LongArrayMap;
|
||||||
import com.android.launcher3.util.ManagedProfileHeuristic;
|
import com.android.launcher3.util.ManagedProfileHeuristic;
|
||||||
import com.android.launcher3.util.Thunk;
|
import com.android.launcher3.util.Thunk;
|
||||||
@@ -195,8 +196,10 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
ArrayList<ShortcutInfo> removed, UserHandleCompat user);
|
ArrayList<ShortcutInfo> removed, UserHandleCompat user);
|
||||||
public void bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets);
|
public void bindWidgetsRestored(ArrayList<LauncherAppWidgetInfo> widgets);
|
||||||
public void bindRestoreItemsChange(HashSet<ItemInfo> updates);
|
public void bindRestoreItemsChange(HashSet<ItemInfo> updates);
|
||||||
public void bindComponentsRemoved(ArrayList<String> packageNames,
|
public void bindWorkspaceComponentsRemoved(
|
||||||
ArrayList<AppInfo> appInfos, UserHandleCompat user, int reason);
|
HashSet<String> packageNames, HashSet<ComponentName> components,
|
||||||
|
UserHandleCompat user);
|
||||||
|
public void bindAppInfosRemoved(ArrayList<AppInfo> appInfos);
|
||||||
public void notifyWidgetProvidersChanged();
|
public void notifyWidgetProvidersChanged();
|
||||||
public void bindWidgetsModel(WidgetsModel model);
|
public void bindWidgetsModel(WidgetsModel model);
|
||||||
public void bindSearchProviderChanged();
|
public void bindSearchProviderChanged();
|
||||||
@@ -2928,6 +2931,7 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
|
|
||||||
final String[] packages = mPackages;
|
final String[] packages = mPackages;
|
||||||
final int N = packages.length;
|
final int N = packages.length;
|
||||||
|
FlagOp flagOp = FlagOp.NO_OP;
|
||||||
switch (mOp) {
|
switch (mOp) {
|
||||||
case OP_ADD: {
|
case OP_ADD: {
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
@@ -2949,6 +2953,8 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
mBgAllAppsList.updatePackage(context, packages[i], mUser);
|
mBgAllAppsList.updatePackage(context, packages[i], mUser);
|
||||||
mApp.getWidgetCache().removePackage(packages[i], mUser);
|
mApp.getWidgetCache().removePackage(packages[i], mUser);
|
||||||
}
|
}
|
||||||
|
// Since package was just updated, the target must be available now.
|
||||||
|
flagOp = FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||||
break;
|
break;
|
||||||
case OP_REMOVE: {
|
case OP_REMOVE: {
|
||||||
ManagedProfileHeuristic heuristic = ManagedProfileHeuristic.get(context, mUser);
|
ManagedProfileHeuristic heuristic = ManagedProfileHeuristic.get(context, mUser);
|
||||||
@@ -2967,14 +2973,16 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
mBgAllAppsList.removePackage(packages[i], mUser);
|
mBgAllAppsList.removePackage(packages[i], mUser);
|
||||||
mApp.getWidgetCache().removePackage(packages[i], mUser);
|
mApp.getWidgetCache().removePackage(packages[i], mUser);
|
||||||
}
|
}
|
||||||
|
flagOp = FlagOp.addFlag(ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE);
|
||||||
break;
|
break;
|
||||||
case OP_SUSPEND:
|
case OP_SUSPEND:
|
||||||
case OP_UNSUSPEND:
|
case OP_UNSUSPEND:
|
||||||
boolean suspend = mOp == OP_SUSPEND;
|
flagOp = mOp == OP_SUSPEND ?
|
||||||
|
FlagOp.addFlag(ShortcutInfo.FLAG_DISABLED_SUSPENDED) :
|
||||||
|
FlagOp.removeFlag(ShortcutInfo.FLAG_DISABLED_SUSPENDED);
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
if (DEBUG_LOADERS) Log.d(TAG, "mAllAppsList.suspendPackage "
|
if (DEBUG_LOADERS) Log.d(TAG, "mAllAppsList.(un)suspend " + packages[i]);
|
||||||
+ suspend + " " + packages[i]);
|
mBgAllAppsList.updatePackageFlags(packages[i], mUser, flagOp);
|
||||||
mBgAllAppsList.suspendPackage(packages[i], mUser, suspend);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2984,11 +2992,11 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
final ArrayList<AppInfo> removedApps = new ArrayList<AppInfo>();
|
final ArrayList<AppInfo> removedApps = new ArrayList<AppInfo>();
|
||||||
|
|
||||||
if (mBgAllAppsList.added.size() > 0) {
|
if (mBgAllAppsList.added.size() > 0) {
|
||||||
added = new ArrayList<AppInfo>(mBgAllAppsList.added);
|
added = new ArrayList<>(mBgAllAppsList.added);
|
||||||
mBgAllAppsList.added.clear();
|
mBgAllAppsList.added.clear();
|
||||||
}
|
}
|
||||||
if (mBgAllAppsList.modified.size() > 0) {
|
if (mBgAllAppsList.modified.size() > 0) {
|
||||||
modified = new ArrayList<AppInfo>(mBgAllAppsList.modified);
|
modified = new ArrayList<>(mBgAllAppsList.modified);
|
||||||
mBgAllAppsList.modified.clear();
|
mBgAllAppsList.modified.clear();
|
||||||
}
|
}
|
||||||
if (mBgAllAppsList.removed.size() > 0) {
|
if (mBgAllAppsList.removed.size() > 0) {
|
||||||
@@ -2996,14 +3004,7 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
mBgAllAppsList.removed.clear();
|
mBgAllAppsList.removed.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Callbacks callbacks = getCallback();
|
final HashMap<ComponentName, AppInfo> addedOrUpdatedApps = new HashMap<>();
|
||||||
if (callbacks == null) {
|
|
||||||
Log.w(TAG, "Nobody to tell about the new app. Launcher is probably loading.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final HashMap<ComponentName, AppInfo> addedOrUpdatedApps =
|
|
||||||
new HashMap<ComponentName, AppInfo>();
|
|
||||||
|
|
||||||
if (added != null) {
|
if (added != null) {
|
||||||
addAppsToAllApps(context, added);
|
addAppsToAllApps(context, added);
|
||||||
@@ -3013,6 +3014,7 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (modified != null) {
|
if (modified != null) {
|
||||||
|
final Callbacks callbacks = getCallback();
|
||||||
final ArrayList<AppInfo> modifiedFinal = modified;
|
final ArrayList<AppInfo> modifiedFinal = modified;
|
||||||
for (AppInfo ai : modified) {
|
for (AppInfo ai : modified) {
|
||||||
addedOrUpdatedApps.put(ai.componentName, ai);
|
addedOrUpdatedApps.put(ai.componentName, ai);
|
||||||
@@ -3029,7 +3031,7 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update shortcut infos
|
// Update shortcut infos
|
||||||
if (mOp == OP_ADD || mOp == OP_UPDATE || mOp == OP_UNSUSPEND) {
|
if (mOp == OP_ADD || flagOp != FlagOp.NO_OP) {
|
||||||
final ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<ShortcutInfo>();
|
final ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<ShortcutInfo>();
|
||||||
final ArrayList<ShortcutInfo> removedShortcuts = new ArrayList<ShortcutInfo>();
|
final ArrayList<ShortcutInfo> removedShortcuts = new ArrayList<ShortcutInfo>();
|
||||||
final ArrayList<LauncherAppWidgetInfo> widgets = new ArrayList<LauncherAppWidgetInfo>();
|
final ArrayList<LauncherAppWidgetInfo> widgets = new ArrayList<LauncherAppWidgetInfo>();
|
||||||
@@ -3042,11 +3044,6 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
boolean infoUpdated = false;
|
boolean infoUpdated = false;
|
||||||
boolean shortcutUpdated = false;
|
boolean shortcutUpdated = false;
|
||||||
|
|
||||||
if (mOp == OP_UNSUSPEND) {
|
|
||||||
si.isDisabled &= ~ ShortcutInfo.FLAG_DISABLED_SUSPENDED;
|
|
||||||
infoUpdated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update shortcuts which use iconResource.
|
// Update shortcuts which use iconResource.
|
||||||
if ((si.iconResource != null)
|
if ((si.iconResource != null)
|
||||||
&& packageSet.contains(si.iconResource.packageName)) {
|
&& packageSet.contains(si.iconResource.packageName)) {
|
||||||
@@ -3109,9 +3106,9 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
infoUpdated = true;
|
infoUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((si.isDisabled & ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE) != 0) {
|
int oldDisabledFlags = si.isDisabled;
|
||||||
// Since package was just updated, the target must be available now.
|
si.isDisabled = flagOp.apply(si.isDisabled);
|
||||||
si.isDisabled &= ~ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE;
|
if (si.isDisabled != oldDisabledFlags) {
|
||||||
shortcutUpdated = true;
|
shortcutUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3144,6 +3141,7 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!updatedShortcuts.isEmpty() || !removedShortcuts.isEmpty()) {
|
if (!updatedShortcuts.isEmpty() || !removedShortcuts.isEmpty()) {
|
||||||
|
final Callbacks callbacks = getCallback();
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -3159,6 +3157,7 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!widgets.isEmpty()) {
|
if (!widgets.isEmpty()) {
|
||||||
|
final Callbacks callbacks = getCallback();
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Callbacks cb = getCallback();
|
Callbacks cb = getCallback();
|
||||||
@@ -3170,48 +3169,60 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final ArrayList<String> removedPackageNames =
|
final HashSet<String> removedPackages = new HashSet<>();
|
||||||
new ArrayList<String>();
|
final HashSet<ComponentName> removedComponents = new HashSet<>();
|
||||||
if (mOp == OP_REMOVE || mOp == OP_UNAVAILABLE || mOp == OP_SUSPEND) {
|
if (mOp == OP_REMOVE) {
|
||||||
// Mark all packages in the broadcast to be removed
|
// Mark all packages in the broadcast to be removed
|
||||||
removedPackageNames.addAll(Arrays.asList(packages));
|
Collections.addAll(removedPackages, packages);
|
||||||
|
|
||||||
|
// No need to update the removedComponents as
|
||||||
|
// removedPackages is a super-set of removedComponents
|
||||||
} else if (mOp == OP_UPDATE) {
|
} else if (mOp == OP_UPDATE) {
|
||||||
// Mark disabled packages in the broadcast to be removed
|
// Mark disabled packages in the broadcast to be removed
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
if (isPackageDisabled(context, packages[i], mUser)) {
|
if (isPackageDisabled(context, packages[i], mUser)) {
|
||||||
removedPackageNames.add(packages[i]);
|
removedPackages.add(packages[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update removedComponents as some components can get removed during package update
|
||||||
|
for (AppInfo info : removedApps) {
|
||||||
|
removedComponents.add(info.componentName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!removedPackageNames.isEmpty() || !removedApps.isEmpty()) {
|
if (!removedPackages.isEmpty() || !removedComponents.isEmpty()) {
|
||||||
final int removeReason;
|
for (String pn : removedPackages) {
|
||||||
if (mOp == OP_UNAVAILABLE) {
|
deletePackageFromDatabase(context, pn, mUser);
|
||||||
removeReason = ShortcutInfo.FLAG_DISABLED_NOT_AVAILABLE;
|
}
|
||||||
} else if (mOp == OP_SUSPEND) {
|
for (ComponentName cn : removedComponents) {
|
||||||
removeReason = ShortcutInfo.FLAG_DISABLED_SUSPENDED;
|
deleteItemsFromDatabase(context, getItemInfoForComponentName(cn, mUser));
|
||||||
} else {
|
|
||||||
// Remove all the components associated with this package
|
|
||||||
for (String pn : removedPackageNames) {
|
|
||||||
deletePackageFromDatabase(context, pn, mUser);
|
|
||||||
}
|
|
||||||
// Remove all the specific components
|
|
||||||
for (AppInfo a : removedApps) {
|
|
||||||
ArrayList<ItemInfo> infos = getItemInfoForComponentName(a.componentName, mUser);
|
|
||||||
deleteItemsFromDatabase(context, infos);
|
|
||||||
}
|
|
||||||
removeReason = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any queued items from the install queue
|
// Remove any queued items from the install queue
|
||||||
InstallShortcutReceiver.removeFromInstallQueue(context, removedPackageNames, mUser);
|
InstallShortcutReceiver.removeFromInstallQueue(context, removedPackages, mUser);
|
||||||
|
|
||||||
// Call the components-removed callback
|
// Call the components-removed callback
|
||||||
|
final Callbacks callbacks = getCallback();
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Callbacks cb = getCallback();
|
Callbacks cb = getCallback();
|
||||||
if (callbacks == cb && cb != null) {
|
if (callbacks == cb && cb != null) {
|
||||||
callbacks.bindComponentsRemoved(
|
callbacks.bindWorkspaceComponentsRemoved(
|
||||||
removedPackageNames, removedApps, mUser, removeReason);
|
removedPackages, removedComponents, mUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!removedApps.isEmpty()) {
|
||||||
|
// Remove corresponding apps from All-Apps
|
||||||
|
final Callbacks callbacks = getCallback();
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
Callbacks cb = getCallback();
|
||||||
|
if (callbacks == cb && cb != null) {
|
||||||
|
callbacks.bindAppInfosRemoved(removedApps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -3221,6 +3232,7 @@ public class LauncherModel extends BroadcastReceiver
|
|||||||
// get widget update signals.
|
// get widget update signals.
|
||||||
if (!Utilities.ATLEAST_MARSHMALLOW &&
|
if (!Utilities.ATLEAST_MARSHMALLOW &&
|
||||||
(mOp == OP_ADD || mOp == OP_REMOVE || mOp == OP_UPDATE)) {
|
(mOp == OP_ADD || mOp == OP_REMOVE || mOp == OP_UPDATE)) {
|
||||||
|
final Callbacks callbacks = getCallback();
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Callbacks cb = getCallback();
|
Callbacks cb = getCallback();
|
||||||
|
|||||||
@@ -3922,41 +3922,10 @@ public class Workspace extends PagedView
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableShortcutsByPackageName(final ArrayList<String> packages,
|
|
||||||
final UserHandleCompat user, final int reason) {
|
|
||||||
final HashSet<String> packageNames = new HashSet<String>();
|
|
||||||
packageNames.addAll(packages);
|
|
||||||
|
|
||||||
mapOverItems(MAP_RECURSE, new ItemOperator() {
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(ItemInfo info, View v, View parent) {
|
|
||||||
if (info instanceof ShortcutInfo && v instanceof BubbleTextView) {
|
|
||||||
ShortcutInfo shortcutInfo = (ShortcutInfo) info;
|
|
||||||
ComponentName cn = shortcutInfo.getTargetComponent();
|
|
||||||
if (user.equals(shortcutInfo.user) && cn != null
|
|
||||||
&& packageNames.contains(cn.getPackageName())) {
|
|
||||||
shortcutInfo.isDisabled |= reason;
|
|
||||||
BubbleTextView shortcut = (BubbleTextView) v;
|
|
||||||
shortcut.applyFromShortcutInfo(shortcutInfo, mIconCache);
|
|
||||||
|
|
||||||
if (parent != null) {
|
|
||||||
parent.invalidate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// process all the shortcuts
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Removes ALL items that match a given package name, this is usually called when a package
|
// Removes ALL items that match a given package name, this is usually called when a package
|
||||||
// has been removed and we want to remove all components (widgets, shortcuts, apps) that
|
// has been removed and we want to remove all components (widgets, shortcuts, apps) that
|
||||||
// belong to that package.
|
// belong to that package.
|
||||||
void removeItemsByPackageName(final ArrayList<String> packages, final UserHandleCompat user) {
|
void removeItemsByPackageName(final HashSet<String> packageNames, final UserHandleCompat user) {
|
||||||
final HashSet<String> packageNames = new HashSet<String>();
|
|
||||||
packageNames.addAll(packages);
|
|
||||||
|
|
||||||
// Filter out all the ItemInfos that this is going to affect
|
// Filter out all the ItemInfos that this is going to affect
|
||||||
final HashSet<ItemInfo> infos = new HashSet<ItemInfo>();
|
final HashSet<ItemInfo> infos = new HashSet<ItemInfo>();
|
||||||
final HashSet<ComponentName> cns = new HashSet<ComponentName>();
|
final HashSet<ComponentName> cns = new HashSet<ComponentName>();
|
||||||
@@ -4138,7 +4107,7 @@ public class Workspace extends PagedView
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeAbandonedPromise(String packageName, UserHandleCompat user) {
|
public void removeAbandonedPromise(String packageName, UserHandleCompat user) {
|
||||||
ArrayList<String> packages = new ArrayList<String>(1);
|
HashSet<String> packages = new HashSet<>(1);
|
||||||
packages.add(packageName);
|
packages.add(packageName);
|
||||||
LauncherModel.deletePackageFromDatabase(mLauncher, packageName, user);
|
LauncherModel.deletePackageFromDatabase(mLauncher, packageName, user);
|
||||||
removeItemsByPackageName(packages, user);
|
removeItemsByPackageName(packages, user);
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ public class DragController implements DragDriver.EventListener {
|
|||||||
endDrag();
|
endDrag();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAppsRemoved(final ArrayList<String> packageNames, HashSet<ComponentName> cns) {
|
public void onAppsRemoved(final HashSet<String> packageNames, HashSet<ComponentName> cns) {
|
||||||
// Cancel the current drag if we are removing an app that we are dragging
|
// Cancel the current drag if we are removing an app that we are dragging
|
||||||
if (mDragObject != null) {
|
if (mDragObject != null) {
|
||||||
Object rawDragInfo = mDragObject.dragInfo;
|
Object rawDragInfo = mDragObject.dragInfo;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.android.launcher3.util;
|
||||||
|
|
||||||
|
public abstract class FlagOp {
|
||||||
|
|
||||||
|
public static FlagOp NO_OP = new FlagOp() {};
|
||||||
|
|
||||||
|
private FlagOp() {}
|
||||||
|
|
||||||
|
public int apply(int flags) {
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FlagOp addFlag(final int flag) {
|
||||||
|
return new FlagOp() {
|
||||||
|
@Override
|
||||||
|
public int apply(int flags) {
|
||||||
|
return flags | flag;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FlagOp removeFlag(final int flag) {
|
||||||
|
return new FlagOp() {
|
||||||
|
@Override
|
||||||
|
public int apply(int flags) {
|
||||||
|
return flags & ~flag;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user