Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 803668c0 authored by Cody Kesting's avatar Cody Kesting Committed by Automerger Merge Worker
Browse files

Merge changes from topic "gateway-connection-id" am: 03f00e5a am: 2fa4b7b7 am: 1230749c

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1659162

Change-Id: Ic60a32e6cefab3807102f1ee2d6565a15e053a15
parents ad064515 1230749c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -27093,12 +27093,13 @@ package android.net.vcn {
  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);
@@ -27122,7 +27123,7 @@ package android.net.vcn {
  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);
  }
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ package android.net.vcn;
oneway interface IVcnStatusCallback {
    void onVcnStatusChanged(int statusCode);
    void onGatewayConnectionError(
            in int[] gatewayNetworkCapabilities,
            in String gatewayConnectionName,
            int errorCode,
            in String exceptionClass,
            in String exceptionMessage);
+13 −0
Original line number Diff line number Diff line
@@ -183,12 +183,25 @@ public final class VcnConfig implements Parcelable {
         *
         * @param gatewayConnectionConfig the configuration for an individual gateway connection
         * @return this {@link Builder} instance, for chaining
         * @throws IllegalArgumentException if a VcnGatewayConnectionConfig has already been set for
         *     this {@link VcnConfig} with the same GatewayConnection name (as returned via {@link
         *     VcnGatewayConnectionConfig#getGatewayConnectionName()}).
         */
        @NonNull
        public Builder addGatewayConnectionConfig(
                @NonNull VcnGatewayConnectionConfig gatewayConnectionConfig) {
            Objects.requireNonNull(gatewayConnectionConfig, "gatewayConnectionConfig was null");

            for (final VcnGatewayConnectionConfig vcnGatewayConnectionConfig :
                    mGatewayConnectionConfigs) {
                if (vcnGatewayConnectionConfig
                        .getGatewayConnectionName()
                        .equals(gatewayConnectionConfig.getGatewayConnectionName())) {
                    throw new IllegalArgumentException(
                            "GatewayConnection for specified name already exists");
                }
            }

            mGatewayConnectionConfigs.add(gatewayConnectionConfig);
            return this;
        }
+37 −2
Original line number Diff line number Diff line
@@ -148,6 +148,8 @@ public final class VcnGatewayConnectionConfig {
                TimeUnit.MINUTES.toMillis(5),
                TimeUnit.MINUTES.toMillis(15)
            };
    private static final String GATEWAY_CONNECTION_NAME_KEY = "mGatewayConnectionName";
    @NonNull private final String mGatewayConnectionName;

    private static final String CTRL_PLANE_CONFIG_KEY = "mCtrlPlaneConfig";
    @NonNull private VcnControlPlaneConfig mCtrlPlaneConfig;
@@ -166,11 +168,13 @@ public final class VcnGatewayConnectionConfig {

    /** Builds a VcnGatewayConnectionConfig with the specified parameters. */
    private VcnGatewayConnectionConfig(
            @NonNull String gatewayConnectionName,
            @NonNull VcnControlPlaneConfig ctrlPlaneConfig,
            @NonNull Set<Integer> exposedCapabilities,
            @NonNull Set<Integer> underlyingCapabilities,
            @NonNull long[] retryIntervalsMs,
            @IntRange(from = MIN_MTU_V6) int maxMtu) {
        mGatewayConnectionName = gatewayConnectionName;
        mCtrlPlaneConfig = ctrlPlaneConfig;
        mExposedCapabilities = new TreeSet(exposedCapabilities);
        mUnderlyingCapabilities = new TreeSet(underlyingCapabilities);
@@ -192,6 +196,7 @@ public final class VcnGatewayConnectionConfig {
        final PersistableBundle underlyingCapsBundle =
                in.getPersistableBundle(UNDERLYING_CAPABILITIES_KEY);

        mGatewayConnectionName = in.getString(GATEWAY_CONNECTION_NAME_KEY);
        mCtrlPlaneConfig = VcnControlPlaneConfig.fromPersistableBundle(ctrlPlaneConfigBundle);
        mExposedCapabilities = new TreeSet<>(PersistableBundleUtils.toList(
                exposedCapsBundle, PersistableBundleUtils.INTEGER_DESERIALIZER));
@@ -204,6 +209,7 @@ public final class VcnGatewayConnectionConfig {
    }

    private void validate() {
        Objects.requireNonNull(mGatewayConnectionName, "gatewayConnectionName was null");
        Objects.requireNonNull(mCtrlPlaneConfig, "control plane config was null");

        Preconditions.checkArgument(
@@ -241,6 +247,20 @@ public final class VcnGatewayConnectionConfig {
        }
    }

    /**
     * Returns the configured Gateway Connection name.
     *
     * <p>This name is used by the configuring apps to distinguish between
     * VcnGatewayConnectionConfigs configured on a single {@link VcnConfig}. This will be used as
     * the identifier in VcnStatusCallback invocations.
     *
     * @see VcnManager.VcnStatusCallback#onGatewayConnectionError
     */
    @NonNull
    public String getGatewayConnectionName() {
        return mGatewayConnectionName;
    }

    /**
     * Returns control plane configuration.
     *
@@ -364,6 +384,7 @@ public final class VcnGatewayConnectionConfig {
                        new ArrayList<>(mUnderlyingCapabilities),
                        PersistableBundleUtils.INTEGER_SERIALIZER);

        result.putString(GATEWAY_CONNECTION_NAME_KEY, mGatewayConnectionName);
        result.putPersistableBundle(CTRL_PLANE_CONFIG_KEY, ctrlPlaneConfigBundle);
        result.putPersistableBundle(EXPOSED_CAPABILITIES_KEY, exposedCapsBundle);
        result.putPersistableBundle(UNDERLYING_CAPABILITIES_KEY, underlyingCapsBundle);
@@ -376,6 +397,7 @@ public final class VcnGatewayConnectionConfig {
    @Override
    public int hashCode() {
        return Objects.hash(
                mGatewayConnectionName,
                mExposedCapabilities,
                mUnderlyingCapabilities,
                Arrays.hashCode(mRetryIntervalsMs),
@@ -389,7 +411,8 @@ public final class VcnGatewayConnectionConfig {
        }

        final VcnGatewayConnectionConfig rhs = (VcnGatewayConnectionConfig) other;
        return mExposedCapabilities.equals(rhs.mExposedCapabilities)
        return mGatewayConnectionName.equals(rhs.mGatewayConnectionName)
                && mExposedCapabilities.equals(rhs.mExposedCapabilities)
                && mUnderlyingCapabilities.equals(rhs.mUnderlyingCapabilities)
                && Arrays.equals(mRetryIntervalsMs, rhs.mRetryIntervalsMs)
                && mMaxMtu == rhs.mMaxMtu;
@@ -399,6 +422,7 @@ public final class VcnGatewayConnectionConfig {
     * This class is used to incrementally build {@link VcnGatewayConnectionConfig} objects.
     */
    public static final class Builder {
        @NonNull private final String mGatewayConnectionName;
        @NonNull private final VcnControlPlaneConfig mCtrlPlaneConfig;
        @NonNull private final Set<Integer> mExposedCapabilities = new ArraySet();
        @NonNull private final Set<Integer> mUnderlyingCapabilities = new ArraySet();
@@ -412,12 +436,22 @@ public final class VcnGatewayConnectionConfig {
        /**
         * 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
         *     distinguish between VcnGatewayConnectionConfigs configured on a single {@link
         *     VcnConfig}. This will be used as the identifier in VcnStatusCallback invocations.
         * @param ctrlPlaneConfig the control plane configuration
         * @see VcnControlPlaneConfig
         * @see VcnManager.VcnStatusCallback#onGatewayConnectionError
         */
        public Builder(@NonNull VcnControlPlaneConfig ctrlPlaneConfig) {
        public Builder(
                @NonNull String gatewayConnectionName,
                @NonNull VcnControlPlaneConfig ctrlPlaneConfig) {
            Objects.requireNonNull(gatewayConnectionName, "gatewayConnectionName was null");
            Objects.requireNonNull(ctrlPlaneConfig, "ctrlPlaneConfig was null");

            mGatewayConnectionName = gatewayConnectionName;
            mCtrlPlaneConfig = ctrlPlaneConfig;
        }

@@ -562,6 +596,7 @@ public final class VcnGatewayConnectionConfig {
        @NonNull
        public VcnGatewayConnectionConfig build() {
            return new VcnGatewayConnectionConfig(
                    mGatewayConnectionName,
                    mCtrlPlaneConfig,
                    mExposedCapabilities,
                    mUnderlyingCapabilities,
+7 −9
Original line number Diff line number Diff line
@@ -445,18 +445,16 @@ public class VcnManager {
         * 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);
    }
@@ -586,7 +584,7 @@ public class VcnManager {
        // TODO(b/180521637): use ServiceSpecificException for safer Exception 'parceling'
        @Override
        public void onGatewayConnectionError(
                @NonNull int[] networkCapabilities,
                @NonNull String gatewayConnectionName,
                @VcnErrorCode int errorCode,
                @Nullable String exceptionClass,
                @Nullable String exceptionMessage) {
@@ -597,7 +595,7 @@ public class VcnManager {
                            mExecutor.execute(
                                    () ->
                                            mCallback.onGatewayConnectionError(
                                                    networkCapabilities, errorCode, cause)));
                                                    gatewayConnectionName, errorCode, cause)));
        }

        private static Throwable createThrowableByClassName(
Loading