diff options
author | Joe Onorato <joeo@android.com> | 2009-06-25 23:53:29 -0400 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2009-06-25 23:53:29 -0400 |
commit | 4a64bded06a0299785c295a975e2818308eb53e2 (patch) | |
tree | a24057a8f82108aae7f8e6fcb5067c2ed7fe9690 /cmds | |
parent | 5e8a4b842c20dd47b82e9915f1bd730ee1b0d46d (diff) | |
download | frameworks_base-4a64bded06a0299785c295a975e2818308eb53e2.zip frameworks_base-4a64bded06a0299785c295a975e2818308eb53e2.tar.gz frameworks_base-4a64bded06a0299785c295a975e2818308eb53e2.tar.bz2 |
Add some helpful tests scripts for backup and make bmgr restore wait until the backup is done.
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java index 8745cff..01083f1 100644 --- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java +++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java @@ -35,16 +35,6 @@ public final class Bmgr { private String[] mArgs; private int mNextArg; private String mCurArgData; - private RestoreObserver mObserver = new RestoreObserver(); - - class RestoreObserver extends IRestoreObserver.Stub { - public void restoreStarting(int numPackages) { - } - public void onUpdate(int nowBeingRestored) { - } - public void restoreFinished(int error) { - } - } public static void main(String[] args) { try { @@ -191,6 +181,25 @@ public final class Bmgr { } } + class RestoreObserver extends IRestoreObserver.Stub { + boolean done; + public void restoreStarting(int numPackages) { + System.out.println("restoreStarting: " + numPackages + " packages"); + } + + public void onUpdate(int nowBeingRestored) { + System.out.println("onUpdate: " + nowBeingRestored); + } + + public void restoreFinished(int error) { + System.out.println("restoreFinished: " + error); + synchronized (this) { + done = true; + this.notify(); + } + } + } + private void doRestore() { int token; try { @@ -200,6 +209,8 @@ public final class Bmgr { return; } + RestoreObserver observer = new RestoreObserver(); + try { int curTransport = mBmgr.getCurrentTransport(); mRestore = mBmgr.beginRestoreSession(curTransport); @@ -211,7 +222,7 @@ public final class Bmgr { for (RestoreSet s : sets) { if (s.token == token) { System.out.println("Scheduling restore: " + s.name); - mRestore.performRestore(token, mObserver); + mRestore.performRestore(token, observer); break; } } @@ -220,6 +231,17 @@ public final class Bmgr { System.err.println(e.toString()); System.err.println(BMGR_NOT_RUNNING_ERR); } + + // now wait for it to be done + synchronized (observer) { + while (!observer.done) { + try { + observer.wait(); + } catch (InterruptedException ex) { + } + } + } + System.out.println("done"); } private String nextArg() { |