Search in sources :

Example 11 with RestoreSet

use of android.app.backup.RestoreSet in project android_frameworks_base by AOSPA.

the class Bmgr method doRestoreAll.

private void doRestoreAll(long token, HashSet<String> filter) {
    RestoreObserver observer = new RestoreObserver();
    try {
        boolean didRestore = false;
        mRestore = mBmgr.beginRestoreSession(null, null);
        if (mRestore == null) {
            System.err.println(BMGR_NOT_RUNNING_ERR);
            return;
        }
        RestoreSet[] sets = null;
        int err = mRestore.getAvailableRestoreSets(observer);
        if (err == 0) {
            observer.waitForCompletion();
            sets = observer.sets;
            if (sets != null) {
                for (RestoreSet s : sets) {
                    if (s.token == token) {
                        System.out.println("Scheduling restore: " + s.name);
                        if (filter == null) {
                            didRestore = (mRestore.restoreAll(token, observer) == 0);
                        } else {
                            String[] names = new String[filter.size()];
                            filter.toArray(names);
                            didRestore = (mRestore.restoreSome(token, observer, names) == 0);
                        }
                        break;
                    }
                }
            }
        }
        if (!didRestore) {
            if (sets == null || sets.length == 0) {
                System.out.println("No available restore sets; no restore performed");
            } else {
                System.out.println("No matching restore set token.  Available sets:");
                printRestoreSets(sets);
            }
        }
        // to complete before we can shut down the restore session safely
        if (didRestore) {
            observer.waitForCompletion();
        }
        // once the restore has finished, close down the session and we're done
        mRestore.endRestoreSession();
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(BMGR_NOT_RUNNING_ERR);
    }
}
Also used : IRestoreObserver(android.app.backup.IRestoreObserver) RestoreSet(android.app.backup.RestoreSet) RemoteException(android.os.RemoteException)

Example 12 with RestoreSet

use of android.app.backup.RestoreSet in project android_frameworks_base by ResurrectionRemix.

the class Bmgr method doRestoreAll.

private void doRestoreAll(long token, HashSet<String> filter) {
    RestoreObserver observer = new RestoreObserver();
    try {
        boolean didRestore = false;
        mRestore = mBmgr.beginRestoreSession(null, null);
        if (mRestore == null) {
            System.err.println(BMGR_NOT_RUNNING_ERR);
            return;
        }
        RestoreSet[] sets = null;
        int err = mRestore.getAvailableRestoreSets(observer);
        if (err == 0) {
            observer.waitForCompletion();
            sets = observer.sets;
            if (sets != null) {
                for (RestoreSet s : sets) {
                    if (s.token == token) {
                        System.out.println("Scheduling restore: " + s.name);
                        if (filter == null) {
                            didRestore = (mRestore.restoreAll(token, observer) == 0);
                        } else {
                            String[] names = new String[filter.size()];
                            filter.toArray(names);
                            didRestore = (mRestore.restoreSome(token, observer, names) == 0);
                        }
                        break;
                    }
                }
            }
        }
        if (!didRestore) {
            if (sets == null || sets.length == 0) {
                System.out.println("No available restore sets; no restore performed");
            } else {
                System.out.println("No matching restore set token.  Available sets:");
                printRestoreSets(sets);
            }
        }
        // to complete before we can shut down the restore session safely
        if (didRestore) {
            observer.waitForCompletion();
        }
        // once the restore has finished, close down the session and we're done
        mRestore.endRestoreSession();
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(BMGR_NOT_RUNNING_ERR);
    }
}
Also used : IRestoreObserver(android.app.backup.IRestoreObserver) RestoreSet(android.app.backup.RestoreSet) RemoteException(android.os.RemoteException)

Example 13 with RestoreSet

use of android.app.backup.RestoreSet in project android_frameworks_base by ResurrectionRemix.

the class LocalTransport method getAvailableRestoreSets.

@Override
public RestoreSet[] getAvailableRestoreSets() {
    long[] existing = new long[POSSIBLE_SETS.length + 1];
    int num = 0;
    // see which possible non-current sets exist...
    for (long token : POSSIBLE_SETS) {
        if ((new File(mDataDir, Long.toString(token))).exists()) {
            existing[num++] = token;
        }
    }
    // ...and always the currently-active set last
    existing[num++] = CURRENT_SET_TOKEN;
    RestoreSet[] available = new RestoreSet[num];
    for (int i = 0; i < available.length; i++) {
        available[i] = new RestoreSet("Local disk image", "flash", existing[i]);
    }
    return available;
}
Also used : RestoreSet(android.app.backup.RestoreSet) File(java.io.File)

Aggregations

RestoreSet (android.app.backup.RestoreSet)13 IRestoreObserver (android.app.backup.IRestoreObserver)6 RemoteException (android.os.RemoteException)6 File (java.io.File)5