summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-01-11 14:33:38 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-01-13 10:38:41 -0800
commitc1ad0ce8aebb76794fdd8b44a0bf50435f0cf39a (patch)
tree7c7d1a7ff0d6418f1e6948f882ef8c19da9e4518 /src/com
parent761d49a7a1c51de256a1b0e6181e9ad46c9347e1 (diff)
downloadandroid_packages_apps_Trebuchet-c1ad0ce8aebb76794fdd8b44a0bf50435f0cf39a.tar.gz
android_packages_apps_Trebuchet-c1ad0ce8aebb76794fdd8b44a0bf50435f0cf39a.tar.bz2
android_packages_apps_Trebuchet-c1ad0ce8aebb76794fdd8b44a0bf50435f0cf39a.zip
Only marking items not already restored as restore
> Moving the restore property to LoaderCursor Bug: 34123089 Change-Id: I1f992ef086d65e0b3cf18d3b2cf37a4f254c97d2
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/LauncherModel.java58
-rw-r--r--src/com/android/launcher3/model/LoaderCursor.java23
2 files changed, 38 insertions, 43 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 693861184..2fc150219 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1105,10 +1105,6 @@ public class LauncherModel extends BroadcastReceiver
final boolean isSdCardReady = Utilities.isBootCompleted();
final MultiHashMap<UserHandle, String> pendingPackages = new MultiHashMap<>();
- InvariantDeviceProfile profile = mApp.getInvariantDeviceProfile();
- int countX = profile.numColumns;
- int countY = profile.numRows;
-
boolean clearDb = false;
try {
ImportDataTask.performImportIfPossible(context);
@@ -1159,8 +1155,6 @@ public class LauncherModel extends BroadcastReceiver
LauncherSettings.Favorites.SPANY);
final int rankIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.RANK);
- final int restoredIndex = c.getColumnIndexOrThrow(
- LauncherSettings.Favorites.RESTORED);
final int optionsIndex = c.getColumnIndexOrThrow(
LauncherSettings.Favorites.OPTIONS);
@@ -1207,7 +1201,6 @@ public class LauncherModel extends BroadcastReceiver
continue;
}
- boolean restored = 0 != c.getInt(restoredIndex);
boolean allowMissingTarget = false;
switch (c.itemType) {
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT: {
@@ -1220,7 +1213,6 @@ public class LauncherModel extends BroadcastReceiver
case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION:
case LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT:
intentDescription = c.getString(intentIndex);
- int promiseType = c.getInt(restoredIndex);
int disabledState = 0;
targetPackage = null;
@@ -1237,17 +1229,14 @@ public class LauncherModel extends BroadcastReceiver
}
if (validComponent) {
- if (restored) {
- // no special handling necessary for this item
- c.markRestored();
- restored = false;
- }
+ // no special handling necessary for this item
+ c.markRestored();
if (quietMode.get(c.serialNumber)) {
disabledState = ShortcutInfo.FLAG_DISABLED_QUIET_USER;
}
} else if (validPkg) {
intent = null;
- if ((promiseType & ShortcutInfo.FLAG_AUTOINTALL_ICON) != 0) {
+ if (c.hasRestoreFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) {
// We allow auto install apps to have their intent
// updated after an install.
intent = manager.getLaunchIntentForPackage(
@@ -1267,21 +1256,20 @@ public class LauncherModel extends BroadcastReceiver
} else {
// no special handling necessary for this item
c.markRestored();
- restored = false;
}
- } else if (restored) {
+ } else if (c.restoreFlag != 0) {
// Package is not yet available but might be
// installed later.
FileLog.d(TAG, "package not yet restored: " + cn);
- if ((promiseType & ShortcutInfo.FLAG_RESTORE_STARTED) != 0) {
+ if (c.hasRestoreFlag(ShortcutInfo.FLAG_RESTORE_STARTED)) {
// Restore has started once.
} else if (installingPkgs.containsKey(cn.getPackageName())) {
// App restore has started. Update the flag
- promiseType |= ShortcutInfo.FLAG_RESTORE_STARTED;
+ c.restoreFlag |= ShortcutInfo.FLAG_RESTORE_STARTED;
c.updater().put(
LauncherSettings.Favorites.RESTORED,
- promiseType).commit();
+ c.restoreFlag).commit();
} else {
c.markDeleted("Unrestored package removed: " + cn);
continue;
@@ -1308,7 +1296,6 @@ public class LauncherModel extends BroadcastReceiver
} else if (cn == null) {
// For shortcuts with no component, keep them as they are
c.markRestored();
- restored = false;
}
} catch (URISyntaxException e) {
c.markDeleted("Invalid uri: " + intentDescription);
@@ -1318,9 +1305,9 @@ public class LauncherModel extends BroadcastReceiver
boolean useLowResIcon = !c.isOnWorkspaceOrHotseat() &&
c.getInt(rankIndex) >= FolderIcon.NUM_ITEMS_IN_PREVIEW;
- if (restored) {
+ if (c.restoreFlag != 0) {
if (c.user.equals(Process.myUserHandle())) {
- info = c.getRestoredItemInfo(intent, promiseType);
+ info = c.getRestoredItemInfo(intent);
} else {
// Don't restore items for other profiles.
c.markDeleted("Restore from managed profile not supported");
@@ -1385,7 +1372,7 @@ public class LauncherModel extends BroadcastReceiver
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SAFEMODE;
}
- if (restored) {
+ if (c.restoreFlag != 0) {
ComponentName cn = info.getTargetComponent();
if (cn != null) {
Integer progress = installingPkgs.get(cn.getPackageName());
@@ -1413,10 +1400,8 @@ public class LauncherModel extends BroadcastReceiver
folderInfo.spanY = 1;
folderInfo.options = c.getInt(optionsIndex);
- if (restored) {
- // no special handling required for restored folders
- c.markRestored();
- }
+ // no special handling required for restored folders
+ c.markRestored();
c.checkAndAddItem(folderInfo, sBgDataModel);
break;
@@ -1433,11 +1418,10 @@ public class LauncherModel extends BroadcastReceiver
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 boolean isIdValid = !c.hasRestoreFlag(
+ LauncherAppWidgetInfo.FLAG_ID_NOT_VALID);
+ final boolean wasProviderReady = !c.hasRestoreFlag(
+ LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY);
if (widgetProvidersMap == null) {
widgetProvidersMap = AppWidgetManagerCompat
@@ -1462,7 +1446,7 @@ public class LauncherModel extends BroadcastReceiver
// The provider is available. So the widget is either
// available or not available. We do not need to track
// any future restore updates.
- int status = restoreStatus &
+ int status = c.restoreFlag &
~LauncherAppWidgetInfo.FLAG_RESTORE_STARTED;
if (!wasProviderReady) {
// If provider was not previously ready, update the
@@ -1480,13 +1464,13 @@ public class LauncherModel extends BroadcastReceiver
} else {
Log.v(TAG, "Widget restore pending id=" + c.id
+ " appWidgetId=" + appWidgetId
- + " status =" + restoreStatus);
+ + " status =" + c.restoreFlag);
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId,
component);
- appWidgetInfo.restoreStatus = restoreStatus;
+ appWidgetInfo.restoreStatus = c.restoreFlag;
Integer installProgress = installingPkgs.get(component.getPackageName());
- if ((restoreStatus & LauncherAppWidgetInfo.FLAG_RESTORE_STARTED) != 0) {
+ if (c.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_RESTORE_STARTED)) {
// Restore has started once.
} else if (installProgress != null) {
// App restore has started. Update the flag
@@ -1524,7 +1508,7 @@ public class LauncherModel extends BroadcastReceiver
String providerName =
appWidgetInfo.providerName.flattenToString();
if (!providerName.equals(savedProvider) ||
- (appWidgetInfo.restoreStatus != restoreStatus)) {
+ (appWidgetInfo.restoreStatus != c.restoreFlag)) {
c.updater()
.put(LauncherSettings.Favorites.APPWIDGET_PROVIDER,
providerName)
diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java
index b271e6fbd..711be37b4 100644
--- a/src/com/android/launcher3/model/LoaderCursor.java
+++ b/src/com/android/launcher3/model/LoaderCursor.java
@@ -83,6 +83,7 @@ public class LoaderCursor extends CursorWrapper {
private final int cellXIndex;
private final int cellYIndex;
private final int profileIdIndex;
+ private final int restoredIndex;
// Properties loaded per iteration
public long serialNumber;
@@ -90,6 +91,7 @@ public class LoaderCursor extends CursorWrapper {
public long id;
public long container;
public int itemType;
+ public int restoreFlag;
public LoaderCursor(Cursor c, LauncherAppState app) {
super(c);
@@ -111,6 +113,7 @@ public class LoaderCursor extends CursorWrapper {
cellXIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.CELLX);
cellYIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.CELLY);
profileIdIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.PROFILE_ID);
+ restoredIndex = getColumnIndexOrThrow(LauncherSettings.Favorites.RESTORED);
}
@Override
@@ -123,6 +126,7 @@ public class LoaderCursor extends CursorWrapper {
id = getLong(idIndex);
serialNumber = getInt(profileIdIndex);
user = allUsers.get(serialNumber);
+ restoreFlag = getInt(restoredIndex);
}
return result;
}
@@ -185,7 +189,7 @@ public class LoaderCursor extends CursorWrapper {
* Make an ShortcutInfo object for a restored application or shortcut item that points
* to a package that is not yet installed on the system.
*/
- public ShortcutInfo getRestoredItemInfo(Intent intent, int promiseType) {
+ public ShortcutInfo getRestoredItemInfo(Intent intent) {
final ShortcutInfo info = new ShortcutInfo();
info.user = user;
info.intent = intent;
@@ -196,22 +200,22 @@ public class LoaderCursor extends CursorWrapper {
mIconCache.getTitleAndIcon(info, false /* useLowResIcon */);
}
- if ((promiseType & ShortcutInfo.FLAG_RESTORED_ICON) != 0) {
+ if (hasRestoreFlag(ShortcutInfo.FLAG_RESTORED_ICON)) {
String title = getTitle();
if (!TextUtils.isEmpty(title)) {
info.title = Utilities.trim(title);
}
- } else if ((promiseType & ShortcutInfo.FLAG_AUTOINTALL_ICON) != 0) {
+ } else if (hasRestoreFlag(ShortcutInfo.FLAG_AUTOINTALL_ICON)) {
if (TextUtils.isEmpty(info.title)) {
info.title = getTitle();
}
} else {
- throw new InvalidParameterException("Invalid restoreType " + promiseType);
+ throw new InvalidParameterException("Invalid restoreType " + restoreFlag);
}
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
info.itemType = itemType;
- info.status = promiseType;
+ info.status = restoreFlag;
return info;
}
@@ -305,7 +309,14 @@ public class LoaderCursor extends CursorWrapper {
* Marks the current item as restored
*/
public void markRestored() {
- restoredRows.add(id);
+ if (restoreFlag != 0) {
+ restoredRows.add(id);
+ restoreFlag = 0;
+ }
+ }
+
+ public boolean hasRestoreFlag(int flagMask) {
+ return (restoreFlag & flagMask) != 0;
}
public void commitRestoredItems() {