summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/launcher3/IconCache.java3
-rw-r--r--src/com/android/launcher3/Workspace.java43
-rw-r--r--src/com/android/launcher3/compat/AppWidgetManagerCompat.java4
-rw-r--r--src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java12
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompat.java4
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompatV16.java4
-rw-r--r--src/com/android/launcher3/compat/PackageInstallerCompatVL.java12
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompatVL.java16
8 files changed, 42 insertions, 56 deletions
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index ddc1bd949..8a3c3193b 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -229,7 +229,8 @@ public class IconCache {
Iterator<Entry<CacheKey, CacheEntry>> it = mCache.entrySet().iterator();
while (it.hasNext()) {
final CacheEntry e = it.next().getValue();
- if (e.icon.getWidth() < grid.iconSizePx || e.icon.getHeight() < grid.iconSizePx) {
+ if ((e.icon != null) && (e.icon.getWidth() < grid.iconSizePx
+ || e.icon.getHeight() < grid.iconSizePx)) {
it.remove();
}
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index f7a0df681..909cf5f8c 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -4801,6 +4801,25 @@ public class Workspace extends SmoothPagedView
}
void updateShortcutsAndWidgets(ArrayList<AppInfo> apps) {
+ // Break the appinfo list per user
+ final HashMap<UserHandleCompat, ArrayList<AppInfo>> appsPerUser =
+ new HashMap<UserHandleCompat, ArrayList<AppInfo>>();
+ for (AppInfo info : apps) {
+ ArrayList<AppInfo> filtered = appsPerUser.get(info.user);
+ if (filtered == null) {
+ filtered = new ArrayList<AppInfo>();
+ appsPerUser.put(info.user, filtered);
+ }
+ filtered.add(info);
+ }
+
+ for (Map.Entry<UserHandleCompat, ArrayList<AppInfo>> entry : appsPerUser.entrySet()) {
+ updateShortcutsAndWidgetsPerUser(entry.getValue(), entry.getKey());
+ }
+ }
+
+ private void updateShortcutsAndWidgetsPerUser(ArrayList<AppInfo> apps,
+ final UserHandleCompat user) {
// Create a map of the apps to test against
final HashMap<ComponentName, AppInfo> appsMap = new HashMap<ComponentName, AppInfo>();
final HashSet<String> pkgNames = new HashSet<String>();
@@ -4808,9 +4827,8 @@ public class Workspace extends SmoothPagedView
appsMap.put(ai.componentName, ai);
pkgNames.add(ai.componentName.getPackageName());
}
+ final HashSet<ComponentName> iconsToRemove = new HashSet<ComponentName>();
- final HashMap<UserHandleCompat, HashSet<ComponentName>> iconsToRemove =
- new HashMap<UserHandleCompat, HashSet<ComponentName>>();
mapOverItems(MAP_RECURSE, new ItemOperator() {
@Override
public boolean evaluate(ItemInfo info, View v, View parent) {
@@ -4818,7 +4836,8 @@ public class Workspace extends SmoothPagedView
ShortcutInfo shortcutInfo = (ShortcutInfo) info;
ComponentName cn = shortcutInfo.getTargetComponent();
AppInfo appInfo = appsMap.get(cn);
- if (cn != null && LauncherModel.isShortcutInfoUpdateable(info)
+ if (user.equals(shortcutInfo.user) && cn != null
+ && LauncherModel.isShortcutInfoUpdateable(info)
&& pkgNames.contains(cn.getPackageName())) {
boolean promiseStateChanged = false;
boolean infoUpdated = false;
@@ -4841,13 +4860,7 @@ public class Workspace extends SmoothPagedView
if ((intent == null) || (appsMap == null)) {
// Could not find a default activity. Remove this item.
- HashSet<ComponentName> cnSet = iconsToRemove
- .get(shortcutInfo.user);
- if (cnSet == null) {
- cnSet = new HashSet<>();
- iconsToRemove.put(shortcutInfo.user, cnSet);
- }
- cnSet.add(shortcutInfo.getTargetComponent());
+ iconsToRemove.add(shortcutInfo.getTargetComponent());
// process next shortcut.
return false;
@@ -4894,12 +4907,11 @@ public class Workspace extends SmoothPagedView
});
if (!iconsToRemove.isEmpty()) {
- for (Map.Entry<UserHandleCompat, HashSet<ComponentName>> entry :
- iconsToRemove.entrySet()) {
- removeItemsByComponentName(entry.getValue(), entry.getKey());
- }
+ removeItemsByComponentName(iconsToRemove, user);
+ }
+ if (user.equals(UserHandleCompat.myUserHandle())) {
+ restorePendingWidgets(pkgNames);
}
- restorePendingWidgets(pkgNames);
}
public void removeAbandonedPromise(String packageName, UserHandleCompat user) {
@@ -4946,6 +4958,7 @@ public class Workspace extends SmoothPagedView
}
}
+ // Note that package states are sent only for myUser
if (!completedPackages.isEmpty()) {
restorePendingWidgets(completedPackages);
}
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompat.java b/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
index 57fac7f8f..5997e7b03 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
@@ -41,9 +41,9 @@ public abstract class AppWidgetManagerCompat {
// TODO change this to use api version once L gets an API number.
if (sInstance == null) {
if (Utilities.isLmp()) {
- sInstance = new AppWidgetManagerCompatVL(context);
+ sInstance = new AppWidgetManagerCompatVL(context.getApplicationContext());
} else {
- sInstance = new AppWidgetManagerCompatV16(context);
+ sInstance = new AppWidgetManagerCompatV16(context.getApplicationContext());
}
}
return sInstance;
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
index 7ca35b72d..c3853ab62 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
@@ -121,15 +121,9 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
} else {
badgeLocation.offset(bitmap.getWidth() - badgeSize - badgeMargin, top);
}
- Drawable drawable = null;
- // STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
- // This hack is just to prevent crash in older builds.
- try {
- drawable = mPm.getUserBadgedDrawableForDensity(new BitmapDrawable(res, bitmap),
- info.getProfile(), badgeLocation, 0);
- } catch (Throwable e) {
- return bitmap;
- }
+
+ Drawable drawable = mPm.getUserBadgedDrawableForDensity(
+ new BitmapDrawable(res, bitmap), info.getProfile(), badgeLocation, 0);
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java
index de8c669e7..e3879eed0 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompat.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java
@@ -51,9 +51,9 @@ public abstract class LauncherAppsCompat {
// STOPSHIP(kennyguy) change this to use api version once L gets an API number.
if (sInstance == null) {
if ("L".equals(Build.VERSION.CODENAME)) {
- sInstance = new LauncherAppsCompatVL(context);
+ sInstance = new LauncherAppsCompatVL(context.getApplicationContext());
} else {
- sInstance = new LauncherAppsCompatV16(context);
+ sInstance = new LauncherAppsCompatV16(context.getApplicationContext());
}
}
return sInstance;
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
index c47f223f3..7e5e6bf2c 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatV16.java
@@ -22,19 +22,17 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.PackageInfo;
import android.content.pm.ResolveInfo;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
-import android.os.UserHandle;
import android.provider.Settings;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
/**
diff --git a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
index eba91cb91..2d56adf91 100644
--- a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
+++ b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
@@ -48,11 +48,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
mResumed = false;
mBound = false;
- // STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
- // This hack is just to prevent crash in older builds.
- try {
- mInstaller.registerSessionCallback(mCallback);
- } catch (Throwable e) { }
+ mInstaller.registerSessionCallback(mCallback);
// On start, send updates for all active sessions
for (SessionInfo info : mInstaller.getAllSessions()) {
@@ -78,11 +74,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
@Override
public void onStop() {
- // STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
- // This hack is just to prevent crash in older builds.
- try {
- mInstaller.unregisterSessionCallback(mCallback);
- } catch (Throwable e) { }
+ mInstaller.unregisterSessionCallback(mCallback);
}
@Override
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVL.java b/src/com/android/launcher3/compat/UserManagerCompatVL.java
index ddef43148..19eeabdcf 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVL.java
@@ -51,13 +51,7 @@ public class UserManagerCompatVL extends UserManagerCompatV17 {
@Override
public Drawable getBadgedDrawableForUser(Drawable unbadged, UserHandleCompat user) {
- // STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
- // This hack is just to prevent crash in older builds.
- try {
- return mPm.getUserBadgedIcon(unbadged, user.getUser());
- } catch (Throwable e) {
- return unbadged;
- }
+ return mPm.getUserBadgedIcon(unbadged, user.getUser());
}
@Override
@@ -65,13 +59,7 @@ public class UserManagerCompatVL extends UserManagerCompatV17 {
if (user == null) {
return label;
}
- // STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
- // This hack is just to prevent crash in older builds.
- try {
- return mPm.getUserBadgedLabel(label, user.getUser());
- } catch (Throwable e) {
- return label;
- }
+ return mPm.getUserBadgedLabel(label, user.getUser());
}
}