mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Merge "Breaking icon update task so that it doesn't block worker thread" into ub-launcher3-burnaby
This commit is contained in:
@@ -2757,7 +2757,7 @@ public class LauncherModel extends BroadcastReceiver
|
||||
return;
|
||||
}
|
||||
}
|
||||
updateAllAppsIconsCache();
|
||||
mIconCache.updateDbIcons();
|
||||
synchronized (LoaderTask.this) {
|
||||
if (mStopped) {
|
||||
return;
|
||||
@@ -2883,68 +2883,6 @@ public class LauncherModel extends BroadcastReceiver
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAllAppsIconsCache() {
|
||||
final ArrayList<AppInfo> updatedApps = new ArrayList<>();
|
||||
|
||||
for (UserHandleCompat user : mUserManager.getUserProfiles()) {
|
||||
// Query for the set of apps
|
||||
final List<LauncherActivityInfoCompat> apps = mLauncherApps.getActivityList(null, user);
|
||||
// Fail if we don't have any apps
|
||||
// TODO: Fix this. Only fail for the current user.
|
||||
if (apps == null || apps.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update icon cache
|
||||
HashSet<String> updatedPackages = mIconCache.updateDBIcons(user, apps);
|
||||
|
||||
// If any package icon has changed (app was updated while launcher was dead),
|
||||
// update the corresponding shortcuts.
|
||||
if (!updatedPackages.isEmpty()) {
|
||||
final ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
|
||||
synchronized (sBgLock) {
|
||||
for (ItemInfo info : sBgItemsIdMap) {
|
||||
if (info instanceof ShortcutInfo && user.equals(info.user)
|
||||
&& info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
|
||||
ShortcutInfo si = (ShortcutInfo) info;
|
||||
ComponentName cn = si.getTargetComponent();
|
||||
if (cn != null && updatedPackages.contains(cn.getPackageName())) {
|
||||
si.updateIcon(mIconCache);
|
||||
updatedShortcuts.add(si);
|
||||
}
|
||||
}
|
||||
}
|
||||
mBgAllAppsList.updateIconsAndLabels(updatedPackages, user, updatedApps);
|
||||
}
|
||||
|
||||
if (!updatedShortcuts.isEmpty()) {
|
||||
final UserHandleCompat userFinal = user;
|
||||
mHandler.post(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
Callbacks cb = getCallback();
|
||||
if (cb != null) {
|
||||
cb.bindShortcutsChanged(updatedShortcuts,
|
||||
new ArrayList<ShortcutInfo>(), userFinal);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!updatedApps.isEmpty()) {
|
||||
mHandler.post(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
Callbacks cb = getCallback();
|
||||
if (cb != null) {
|
||||
cb.bindAppsUpdated(updatedApps);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void dumpState() {
|
||||
synchronized (sBgLock) {
|
||||
Log.d(TAG, "mLoaderTask.mContext=" + mContext);
|
||||
@@ -2955,6 +2893,58 @@ public class LauncherModel extends BroadcastReceiver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the icons for packages have been updated in the icon cache.
|
||||
*/
|
||||
public void onPackageIconsUpdated(HashSet<String> updatedPackages, UserHandleCompat user) {
|
||||
final Callbacks callbacks = getCallback();
|
||||
final ArrayList<AppInfo> updatedApps = new ArrayList<>();
|
||||
final ArrayList<ShortcutInfo> updatedShortcuts = new ArrayList<>();
|
||||
|
||||
// If any package icon has changed (app was updated while launcher was dead),
|
||||
// update the corresponding shortcuts.
|
||||
synchronized (sBgLock) {
|
||||
for (ItemInfo info : sBgItemsIdMap) {
|
||||
if (info instanceof ShortcutInfo && user.equals(info.user)
|
||||
&& info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
|
||||
ShortcutInfo si = (ShortcutInfo) info;
|
||||
ComponentName cn = si.getTargetComponent();
|
||||
if (cn != null && updatedPackages.contains(cn.getPackageName())) {
|
||||
si.updateIcon(mIconCache);
|
||||
updatedShortcuts.add(si);
|
||||
}
|
||||
}
|
||||
}
|
||||
mBgAllAppsList.updateIconsAndLabels(updatedPackages, user, updatedApps);
|
||||
}
|
||||
|
||||
if (!updatedShortcuts.isEmpty()) {
|
||||
final UserHandleCompat userFinal = user;
|
||||
mHandler.post(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
Callbacks cb = getCallback();
|
||||
if (cb != null && callbacks == cb) {
|
||||
cb.bindShortcutsChanged(updatedShortcuts,
|
||||
new ArrayList<ShortcutInfo>(), userFinal);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!updatedApps.isEmpty()) {
|
||||
mHandler.post(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
Callbacks cb = getCallback();
|
||||
if (cb != null && callbacks == cb) {
|
||||
cb.bindAppsUpdated(updatedApps);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void enqueuePackageUpdated(PackageUpdatedTask task) {
|
||||
sWorker.post(task);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user