Merge changes I4994dd8d,I98c1aab4
* changes: Annotate ClatCoordinator with RequiresApi(T), part 2 Annotate ClatCoordinator with RequiresApi(T)
This commit is contained in:
commit
472d51344c
3 changed files with 12 additions and 18 deletions
|
|
@ -1432,6 +1432,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||
/**
|
||||
* @see ClatCoordinator
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||
public ClatCoordinator getClatCoordinator(INetd netd) {
|
||||
return new ClatCoordinator(
|
||||
new ClatCoordinator.Dependencies() {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import android.net.INetd;
|
|||
import android.net.InetAddresses;
|
||||
import android.net.InterfaceConfigurationParcel;
|
||||
import android.net.IpPrefix;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceSpecificException;
|
||||
|
|
@ -58,11 +59,14 @@ import java.net.InetAddress;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
/**
|
||||
* This coordinator is responsible for providing clat relevant functionality.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||
public class ClatCoordinator {
|
||||
private static final String TAG = ClatCoordinator.class.getSimpleName();
|
||||
|
||||
|
|
@ -251,11 +255,6 @@ public class ClatCoordinator {
|
|||
/** Get ingress6 BPF map. */
|
||||
@Nullable
|
||||
public IBpfMap<ClatIngress6Key, ClatIngress6Value> getBpfIngress6Map() {
|
||||
// Pre-T devices don't use ClatCoordinator to access clat map. Since Nat464Xlat
|
||||
// initializes a ClatCoordinator object to avoid redundant null pointer check
|
||||
// while using, ignore the BPF map initialization on pre-T devices.
|
||||
// TODO: probably don't initialize ClatCoordinator object on pre-T devices.
|
||||
if (!SdkLevel.isAtLeastT()) return null;
|
||||
try {
|
||||
return new BpfMap<>(CLAT_INGRESS6_MAP_PATH,
|
||||
BpfMap.BPF_F_RDWR, ClatIngress6Key.class, ClatIngress6Value.class);
|
||||
|
|
@ -268,11 +267,6 @@ public class ClatCoordinator {
|
|||
/** Get egress4 BPF map. */
|
||||
@Nullable
|
||||
public IBpfMap<ClatEgress4Key, ClatEgress4Value> getBpfEgress4Map() {
|
||||
// Pre-T devices don't use ClatCoordinator to access clat map. Since Nat464Xlat
|
||||
// initializes a ClatCoordinator object to avoid redundant null pointer check
|
||||
// while using, ignore the BPF map initialization on pre-T devices.
|
||||
// TODO: probably don't initialize ClatCoordinator object on pre-T devices.
|
||||
if (!SdkLevel.isAtLeastT()) return null;
|
||||
try {
|
||||
return new BpfMap<>(CLAT_EGRESS4_MAP_PATH,
|
||||
BpfMap.BPF_F_RDWR, ClatEgress4Key.class, ClatEgress4Value.class);
|
||||
|
|
@ -285,11 +279,6 @@ public class ClatCoordinator {
|
|||
/** Get cookie tag map */
|
||||
@Nullable
|
||||
public IBpfMap<CookieTagMapKey, CookieTagMapValue> getBpfCookieTagMap() {
|
||||
// Pre-T devices don't use ClatCoordinator to access clat map. Since Nat464Xlat
|
||||
// initializes a ClatCoordinator object to avoid redundant null pointer check
|
||||
// while using, ignore the BPF map initialization on pre-T devices.
|
||||
// TODO: probably don't initialize ClatCoordinator object on pre-T devices.
|
||||
if (!SdkLevel.isAtLeastT()) return null;
|
||||
try {
|
||||
return new BpfMap<>(COOKIE_TAG_MAP_PATH,
|
||||
BpfMap.BPF_F_RDWR, CookieTagMapKey.class, CookieTagMapValue.class);
|
||||
|
|
|
|||
|
|
@ -101,9 +101,9 @@ public class Nat464Xlat {
|
|||
private String mIface;
|
||||
private Inet6Address mIPv6Address;
|
||||
private State mState = State.IDLE;
|
||||
private ClatCoordinator mClatCoordinator;
|
||||
private final ClatCoordinator mClatCoordinator; // non-null iff T+
|
||||
|
||||
private boolean mEnableClatOnCellular;
|
||||
private final boolean mEnableClatOnCellular;
|
||||
private boolean mPrefixDiscoveryRunning;
|
||||
|
||||
public Nat464Xlat(NetworkAgentInfo nai, INetd netd, IDnsResolver dnsResolver,
|
||||
|
|
@ -112,7 +112,11 @@ public class Nat464Xlat {
|
|||
mNetd = netd;
|
||||
mNetwork = nai;
|
||||
mEnableClatOnCellular = deps.getCellular464XlatEnabled();
|
||||
mClatCoordinator = deps.getClatCoordinator(mNetd);
|
||||
if (SdkLevel.isAtLeastT()) {
|
||||
mClatCoordinator = deps.getClatCoordinator(mNetd);
|
||||
} else {
|
||||
mClatCoordinator = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue