diff options
author | Christopher Tate <ctate@android.com> | 2009-09-20 15:28:33 -0700 |
---|---|---|
committer | Christopher Tate <ctate@android.com> | 2009-09-20 15:33:35 -0700 |
commit | 90967f4f0d5ba38ae7225788b111289516d1dda1 (patch) | |
tree | a2379cfab758280839c9c5dc812e94f925fa9a08 /services | |
parent | 0647b580aa7874311fc77b659e4f646750ddd74e (diff) | |
download | frameworks_base-90967f4f0d5ba38ae7225788b111289516d1dda1.zip frameworks_base-90967f4f0d5ba38ae7225788b111289516d1dda1.tar.gz frameworks_base-90967f4f0d5ba38ae7225788b111289516d1dda1.tar.bz2 |
Fix up the first-backup-ever tracking
This changes a couple of bits of the Backup Manager's logic around
first-backup-ever handling. First, it uses the same "what we've ever backed up"
handling as the rest of the system for purposes of instructing the backend to do
a wipe when the metadata is initialized for the device, instead of looking at
the presence of the @pm@ file. Secondly, for the time being we won't be using
the saved state produced by agents' doRestore() logic. Until the server is
migrating each restored package's data over to the new dataset, this was
resulting in the client holding an agent state blob for which no data existed on
the server under this device's identity but which the device thought was fully
up to date.
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/BackupManagerService.java | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 776de7e..854a6f9 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -887,8 +887,12 @@ class BackupManagerService extends IBackupManager.Stub { mPackageManager, allAgentPackages()); BackupRequest pmRequest = new BackupRequest(new ApplicationInfo(), false); pmRequest.appInfo.packageName = PACKAGE_MANAGER_SENTINEL; - processOneBackup(pmRequest, - IBackupAgent.Stub.asInterface(pmAgent.onBind()), mTransport); + + // If we haven't stored anything yet, we need to do an init + // operation along with recording the metadata blob. + boolean needInit = (mEverStoredApps.size() == 0); + processOneBackup(pmRequest, IBackupAgent.Stub.asInterface(pmAgent.onBind()), + mTransport, needInit); // Now run all the backups in our queue int count = mQueue.size(); @@ -934,7 +938,7 @@ class BackupManagerService extends IBackupManager.Stub { try { agent = bindToAgentSynchronous(request.appInfo, mode); if (agent != null) { - processOneBackup(request, agent, transport); + processOneBackup(request, agent, transport, false); } // unbind even on timeout, just in case @@ -950,9 +954,9 @@ class BackupManagerService extends IBackupManager.Stub { } void processOneBackup(BackupRequest request, IBackupAgent agent, - IBackupTransport transport) { + IBackupTransport transport, boolean doInit) { final String packageName = request.appInfo.packageName; - if (DEBUG) Log.d(TAG, "processOneBackup doBackup() on " + packageName); + if (DEBUG) Log.d(TAG, "processOneBackup doBackup(" + doInit + ") on " + packageName); File savedStateName = new File(mStateDir, packageName); File backupDataName = new File(mDataDir, packageName + ".data"); @@ -962,12 +966,6 @@ class BackupManagerService extends IBackupManager.Stub { ParcelFileDescriptor backupData = null; ParcelFileDescriptor newState = null; - // Usually we won't force a server-side init, except the first time - // we ever back up following enable of backup. To keep the bookkeeping - // simple, we detect this here rather than maintain state throughout - // the backup manager. - boolean doInit = false; - PackageInfo packInfo; try { // Look up the package info & signatures. This is first so that if it @@ -977,13 +975,6 @@ class BackupManagerService extends IBackupManager.Stub { // The metadata 'package' is synthetic packInfo = new PackageInfo(); packInfo.packageName = packageName; - - // if there's no metadata backup state, this must be the - // first time we've done one since enabling it. - if (savedStateName.exists() == false) { - if (DEBUG) Log.i(TAG, "First backup pass, issuing init"); - doInit = true; - } } else { packInfo = mPackageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); @@ -1400,7 +1391,21 @@ class BackupManagerService extends IBackupManager.Stub { agent.doRestore(backupData, appVersionCode, newState); // if everything went okay, remember the recorded state now - newStateName.renameTo(savedStateName); + // + // !!! TODO: the restored data should be migrated on the server + // side into the current dataset. In that case the new state file + // we just created would reflect the data already extant in the + // backend, so there'd be nothing more to do. Until that happens, + // however, we need to make sure that we record the data to the + // current backend dataset. (Yes, this means shipping the data over + // the wire in both directions. That's bad, but consistency comes + // first, then efficiency.) Once we introduce server-side data + // migration to the newly-restored device's dataset, we will change + // the following from a discard of the newly-written state to the + // "correct" operation of renaming into the canonical state blob. + newStateName.delete(); // TODO: remove; see above comment + //newStateName.renameTo(savedStateName); // TODO: replace with this + int size = (int) backupDataName.length(); EventLog.writeEvent(RESTORE_PACKAGE_EVENT, packageName, size); } catch (Exception e) { |