summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-04-21 17:10:23 (GMT)
committerSunny Goyal <sunnygoyal@google.com>2015-04-21 17:13:03 (GMT)
commit7f834d2b3084f012b935e6e95f038f2eb4a0acfa (patch)
treed5cad099b03ec0de76a657d6c0f16736dfd7e144
parent7e2a3608b6fa51c884e051625e10d13597cb8796 (diff)
downloadandroid_packages_apps_Trebuchet-7f834d2b3084f012b935e6e95f038f2eb4a0acfa.zip
android_packages_apps_Trebuchet-7f834d2b3084f012b935e6e95f038f2eb4a0acfa.tar.gz
android_packages_apps_Trebuchet-7f834d2b3084f012b935e6e95f038f2eb4a0acfa.tar.bz2
Using a different userManager class as getUserForSerialNumber gives
a valid userHandle for deleted user. > Also chaching the user handles during loader to avoid multiple calls for UserManager Bug: 19389411 Change-Id: I95af3b41b2c9d2ea41d9a75b1020656f57f5e4c9
-rw-r--r--src/com/android/launcher3/LauncherModel.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index f7df6bc..353de13 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1865,6 +1865,11 @@ public class LauncherModel extends BroadcastReceiver
final int optionsIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.OPTIONS);
+ final LongSparseArray<UserHandleCompat> allUsers = new LongSparseArray<>();
+ for (UserHandleCompat user : mUserManager.getUserProfiles()) {
+ allUsers.put(mUserManager.getSerialNumberForUser(user), user);
+ }
+
ShortcutInfo info;
String intentDescription;
LauncherAppWidgetInfo appWidgetInfo;
@@ -1886,7 +1891,7 @@ public class LauncherModel extends BroadcastReceiver
id = c.getLong(idIndex);
intentDescription = c.getString(intentIndex);
serialNumber = c.getInt(profileIdIndex);
- user = mUserManager.getUserForSerialNumber(serialNumber);
+ user = allUsers.get(serialNumber);
int promiseType = c.getInt(restoredIndex);
int disabledState = 0;
boolean itemReplaced = false;
@@ -2149,23 +2154,28 @@ public class LauncherModel extends BroadcastReceiver
LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
int appWidgetId = c.getInt(appWidgetIdIndex);
- serialNumber= c.getLong(profileIdIndex);
+ serialNumber = c.getLong(profileIdIndex);
String savedProvider = c.getString(appWidgetProviderIndex);
id = c.getLong(idIndex);
+ user = allUsers.get(serialNumber);
+ if (user == null) {
+ itemsToRemove.add(id);
+ continue;
+ }
+
final ComponentName component =
ComponentName.unflattenFromString(savedProvider);
final int restoreStatus = c.getInt(restoredIndex);
final boolean isIdValid = (restoreStatus &
LauncherAppWidgetInfo.FLAG_ID_NOT_VALID) == 0;
-
final boolean wasProviderReady = (restoreStatus &
LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY) == 0;
final LauncherAppWidgetProviderInfo provider =
LauncherModel.getProviderInfo(context,
ComponentName.unflattenFromString(savedProvider),
- mUserManager.getUserForSerialNumber(serialNumber));
+ user);
final boolean isProviderReady = isValidProvider(provider);
if (!isSafeMode && !customWidget &&