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

Commit 391e6269 authored by Chris Tate's avatar Chris Tate Committed by Android (Google) Code Review
Browse files

Merge "Add a method to IBackupTransport to get the current backup set token"

parents 8b6c5410 50c6df04
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -102,19 +102,30 @@ interface IBackupTransport {
    int finishBackup();

    /**
     * Get the set of backups currently available over this transport.
     * Get the set of all backups currently available over this transport.
     *
     * @return Descriptions of the set of restore images available for this device,
     *   or null if an error occurred (the attempt should be rescheduled).
     **/
    RestoreSet[] getAvailableRestoreSets();

    /**
     * Get the identifying token of the backup set currently being stored from
     * this device.  This is used in the case of applications wishing to restore
     * their last-known-good data.
     *
     * @return A token that can be passed to {@link #startRestore}, or 0 if there
     *   is no backup set available corresponding to the current device state.
     */
    long getCurrentRestoreSet();

    /**
     * Start restoring application data from backup.  After calling this function,
     * alternate calls to {@link #nextRestorePackage} and {@link #nextRestoreData}
     * to walk through the actual application data.
     *
     * @param token A backup token as returned by {@link #getAvailableRestoreSets}.
     * @param token A backup token as returned by {@link #getAvailableRestoreSets}
     *   or {@link #getCurrentRestoreSet}.
     * @param packages List of applications to restore (if data is available).
     *   Application data will be restored in the order given.
     * @return One of {@link BackupConstants#TRANSPORT_OK} (OK so far, call
+9 −1
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ public class LocalTransport extends IBackupTransport.Stub {
    private static final String TRANSPORT_DIR_NAME
            = "com.android.internal.backup.LocalTransport";

    // The single hardcoded restore set always has the same (nonzero!) token
    private static final long RESTORE_TOKEN = 1;

    private Context mContext;
    private PackageManager mPackageManager;
    private File mDataDir = new File(Environment.getDownloadCacheDirectory(), "backup");
@@ -149,11 +152,16 @@ public class LocalTransport extends IBackupTransport.Stub {
    // Restore handling
    public RestoreSet[] getAvailableRestoreSets() throws android.os.RemoteException {
        // one hardcoded restore set
        RestoreSet set = new RestoreSet("Local disk image", "flash", 0);
        RestoreSet set = new RestoreSet("Local disk image", "flash", RESTORE_TOKEN);
        RestoreSet[] array = { set };
        return array;
    }

    public long getCurrentRestoreSet() {
        // The hardcoded restore set always has the same token
        return RESTORE_TOKEN;
    }

    public int startRestore(long token, PackageInfo[] packages) {
        if (DEBUG) Log.v(TAG, "start restore " + token);
        mRestorePackages = packages;