From cef28e74afea535c038910d129a1dbe15969c49e Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Thu, 27 Aug 2009 18:45:21 +0800 Subject: Simplifies err code propagation. * Other changes + Re-assign err codes in VpnManager. + Add new err codes: REMOTE_PPP_HUNG_UP, PPP_NEGOTIATION_FAILED. + Delete the state file only if it exists (to prevent logging an unable-to-unlink error). + Extend timeout to 40 seconds. --- .../src/com/android/server/vpn/VpnService.java | 24 +++------------------- .../com/android/server/vpn/VpnServiceBinder.java | 3 ++- 2 files changed, 5 insertions(+), 22 deletions(-) (limited to 'packages') diff --git a/packages/VpnServices/src/com/android/server/vpn/VpnService.java b/packages/VpnServices/src/com/android/server/vpn/VpnService.java index e3ac996..53167f6 100644 --- a/packages/VpnServices/src/com/android/server/vpn/VpnService.java +++ b/packages/VpnServices/src/com/android/server/vpn/VpnService.java @@ -56,10 +56,6 @@ abstract class VpnService implements Serializable { private static final String REMOTE_IP = "net.ipremote"; private static final String DNS_DOMAIN_SUFFICES = "net.dns.search"; - private static final int CHALLENGE_ERROR_CODE = 5; - private static final int REMOTE_HUNG_UP_ERROR_CODE = 7; - private static final int AUTH_ERROR_CODE = 51; - private final String TAG = VpnService.class.getSimpleName(); // FIXME: profile is only needed in connecting phase, so we can just save @@ -202,7 +198,7 @@ abstract class VpnService implements Serializable { private void waitUntilConnectedOrTimedout() throws IOException { sleep(2000); // 2 seconds - for (int i = 0; i < 60; i++) { + for (int i = 0; i < 80; i++) { if (mState != VpnState.CONNECTING) { break; } else if (VPN_IS_UP.equals( @@ -464,22 +460,8 @@ abstract class VpnService implements Serializable { synchronized int getSocketError() { for (DaemonProxy s : mDaemonList) { - switch (getResultFromSocket(s)) { - case 0: - continue; - - case AUTH_ERROR_CODE: - return VpnManager.VPN_ERROR_AUTH; - - case CHALLENGE_ERROR_CODE: - return VpnManager.VPN_ERROR_CHALLENGE; - - case REMOTE_HUNG_UP_ERROR_CODE: - return VpnManager.VPN_ERROR_REMOTE_HUNG_UP; - - default: - return VpnManager.VPN_ERROR_CONNECTION_FAILED; - } + int errCode = getResultFromSocket(s); + if (errCode != 0) return errCode; } return 0; } diff --git a/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java b/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java index 4892a7b..e5be847 100644 --- a/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java +++ b/packages/VpnServices/src/com/android/server/vpn/VpnServiceBinder.java @@ -91,7 +91,8 @@ public class VpnServiceBinder extends Service { void removeStates() { try { - new File(STATES_FILE_PATH).delete(); + File f = new File(STATES_FILE_PATH); + if (f.exists()) f.delete(); } catch (Throwable e) { if (DBG) Log.d("VpnServiceBinder", " remove states: " + e); } -- cgit v1.1