summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/backup/java/com/android/server/backup/BackupManagerService.java77
1 files changed, 5 insertions, 72 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java
index 41de97c8bcbb..207c02a96ecf 100644
--- a/services/backup/java/com/android/server/backup/BackupManagerService.java
+++ b/services/backup/java/com/android/server/backup/BackupManagerService.java
@@ -1446,52 +1446,23 @@ public class BackupManagerService implements BackupManagerServiceInterface {
// rebooted in the middle of an operation that was removing something from
// this log, we sanity-check its contents here and reconstruct it.
mEverStored = new File(mBaseStateDir, "processed");
- File tempProcessedFile = new File(mBaseStateDir, "processed.new");
-
- // If we were in the middle of removing something from the ever-backed-up
- // file, there might be a transient "processed.new" file still present.
- // Ignore it -- we'll validate "processed" against the current package set.
- if (tempProcessedFile.exists()) {
- tempProcessedFile.delete();
- }
// If there are previous contents, parse them out then start a new
// file to continue the recordkeeping.
if (mEverStored.exists()) {
- DataOutputStream temp = null;
- DataInputStream in = null;
-
- try {
- temp = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(
- tempProcessedFile)));
- in = new DataInputStream(new BufferedInputStream(new FileInputStream(mEverStored)));
+ try (DataInputStream in = new DataInputStream(
+ new BufferedInputStream(new FileInputStream(mEverStored)))) {
// Loop until we hit EOF
while (true) {
String pkg = in.readUTF();
- try {
- // is this package still present?
- mPackageManager.getPackageInfo(pkg, 0);
- // if we get here then yes it is; remember it
- mEverStoredApps.add(pkg);
- temp.writeUTF(pkg);
- if (MORE_DEBUG) Slog.v(TAG, " + " + pkg);
- } catch (NameNotFoundException e) {
- // nope, this package was uninstalled; don't include it
- if (MORE_DEBUG) Slog.v(TAG, " - " + pkg);
- }
+ mEverStoredApps.add(pkg);
+ if (MORE_DEBUG) Slog.v(TAG, " + " + pkg);
}
} catch (EOFException e) {
- // Once we've rewritten the backup history log, atomically replace the
- // old one with the new one then reopen the file for continuing use.
- if (!tempProcessedFile.renameTo(mEverStored)) {
- Slog.e(TAG, "Error renaming " + tempProcessedFile + " to " + mEverStored);
- }
+ // Done
} catch (IOException e) {
Slog.e(TAG, "Error in processed file", e);
- } finally {
- try { if (temp != null) temp.close(); } catch (IOException e) {}
- try { if (in != null) in.close(); } catch (IOException e) {}
}
}
@@ -2238,44 +2209,6 @@ public class BackupManagerService implements BackupManagerServiceInterface {
}
}
- // Remove our awareness of having ever backed up the given package
- void removeEverBackedUp(String packageName) {
- if (DEBUG) Slog.v(TAG, "Removing backed-up knowledge of " + packageName);
- if (MORE_DEBUG) Slog.v(TAG, "New set:");
-
- synchronized (mEverStoredApps) {
- // Rewrite the file and rename to overwrite. If we reboot in the middle,
- // we'll recognize on initialization time that the package no longer
- // exists and fix it up then.
- File tempKnownFile = new File(mBaseStateDir, "processed.new");
- RandomAccessFile known = null;
- try {
- known = new RandomAccessFile(tempKnownFile, "rws");
- mEverStoredApps.remove(packageName);
- for (String s : mEverStoredApps) {
- known.writeUTF(s);
- if (MORE_DEBUG) Slog.v(TAG, " " + s);
- }
- known.close();
- known = null;
- if (!tempKnownFile.renameTo(mEverStored)) {
- throw new IOException("Can't rename " + tempKnownFile + " to " + mEverStored);
- }
- } catch (IOException e) {
- // Bad: we couldn't create the new copy. For safety's sake we
- // abandon the whole process and remove all what's-backed-up
- // state entirely, meaning we'll force a backup pass for every
- // participant on the next boot or [re]install.
- Slog.w(TAG, "Error rewriting " + mEverStored, e);
- mEverStoredApps.clear();
- tempKnownFile.delete();
- mEverStored.delete();
- } finally {
- try { if (known != null) known.close(); } catch (IOException e) {}
- }
- }
- }
-
// Persistently record the current and ancestral backup tokens as well
// as the set of packages with data [supposedly] available in the
// ancestral dataset.