Address API review feedback
Address API review feedback to:
- Rename NetworkAgent#setTeardownDelayMs to
NetworkAgent#setTeardownDelayMillis
- Use getters instead of fields in VpnTransportInfo
- Rename registerDefaultNetworkCallbackAsUid to
registerDefaultNetworkCallbackForUid in ConnectiivityManager
Bug: 183972850
Bug: 185246410
Fix: 184735863
Test: make update-api
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
Merged-In: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
diff --git a/framework/api/module-lib-current.txt b/framework/api/module-lib-current.txt
index 9e2cd3e..8b10fcc 100644
--- a/framework/api/module-lib-current.txt
+++ b/framework/api/module-lib-current.txt
@@ -11,7 +11,7 @@
method @Nullable public android.net.ProxyInfo getGlobalProxy();
method @NonNull public static android.util.Range<java.lang.Integer> getIpSecNetIdRange();
method @NonNull public static String getPrivateDnsMode(@NonNull android.content.Context);
- method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_SETTINGS}) public void registerDefaultNetworkCallbackAsUid(int, @NonNull android.net.ConnectivityManager.NetworkCallback, @NonNull android.os.Handler);
+ method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_SETTINGS}) public void registerDefaultNetworkCallbackForUid(int, @NonNull android.net.ConnectivityManager.NetworkCallback, @NonNull android.os.Handler);
method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_SETTINGS}) public void registerSystemDefaultNetworkCallback(@NonNull android.net.ConnectivityManager.NetworkCallback, @NonNull android.os.Handler);
method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public void requestBackgroundNetwork(@NonNull android.net.NetworkRequest, @NonNull android.net.ConnectivityManager.NetworkCallback, @NonNull android.os.Handler);
method @Deprecated public boolean requestRouteToHostAddress(int, java.net.InetAddress);
@@ -166,11 +166,11 @@
public final class VpnTransportInfo implements android.os.Parcelable android.net.TransportInfo {
ctor public VpnTransportInfo(int, @Nullable String);
method public int describeContents();
+ method @Nullable public String getSessionId();
+ method public int getType();
method @NonNull public android.net.VpnTransportInfo makeCopy(long);
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.net.VpnTransportInfo> CREATOR;
- field @Nullable public final String sessionId;
- field public final int type;
}
}
diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt
index de673ee..fc65fec 100644
--- a/framework/api/system-current.txt
+++ b/framework/api/system-current.txt
@@ -238,7 +238,7 @@
method public final void sendQosSessionLost(int, int, int);
method public final void sendSocketKeepaliveEvent(int, int);
method @Deprecated public void setLegacySubtype(int, @NonNull String);
- method public void setTeardownDelayMs(@IntRange(from=0, to=0x1388) int);
+ method public void setTeardownDelayMillis(@IntRange(from=0, to=0x1388) int);
method public final void setUnderlyingNetworks(@Nullable java.util.List<android.net.Network>);
method public void unregister();
field public static final int VALIDATION_STATUS_NOT_VALID = 2; // 0x2
diff --git a/framework/src/android/net/ConnectivityManager.java b/framework/src/android/net/ConnectivityManager.java
index 043ff38..c042395 100644
--- a/framework/src/android/net/ConnectivityManager.java
+++ b/framework/src/android/net/ConnectivityManager.java
@@ -4407,7 +4407,7 @@
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
public void registerDefaultNetworkCallback(@NonNull NetworkCallback networkCallback,
@NonNull Handler handler) {
- registerDefaultNetworkCallbackAsUid(Process.INVALID_UID, networkCallback, handler);
+ registerDefaultNetworkCallbackForUid(Process.INVALID_UID, networkCallback, handler);
}
/**
@@ -4437,7 +4437,7 @@
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_SETTINGS})
- public void registerDefaultNetworkCallbackAsUid(int uid,
+ public void registerDefaultNetworkCallbackForUid(int uid,
@NonNull NetworkCallback networkCallback, @NonNull Handler handler) {
CallbackHandler cbHandler = new CallbackHandler(handler);
sendRequestForNetwork(uid, null /* need */, networkCallback, 0 /* timeoutMs */,
diff --git a/framework/src/android/net/NetworkAgent.java b/framework/src/android/net/NetworkAgent.java
index c57da53..f65acdd 100644
--- a/framework/src/android/net/NetworkAgent.java
+++ b/framework/src/android/net/NetworkAgent.java
@@ -879,11 +879,11 @@
* This method may be called at any time while the network is connected. It has no effect if
* the network is already disconnected and the teardown delay timer is running.
*
- * @param teardownDelayMs the teardown delay to set, or 0 to disable teardown delay.
+ * @param teardownDelayMillis the teardown delay to set, or 0 to disable teardown delay.
*/
- public void setTeardownDelayMs(
- @IntRange(from = 0, to = MAX_TEARDOWN_DELAY_MS) int teardownDelayMs) {
- queueOrSendMessage(reg -> reg.sendTeardownDelayMs(teardownDelayMs));
+ public void setTeardownDelayMillis(
+ @IntRange(from = 0, to = MAX_TEARDOWN_DELAY_MS) int teardownDelayMillis) {
+ queueOrSendMessage(reg -> reg.sendTeardownDelayMs(teardownDelayMillis));
}
/**
diff --git a/framework/src/android/net/VpnTransportInfo.java b/framework/src/android/net/VpnTransportInfo.java
index efd3363..4071c9a 100644
--- a/framework/src/android/net/VpnTransportInfo.java
+++ b/framework/src/android/net/VpnTransportInfo.java
@@ -40,10 +40,10 @@
@SystemApi(client = MODULE_LIBRARIES)
public final class VpnTransportInfo implements TransportInfo, Parcelable {
/** Type of this VPN. */
- public final int type;
+ private final int mType;
@Nullable
- public final String sessionId;
+ private final String mSessionId;
@Override
public @RedactionType long getApplicableRedactions() {
@@ -55,13 +55,28 @@
*/
@NonNull
public VpnTransportInfo makeCopy(@RedactionType long redactions) {
- return new VpnTransportInfo(type,
- ((redactions & REDACT_FOR_NETWORK_SETTINGS) != 0) ? null : sessionId);
+ return new VpnTransportInfo(mType,
+ ((redactions & REDACT_FOR_NETWORK_SETTINGS) != 0) ? null : mSessionId);
}
public VpnTransportInfo(int type, @Nullable String sessionId) {
- this.type = type;
- this.sessionId = sessionId;
+ this.mType = type;
+ this.mSessionId = sessionId;
+ }
+
+ /**
+ * Returns the session Id of this VpnTransportInfo.
+ */
+ @Nullable
+ public String getSessionId() {
+ return mSessionId;
+ }
+
+ /**
+ * Returns the type of this VPN.
+ */
+ public int getType() {
+ return mType;
}
@Override
@@ -69,17 +84,17 @@
if (!(o instanceof VpnTransportInfo)) return false;
VpnTransportInfo that = (VpnTransportInfo) o;
- return (this.type == that.type) && TextUtils.equals(this.sessionId, that.sessionId);
+ return (this.mType == that.mType) && TextUtils.equals(this.mSessionId, that.mSessionId);
}
@Override
public int hashCode() {
- return Objects.hash(type, sessionId);
+ return Objects.hash(mType, mSessionId);
}
@Override
public String toString() {
- return String.format("VpnTransportInfo{type=%d, sessionId=%s}", type, sessionId);
+ return String.format("VpnTransportInfo{type=%d, sessionId=%s}", mType, mSessionId);
}
@Override
@@ -89,8 +104,8 @@
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeInt(type);
- dest.writeString(sessionId);
+ dest.writeInt(mType);
+ dest.writeString(mSessionId);
}
public static final @NonNull Creator<VpnTransportInfo> CREATOR =