summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorBenedict Wong <benedictwong@google.com>2020-11-17 06:10:47 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-11-17 06:10:47 +0000
commitd5e3147ca11b6eee4c3de9706447f3dfd82db5aa (patch)
tree9fa4e5f52aa29dd1c51f7e9d5752dff57c4a70c3 /core/java
parent99dab3c8eb36a9d2303a81c3d9dd6a4d92a5c7d7 (diff)
parent292f2b8dbf37cb5eb1db9a8bd687a9adf6cc6a24 (diff)
Merge "Add stubs for VCN configuration management" am: 03492715e8 am: 43dbf5cb2c am: a0740b9727 am: 292f2b8dbf
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1477377 Change-Id: Id2d4d4fdc716cb6a9e72ec5ad072d72063fdad59
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/vcn/IVcnManagementService.aidl5
-rw-r--r--core/java/android/net/vcn/VcnConfig.aidl20
-rw-r--r--core/java/android/net/vcn/VcnConfig.java83
-rw-r--r--core/java/android/net/vcn/VcnManager.java57
4 files changed, 164 insertions, 1 deletions
diff --git a/core/java/android/net/vcn/IVcnManagementService.aidl b/core/java/android/net/vcn/IVcnManagementService.aidl
index af06906ca2e9..9dd01140b413 100644
--- a/core/java/android/net/vcn/IVcnManagementService.aidl
+++ b/core/java/android/net/vcn/IVcnManagementService.aidl
@@ -16,8 +16,13 @@
package android.net.vcn;
+import android.net.vcn.VcnConfig;
+import android.os.ParcelUuid;
+
/**
* @hide
*/
interface IVcnManagementService {
+ void setVcnConfig(in ParcelUuid subscriptionGroup, in VcnConfig config);
+ void clearVcnConfig(in ParcelUuid subscriptionGroup);
}
diff --git a/core/java/android/net/vcn/VcnConfig.aidl b/core/java/android/net/vcn/VcnConfig.aidl
new file mode 100644
index 000000000000..67006a42a701
--- /dev/null
+++ b/core/java/android/net/vcn/VcnConfig.aidl
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.vcn;
+
+/** @hide */
+parcelable VcnConfig;
diff --git a/core/java/android/net/vcn/VcnConfig.java b/core/java/android/net/vcn/VcnConfig.java
new file mode 100644
index 000000000000..148acf130857
--- /dev/null
+++ b/core/java/android/net/vcn/VcnConfig.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.net.vcn;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * This class represents a configuration for a Virtual Carrier Network.
+ *
+ * @hide
+ */
+public final class VcnConfig implements Parcelable {
+ @NonNull private static final String TAG = VcnConfig.class.getSimpleName();
+
+ private VcnConfig() {
+ validate();
+ }
+ // TODO: Implement getters, validators, etc
+
+ /**
+ * Validates this configuration.
+ *
+ * @hide
+ */
+ private void validate() {
+ // TODO: implement validation logic
+ }
+
+ // Parcelable methods
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int flags) {}
+
+ @NonNull
+ public static final Parcelable.Creator<VcnConfig> CREATOR =
+ new Parcelable.Creator<VcnConfig>() {
+ @NonNull
+ public VcnConfig createFromParcel(Parcel in) {
+ // TODO: Ensure all methods are pulled from the parcels
+ return new VcnConfig();
+ }
+
+ @NonNull
+ public VcnConfig[] newArray(int size) {
+ return new VcnConfig[size];
+ }
+ };
+
+ /** This class is used to incrementally build {@link VcnConfig} objects. */
+ public static class Builder {
+ // TODO: Implement this builder
+
+ /**
+ * Builds and validates the VcnConfig.
+ *
+ * @return an immutable VcnConfig instance
+ */
+ @NonNull
+ public VcnConfig build() {
+ return new VcnConfig();
+ }
+ }
+}
diff --git a/core/java/android/net/vcn/VcnManager.java b/core/java/android/net/vcn/VcnManager.java
index d563b0350187..6769b9e46e4c 100644
--- a/core/java/android/net/vcn/VcnManager.java
+++ b/core/java/android/net/vcn/VcnManager.java
@@ -18,11 +18,14 @@ package android.net.vcn;
import static java.util.Objects.requireNonNull;
import android.annotation.NonNull;
+import android.annotation.RequiresPermission;
import android.annotation.SystemService;
import android.content.Context;
+import android.os.ParcelUuid;
+import android.os.RemoteException;
/**
- * VcnManager publishes APIs for applications to configure and manage Virtual Carrier Networks
+ * VcnManager publishes APIs for applications to configure and manage Virtual Carrier Networks.
*
* @hide
*/
@@ -45,4 +48,56 @@ public final class VcnManager {
mContext = requireNonNull(ctx, "missing context");
mService = requireNonNull(service, "missing service");
}
+
+ // TODO: Make setVcnConfig(), clearVcnConfig() Public API
+ /**
+ * Sets the VCN configuration for a given subscription group.
+ *
+ * <p>An app that has carrier privileges for any of the subscriptions in the given group may set
+ * a VCN configuration. If a configuration already exists for the given subscription group, it
+ * will be overridden. Any active VCN(s) may be forced to restart to use the new configuration.
+ *
+ * <p>This API is ONLY permitted for callers running as the primary user.
+ *
+ * @param subscriptionGroup the subscription group that the configuration should be applied to
+ * @param config the configuration parameters for the VCN
+ * @throws SecurityException if the caller does not have carrier privileges, or is not running
+ * as the primary user
+ * @hide
+ */
+ @RequiresPermission("carrier privileges") // TODO (b/72967236): Define a system-wide constant
+ public void setVcnConfig(@NonNull ParcelUuid subscriptionGroup, @NonNull VcnConfig config) {
+ requireNonNull(subscriptionGroup, "subscriptionGroup was null");
+ requireNonNull(config, "config was null");
+
+ try {
+ mService.setVcnConfig(subscriptionGroup, config);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ // TODO: Make setVcnConfig(), clearVcnConfig() Public API
+ /**
+ * Clears the VCN configuration for a given subscription group.
+ *
+ * <p>An app that has carrier privileges for any of the subscriptions in the given group may
+ * clear a VCN configuration. This API is ONLY permitted for callers running as the primary
+ * user. Any active VCN will be torn down.
+ *
+ * @param subscriptionGroup the subscription group that the configuration should be applied to
+ * @throws SecurityException if the caller does not have carrier privileges, or is not running
+ * as the primary user
+ * @hide
+ */
+ @RequiresPermission("carrier privileges") // TODO (b/72967236): Define a system-wide constant
+ public void clearVcnConfig(@NonNull ParcelUuid subscriptionGroup) {
+ requireNonNull(subscriptionGroup, "subscriptionGroup was null");
+
+ try {
+ mService.clearVcnConfig(subscriptionGroup);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
}