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

Commit e82f68d0 authored by Christopher Tate's avatar Christopher Tate
Browse files

Fix the Backup Manager's uninstall tracking

The bug was that when an app was uninstalled, the Backup Manager was
discarding its bookkeeping about that app being represented in the
device's current live backup dataset.  This in turn meant that if the
app was subsequently reinstalled, its data would not be restored from
that most-recent dataset: it would be restored from the *ancestral*
dataset if possible, or not at all.

Now the "ever backed up" state is retained correctly, and the app
will get its most-recent-data restored as expected.

Bug 7394519

Change-Id: I733cf41737765676e0a3a05fb1bcd32b165cb4ba
parent cd92db84
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -1433,15 +1433,12 @@ class BackupManagerService extends IBackupManager.Stub {
                set.add(pkg.packageName);
                if (MORE_DEBUG) Slog.v(TAG, "Agent found; added");

                // If we've never seen this app before, schedule a backup for it
                if (!mEverStoredApps.contains(pkg.packageName)) {
                    if (DEBUG) Slog.i(TAG, "New app " + pkg.packageName
                            + " never backed up; scheduling");
                // Schedule a backup for it on general principles
                if (DEBUG) Slog.i(TAG, "Scheduling backup for new app " + pkg.packageName);
                dataChangedImpl(pkg.packageName);
            }
        }
    }
    }

    // Remove the given packages' entries from our known active set.
    void removePackageParticipantsLocked(String[] packageNames, int oldUid) {
@@ -1471,8 +1468,10 @@ class BackupManagerService extends IBackupManager.Stub {
            // Found it.  Remove this one package from the bookkeeping, and
            // if it's the last participating app under this uid we drop the
            // (now-empty) set as well.
            // Note that we deliberately leave it 'known' in the "ever backed up"
            // bookkeeping so that its current-dataset data will be retrieved
            // if the app is subsequently reinstalled
            if (MORE_DEBUG) Slog.v(TAG, "  removing participant " + packageName);
            removeEverBackedUp(packageName);
            set.remove(packageName);
            mPendingBackups.remove(packageName);
        }
@@ -5440,7 +5439,8 @@ class BackupManagerService extends IBackupManager.Stub {

        long restoreSet = getAvailableRestoreToken(packageName);
        if (DEBUG) Slog.v(TAG, "restoreAtInstall pkg=" + packageName
                + " token=" + Integer.toHexString(token));
                + " token=" + Integer.toHexString(token)
                + " restoreSet=" + Long.toHexString(restoreSet));

        if (mAutoRestore && mProvisioned && restoreSet != 0) {
            // okay, we're going to attempt a restore of this package from this restore set.