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
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index 81ced7b..ea14753 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -819,9 +819,15 @@
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 @@
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);