This API was added in Q but is not necessary anymore as
Os#setsockoptTimeval was exposed as public API.
Test: m
Fixes:
129433363
Merged-In: If4a75f23c6c0589c23cadce3b088966649062463
(cherry picked from commit
77f9d85f120df6313938f4105aeb005c1fe888c3)
Change-Id: I4669eb2f9fa073d765be6bcb5863a5887eaf1ab5
method @NonNull public static java.net.SocketAddress makeNetlinkSocketAddress(int, int);
method @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, int);
method @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, @NonNull byte[]);
- method public static void setSocketTimeValueOption(@NonNull java.io.FileDescriptor, int, int, long) throws android.system.ErrnoException;
}
}
method @NonNull public static java.net.SocketAddress makeNetlinkSocketAddress(int, int);
method @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, int);
method @NonNull public static java.net.SocketAddress makePacketSocketAddress(int, @NonNull byte[]);
- method public static void setSocketTimeValueOption(@NonNull java.io.FileDescriptor, int, int, long) throws android.system.ErrnoException;
}
}
import android.system.NetlinkSocketAddress;
import android.system.Os;
import android.system.PacketSocketAddress;
-import android.system.StructTimeval;
import libcore.io.IoBridge;
}
/**
- * Set an option on a socket that takes a time value argument.
- */
- public static void setSocketTimeValueOption(
- @NonNull FileDescriptor fd, int level, int option, long millis) throws ErrnoException {
- Os.setsockoptTimeval(fd, level, option, StructTimeval.fromMillis(millis));
- }
-
- /**
* @see IoBridge#closeAndSignalBlockedThreads(FileDescriptor)
*/
public static void closeSocket(@Nullable FileDescriptor fd) throws IOException {
import android.net.util.SocketUtils;
import android.system.ErrnoException;
import android.system.Os;
+import android.system.StructTimeval;
import android.util.Log;
import java.io.FileDescriptor;
throws ErrnoException, IllegalArgumentException, InterruptedIOException {
checkTimeout(timeoutMs);
- SocketUtils.setSocketTimeValueOption(fd, SOL_SOCKET, SO_RCVTIMEO, timeoutMs);
+ Os.setsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO, StructTimeval.fromMillis(timeoutMs));
ByteBuffer byteBuffer = ByteBuffer.allocate(bufsize);
int length = Os.read(fd, byteBuffer);
FileDescriptor fd, byte[] bytes, int offset, int count, long timeoutMs)
throws ErrnoException, IllegalArgumentException, InterruptedIOException {
checkTimeout(timeoutMs);
- SocketUtils.setSocketTimeValueOption(fd, SOL_SOCKET, SO_SNDTIMEO, timeoutMs);
+ Os.setsockoptTimeval(fd, SOL_SOCKET, SO_SNDTIMEO, StructTimeval.fromMillis(timeoutMs));
return Os.write(fd, bytes, offset, count);
}
}