Loading api/current.txt +4 −0 Original line number Original line Diff line number Diff line Loading @@ -13462,6 +13462,7 @@ package android.net { public class LocalSocket implements java.io.Closeable { public class LocalSocket implements java.io.Closeable { ctor public LocalSocket(); ctor public LocalSocket(); ctor public LocalSocket(int); method public void bind(android.net.LocalSocketAddress) throws java.io.IOException; method public void bind(android.net.LocalSocketAddress) throws java.io.IOException; method public void close() throws java.io.IOException; method public void close() throws java.io.IOException; method public void connect(android.net.LocalSocketAddress) throws java.io.IOException; method public void connect(android.net.LocalSocketAddress) throws java.io.IOException; Loading @@ -13487,6 +13488,9 @@ package android.net { method public void setSoTimeout(int) throws java.io.IOException; method public void setSoTimeout(int) throws java.io.IOException; method public void shutdownInput() throws java.io.IOException; method public void shutdownInput() throws java.io.IOException; method public void shutdownOutput() throws java.io.IOException; method public void shutdownOutput() throws java.io.IOException; field public static final int SOCKET_DGRAM = 1; // 0x1 field public static final int SOCKET_SEQPACKET = 3; // 0x3 field public static final int SOCKET_STREAM = 2; // 0x2 } } public class LocalSocketAddress { public class LocalSocketAddress { core/java/android/net/LocalServerSocket.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class LocalServerSocket { { { impl = new LocalSocketImpl(); impl = new LocalSocketImpl(); impl.create(true); impl.create(LocalSocket.SOCKET_STREAM); localAddress = new LocalSocketAddress(name); localAddress = new LocalSocketAddress(name); impl.bind(localAddress); impl.bind(localAddress); Loading Loading @@ -93,7 +93,7 @@ public class LocalServerSocket { impl.accept (acceptedImpl); impl.accept (acceptedImpl); return new LocalSocket(acceptedImpl); return new LocalSocket(acceptedImpl, LocalSocket.SOCKET_UNKNOWN); } } /** /** Loading core/java/android/net/LocalSocket.java +26 −4 Original line number Original line Diff line number Diff line Loading @@ -34,21 +34,42 @@ public class LocalSocket implements Closeable { private LocalSocketAddress localAddress; private LocalSocketAddress localAddress; private boolean isBound; private boolean isBound; private boolean isConnected; private boolean isConnected; private final int sockType; /** unknown socket type (used for constructor with existing file descriptor) */ /* package */ static final int SOCKET_UNKNOWN = 0; /** Datagram socket type */ public static final int SOCKET_DGRAM = 1; /** Stream socket type */ public static final int SOCKET_STREAM = 2; /** Sequential packet socket type */ public static final int SOCKET_SEQPACKET = 3; /** /** * Creates a AF_LOCAL/UNIX domain stream socket. * Creates a AF_LOCAL/UNIX domain stream socket. */ */ public LocalSocket() { public LocalSocket() { this(new LocalSocketImpl()); this(SOCKET_STREAM); } /** * Creates a AF_LOCAL/UNIX domain stream socket with given socket type * * @param sockType either {@link #SOCKET_DGRAM}, {@link #SOCKET_STREAM} * or {@link #SOCKET_SEQPACKET} */ public LocalSocket(int sockType) { this(new LocalSocketImpl(), sockType); isBound = false; isBound = false; isConnected = false; isConnected = false; } } /** /** * Creates a AF_LOCAL/UNIX domain stream socket with FileDescriptor. * Creates a AF_LOCAL/UNIX domain stream socket with FileDescriptor. * @hide * @hide */ */ public LocalSocket(FileDescriptor fd) throws IOException { public LocalSocket(FileDescriptor fd) throws IOException { this(new LocalSocketImpl(fd)); this(new LocalSocketImpl(fd), SOCKET_UNKNOWN); isBound = true; isBound = true; isConnected = true; isConnected = true; } } Loading @@ -57,8 +78,9 @@ public class LocalSocket implements Closeable { * for use with AndroidServerSocket * for use with AndroidServerSocket * @param impl a SocketImpl * @param impl a SocketImpl */ */ /*package*/ LocalSocket(LocalSocketImpl impl) { /*package*/ LocalSocket(LocalSocketImpl impl, int sockType) { this.impl = impl; this.impl = impl; this.sockType = sockType; this.isConnected = false; this.isConnected = false; this.isBound = false; this.isBound = false; } } Loading @@ -81,7 +103,7 @@ public class LocalSocket implements Closeable { synchronized (this) { synchronized (this) { if (!implCreated) { if (!implCreated) { try { try { impl.create(true); impl.create(sockType); } finally { } finally { implCreated = true; implCreated = true; } } Loading core/java/android/net/LocalSocketImpl.java +31 −8 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,10 @@ import java.io.InputStream; import java.io.FileDescriptor; import java.io.FileDescriptor; import java.net.SocketOptions; import java.net.SocketOptions; import libcore.io.ErrnoException; import libcore.io.Libcore; import libcore.io.OsConstants; /** /** * Socket implementation used for android.net.LocalSocket and * Socket implementation used for android.net.LocalSocket and * android.net.LocalServerSocket. Supports only AF_LOCAL sockets. * android.net.LocalServerSocket. Supports only AF_LOCAL sockets. Loading Loading @@ -159,7 +163,6 @@ class LocalSocketImpl private native int pending_native(FileDescriptor fd) throws IOException; private native int pending_native(FileDescriptor fd) throws IOException; private native int available_native(FileDescriptor fd) throws IOException; private native int available_native(FileDescriptor fd) throws IOException; private native void close_native(FileDescriptor fd) throws IOException; private native int read_native(FileDescriptor fd) throws IOException; private native int read_native(FileDescriptor fd) throws IOException; private native int readba_native(byte[] b, int off, int len, private native int readba_native(byte[] b, int off, int len, FileDescriptor fd) throws IOException; FileDescriptor fd) throws IOException; Loading @@ -171,8 +174,6 @@ class LocalSocketImpl int namespace) throws IOException; int namespace) throws IOException; private native void bindLocal(FileDescriptor fd, String name, int namespace) private native void bindLocal(FileDescriptor fd, String name, int namespace) throws IOException; throws IOException; private native FileDescriptor create_native(boolean stream) throws IOException; private native void listen_native(FileDescriptor fd, int backlog) private native void listen_native(FileDescriptor fd, int backlog) throws IOException; throws IOException; private native void shutdown(FileDescriptor fd, boolean shutdownInput); private native void shutdown(FileDescriptor fd, boolean shutdownInput); Loading Loading @@ -222,15 +223,33 @@ class LocalSocketImpl /** /** * Creates a socket in the underlying OS. * Creates a socket in the underlying OS. * * * @param stream true if this should be a stream socket, false for * @param sockType either {@link LocalSocket#SOCKET_DGRAM}, {@link LocalSocket#SOCKET_STREAM} * datagram. * or {@link LocalSocket#SOCKET_SEQPACKET} * @throws IOException * @throws IOException */ */ public void create (boolean stream) throws IOException { public void create (int sockType) throws IOException { // no error if socket already created // no error if socket already created // need this for LocalServerSocket.accept() // need this for LocalServerSocket.accept() if (fd == null) { if (fd == null) { fd = create_native(stream); int osType; switch (sockType) { case LocalSocket.SOCKET_DGRAM: osType = OsConstants.SOCK_DGRAM; break; case LocalSocket.SOCKET_STREAM: osType = OsConstants.SOCK_STREAM; break; case LocalSocket.SOCKET_SEQPACKET: osType = OsConstants.SOCK_SEQPACKET; break; default: throw new IllegalStateException("unknown sockType"); } try { fd = Libcore.os.socket(OsConstants.AF_UNIX, osType, 0); } catch (ErrnoException e) { e.rethrowAsIOException(); } } } } } Loading @@ -242,7 +261,11 @@ class LocalSocketImpl public void close() throws IOException { public void close() throws IOException { synchronized (LocalSocketImpl.this) { synchronized (LocalSocketImpl.this) { if (fd == null) return; if (fd == null) return; close_native(fd); try { Libcore.os.close(fd); } catch (ErrnoException e) { e.rethrowAsIOException(); } fd = null; fd = null; } } } } Loading core/jni/android_net_LocalSocketImpl.cpp +0 −48 Original line number Original line Diff line number Diff line Loading @@ -44,26 +44,6 @@ static jclass class_Credentials; static jclass class_FileDescriptor; static jclass class_FileDescriptor; static jmethodID method_CredentialsInit; static jmethodID method_CredentialsInit; /* * private native FileDescriptor * create_native(boolean stream) * throws IOException; */ static jobject socket_create (JNIEnv *env, jobject object, jboolean stream) { int ret; ret = socket(PF_LOCAL, stream ? SOCK_STREAM : SOCK_DGRAM, 0); if (ret < 0) { jniThrowIOException(env, errno); return NULL; } return jniCreateFileDescriptor(env,ret); } /* private native void connectLocal(FileDescriptor fd, /* private native void connectLocal(FileDescriptor fd, * String name, int namespace) throws IOException * String name, int namespace) throws IOException */ */ Loading Loading @@ -445,32 +425,6 @@ static jint socket_available (JNIEnv *env, jobject object, #endif #endif } } static void socket_close (JNIEnv *env, jobject object, jobject fileDescriptor) { int fd; int err; if (fileDescriptor == NULL) { jniThrowNullPointerException(env, NULL); return; } fd = jniGetFDFromFileDescriptor(env, fileDescriptor); if (env->ExceptionOccurred() != NULL) { return; } do { err = close(fd); } while (err < 0 && errno == EINTR); if (err < 0) { jniThrowIOException(env, errno); return; } } /** /** * Processes ancillary data, handling only * Processes ancillary data, handling only * SCM_RIGHTS. Creates appropriate objects and sets appropriate * SCM_RIGHTS. Creates appropriate objects and sets appropriate Loading Loading @@ -909,7 +863,6 @@ static JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ /* name, signature, funcPtr */ {"getOption_native", "(Ljava/io/FileDescriptor;I)I", (void*)socket_getOption}, {"getOption_native", "(Ljava/io/FileDescriptor;I)I", (void*)socket_getOption}, {"setOption_native", "(Ljava/io/FileDescriptor;III)V", (void*)socket_setOption}, {"setOption_native", "(Ljava/io/FileDescriptor;III)V", (void*)socket_setOption}, {"create_native", "(Z)Ljava/io/FileDescriptor;", (void*)socket_create}, {"connectLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", {"connectLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", (void*)socket_connect_local}, (void*)socket_connect_local}, {"bindLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", (void*)socket_bind_local}, {"bindLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", (void*)socket_bind_local}, Loading @@ -918,7 +871,6 @@ static JNINativeMethod gMethods[] = { {"shutdown", "(Ljava/io/FileDescriptor;Z)V", (void*)socket_shutdown}, {"shutdown", "(Ljava/io/FileDescriptor;Z)V", (void*)socket_shutdown}, {"available_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_available}, {"available_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_available}, {"pending_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_pending}, {"pending_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_pending}, {"close_native", "(Ljava/io/FileDescriptor;)V", (void*) socket_close}, {"read_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_read}, {"read_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_read}, {"readba_native", "([BIILjava/io/FileDescriptor;)I", (void*) socket_readba}, {"readba_native", "([BIILjava/io/FileDescriptor;)I", (void*) socket_readba}, {"writeba_native", "([BIILjava/io/FileDescriptor;)V", (void*) socket_writeba}, {"writeba_native", "([BIILjava/io/FileDescriptor;)V", (void*) socket_writeba}, Loading Loading
api/current.txt +4 −0 Original line number Original line Diff line number Diff line Loading @@ -13462,6 +13462,7 @@ package android.net { public class LocalSocket implements java.io.Closeable { public class LocalSocket implements java.io.Closeable { ctor public LocalSocket(); ctor public LocalSocket(); ctor public LocalSocket(int); method public void bind(android.net.LocalSocketAddress) throws java.io.IOException; method public void bind(android.net.LocalSocketAddress) throws java.io.IOException; method public void close() throws java.io.IOException; method public void close() throws java.io.IOException; method public void connect(android.net.LocalSocketAddress) throws java.io.IOException; method public void connect(android.net.LocalSocketAddress) throws java.io.IOException; Loading @@ -13487,6 +13488,9 @@ package android.net { method public void setSoTimeout(int) throws java.io.IOException; method public void setSoTimeout(int) throws java.io.IOException; method public void shutdownInput() throws java.io.IOException; method public void shutdownInput() throws java.io.IOException; method public void shutdownOutput() throws java.io.IOException; method public void shutdownOutput() throws java.io.IOException; field public static final int SOCKET_DGRAM = 1; // 0x1 field public static final int SOCKET_SEQPACKET = 3; // 0x3 field public static final int SOCKET_STREAM = 2; // 0x2 } } public class LocalSocketAddress { public class LocalSocketAddress {
core/java/android/net/LocalServerSocket.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class LocalServerSocket { { { impl = new LocalSocketImpl(); impl = new LocalSocketImpl(); impl.create(true); impl.create(LocalSocket.SOCKET_STREAM); localAddress = new LocalSocketAddress(name); localAddress = new LocalSocketAddress(name); impl.bind(localAddress); impl.bind(localAddress); Loading Loading @@ -93,7 +93,7 @@ public class LocalServerSocket { impl.accept (acceptedImpl); impl.accept (acceptedImpl); return new LocalSocket(acceptedImpl); return new LocalSocket(acceptedImpl, LocalSocket.SOCKET_UNKNOWN); } } /** /** Loading
core/java/android/net/LocalSocket.java +26 −4 Original line number Original line Diff line number Diff line Loading @@ -34,21 +34,42 @@ public class LocalSocket implements Closeable { private LocalSocketAddress localAddress; private LocalSocketAddress localAddress; private boolean isBound; private boolean isBound; private boolean isConnected; private boolean isConnected; private final int sockType; /** unknown socket type (used for constructor with existing file descriptor) */ /* package */ static final int SOCKET_UNKNOWN = 0; /** Datagram socket type */ public static final int SOCKET_DGRAM = 1; /** Stream socket type */ public static final int SOCKET_STREAM = 2; /** Sequential packet socket type */ public static final int SOCKET_SEQPACKET = 3; /** /** * Creates a AF_LOCAL/UNIX domain stream socket. * Creates a AF_LOCAL/UNIX domain stream socket. */ */ public LocalSocket() { public LocalSocket() { this(new LocalSocketImpl()); this(SOCKET_STREAM); } /** * Creates a AF_LOCAL/UNIX domain stream socket with given socket type * * @param sockType either {@link #SOCKET_DGRAM}, {@link #SOCKET_STREAM} * or {@link #SOCKET_SEQPACKET} */ public LocalSocket(int sockType) { this(new LocalSocketImpl(), sockType); isBound = false; isBound = false; isConnected = false; isConnected = false; } } /** /** * Creates a AF_LOCAL/UNIX domain stream socket with FileDescriptor. * Creates a AF_LOCAL/UNIX domain stream socket with FileDescriptor. * @hide * @hide */ */ public LocalSocket(FileDescriptor fd) throws IOException { public LocalSocket(FileDescriptor fd) throws IOException { this(new LocalSocketImpl(fd)); this(new LocalSocketImpl(fd), SOCKET_UNKNOWN); isBound = true; isBound = true; isConnected = true; isConnected = true; } } Loading @@ -57,8 +78,9 @@ public class LocalSocket implements Closeable { * for use with AndroidServerSocket * for use with AndroidServerSocket * @param impl a SocketImpl * @param impl a SocketImpl */ */ /*package*/ LocalSocket(LocalSocketImpl impl) { /*package*/ LocalSocket(LocalSocketImpl impl, int sockType) { this.impl = impl; this.impl = impl; this.sockType = sockType; this.isConnected = false; this.isConnected = false; this.isBound = false; this.isBound = false; } } Loading @@ -81,7 +103,7 @@ public class LocalSocket implements Closeable { synchronized (this) { synchronized (this) { if (!implCreated) { if (!implCreated) { try { try { impl.create(true); impl.create(sockType); } finally { } finally { implCreated = true; implCreated = true; } } Loading
core/java/android/net/LocalSocketImpl.java +31 −8 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,10 @@ import java.io.InputStream; import java.io.FileDescriptor; import java.io.FileDescriptor; import java.net.SocketOptions; import java.net.SocketOptions; import libcore.io.ErrnoException; import libcore.io.Libcore; import libcore.io.OsConstants; /** /** * Socket implementation used for android.net.LocalSocket and * Socket implementation used for android.net.LocalSocket and * android.net.LocalServerSocket. Supports only AF_LOCAL sockets. * android.net.LocalServerSocket. Supports only AF_LOCAL sockets. Loading Loading @@ -159,7 +163,6 @@ class LocalSocketImpl private native int pending_native(FileDescriptor fd) throws IOException; private native int pending_native(FileDescriptor fd) throws IOException; private native int available_native(FileDescriptor fd) throws IOException; private native int available_native(FileDescriptor fd) throws IOException; private native void close_native(FileDescriptor fd) throws IOException; private native int read_native(FileDescriptor fd) throws IOException; private native int read_native(FileDescriptor fd) throws IOException; private native int readba_native(byte[] b, int off, int len, private native int readba_native(byte[] b, int off, int len, FileDescriptor fd) throws IOException; FileDescriptor fd) throws IOException; Loading @@ -171,8 +174,6 @@ class LocalSocketImpl int namespace) throws IOException; int namespace) throws IOException; private native void bindLocal(FileDescriptor fd, String name, int namespace) private native void bindLocal(FileDescriptor fd, String name, int namespace) throws IOException; throws IOException; private native FileDescriptor create_native(boolean stream) throws IOException; private native void listen_native(FileDescriptor fd, int backlog) private native void listen_native(FileDescriptor fd, int backlog) throws IOException; throws IOException; private native void shutdown(FileDescriptor fd, boolean shutdownInput); private native void shutdown(FileDescriptor fd, boolean shutdownInput); Loading Loading @@ -222,15 +223,33 @@ class LocalSocketImpl /** /** * Creates a socket in the underlying OS. * Creates a socket in the underlying OS. * * * @param stream true if this should be a stream socket, false for * @param sockType either {@link LocalSocket#SOCKET_DGRAM}, {@link LocalSocket#SOCKET_STREAM} * datagram. * or {@link LocalSocket#SOCKET_SEQPACKET} * @throws IOException * @throws IOException */ */ public void create (boolean stream) throws IOException { public void create (int sockType) throws IOException { // no error if socket already created // no error if socket already created // need this for LocalServerSocket.accept() // need this for LocalServerSocket.accept() if (fd == null) { if (fd == null) { fd = create_native(stream); int osType; switch (sockType) { case LocalSocket.SOCKET_DGRAM: osType = OsConstants.SOCK_DGRAM; break; case LocalSocket.SOCKET_STREAM: osType = OsConstants.SOCK_STREAM; break; case LocalSocket.SOCKET_SEQPACKET: osType = OsConstants.SOCK_SEQPACKET; break; default: throw new IllegalStateException("unknown sockType"); } try { fd = Libcore.os.socket(OsConstants.AF_UNIX, osType, 0); } catch (ErrnoException e) { e.rethrowAsIOException(); } } } } } Loading @@ -242,7 +261,11 @@ class LocalSocketImpl public void close() throws IOException { public void close() throws IOException { synchronized (LocalSocketImpl.this) { synchronized (LocalSocketImpl.this) { if (fd == null) return; if (fd == null) return; close_native(fd); try { Libcore.os.close(fd); } catch (ErrnoException e) { e.rethrowAsIOException(); } fd = null; fd = null; } } } } Loading
core/jni/android_net_LocalSocketImpl.cpp +0 −48 Original line number Original line Diff line number Diff line Loading @@ -44,26 +44,6 @@ static jclass class_Credentials; static jclass class_FileDescriptor; static jclass class_FileDescriptor; static jmethodID method_CredentialsInit; static jmethodID method_CredentialsInit; /* * private native FileDescriptor * create_native(boolean stream) * throws IOException; */ static jobject socket_create (JNIEnv *env, jobject object, jboolean stream) { int ret; ret = socket(PF_LOCAL, stream ? SOCK_STREAM : SOCK_DGRAM, 0); if (ret < 0) { jniThrowIOException(env, errno); return NULL; } return jniCreateFileDescriptor(env,ret); } /* private native void connectLocal(FileDescriptor fd, /* private native void connectLocal(FileDescriptor fd, * String name, int namespace) throws IOException * String name, int namespace) throws IOException */ */ Loading Loading @@ -445,32 +425,6 @@ static jint socket_available (JNIEnv *env, jobject object, #endif #endif } } static void socket_close (JNIEnv *env, jobject object, jobject fileDescriptor) { int fd; int err; if (fileDescriptor == NULL) { jniThrowNullPointerException(env, NULL); return; } fd = jniGetFDFromFileDescriptor(env, fileDescriptor); if (env->ExceptionOccurred() != NULL) { return; } do { err = close(fd); } while (err < 0 && errno == EINTR); if (err < 0) { jniThrowIOException(env, errno); return; } } /** /** * Processes ancillary data, handling only * Processes ancillary data, handling only * SCM_RIGHTS. Creates appropriate objects and sets appropriate * SCM_RIGHTS. Creates appropriate objects and sets appropriate Loading Loading @@ -909,7 +863,6 @@ static JNINativeMethod gMethods[] = { /* name, signature, funcPtr */ /* name, signature, funcPtr */ {"getOption_native", "(Ljava/io/FileDescriptor;I)I", (void*)socket_getOption}, {"getOption_native", "(Ljava/io/FileDescriptor;I)I", (void*)socket_getOption}, {"setOption_native", "(Ljava/io/FileDescriptor;III)V", (void*)socket_setOption}, {"setOption_native", "(Ljava/io/FileDescriptor;III)V", (void*)socket_setOption}, {"create_native", "(Z)Ljava/io/FileDescriptor;", (void*)socket_create}, {"connectLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", {"connectLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", (void*)socket_connect_local}, (void*)socket_connect_local}, {"bindLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", (void*)socket_bind_local}, {"bindLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", (void*)socket_bind_local}, Loading @@ -918,7 +871,6 @@ static JNINativeMethod gMethods[] = { {"shutdown", "(Ljava/io/FileDescriptor;Z)V", (void*)socket_shutdown}, {"shutdown", "(Ljava/io/FileDescriptor;Z)V", (void*)socket_shutdown}, {"available_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_available}, {"available_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_available}, {"pending_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_pending}, {"pending_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_pending}, {"close_native", "(Ljava/io/FileDescriptor;)V", (void*) socket_close}, {"read_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_read}, {"read_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_read}, {"readba_native", "([BIILjava/io/FileDescriptor;)I", (void*) socket_readba}, {"readba_native", "([BIILjava/io/FileDescriptor;)I", (void*) socket_readba}, {"writeba_native", "([BIILjava/io/FileDescriptor;)V", (void*) socket_writeba}, {"writeba_native", "([BIILjava/io/FileDescriptor;)V", (void*) socket_writeba}, Loading