Reset profile ids when backing up / restoring favorites.

Clear the profile id when packing an intent for backup.
Set the profile id to the current user when restoring
a favorite from a backup.

Change-Id: I9d976fbe16773b34a74e57d080ff797ba51f9b04
This commit is contained in:
Kenny Guy
2014-05-13 12:59:34 +01:00
parent 418dcb881a
commit f8b1dfd293

View File

@@ -819,9 +819,15 @@ public class LauncherBackupHelper implements BackupHelper {
if (!TextUtils.isEmpty(title)) {
favorite.title = title;
}
String intent = c.getString(INTENT_INDEX);
if (!TextUtils.isEmpty(intent)) {
favorite.intent = intent;
String intentDescription = c.getString(INTENT_INDEX);
if (!TextUtils.isEmpty(intentDescription)) {
try {
Intent intent = Intent.parseUri(intentDescription, 0);
intent.removeExtra(ItemInfo.EXTRA_PROFILE);
favorite.intent = intent.toUri(0);
} catch (URISyntaxException e) {
Log.e(TAG, "Invalid intent", e);
}
}
favorite.itemType = c.getInt(ITEM_TYPE_INDEX);
if (favorite.itemType == Favorites.ITEM_TYPE_APPWIDGET) {
@@ -874,6 +880,11 @@ public class LauncherBackupHelper implements BackupHelper {
values.put(Favorites.APPWIDGET_ID, favorite.appWidgetId);
}
UserHandleCompat myUserHandle = UserHandleCompat.myUserHandle();
long userSerialNumber =
UserManagerCompat.getInstance(mContext).getSerialNumberForUser(myUserHandle);
values.put(LauncherSettings.Favorites.PROFILE_ID, userSerialNumber);
// Let LauncherModel know we've been here.
values.put(LauncherSettings.Favorites.RESTORED, 1);