try {
File restoreData = prepareRestoreData(mInfo, mInFD);
- // TODO: version ?
- invokeAgentForAdbRestore(mAgent, mInfo, restoreData, 0);
+ invokeAgentForAdbRestore(mAgent, mInfo, restoreData);
} catch (IOException e) {
e.printStackTrace();
}
return sortedDataName;
}
- private void invokeAgentForAdbRestore(IBackupAgent agent, FileMetadata info, File restoreData,
- int versionCode) throws IOException {
+ private void invokeAgentForAdbRestore(IBackupAgent agent, FileMetadata info, File restoreData)
+ throws IOException {
String pkg = info.packageName;
File newStateName = new File(mDataDir, pkg + ".new");
try {
if (DEBUG) {
Slog.i(TAG, "Starting restore of package " + pkg + " for version code "
- + versionCode);
+ + info.version);
}
- agent.doRestore(backupData, versionCode, newState, mToken,
+ agent.doRestore(backupData, info.version, newState, mToken,
mBackupManagerService.getBackupManagerBinder());
} catch (IOException e) {
Slog.e(TAG, "Exception opening file. " + e);
private FullBackupObbConnection mObbConnection = null;
private ParcelFileDescriptor[] mPipes = null;
private byte[] mWidgetData = null;
+ private long mAppVersion;
private long mBytes;
private final BackupAgentTimeoutParameters mAgentTimeoutParameters;
if (info.path.equals(BACKUP_MANIFEST_FILENAME)) {
Signature[] signatures = tarBackupReader.readAppManifestAndReturnSignatures(
info);
+ // readAppManifestAndReturnSignatures() will have extracted the version from
+ // the manifest, so we save it to use in key-value restore later.
+ mAppVersion = info.version;
PackageManagerInternal pmi = LocalServices.getService(
PackageManagerInternal.class);
RestorePolicy restorePolicy = tarBackupReader.chooseRestorePolicy(
Slog.d(TAG, "Restoring key-value file for " + pkg
+ " : " + info.path);
}
+ // Set the version saved from manifest entry.
+ info.version = mAppVersion;
KeyValueAdbRestoreEngine restoreEngine =
new KeyValueAdbRestoreEngine(
mBackupManagerService,