Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8b1dfd2 authored by Kenny Guy's avatar Kenny Guy
Browse files

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
parent 418dcb88
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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);