Fix some @hide usage in Tethering
Using alternative way to replace some @hide API.
Bug: 144814072
Test: build, flash, boot
atest TetheringTests
Change-Id: I1e12d69db1ad91dff553e142e17c6a70808e1639
This commit is contained in:
@@ -22,14 +22,13 @@ import static android.system.OsConstants.AF_INET6;
|
||||
import static android.system.OsConstants.IPPROTO_ICMPV6;
|
||||
import static android.system.OsConstants.SOCK_RAW;
|
||||
import static android.system.OsConstants.SOL_SOCKET;
|
||||
import static android.system.OsConstants.SO_BINDTODEVICE;
|
||||
import static android.system.OsConstants.SO_SNDTIMEO;
|
||||
|
||||
import android.net.IpPrefix;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.TrafficStats;
|
||||
import android.net.util.InterfaceParams;
|
||||
import android.net.util.SocketUtils;
|
||||
import android.net.util.TetheringUtils;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
@@ -39,8 +38,6 @@ import android.util.Log;
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
|
||||
import libcore.io.IoBridge;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
import java.net.Inet6Address;
|
||||
@@ -612,8 +609,7 @@ public class RouterAdvertisementDaemon {
|
||||
// Setting SNDTIMEO is purely for defensive purposes.
|
||||
Os.setsockoptTimeval(
|
||||
mSocket, SOL_SOCKET, SO_SNDTIMEO, StructTimeval.fromMillis(send_timout_ms));
|
||||
Os.setsockoptIfreq(mSocket, SOL_SOCKET, SO_BINDTODEVICE, mInterface.name);
|
||||
NetworkUtils.protectFromVpn(mSocket);
|
||||
SocketUtils.bindSocketToInterface(mSocket, mInterface.name);
|
||||
TetheringUtils.setupRaSocket(mSocket, mInterface.index);
|
||||
} catch (ErrnoException | IOException e) {
|
||||
Log.e(TAG, "Failed to create RA daemon socket: " + e);
|
||||
@@ -628,7 +624,7 @@ public class RouterAdvertisementDaemon {
|
||||
private void closeSocket() {
|
||||
if (mSocket != null) {
|
||||
try {
|
||||
IoBridge.closeAndSignalBlockedThreads(mSocket);
|
||||
SocketUtils.closeSocket(mSocket);
|
||||
} catch (IOException ignored) { }
|
||||
}
|
||||
mSocket = null;
|
||||
|
||||
Reference in New Issue
Block a user