Add return value for RemoteProvisioning

This commit is contained in:
Yann Diorcet 2013-02-21 11:52:00 +01:00
parent faa0900c9e
commit 7e05701abe

View file

@ -19,6 +19,7 @@ public class RemoteProvisioning {
String mRPAddress; String mRPAddress;
String mSchema; String mSchema;
String mLocalLP; String mLocalLP;
boolean value;
public RemoteProvisioningThread(final String RPAddress, final String LocalLP, final String schema) { public RemoteProvisioningThread(final String RPAddress, final String LocalLP, final String schema) {
this.mRPAddress = RPAddress; this.mRPAddress = RPAddress;
@ -28,6 +29,7 @@ public class RemoteProvisioning {
public void run() { public void run() {
try { try {
value = false;
Log.i("Download remote provisioning file from " + mRPAddress); Log.i("Download remote provisioning file from " + mRPAddress);
URL url = new URL(mRPAddress); URL url = new URL(mRPAddress);
URLConnection ucon = url.openConnection(); URLConnection ucon = url.openConnection();
@ -68,6 +70,7 @@ public class RemoteProvisioning {
} else { } else {
lp.sync(); lp.sync();
} }
value = true;
Log.i("Remote provisioning ok"); Log.i("Remote provisioning ok");
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
Log.e("Invalid remote provisioning url: " + e.getLocalizedMessage()); Log.e("Invalid remote provisioning url: " + e.getLocalizedMessage());
@ -81,7 +84,7 @@ public class RemoteProvisioning {
} }
}; };
static void download(String address, String lpfile, boolean check) { static boolean download(String address, String lpfile, boolean check) {
try { try {
String schema = null; String schema = null;
if(check) { if(check) {
@ -92,13 +95,15 @@ public class RemoteProvisioning {
thread.start(); thread.start();
thread.wait(); thread.wait();
} }
return thread.value;
} catch (InterruptedException e) { } catch (InterruptedException e) {
Log.e(e); Log.e(e);
} }
return false;
} }
static void download(String address, String lpfile) { static boolean download(String address, String lpfile) {
download(address, lpfile, true); return download(address, lpfile, true);
} }
static boolean isAvailable() { static boolean isAvailable() {