summaryrefslogtreecommitdiffstats
path: root/cmds/bmgr
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2010-03-29 19:14:24 -0700
committerChristopher Tate <ctate@google.com>2010-03-30 12:42:35 -0700
commit2d449afe3d075020bdd1115bcc15c9383cbce122 (patch)
treed7c71c9a74e317319de947f3e3fe3ee673f0c559 /cmds/bmgr
parentae405d56215e4ab43e8210b66e741a0bf9d5edcf (diff)
downloadframeworks_base-2d449afe3d075020bdd1115bcc15c9383cbce122.zip
frameworks_base-2d449afe3d075020bdd1115bcc15c9383cbce122.tar.gz
frameworks_base-2d449afe3d075020bdd1115bcc15c9383cbce122.tar.bz2
Make RestoreSession.getAvailableRestoreSets() asynchronous
This transaction can involve the transport having to query a remote backend over the wire, so it can take a Long Time(tm). Make it main-thread-safe by making it asynchronous, with the results passed as a callback to the invoker's RestoreObserver. We also make the IRestoreObserver callback interface properly oneway. Bug #2550665 Bug #2549422 Change-Id: If18a233a0a3d54c7b55101715c9e6195b762c5a0
Diffstat (limited to 'cmds/bmgr')
-rw-r--r--cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java27
1 files changed, 21 insertions, 6 deletions
diff --git a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
index fa8a7c8..5612158 100644
--- a/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
+++ b/cmds/bmgr/src/com/android/commands/bmgr/Bmgr.java
@@ -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);