diff options
author | Hung-ying Tyan <tyanh@google.com> | 2009-07-09 14:43:55 +0800 |
---|---|---|
committer | Hung-ying Tyan <tyanh@google.com> | 2009-07-09 14:43:55 +0800 |
commit | 296a182dea620230cc72e24e14b195a6b807b886 (patch) | |
tree | 9c5bf6b69ecd642666723f92be2b5c5f8bcb0031 /packages | |
parent | d6fe243c1c6d5e994cacede8110eef736767bd7f (diff) | |
download | frameworks_base-296a182dea620230cc72e24e14b195a6b807b886.zip frameworks_base-296a182dea620230cc72e24e14b195a6b807b886.tar.gz frameworks_base-296a182dea620230cc72e24e14b195a6b807b886.tar.bz2 |
Move the watchdog timer to a separate thread...
so that it won't block the UI thread.
Diffstat (limited to 'packages')
-rw-r--r-- | packages/VpnServices/src/com/android/server/vpn/VpnService.java | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/packages/VpnServices/src/com/android/server/vpn/VpnService.java b/packages/VpnServices/src/com/android/server/vpn/VpnService.java index a60788a..22669d2 100644 --- a/packages/VpnServices/src/com/android/server/vpn/VpnService.java +++ b/packages/VpnServices/src/com/android/server/vpn/VpnService.java @@ -189,7 +189,7 @@ abstract class VpnService<E extends VpnProfile> { mServiceHelper.stop(); } catch (Throwable e) { - Log.e(TAG, "onError()", e); + Log.e(TAG, "onDisconnect()", e); onFinalCleanUp(); } } @@ -219,21 +219,28 @@ abstract class VpnService<E extends VpnProfile> { } private void waitUntilConnectedOrTimedout() { - sleep(2000); // 2 seconds - for (int i = 0; i < 60; i++) { - if (VPN_IS_UP.equals(SystemProperties.get(VPN_UP))) { - onConnected(); - return; - } - sleep(500); // 0.5 second - } + // Run this in the background thread to not block UI + new Thread(new Runnable() { + public void run() { + sleep(2000); // 2 seconds + for (int i = 0; i < 60; i++) { + if (VPN_IS_UP.equals(SystemProperties.get(VPN_UP))) { + onConnected(); + return; + } else if (mState != VpnState.CONNECTING) { + break; + } + sleep(500); // 0.5 second + } - synchronized (this) { - if (mState == VpnState.CONNECTING) { - Log.d(TAG, " connecting timed out !!"); - onError(); + synchronized (VpnService.this) { + if (mState == VpnState.CONNECTING) { + Log.d(TAG, " connecting timed out !!"); + onError(); + } + } } - } + }).start(); } private synchronized void onConnected() { |