Merge "Migrate frameworks/base/cmds/statsd to packages/modules/StatsD/bin"
diff --git a/core/java/android/net/Ikev2VpnProfile.java b/core/java/android/net/Ikev2VpnProfile.java
index c8ca618e..63fc5f2 100644
--- a/core/java/android/net/Ikev2VpnProfile.java
+++ b/core/java/android/net/Ikev2VpnProfile.java
@@ -16,12 +16,9 @@
package android.net;
-import static android.net.PlatformVpnProfile.TYPE_IKEV2_IPSEC_PSK;
-import static android.net.PlatformVpnProfile.TYPE_IKEV2_IPSEC_RSA;
-import static android.net.PlatformVpnProfile.TYPE_IKEV2_IPSEC_USER_PASS;
-
import static com.android.internal.annotations.VisibleForTesting.Visibility;
import static com.android.internal.util.Preconditions.checkStringNotEmpty;
+import static com.android.net.module.util.NetworkStackConstants.IPV6_MIN_MTU;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -158,9 +155,8 @@
// IPv6 MTU is greater; since profiles may be started by the system on IPv4 and IPv6
// networks, the VPN must provide a link fulfilling the stricter of the two conditions
// (at least that of the IPv6 MTU).
- if (mMaxMtu < LinkProperties.MIN_MTU_V6) {
- throw new IllegalArgumentException(
- "Max MTU must be at least" + LinkProperties.MIN_MTU_V6);
+ if (mMaxMtu < IPV6_MIN_MTU) {
+ throw new IllegalArgumentException("Max MTU must be at least" + IPV6_MIN_MTU);
}
switch (mType) {
@@ -811,9 +807,8 @@
// IPv6 MTU is greater; since profiles may be started by the system on IPv4 and IPv6
// networks, the VPN must provide a link fulfilling the stricter of the two conditions
// (at least that of the IPv6 MTU).
- if (mtu < LinkProperties.MIN_MTU_V6) {
- throw new IllegalArgumentException(
- "Max MTU must be at least " + LinkProperties.MIN_MTU_V6);
+ if (mtu < IPV6_MIN_MTU) {
+ throw new IllegalArgumentException("Max MTU must be at least " + IPV6_MIN_MTU);
}
mMaxMtu = mtu;
return this;
diff --git a/core/java/android/net/IpSecTransform.java b/core/java/android/net/IpSecTransform.java
index 44a0a4f..aa7811a 100644
--- a/core/java/android/net/IpSecTransform.java
+++ b/core/java/android/net/IpSecTransform.java
@@ -17,8 +17,6 @@
import static android.net.IpSecManager.INVALID_RESOURCE_ID;
-import static com.android.internal.util.Preconditions.checkNotNull;
-
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.RequiresFeature;
@@ -27,7 +25,6 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Binder;
-import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -181,7 +178,6 @@
try {
IIpSecService svc = getIpSecService();
svc.deleteTransform(mResourceId);
- stopNattKeepalive();
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
} catch (Exception e) {
@@ -212,36 +208,6 @@
private int mResourceId;
private final Context mContext;
private final CloseGuard mCloseGuard = CloseGuard.get();
- private ConnectivityManager.PacketKeepalive mKeepalive;
- private Handler mCallbackHandler;
- private final ConnectivityManager.PacketKeepaliveCallback mKeepaliveCallback =
- new ConnectivityManager.PacketKeepaliveCallback() {
-
- @Override
- public void onStarted() {
- synchronized (this) {
- mCallbackHandler.post(() -> mUserKeepaliveCallback.onStarted());
- }
- }
-
- @Override
- public void onStopped() {
- synchronized (this) {
- mKeepalive = null;
- mCallbackHandler.post(() -> mUserKeepaliveCallback.onStopped());
- }
- }
-
- @Override
- public void onError(int error) {
- synchronized (this) {
- mKeepalive = null;
- mCallbackHandler.post(() -> mUserKeepaliveCallback.onError(error));
- }
- }
- };
-
- private NattKeepaliveCallback mUserKeepaliveCallback;
/** @hide */
@VisibleForTesting
@@ -273,76 +239,6 @@
public void onError(int error) {}
}
- /**
- * Start a NAT-T keepalive session for the current transform.
- *
- * For a transform that is using UDP encapsulated IPv4, NAT-T offloading provides
- * a power efficient mechanism of sending NAT-T packets at a specified interval.
- *
- * @param userCallback a {@link #NattKeepaliveCallback} to receive asynchronous status
- * information about the requested NAT-T keepalive session.
- * @param intervalSeconds the interval between NAT-T keepalives being sent. The
- * the allowed range is between 20 and 3600 seconds.
- * @param handler a handler on which to post callbacks when received.
- *
- * @hide
- */
- @RequiresPermission(anyOf = {
- android.Manifest.permission.MANAGE_IPSEC_TUNNELS,
- android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD
- })
- public void startNattKeepalive(@NonNull NattKeepaliveCallback userCallback,
- int intervalSeconds, @NonNull Handler handler) throws IOException {
- checkNotNull(userCallback);
- if (intervalSeconds < 20 || intervalSeconds > 3600) {
- throw new IllegalArgumentException("Invalid NAT-T keepalive interval");
- }
- checkNotNull(handler);
- if (mResourceId == INVALID_RESOURCE_ID) {
- throw new IllegalStateException(
- "Packet keepalive cannot be started for an inactive transform");
- }
-
- synchronized (mKeepaliveCallback) {
- if (mKeepaliveCallback != null) {
- throw new IllegalStateException("Keepalive already active");
- }
-
- mUserKeepaliveCallback = userCallback;
- ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(
- Context.CONNECTIVITY_SERVICE);
- mKeepalive = cm.startNattKeepalive(
- mConfig.getNetwork(), intervalSeconds, mKeepaliveCallback,
- NetworkUtils.numericToInetAddress(mConfig.getSourceAddress()),
- 4500, // FIXME urgently, we need to get the port number from the Encap socket
- NetworkUtils.numericToInetAddress(mConfig.getDestinationAddress()));
- mCallbackHandler = handler;
- }
- }
-
- /**
- * Stop an ongoing NAT-T keepalive session.
- *
- * Calling this API will request that an ongoing NAT-T keepalive session be terminated.
- * If this API is not called when a Transform is closed, the underlying NAT-T session will
- * be terminated automatically.
- *
- * @hide
- */
- @RequiresPermission(anyOf = {
- android.Manifest.permission.MANAGE_IPSEC_TUNNELS,
- android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD
- })
- public void stopNattKeepalive() {
- synchronized (mKeepaliveCallback) {
- if (mKeepalive == null) {
- Log.e(TAG, "No active keepalive to stop");
- return;
- }
- mKeepalive.stop();
- }
- }
-
/** This class is used to build {@link IpSecTransform} objects. */
public static class Builder {
private Context mContext;
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index 06046f7..0941e7d 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -81,8 +81,7 @@
private static final int MIN_MTU = 68;
- /** @hide */
- public static final int MIN_MTU_V6 = 1280;
+ private static final int MIN_MTU_V6 = 1280;
private static final int MAX_MTU = 10000;
diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java
index efbfbf9..a0dc72d 100644
--- a/core/java/android/net/NetworkIdentity.java
+++ b/core/java/android/net/NetworkIdentity.java
@@ -17,7 +17,6 @@
package android.net;
import static android.net.ConnectivityManager.TYPE_WIFI;
-import static android.net.ConnectivityManager.isNetworkTypeMobile;
import android.content.Context;
import android.net.wifi.WifiInfo;
@@ -25,7 +24,6 @@
import android.os.Build;
import android.service.NetworkIdentityProto;
import android.telephony.Annotation.NetworkType;
-import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import java.util.Objects;
@@ -193,18 +191,9 @@
boolean metered = !state.networkCapabilities.hasCapability(
NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
- if (isNetworkTypeMobile(type)) {
- if (state.subscriberId == null) {
- if (state.networkInfo.getState() != NetworkInfo.State.DISCONNECTED &&
- state.networkInfo.getState() != NetworkInfo.State.UNKNOWN) {
- Slog.w(TAG, "Active mobile network without subscriber! ni = "
- + state.networkInfo);
- }
- }
+ subscriberId = state.subscriberId;
- subscriberId = state.subscriberId;
-
- } else if (type == TYPE_WIFI) {
+ if (type == TYPE_WIFI) {
if (state.networkId != null) {
networkId = state.networkId;
} else {