Don't enqueue allowBackup=false apps for full backup attempts
We are correctly refusing to actually process apps for backup if they have
declared android:allowBackup="false" in their manifests, but we're still
wasting bookkeeping & a certain amount of work in tracking them as part of
the full backup queue. Fix that; now we recognize that they shouldn't be
in the queue in the first place.
When reinflating the queue at boot time we also re-verify the participation
of each mentioned app so that we properly drop ones that have been uninstalled
or altered such that they are no longer full-data backup candidates.
Finally, if an app previously implemented key/value backup, so we think
we'll be running it in that mode in a future backup pass, but has been
updated to use the full-data path instead, we don't want to go ahead and
run a key/value pass on it. Added a backstop check and proceed gracefully
in this situation.
(Also add bit more debug-build logging to LocalTransport)
Bug 19462310
Change-Id: I07ab4f2e68e92766d9e8f2595fa763c91193d743
diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java
index c3cc60a..fb0ffb0 100644
--- a/core/java/com/android/internal/backup/LocalTransport.java
+++ b/core/java/com/android/internal/backup/LocalTransport.java
@@ -369,6 +369,9 @@
return TRANSPORT_ERROR;
}
}
+ if (DEBUG) {
+ Log.v(TAG, " stored " + numBytes + " of data");
+ }
return TRANSPORT_OK;
}
@@ -431,6 +434,10 @@
@Override
public RestoreDescription nextRestorePackage() {
+ if (DEBUG) {
+ Log.v(TAG, "nextRestorePackage() : mRestorePackage=" + mRestorePackage
+ + " length=" + mRestorePackages.length);
+ }
if (mRestorePackages == null) throw new IllegalStateException("startRestore not called");
boolean found = false;
@@ -441,7 +448,10 @@
// skip packages where we have a data dir but no actual contents
String[] contents = (new File(mRestoreSetIncrementalDir, name)).list();
if (contents != null && contents.length > 0) {
- if (DEBUG) Log.v(TAG, " nextRestorePackage(TYPE_KEY_VALUE) = " + name);
+ if (DEBUG) {
+ Log.v(TAG, " nextRestorePackage(TYPE_KEY_VALUE) @ "
+ + mRestorePackage + " = " + name);
+ }
mRestoreType = RestoreDescription.TYPE_KEY_VALUE;
found = true;
}
@@ -450,7 +460,10 @@
// No key/value data; check for [non-empty] full data
File maybeFullData = new File(mRestoreSetFullDir, name);
if (maybeFullData.length() > 0) {
- if (DEBUG) Log.v(TAG, " nextRestorePackage(TYPE_FULL_STREAM) = " + name);
+ if (DEBUG) {
+ Log.v(TAG, " nextRestorePackage(TYPE_FULL_STREAM) @ "
+ + mRestorePackage + " = " + name);
+ }
mRestoreType = RestoreDescription.TYPE_FULL_STREAM;
mCurFullRestoreStream = null; // ensure starting from the ground state
found = true;
@@ -460,6 +473,11 @@
if (found) {
return new RestoreDescription(name, mRestoreType);
}
+
+ if (DEBUG) {
+ Log.v(TAG, " ... package @ " + mRestorePackage + " = " + name
+ + " has no data; skipping");
+ }
}
if (DEBUG) Log.v(TAG, " no more packages to restore");