Merge "Pass app version to agent in adb restore for kv." into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
133f93bbbb
@@ -64,8 +64,7 @@ public class KeyValueAdbRestoreEngine implements Runnable {
|
|||||||
try {
|
try {
|
||||||
File restoreData = prepareRestoreData(mInfo, mInFD);
|
File restoreData = prepareRestoreData(mInfo, mInFD);
|
||||||
|
|
||||||
// TODO: version ?
|
invokeAgentForAdbRestore(mAgent, mInfo, restoreData);
|
||||||
invokeAgentForAdbRestore(mAgent, mInfo, restoreData, 0);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -83,8 +82,8 @@ public class KeyValueAdbRestoreEngine implements Runnable {
|
|||||||
return sortedDataName;
|
return sortedDataName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeAgentForAdbRestore(IBackupAgent agent, FileMetadata info, File restoreData,
|
private void invokeAgentForAdbRestore(IBackupAgent agent, FileMetadata info, File restoreData)
|
||||||
int versionCode) throws IOException {
|
throws IOException {
|
||||||
String pkg = info.packageName;
|
String pkg = info.packageName;
|
||||||
File newStateName = new File(mDataDir, pkg + ".new");
|
File newStateName = new File(mDataDir, pkg + ".new");
|
||||||
try {
|
try {
|
||||||
@@ -95,9 +94,9 @@ public class KeyValueAdbRestoreEngine implements Runnable {
|
|||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.i(TAG, "Starting restore of package " + pkg + " for version code "
|
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());
|
mBackupManagerService.getBackupManagerBinder());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slog.e(TAG, "Exception opening file. " + e);
|
Slog.e(TAG, "Exception opening file. " + e);
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public class PerformAdbRestoreTask implements Runnable {
|
|||||||
private FullBackupObbConnection mObbConnection = null;
|
private FullBackupObbConnection mObbConnection = null;
|
||||||
private ParcelFileDescriptor[] mPipes = null;
|
private ParcelFileDescriptor[] mPipes = null;
|
||||||
private byte[] mWidgetData = null;
|
private byte[] mWidgetData = null;
|
||||||
|
private long mAppVersion;
|
||||||
|
|
||||||
private long mBytes;
|
private long mBytes;
|
||||||
private final BackupAgentTimeoutParameters mAgentTimeoutParameters;
|
private final BackupAgentTimeoutParameters mAgentTimeoutParameters;
|
||||||
@@ -476,6 +477,9 @@ public class PerformAdbRestoreTask implements Runnable {
|
|||||||
if (info.path.equals(BACKUP_MANIFEST_FILENAME)) {
|
if (info.path.equals(BACKUP_MANIFEST_FILENAME)) {
|
||||||
Signature[] signatures = tarBackupReader.readAppManifestAndReturnSignatures(
|
Signature[] signatures = tarBackupReader.readAppManifestAndReturnSignatures(
|
||||||
info);
|
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 pmi = LocalServices.getService(
|
||||||
PackageManagerInternal.class);
|
PackageManagerInternal.class);
|
||||||
RestorePolicy restorePolicy = tarBackupReader.chooseRestorePolicy(
|
RestorePolicy restorePolicy = tarBackupReader.chooseRestorePolicy(
|
||||||
@@ -667,6 +671,8 @@ public class PerformAdbRestoreTask implements Runnable {
|
|||||||
Slog.d(TAG, "Restoring key-value file for " + pkg
|
Slog.d(TAG, "Restoring key-value file for " + pkg
|
||||||
+ " : " + info.path);
|
+ " : " + info.path);
|
||||||
}
|
}
|
||||||
|
// Set the version saved from manifest entry.
|
||||||
|
info.version = mAppVersion;
|
||||||
KeyValueAdbRestoreEngine restoreEngine =
|
KeyValueAdbRestoreEngine restoreEngine =
|
||||||
new KeyValueAdbRestoreEngine(
|
new KeyValueAdbRestoreEngine(
|
||||||
mBackupManagerService,
|
mBackupManagerService,
|
||||||
|
|||||||
Reference in New Issue
Block a user