From 909dfd1352602e839506b8eabd74d69eae101d8c Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Fri, 5 Apr 2019 05:39:23 -0700 Subject: [PATCH] Remove SocketUtils#setSocketTimeValueOption 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 --- api/system-current.txt | 1 - api/test-current.txt | 1 - core/java/android/net/util/SocketUtils.java | 9 --------- services/net/java/android/net/netlink/NetlinkSocket.java | 5 +++-- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 64589093654eb..0bfc939c4356d 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4463,7 +4463,6 @@ package android.net.util { 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; } } diff --git a/api/test-current.txt b/api/test-current.txt index 99cdfb012155c..c03eb7503269b 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -1551,7 +1551,6 @@ package android.net.util { 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; } } diff --git a/core/java/android/net/util/SocketUtils.java b/core/java/android/net/util/SocketUtils.java index 6f8aece848f88..2b9ec540dccd4 100644 --- a/core/java/android/net/util/SocketUtils.java +++ b/core/java/android/net/util/SocketUtils.java @@ -29,7 +29,6 @@ import android.system.ErrnoException; import android.system.NetlinkSocketAddress; import android.system.Os; import android.system.PacketSocketAddress; -import android.system.StructTimeval; import libcore.io.IoBridge; @@ -84,14 +83,6 @@ public final class SocketUtils { return new PacketSocketAddress(ifIndex, hwAddr); } - /** - * 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) */ diff --git a/services/net/java/android/net/netlink/NetlinkSocket.java b/services/net/java/android/net/netlink/NetlinkSocket.java index 4240d240ca236..7311fc5372059 100644 --- a/services/net/java/android/net/netlink/NetlinkSocket.java +++ b/services/net/java/android/net/netlink/NetlinkSocket.java @@ -30,6 +30,7 @@ import static android.system.OsConstants.SO_SNDTIMEO; 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; @@ -128,7 +129,7 @@ public class NetlinkSocket { 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); @@ -151,7 +152,7 @@ public class NetlinkSocket { 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); } }