From f68eb500f99361541049e09eb7f9ddd6f4ef4efa Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Tue, 16 Jun 2009 11:02:01 -0700 Subject: More bmgr work; fix clear-data signalling The 'list sets' and 'restore token#' commands from bmgr now do what they are supposed to. At this point we see the restore target's data being cleared properly and its agent being launched and invoked for restore. --- cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java | 54 ++++++++++++++++++++--- 1 file changed, 49 insertions(+), 5 deletions(-) (limited to 'cmds/bmgr') diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java index 467cac1..3af80fa 100644 --- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java +++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java @@ -36,9 +36,14 @@ public final class Bmgr { private String mCurArgData; public static void main(String[] args) { - new Bmgr().run(args); + try { + new Bmgr().run(args); + } catch (Exception e) { + System.err.println("Exception caught:"); + e.printStackTrace(); + } } - + public void run(String[] args) { boolean validCommand = false; if (args.length < 1) { @@ -70,6 +75,11 @@ public final class Bmgr { doList(); return; } + + if ("restore".equals(op)) { + doRestore(); + return; + } } private void doRun() { @@ -114,6 +124,10 @@ public final class Bmgr { try { int curTransport = mBmgr.getCurrentTransport(); mRestore = mBmgr.beginRestoreSession(curTransport); + if (mRestore == null) { + System.err.println(BMGR_NOT_RUNNING_ERR); + return; + } if ("sets".equals(arg)) { doListRestoreSets(); @@ -127,13 +141,12 @@ public final class Bmgr { } private void doListTransports() { - } private void doListRestoreSets() { try { RestoreSet[] sets = mRestore.getAvailableRestoreSets(); - if (sets.length == 0) { + if (sets == null || sets.length == 0) { System.out.println("No restore sets available"); } else { for (RestoreSet s : sets) { @@ -146,6 +159,37 @@ public final class Bmgr { } } + private void doRestore() { + int token; + try { + token = Integer.parseInt(nextArg()); + } catch (NumberFormatException e) { + showUsage(); + return; + } + + try { + int curTransport = mBmgr.getCurrentTransport(); + mRestore = mBmgr.beginRestoreSession(curTransport); + if (mRestore == null) { + System.err.println(BMGR_NOT_RUNNING_ERR); + return; + } + RestoreSet[] sets = mRestore.getAvailableRestoreSets(); + for (RestoreSet s : sets) { + if (s.token == token) { + System.out.println("Scheduling restore: " + s.name); + mRestore.performRestore(token); + break; + } + } + mRestore.endRestoreSession(); + } catch (RemoteException e) { + System.err.println(e.toString()); + System.err.println(BMGR_NOT_RUNNING_ERR); + } + } + private String nextArg() { if (mNextArg >= mArgs.length) { return null; @@ -161,7 +205,7 @@ public final class Bmgr { System.err.println(" bmgr list sets"); System.err.println(" #bmgr list transports"); System.err.println(" #bmgr transport which#"); - System.err.println(" #bmgr restore set#"); + System.err.println(" bmgr restore token#"); System.err.println(" bmgr run"); } } \ No newline at end of file -- cgit v1.1