Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51fea57e authored by Christopher Tate's avatar Christopher Tate
Browse files

Refactor restore to deal with heterogeneous datasets

Transport-based restore now handles both key/value and full-data
(stream) data delivery.

Also: PMBA now holds metadata for *all* apps, not just those with
backup agents.  Since we need to consult this for every restore-
at-install operation we cache this locally now, tagged per transport
and per remote dataset, to avoid having to re-download it as part
of every future restore operation.

Also fixed a bug in LocalTransport that was preventing restore of
key/value datasets, i.e. all of them that were nominally available
prior to this change.

NOTE: at present there is no automatic full-data backup; if for
testing purposes you need to create some to then use for restore,
you still need to use 'bmgr fullbackup ...' to push them.

NOTE: at present the unified transport restore uses a refactored
"engine" implementation to handle stream data that encapsulates
the existing "adb restore" implementation.  However, the adb
restore code path has not yet been refactored to wrap the newly-
extracted engine version; it still contains its own copy of all
the relevant logic.  This will change in a future CL, at which
point offline/USB archive restore will simply wrap the same
shared stream-restore engine implementation.

Bug 15330073
Bug 15989617

Change-Id: Ieedb18fd7836ad31ba24656ec9feaaf69e164af8
parent 9a347f19
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -250,6 +250,14 @@ public class BackupTransport {
     * <p>If this method returns {@code null}, it means that a transport-level error has
     * occurred and the entire restore operation should be abandoned.
     *
     * <p class="note">The OS may call {@link #nextRestorePackage()} multiple times
     * before calling either {@link #getRestoreData(ParcelFileDescriptor) getRestoreData()}
     * or {@link #getNextFullRestoreDataChunk(ParcelFileDescriptor) getNextFullRestoreDataChunk()}.
     * It does this when it has determined that it needs to skip restore of one or more
     * packages.  The transport should not actually transfer any restore data for
     * the given package in response to {@link #nextRestorePackage()}, but rather wait
     * for an explicit request before doing so.
     *
     * @return A RestoreDescription object containing the name of one of the packages
     *   supplied to {@link #startRestore} plus an indicator of the data type of that
     *   restore data; or {@link RestoreDescription#NO_MORE_PACKAGES} to indicate that
+7 −0
Original line number Diff line number Diff line
@@ -50,6 +50,13 @@ public class RestoreDescription implements Parcelable {
    /** This package's restore data is a tarball-type full data stream */
    public static final int TYPE_FULL_STREAM = 2;

    @Override
    public String toString() {
        return "RestoreDescription{" + mPackageName + " : "
                + ((mDataType == TYPE_KEY_VALUE) ? "KEY_VALUE" : "STREAM")
                + '}';
    }

    // ---------------------------------------
    // API

+5 −3
Original line number Diff line number Diff line
@@ -384,7 +384,8 @@ public class LocalTransport extends BackupTransport {

    @Override
    public int startRestore(long token, PackageInfo[] packages) {
        if (DEBUG) Log.v(TAG, "start restore " + token);
        if (DEBUG) Log.v(TAG, "start restore " + token + " : " + packages.length
                + " matching packages");
        mRestorePackages = packages;
        mRestorePackage = -1;
        mRestoreToken = token;
@@ -438,7 +439,8 @@ public class LocalTransport extends BackupTransport {
        if (mRestoreType != RestoreDescription.TYPE_KEY_VALUE) {
            throw new IllegalStateException("getRestoreData(fd) for non-key/value dataset");
        }
        File packageDir = new File(mRestoreSetDir, mRestorePackages[mRestorePackage].packageName);
        File packageDir = new File(mRestoreSetIncrementalDir,
                mRestorePackages[mRestorePackage].packageName);

        // The restore set is the concatenation of the individual record blobs,
        // each of which is a file in the package's directory.  We return the
+2109 −491

File changed.

Preview size limit exceeded, changes collapsed.

+230 −40

File changed.

Preview size limit exceeded, changes collapsed.