Add some global metadata to the restore set

In addition to the signatures of each participating application, we now also
store the versionCode of each backed-up package, plus the OS version running on
the device that contributed the backup set.  We also refuse to process a backup
from a later OS revision to an earlier one, or from a later app version to an
earlier.

LocalTransport has been modified as well to be more resilient to changes in the
system's use of metadata pseudopackages.
This commit is contained in:
Christopher Tate
2009-06-22 15:10:30 -07:00
parent e146d82478
commit 3a31a93b8a
3 changed files with 171 additions and 95 deletions

View File

@@ -34,6 +34,7 @@ import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
@@ -850,18 +851,27 @@ class BackupManagerService extends IBackupManager.Stub {
if (app != null) {
// Validate against the backed-up signature block, too
Metadata info = pmAgent.getRestoredMetadata(app.packageName);
if (app.versionCode >= info.versionCode) {
if (DEBUG) Log.v(TAG, "Restore version " + info.versionCode
+ " compatible with app version " + app.versionCode);
if (signaturesMatch(info.signatures, app.signatures)) {
appsToRestore.add(app);
if (info != null) {
if (app.versionCode >= info.versionCode) {
if (DEBUG) Log.v(TAG, "Restore version "
+ info.versionCode
+ " compatible with app version "
+ app.versionCode);
if (signaturesMatch(info.signatures, app.signatures)) {
appsToRestore.add(app);
} else {
Log.w(TAG, "Sig mismatch restoring "
+ app.packageName);
}
} else {
Log.w(TAG, "Sig mismatch restoring " + app.packageName);
Log.i(TAG, "Restore set for " + app.packageName
+ " is too new [" + info.versionCode
+ "] for installed app version "
+ app.versionCode);
}
} else {
Log.i(TAG, "Restore set for " + app.packageName
+ " is too new [" + info.versionCode
+ "] for installed app version " + app.versionCode);
Log.d(TAG, "Unable to get metadata for "
+ app.packageName);
}
}
}