Expose API for identifying GatewayConnections.
This CL exposes the updated APIs for identifying GatewayConnections via
a user-configured String set in VcnGatewayConnectionConfig.Builder, as
requested by the API Council.
Bug: 182345902
Bug: 180522464
Test: atest FrameworksVcnTests
Change-Id: I10afd074906bc0f3831157dcee1da813b4cfce78
diff --git a/core/api/current.txt b/core/api/current.txt
index 4ba49a3..00ff3d0 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -25702,12 +25702,13 @@
public final class VcnGatewayConnectionConfig {
method @NonNull public int[] getExposedCapabilities();
+ method @NonNull public String getGatewayConnectionName();
method @IntRange(from=android.net.vcn.VcnGatewayConnectionConfig.MIN_MTU_V6) public int getMaxMtu();
method @NonNull public long[] getRetryInterval();
}
public static final class VcnGatewayConnectionConfig.Builder {
- ctor public VcnGatewayConnectionConfig.Builder(@NonNull android.net.vcn.VcnControlPlaneConfig);
+ ctor public VcnGatewayConnectionConfig.Builder(@NonNull String, @NonNull android.net.vcn.VcnControlPlaneConfig);
method @NonNull public android.net.vcn.VcnGatewayConnectionConfig.Builder addExposedCapability(int);
method @NonNull public android.net.vcn.VcnGatewayConnectionConfig build();
method @NonNull public android.net.vcn.VcnGatewayConnectionConfig.Builder removeExposedCapability(int);
@@ -25731,7 +25732,7 @@
public abstract static class VcnManager.VcnStatusCallback {
ctor public VcnManager.VcnStatusCallback();
- method public abstract void onGatewayConnectionError(@NonNull int[], int, @Nullable Throwable);
+ method public abstract void onGatewayConnectionError(@NonNull String, int, @Nullable Throwable);
method public abstract void onStatusChanged(int);
}
diff --git a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
index ae52cc4..75db382 100644
--- a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
+++ b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
@@ -255,7 +255,6 @@
* the identifier in VcnStatusCallback invocations.
*
* @see VcnManager.VcnStatusCallback#onGatewayConnectionError
- * @hide
*/
@NonNull
public String getGatewayConnectionName() {
@@ -437,16 +436,6 @@
/**
* Construct a Builder object.
*
- * @param ctrlPlaneConfig the control plane configuration
- * @see VcnControlPlaneConfig
- */
- public Builder(@NonNull VcnControlPlaneConfig ctrlPlaneConfig) {
- this("" /* gatewayConnectionName */, ctrlPlaneConfig);
- }
-
- /**
- * Construct a Builder object.
- *
* @param gatewayConnectionName the String GatewayConnection name for this
* VcnGatewayConnectionConfig. Each VcnGatewayConnectionConfig within a {@link
* VcnConfig} must be given a unique name. This name is used by the caller to
@@ -455,7 +444,6 @@
* @param ctrlPlaneConfig the control plane configuration
* @see VcnControlPlaneConfig
* @see VcnManager.VcnStatusCallback#onGatewayConnectionError
- * @hide
*/
public Builder(
@NonNull String gatewayConnectionName,
diff --git a/core/java/android/net/vcn/VcnManager.java b/core/java/android/net/vcn/VcnManager.java
index 36be16f5..d09094c 100644
--- a/core/java/android/net/vcn/VcnManager.java
+++ b/core/java/android/net/vcn/VcnManager.java
@@ -445,18 +445,16 @@
* Invoked when a VCN Gateway Connection corresponding to this callback's subscription group
* encounters an error.
*
- * @param networkCapabilities an array of NetworkCapabilities.NET_CAPABILITY_* capabilities
- * for the Gateway Connection that encountered the error, for identification purposes.
- * These will be a sorted list with no duplicates and will match {@link
- * VcnGatewayConnectionConfig#getExposedCapabilities()} for one of the {@link
- * VcnGatewayConnectionConfig}s set in the {@link VcnConfig} for this subscription
- * group.
+ * @param gatewayConnectionName the String GatewayConnection name for the GatewayConnection
+ * encountering an error. This will match the name for exactly one {@link
+ * VcnGatewayConnectionConfig} for the {@link VcnConfig} configured for this callback's
+ * subscription group
* @param errorCode the code to indicate the error that occurred
* @param detail Throwable to provide additional information about the error, or {@code
* null} if none
*/
public abstract void onGatewayConnectionError(
- @NonNull int[] networkCapabilities,
+ @NonNull String gatewayConnectionName,
@VcnErrorCode int errorCode,
@Nullable Throwable detail);
}
@@ -597,7 +595,7 @@
mExecutor.execute(
() ->
mCallback.onGatewayConnectionError(
- new int[0], errorCode, cause)));
+ gatewayConnectionName, errorCode, cause)));
}
private static Throwable createThrowableByClassName(
diff --git a/tests/vcn/java/android/net/vcn/VcnManagerTest.java b/tests/vcn/java/android/net/vcn/VcnManagerTest.java
index 54cdeb8..8461de6 100644
--- a/tests/vcn/java/android/net/vcn/VcnManagerTest.java
+++ b/tests/vcn/java/android/net/vcn/VcnManagerTest.java
@@ -211,7 +211,7 @@
"exception_message");
verify(mMockStatusCallback)
.onGatewayConnectionError(
- any(int[].class),
+ eq(GATEWAY_CONNECTION_NAME),
eq(VcnManager.VCN_ERROR_CODE_NETWORK_ERROR),
any(UnknownHostException.class));
}