diff options
| author | Benedict Wong <benedictwong@google.com> | 2020-08-04 11:51:17 -0700 |
|---|---|---|
| committer | Benedict Wong <benedictwong@google.com> | 2020-11-16 13:29:34 -0800 |
| commit | 4b140e2bd66ee532ee36b2597a2f7822f85c1a72 (patch) | |
| tree | 521d1b4cb80aa4ca70fd4fa53a3aaab325c61d28 /core/java/android | |
| parent | febaec9f3e70de992cc6cc72789aa95c0b80a66f (diff) | |
Add stubs for VCN configuration management
This change adds stubs for both the API and the internal binder
interfaces.
Bug: 163431877
Test: Compiles, boots
Change-Id: I11183d9fe3ad53944882b163eee5110e85898393
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/net/vcn/IVcnManagementService.aidl | 5 | ||||
| -rw-r--r-- | core/java/android/net/vcn/VcnConfig.aidl | 20 | ||||
| -rw-r--r-- | core/java/android/net/vcn/VcnConfig.java | 83 | ||||
| -rw-r--r-- | core/java/android/net/vcn/VcnManager.java | 57 |
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(); + } + } } |
