Skip to content

Commit e82f68d

Browse files
author
Christopher Tate
committed
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
1 parent cd92db8 commit e82f68d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

services/java/com/android/server/BackupManagerService.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,12 +1433,9 @@ private void addPackageParticipantsLockedInner(String packageName,
14331433
set.add(pkg.packageName);
14341434
if (MORE_DEBUG) Slog.v(TAG, "Agent found; added");
14351435

1436-
// If we've never seen this app before, schedule a backup for it
1437-
if (!mEverStoredApps.contains(pkg.packageName)) {
1438-
if (DEBUG) Slog.i(TAG, "New app " + pkg.packageName
1439-
+ " never backed up; scheduling");
1440-
dataChangedImpl(pkg.packageName);
1441-
}
1436+
// Schedule a backup for it on general principles
1437+
if (DEBUG) Slog.i(TAG, "Scheduling backup for new app " + pkg.packageName);
1438+
dataChangedImpl(pkg.packageName);
14421439
}
14431440
}
14441441
}
@@ -1471,8 +1468,10 @@ private void removePackageFromSetLocked(final HashSet<String> set,
14711468
// Found it. Remove this one package from the bookkeeping, and
14721469
// if it's the last participating app under this uid we drop the
14731470
// (now-empty) set as well.
1471+
// Note that we deliberately leave it 'known' in the "ever backed up"
1472+
// bookkeeping so that its current-dataset data will be retrieved
1473+
// if the app is subsequently reinstalled
14741474
if (MORE_DEBUG) Slog.v(TAG, " removing participant " + packageName);
1475-
removeEverBackedUp(packageName);
14761475
set.remove(packageName);
14771476
mPendingBackups.remove(packageName);
14781477
}
@@ -5440,7 +5439,8 @@ public void restoreAtInstall(String packageName, int token) {
54405439

54415440
long restoreSet = getAvailableRestoreToken(packageName);
54425441
if (DEBUG) Slog.v(TAG, "restoreAtInstall pkg=" + packageName
5443-
+ " token=" + Integer.toHexString(token));
5442+
+ " token=" + Integer.toHexString(token)
5443+
+ " restoreSet=" + Long.toHexString(restoreSet));
54445444

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

0 commit comments

Comments
 (0)