summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2021-05-12 17:01:13 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-05-12 17:01:13 +0000
commit32c2d343834fc3120f09a712eb906497cd80ae44 (patch)
tree1f426f821479ed1f5c4ab0f43c710ceb76801a47 /core/java
parent6cc8dc45c78eb4e7cafdb8aa7c6a2c2608d76c2f (diff)
parent5804521e8cc3c6ad3b5d801342fbe4297206b11f (diff)
Merge changes Icb59b15d,I6fc6a266,I5cc340e5,I94db52a8 am: b79dcb24d0 am: 5804521e8c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1700309 Change-Id: I0c8987358edd0d77965507819e81faa21daaf767
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/vcn/VcnConfig.java43
-rw-r--r--core/java/android/net/vcn/VcnGatewayConnectionConfig.java8
2 files changed, 47 insertions, 4 deletions
diff --git a/core/java/android/net/vcn/VcnConfig.java b/core/java/android/net/vcn/VcnConfig.java
index d41c0b4fbdb3..caab15251f58 100644
--- a/core/java/android/net/vcn/VcnConfig.java
+++ b/core/java/android/net/vcn/VcnConfig.java
@@ -52,12 +52,17 @@ public final class VcnConfig implements Parcelable {
private static final String GATEWAY_CONNECTION_CONFIGS_KEY = "mGatewayConnectionConfigs";
@NonNull private final Set<VcnGatewayConnectionConfig> mGatewayConnectionConfigs;
+ private static final String IS_TEST_MODE_PROFILE_KEY = "mIsTestModeProfile";
+ private final boolean mIsTestModeProfile;
+
private VcnConfig(
@NonNull String packageName,
- @NonNull Set<VcnGatewayConnectionConfig> gatewayConnectionConfigs) {
+ @NonNull Set<VcnGatewayConnectionConfig> gatewayConnectionConfigs,
+ boolean isTestModeProfile) {
mPackageName = packageName;
mGatewayConnectionConfigs =
Collections.unmodifiableSet(new ArraySet<>(gatewayConnectionConfigs));
+ mIsTestModeProfile = isTestModeProfile;
validate();
}
@@ -77,6 +82,7 @@ public final class VcnConfig implements Parcelable {
new ArraySet<>(
PersistableBundleUtils.toList(
gatewayConnectionConfigsBundle, VcnGatewayConnectionConfig::new));
+ mIsTestModeProfile = in.getBoolean(IS_TEST_MODE_PROFILE_KEY);
validate();
}
@@ -104,6 +110,15 @@ public final class VcnConfig implements Parcelable {
}
/**
+ * Returns whether or not this VcnConfig is restricted to test networks.
+ *
+ * @hide
+ */
+ public boolean isTestModeProfile() {
+ return mIsTestModeProfile;
+ }
+
+ /**
* Serializes this object to a PersistableBundle.
*
* @hide
@@ -119,13 +134,14 @@ public final class VcnConfig implements Parcelable {
new ArrayList<>(mGatewayConnectionConfigs),
VcnGatewayConnectionConfig::toPersistableBundle);
result.putPersistableBundle(GATEWAY_CONNECTION_CONFIGS_KEY, gatewayConnectionConfigsBundle);
+ result.putBoolean(IS_TEST_MODE_PROFILE_KEY, mIsTestModeProfile);
return result;
}
@Override
public int hashCode() {
- return Objects.hash(mPackageName, mGatewayConnectionConfigs);
+ return Objects.hash(mPackageName, mGatewayConnectionConfigs, mIsTestModeProfile);
}
@Override
@@ -136,7 +152,8 @@ public final class VcnConfig implements Parcelable {
final VcnConfig rhs = (VcnConfig) other;
return mPackageName.equals(rhs.mPackageName)
- && mGatewayConnectionConfigs.equals(rhs.mGatewayConnectionConfigs);
+ && mGatewayConnectionConfigs.equals(rhs.mGatewayConnectionConfigs)
+ && mIsTestModeProfile == rhs.mIsTestModeProfile;
}
// Parcelable methods
@@ -172,6 +189,8 @@ public final class VcnConfig implements Parcelable {
@NonNull
private final Set<VcnGatewayConnectionConfig> mGatewayConnectionConfigs = new ArraySet<>();
+ private boolean mIsTestModeProfile = false;
+
public Builder(@NonNull Context context) {
Objects.requireNonNull(context, "context was null");
@@ -207,13 +226,29 @@ public final class VcnConfig implements Parcelable {
}
/**
+ * Restricts this VcnConfig to matching with test networks (only).
+ *
+ * <p>This method is for testing only, and must not be used by apps. Calling {@link
+ * VcnManager#setVcnConfig(ParcelUuid, VcnConfig)} with a VcnConfig where test-network usage
+ * is enabled will require the MANAGE_TEST_NETWORKS permission.
+ *
+ * @return this {@link Builder} instance, for chaining
+ * @hide
+ */
+ @NonNull
+ public Builder setIsTestModeProfile() {
+ mIsTestModeProfile = true;
+ return this;
+ }
+
+ /**
* Builds and validates the VcnConfig.
*
* @return an immutable VcnConfig instance
*/
@NonNull
public VcnConfig build() {
- return new VcnConfig(mPackageName, mGatewayConnectionConfigs);
+ return new VcnConfig(mPackageName, mGatewayConnectionConfigs, mIsTestModeProfile);
}
}
}
diff --git a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
index be308d01d98a..2df3e6c7ecd6 100644
--- a/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
+++ b/core/java/android/net/vcn/VcnGatewayConnectionConfig.java
@@ -15,6 +15,8 @@
*/
package android.net.vcn;
+import static android.net.ipsec.ike.IkeSessionParams.IKE_OPTION_MOBIKE;
+
import static com.android.internal.annotations.VisibleForTesting.Visibility;
import android.annotation.IntDef;
@@ -433,6 +435,8 @@ public final class VcnGatewayConnectionConfig {
* distinguish between VcnGatewayConnectionConfigs configured on a single {@link
* VcnConfig}. This will be used as the identifier in VcnStatusCallback invocations.
* @param tunnelConnectionParams the IKE tunnel connection configuration
+ * @throws IllegalArgumentException if the provided IkeTunnelConnectionParams is not
+ * configured to support MOBIKE
* @see IkeTunnelConnectionParams
* @see VcnManager.VcnStatusCallback#onGatewayConnectionError
*/
@@ -441,6 +445,10 @@ public final class VcnGatewayConnectionConfig {
@NonNull IkeTunnelConnectionParams tunnelConnectionParams) {
Objects.requireNonNull(gatewayConnectionName, "gatewayConnectionName was null");
Objects.requireNonNull(tunnelConnectionParams, "tunnelConnectionParams was null");
+ if (!tunnelConnectionParams.getIkeSessionParams().hasIkeOption(IKE_OPTION_MOBIKE)) {
+ throw new IllegalArgumentException(
+ "MOBIKE must be configured for the provided IkeSessionParams");
+ }
mGatewayConnectionName = gatewayConnectionName;
mTunnelConnectionParams = tunnelConnectionParams;