Merge "Make LocalSocket Closeable." into jb-mr1-dev
This commit is contained in:
@@ -12446,7 +12446,7 @@ package android.net {
|
||||
method public android.net.LocalSocketAddress getLocalSocketAddress();
|
||||
}
|
||||
|
||||
public class LocalSocket {
|
||||
public class LocalSocket implements java.io.Closeable {
|
||||
ctor public LocalSocket();
|
||||
method public void bind(android.net.LocalSocketAddress) throws java.io.IOException;
|
||||
method public void close() throws java.io.IOException;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package android.net;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -26,7 +27,7 @@ import java.net.SocketOptions;
|
||||
* Creates a (non-server) socket in the UNIX-domain namespace. The interface
|
||||
* here is not entirely unlike that of java.net.Socket
|
||||
*/
|
||||
public class LocalSocket {
|
||||
public class LocalSocket implements Closeable {
|
||||
|
||||
private LocalSocketImpl impl;
|
||||
private volatile boolean implCreated;
|
||||
@@ -167,6 +168,7 @@ public class LocalSocket {
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
implCreateIfNeeded();
|
||||
impl.close();
|
||||
|
||||
@@ -53,6 +53,8 @@ import java.io.OutputStream;
|
||||
import java.nio.charset.Charsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
import libcore.io.IoUtils;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@@ -228,11 +230,7 @@ public class Vpn extends INetworkManagementEventObserver.Stub {
|
||||
mConnection = connection;
|
||||
mInterface = interfaze;
|
||||
} catch (RuntimeException e) {
|
||||
try {
|
||||
tun.close();
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
IoUtils.closeQuietly(tun);
|
||||
throw e;
|
||||
}
|
||||
Log.i(TAG, "Established by " + config.user + " on " + mInterface);
|
||||
@@ -442,11 +440,7 @@ public class Vpn extends INetworkManagementEventObserver.Stub {
|
||||
// We assume that everything is reset after stopping the daemons.
|
||||
interrupt();
|
||||
for (LocalSocket socket : mSockets) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
IoUtils.closeQuietly(socket);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user