Add WaitForProvisioningCallback

This centralizes code that is shared by both bluetooth and ethernet
transport layers.

Bug: 26991160
Change-Id: I8e2dd8580c29c86394119768e3a5529850b4b859
This commit is contained in:
Erik Kline
2016-02-19 15:48:22 +09:00
parent d0e843b8ef
commit 111d55658b

View File

@@ -109,6 +109,35 @@ public class IpManager extends StateMachine {
public void onQuit() {}
}
public static class WaitForProvisioningCallback extends Callback {
private LinkProperties mCallbackLinkProperties;
public LinkProperties waitForProvisioning() {
synchronized (this) {
try {
wait();
} catch (InterruptedException e) {}
return mCallbackLinkProperties;
}
}
@Override
public void onProvisioningSuccess(LinkProperties newLp) {
synchronized (this) {
mCallbackLinkProperties = newLp;
notify();
}
}
@Override
public void onProvisioningFailure(LinkProperties newLp) {
synchronized (this) {
mCallbackLinkProperties = null;
notify();
}
}
}
/**
* This class encapsulates parameters to be passed to
* IpManager#startProvisioning(). A defensive copy is made by IpManager