Search in sources :

Example 1 with RestoreSet

use of android.app.backup.RestoreSet in project platform_frameworks_base by android.

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 2 with RestoreSet

use of android.app.backup.RestoreSet in project XobotOS by xamarin.

the class LocalTransport method getAvailableRestoreSets.

// Restore handling
public RestoreSet[] getAvailableRestoreSets() throws android.os.RemoteException {
    // one hardcoded restore set
    RestoreSet set = new RestoreSet("Local disk image", "flash", RESTORE_TOKEN);
    RestoreSet[] array = { set };
    return array;
}
Also used : RestoreSet(android.app.backup.RestoreSet)

Example 3 with RestoreSet

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

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 4 with RestoreSet

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

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)

Example 5 with RestoreSet

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

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)

Aggregations

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