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

Commit 22375e4a authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "Make RestoreSession.getAvailableRestoreSets() asynchronous" into froyo

parents a7035909 2d449afe
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -27381,6 +27381,47 @@
 visibility="public"
>
</constructor>
<method name="onUpdate"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="nowBeingRestored" type="int">
</parameter>
<parameter name="currentPackage" type="java.lang.String">
</parameter>
</method>
<method name="restoreFinished"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="error" type="int">
</parameter>
</method>
<method name="restoreStarting"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="numPackages" type="int">
</parameter>
</method>
</class>
<class name="SharedPreferencesBackupHelper"
 extends="android.app.backup.FileBackupHelperBase"
+21 −6
Original line number Diff line number Diff line
@@ -254,11 +254,13 @@ public final class Bmgr {

    private void doListRestoreSets() {
        try {
            RestoreSet[] sets = mRestore.getAvailableRestoreSets();
            if (sets == null || sets.length == 0) {
                System.out.println("No restore sets available");
            RestoreObserver observer = new RestoreObserver();
            int err = mRestore.getAvailableRestoreSets(observer);
            if (err != 0) {
                System.out.println("Unable to request restore sets");
            } else {
                printRestoreSets(sets);
                observer.waitForCompletion();
                printRestoreSets(observer.sets);
            }
        } catch (RemoteException e) {
            System.err.println(e.toString());
@@ -274,6 +276,16 @@ public final class Bmgr {

    class RestoreObserver extends IRestoreObserver.Stub {
        boolean done;
        RestoreSet[] sets = null;

        public void restoreSetsAvailable(RestoreSet[] result) {
            synchronized (this) {
                sets = result;
                done = true;
                this.notify();
            }
        }

        public void restoreStarting(int numPackages) {
            System.out.println("restoreStarting: " + numPackages + " packages");
        }
@@ -359,8 +371,11 @@ public final class Bmgr {
                System.err.println(BMGR_NOT_RUNNING_ERR);
                return;
            }
            RestoreSet[] sets = mRestore.getAvailableRestoreSets();
            if (sets != null) {
            RestoreSet[] sets = null;
            int err = mRestore.getAvailableRestoreSets(observer);
            if (err != 0) {
                observer.waitForCompletion();
                sets = observer.sets;
                for (RestoreSet s : sets) {
                    if (s.token == token) {
                        System.out.println("Scheduling restore: " + s.name);
+17 −3
Original line number Diff line number Diff line
@@ -16,12 +16,26 @@

package android.app.backup;

import android.app.backup.RestoreSet;

/**
 * Callback class for receiving progress reports during a restore operation.
 *
 * @hide
 */
interface IRestoreObserver {
oneway interface IRestoreObserver {
    /**
     * Supply a list of the restore datasets available from the current transport.  This
     * method is invoked as a callback following the application's use of the
     * {@link android.app.backup.IRestoreSession.getAvailableRestoreSets} method.
     *
     * @param result An array of {@link android.app.backup.RestoreSet RestoreSet} objects
     *   describing all of the available datasets that are candidates for restoring to
     *   the current device.  If no applicable datasets exist, {@code result} will be
     *   {@code null}.
     */
    void restoreSetsAvailable(in RestoreSet[] result);

    /**
     * The restore operation has begun.
     *
@@ -32,8 +46,8 @@ interface IRestoreObserver {

    /**
     * An indication of which package is being restored currently, out of the
     * total number provided in the restoreStarting() callback.  This method
     * is not guaranteed to be called.
     * total number provided in the {@link #restoreStarting(int numPackages)} callback.
     * This method is not guaranteed to be called.
     *
     * @param nowBeingRestored The index, between 1 and the numPackages parameter
     *   to the restoreStarting() callback, of the package now being restored.
+5 −5
Original line number Diff line number Diff line
@@ -29,12 +29,12 @@ interface IRestoreSession {
    /**
     * Ask the current transport what the available restore sets are.
     *
     * @return A bundle containing two elements:  an int array under the key
     *   "tokens" whose entries are a transport-private identifier for each backup set;
     *   and a String array under the key "names" whose entries are the user-meaningful
     *   text corresponding to the backup sets at each index in the tokens array.
     * @param observer This binder points to an object whose onRestoreSetsAvailable()
     *   method will be called to supply the results of the transport's lookup.
     * @return Zero on success; nonzero on error.  The observer will only receive a
     *   result callback if this method returned zero.
     */
    RestoreSet[] getAvailableRestoreSets();
    int getAvailableRestoreSets(IRestoreObserver observer);

    /**
     * Restore the given set onto the device, replacing the current data of any app
+19 −3
Original line number Diff line number Diff line
@@ -17,19 +17,35 @@
package android.app.backup;

import java.lang.String;
import android.app.backup.RestoreSet;

/**
 * Callback class for receiving progress reports during a restore operation.  These
 * methods will all be called on your application's main thread.
 */
public abstract class RestoreObserver {
    /**
     * Supply a list of the restore datasets available from the current transport.  This
     * method is invoked as a callback following the application's use of the
     * {@link android.app.backup.IRestoreSession.getAvailableRestoreSets} method.
     *
     * @param result An array of {@link android.app.backup.RestoreSet RestoreSet} objects
     *   describing all of the available datasets that are candidates for restoring to
     *   the current device.  If no applicable datasets exist, {@code result} will be
     *   {@code null}.
     *
     * @hide
     */
    public void restoreSetsAvailable(RestoreSet[] result) {
    }

    /**
     * The restore operation has begun.
     *
     * @param numPackages The total number of packages being processed in
     *   this restore operation.
     */
    void restoreStarting(int numPackages) {
    public void restoreStarting(int numPackages) {
    }

    /**
@@ -45,7 +61,7 @@ public abstract class RestoreObserver {
     *   indication of the backup manager's progress through the overall restore process.
     * @param currentPackage The name of the package now being restored.
     */
    void onUpdate(int nowBeingRestored, String currentPackage) {
    public void onUpdate(int nowBeingRestored, String currentPackage) {
    }

    /**
@@ -55,6 +71,6 @@ public abstract class RestoreObserver {
     * @param error Zero on success; a nonzero error code if the restore operation
     *   as a whole failed.
     */
    void restoreFinished(int error) {
    public void restoreFinished(int error) {
    }
}
Loading