Merge change 23066 into eclair

* changes:
  - don't schedule syncs that we will never dispatch - expedite the INITIALIZATION sync
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 77a126c..3a419b5 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -136,8 +136,17 @@
 
 AudioFlinger::~AudioFlinger()
 {
-    mRecordThreads.clear();
-    mPlaybackThreads.clear();
+    while (!mRecordThreads.isEmpty()) {
+        // closeInput() will remove first entry from mRecordThreads
+        closeInput(mRecordThreads.keyAt(0));
+    }
+    while (!mPlaybackThreads.isEmpty()) {
+        // closeOutput() will remove first entry from mPlaybackThreads
+        closeOutput(mPlaybackThreads.keyAt(0));
+    }
+    if (mAudioHardware) {
+        delete mAudioHardware;
+    }
 }
 
 
diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp
index df713cb..60c177b 100644
--- a/libs/ui/EventHub.cpp
+++ b/libs/ui/EventHub.cpp
@@ -784,6 +784,7 @@
             int count = mFDCount - i - 1;
             int index = (device->id&ID_MASK);
             mDevicesById[index].device = NULL;
+            close(mFDs[i].fd);
             memmove(mDevices + i, mDevices + i + 1, sizeof(mDevices[0]) * count);
             memmove(mFDs + i, mFDs + i + 1, sizeof(mFDs[0]) * count);
 
diff --git a/vpn/java/android/net/vpn/VpnManager.java b/vpn/java/android/net/vpn/VpnManager.java
index f71bbea..6df612e 100644
--- a/vpn/java/android/net/vpn/VpnManager.java
+++ b/vpn/java/android/net/vpn/VpnManager.java
@@ -45,18 +45,25 @@
     /** Key to the error code of a connectivity broadcast event. */
     public static final String BROADCAST_ERROR_CODE = "err";
     /** Error code to indicate an error from authentication. */
-    public static final int VPN_ERROR_AUTH = 1;
+    public static final int VPN_ERROR_AUTH = 51;
     /** Error code to indicate the connection attempt failed. */
-    public static final int VPN_ERROR_CONNECTION_FAILED = 2;
+    public static final int VPN_ERROR_CONNECTION_FAILED = 101;
     /** Error code to indicate the server is not known. */
-    public static final int VPN_ERROR_UNKNOWN_SERVER = 3;
+    public static final int VPN_ERROR_UNKNOWN_SERVER = 102;
     /** Error code to indicate an error from challenge response. */
-    public static final int VPN_ERROR_CHALLENGE = 4;
+    public static final int VPN_ERROR_CHALLENGE = 5;
     /** Error code to indicate an error of remote server hanging up. */
-    public static final int VPN_ERROR_REMOTE_HUNG_UP = 5;
+    public static final int VPN_ERROR_REMOTE_HUNG_UP = 7;
+    /** Error code to indicate an error of remote PPP server hanging up. */
+    public static final int VPN_ERROR_REMOTE_PPP_HUNG_UP = 48;
+    /** Error code to indicate a PPP negotiation error. */
+    public static final int VPN_ERROR_PPP_NEGOTIATION_FAILED = 42;
     /** Error code to indicate an error of losing connectivity. */
-    public static final int VPN_ERROR_CONNECTION_LOST = 6;
-    private static final int VPN_ERROR_NO_ERROR = 0;
+    public static final int VPN_ERROR_CONNECTION_LOST = 103;
+    /** Largest error code used by VPN. */
+    public static final int VPN_ERROR_LARGEST = 200;
+    /** Error code to indicate a successful connection. */
+    public static final int VPN_ERROR_NO_ERROR = 0;
 
     public static final String PROFILES_PATH = "/data/misc/vpn/profiles";