Merge change 6608 into donut

* changes:
  Move the watchdog timer to a separate thread...
This commit is contained in:
Android (Google) Code Review
2009-07-09 00:29:53 -07:00

View File

@@ -189,7 +189,7 @@ abstract class VpnService<E extends VpnProfile> {
mServiceHelper.stop(); mServiceHelper.stop();
} catch (Throwable e) { } catch (Throwable e) {
Log.e(TAG, "onError()", e); Log.e(TAG, "onDisconnect()", e);
onFinalCleanUp(); onFinalCleanUp();
} }
} }
@@ -219,21 +219,28 @@ abstract class VpnService<E extends VpnProfile> {
} }
private void waitUntilConnectedOrTimedout() { private void waitUntilConnectedOrTimedout() {
sleep(2000); // 2 seconds // Run this in the background thread to not block UI
for (int i = 0; i < 60; i++) { new Thread(new Runnable() {
if (VPN_IS_UP.equals(SystemProperties.get(VPN_UP))) { public void run() {
onConnected(); sleep(2000); // 2 seconds
return; for (int i = 0; i < 60; i++) {
} if (VPN_IS_UP.equals(SystemProperties.get(VPN_UP))) {
sleep(500); // 0.5 second onConnected();
} return;
} else if (mState != VpnState.CONNECTING) {
break;
}
sleep(500); // 0.5 second
}
synchronized (this) { synchronized (VpnService.this) {
if (mState == VpnState.CONNECTING) { if (mState == VpnState.CONNECTING) {
Log.d(TAG, " connecting timed out !!"); Log.d(TAG, " connecting timed out !!");
onError(); onError();
}
}
} }
} }).start();
} }
private synchronized void onConnected() { private synchronized void onConnected() {