BlockGuard.getThreadPolicy().onNetwork();
@Override public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { // We permit datagrams without hostname lookups. if (inetAddress != null) { BlockGuard.getThreadPolicy().onNetwork(); } return os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); }
@Override public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { BlockGuard.getThreadPolicy().onNetwork(); return os.recvfrom(fd, buffer, flags, srcAddress); }
@Override public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { // We permit datagrams without hostname lookups. if (inetAddress != null) { BlockGuard.getThreadPolicy().onNetwork(); } return os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); }
private static InetAddress getHostByAddrImpl(InetAddress address) throws UnknownHostException { BlockGuard.getThreadPolicy().onNetwork(); try { String hostname = Libcore.os.getnameinfo(address, NI_NAMEREQD); return makeInetAddress(address.ipaddress.clone(), hostname); } catch (GaiException gaiException) { throw gaiException.rethrowAsUnknownHostException(); } }
private static InetAddress getHostByAddrImpl(InetAddress address) throws UnknownHostException { BlockGuard.getThreadPolicy().onNetwork(); try { String hostname = Libcore.os.getnameinfo(address, NI_NAMEREQD); return makeInetAddress(address.ipaddress.clone(), hostname); } catch (GaiException gaiException) { throw gaiException.rethrowAsUnknownHostException(); } }
@Override public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { // We permit datagrams without hostname lookups. if (inetAddress != null) { BlockGuard.getThreadPolicy().onNetwork(); } return os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); }
@Override public int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { // Greater than 0 is a timeout in milliseconds and -1 means "block forever", // but 0 means "poll and return immediately", which shouldn't be subject to BlockGuard. if (timeoutMs != 0) { BlockGuard.getThreadPolicy().onNetwork(); } return os.poll(fds, timeoutMs); }
@Override public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { // We permit datagrams without hostname lookups. if (inetAddress != null) { BlockGuard.getThreadPolicy().onNetwork(); } return os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); }
@Override public int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { // Greater than 0 is a timeout in milliseconds and -1 means "block forever", // but 0 means "poll and return immediately", which shouldn't be subject to BlockGuard. if (timeoutMs != 0) { BlockGuard.getThreadPolicy().onNetwork(); } return os.poll(fds, timeoutMs); }
private static InetAddress getHostByAddrImpl(InetAddress address) throws UnknownHostException { BlockGuard.getThreadPolicy().onNetwork(); try { String hostname = Libcore.os.getnameinfo(address, NI_NAMEREQD); return makeInetAddress(address.ipaddress.clone(), hostname); } catch (GaiException gaiException) { throw gaiException.rethrowAsUnknownHostException(); } }
@Override public void close(FileDescriptor fd) throws ErrnoException { try { if (S_ISSOCK(Libcore.os.fstat(fd).st_mode)) { if (isLingerSocket(fd)) { // If the fd is a socket with SO_LINGER set, we might block indefinitely. // We allow non-linger sockets so that apps can close their network // connections in methods like onDestroy which will run on the UI thread. BlockGuard.getThreadPolicy().onNetwork(); } untagSocket(fd); } } catch (ErrnoException ignored) { // We're called via Socket.close (which doesn't ask for us to be called), so we // must not throw here, because Socket.close must not throw if asked to close an // already-closed socket. Also, the passed-in FileDescriptor isn't necessarily // a socket at all. } os.close(fd); }
@Override public FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException { BlockGuard.getThreadPolicy().onNetwork(); return tagSocket(os.accept(fd, peerAddress)); }
@Override public int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { BlockGuard.getThreadPolicy().onNetwork(); return os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress); }
@Override public int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { BlockGuard.getThreadPolicy().onNetwork(); return os.sendto(fd, buffer, flags, inetAddress, port); }
@Override public void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { BlockGuard.getThreadPolicy().onNetwork(); os.connect(fd, address, port); }
@Override public int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { BlockGuard.getThreadPolicy().onNetwork(); return os.recvfrom(fd, buffer, flags, srcAddress); }
@Override public int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { // We permit datagrams without hostname lookups. if (inetAddress != null) { BlockGuard.getThreadPolicy().onNetwork(); } return os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); }
private static InetAddress getHostByAddrImpl(InetAddress address) throws UnknownHostException { BlockGuard.getThreadPolicy().onNetwork(); try { String hostname = Libcore.os.getnameinfo(address, NI_NAMEREQD); return makeInetAddress(address.ipaddress.clone(), hostname); } catch (GaiException gaiException) { throw gaiException.rethrowAsUnknownHostException(); } }
@Override public int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { // Greater than 0 is a timeout in milliseconds and -1 means "block forever", // but 0 means "poll and return immediately", which shouldn't be subject to BlockGuard. if (timeoutMs != 0) { BlockGuard.getThreadPolicy().onNetwork(); } return os.poll(fds, timeoutMs); }