Loading services/core/java/com/android/server/VcnManagementService.java +7 −3 Original line number Diff line number Diff line Loading @@ -165,9 +165,13 @@ public class VcnManagementService extends IVcnManagementService.Stub { // TODO: Clear VCN configuration, trigger teardown as necessary } @VisibleForTesting(visibility = Visibility.PRIVATE) class VcnNetworkProvider extends NetworkProvider { VcnNetworkProvider(@NonNull Context context, @NonNull Looper looper) { /** * Network provider for VCN networks. * * @hide */ public class VcnNetworkProvider extends NetworkProvider { VcnNetworkProvider(Context context, Looper looper) { super(context, looper, VcnNetworkProvider.class.getSimpleName()); } Loading services/core/java/com/android/server/vcn/Vcn.java 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * 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 com.android.server.vcn; import android.annotation.NonNull; import android.net.NetworkRequest; import android.net.vcn.VcnConfig; import android.os.Handler; import android.os.Message; import android.os.ParcelUuid; import java.util.Objects; /** * Represents an single instance of a VCN. * * <p>Each Vcn instance manages all tunnels for a given subscription group, including per-capability * networks, network selection, and multi-homing. * * @hide */ public class Vcn extends Handler { private static final String TAG = Vcn.class.getSimpleName(); @NonNull private final VcnContext mVcnContext; @NonNull private final ParcelUuid mSubscriptionGroup; @NonNull private final Dependencies mDeps; @NonNull private VcnConfig mConfig; public Vcn( @NonNull VcnContext vcnContext, @NonNull ParcelUuid subscriptionGroup, @NonNull VcnConfig config) { this(vcnContext, subscriptionGroup, config, new Dependencies()); } private Vcn( @NonNull VcnContext vcnContext, @NonNull ParcelUuid subscriptionGroup, @NonNull VcnConfig config, @NonNull Dependencies deps) { super(Objects.requireNonNull(vcnContext, "Missing vcnContext").getLooper()); mVcnContext = vcnContext; mSubscriptionGroup = Objects.requireNonNull(subscriptionGroup, "Missing subscriptionGroup"); mDeps = Objects.requireNonNull(deps, "Missing deps"); mConfig = Objects.requireNonNull(config, "Missing config"); } /** Asynchronously updates the configuration and triggers a re-evaluation of Networks */ public void updateConfig(@NonNull VcnConfig config) { Objects.requireNonNull(config, "Missing config"); // TODO: Proxy to handler, and make config there. } /** Asynchronously tears down this Vcn instance, along with all tunnels and Networks */ public void teardown() { // TODO: Proxy to handler, and teardown there. } /** Notifies this Vcn instance of a new NetworkRequest */ public void onNetworkRequested(@NonNull NetworkRequest request, int score, int providerId) { Objects.requireNonNull(request, "Missing request"); // TODO: Proxy to handler, and handle there. } @Override public void handleMessage(@NonNull Message msg) { // TODO: Do something } /** Retrieves the network score for a VCN Network */ private int getNetworkScore() { // TODO: STOPSHIP: Make this use new NetworkSelection, or some magic "max in subGrp" value return 52; } private static class Dependencies {} } services/core/java/com/android/server/vcn/VcnContext.java 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * 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 com.android.server.vcn; import android.annotation.NonNull; import android.content.Context; import android.os.Looper; import com.android.server.VcnManagementService.VcnNetworkProvider; import java.util.Objects; /** * A simple class to pass around context information. * * @hide */ public class VcnContext { @NonNull private final Context mContext; @NonNull private final Looper mLooper; @NonNull private final VcnNetworkProvider mVcnNetworkProvider; public VcnContext( @NonNull Context context, @NonNull Looper looper, @NonNull VcnNetworkProvider vcnNetworkProvider) { mContext = Objects.requireNonNull(context, "Missing context"); mLooper = Objects.requireNonNull(looper, "Missing looper"); mVcnNetworkProvider = Objects.requireNonNull(vcnNetworkProvider, "Missing networkProvider"); } @NonNull public Context getContext() { return mContext; } @NonNull public Looper getLooper() { return mLooper; } @NonNull public VcnNetworkProvider getVcnNetworkProvider() { return mVcnNetworkProvider; } } Loading
services/core/java/com/android/server/VcnManagementService.java +7 −3 Original line number Diff line number Diff line Loading @@ -165,9 +165,13 @@ public class VcnManagementService extends IVcnManagementService.Stub { // TODO: Clear VCN configuration, trigger teardown as necessary } @VisibleForTesting(visibility = Visibility.PRIVATE) class VcnNetworkProvider extends NetworkProvider { VcnNetworkProvider(@NonNull Context context, @NonNull Looper looper) { /** * Network provider for VCN networks. * * @hide */ public class VcnNetworkProvider extends NetworkProvider { VcnNetworkProvider(Context context, Looper looper) { super(context, looper, VcnNetworkProvider.class.getSimpleName()); } Loading
services/core/java/com/android/server/vcn/Vcn.java 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * 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 com.android.server.vcn; import android.annotation.NonNull; import android.net.NetworkRequest; import android.net.vcn.VcnConfig; import android.os.Handler; import android.os.Message; import android.os.ParcelUuid; import java.util.Objects; /** * Represents an single instance of a VCN. * * <p>Each Vcn instance manages all tunnels for a given subscription group, including per-capability * networks, network selection, and multi-homing. * * @hide */ public class Vcn extends Handler { private static final String TAG = Vcn.class.getSimpleName(); @NonNull private final VcnContext mVcnContext; @NonNull private final ParcelUuid mSubscriptionGroup; @NonNull private final Dependencies mDeps; @NonNull private VcnConfig mConfig; public Vcn( @NonNull VcnContext vcnContext, @NonNull ParcelUuid subscriptionGroup, @NonNull VcnConfig config) { this(vcnContext, subscriptionGroup, config, new Dependencies()); } private Vcn( @NonNull VcnContext vcnContext, @NonNull ParcelUuid subscriptionGroup, @NonNull VcnConfig config, @NonNull Dependencies deps) { super(Objects.requireNonNull(vcnContext, "Missing vcnContext").getLooper()); mVcnContext = vcnContext; mSubscriptionGroup = Objects.requireNonNull(subscriptionGroup, "Missing subscriptionGroup"); mDeps = Objects.requireNonNull(deps, "Missing deps"); mConfig = Objects.requireNonNull(config, "Missing config"); } /** Asynchronously updates the configuration and triggers a re-evaluation of Networks */ public void updateConfig(@NonNull VcnConfig config) { Objects.requireNonNull(config, "Missing config"); // TODO: Proxy to handler, and make config there. } /** Asynchronously tears down this Vcn instance, along with all tunnels and Networks */ public void teardown() { // TODO: Proxy to handler, and teardown there. } /** Notifies this Vcn instance of a new NetworkRequest */ public void onNetworkRequested(@NonNull NetworkRequest request, int score, int providerId) { Objects.requireNonNull(request, "Missing request"); // TODO: Proxy to handler, and handle there. } @Override public void handleMessage(@NonNull Message msg) { // TODO: Do something } /** Retrieves the network score for a VCN Network */ private int getNetworkScore() { // TODO: STOPSHIP: Make this use new NetworkSelection, or some magic "max in subGrp" value return 52; } private static class Dependencies {} }
services/core/java/com/android/server/vcn/VcnContext.java 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * 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 com.android.server.vcn; import android.annotation.NonNull; import android.content.Context; import android.os.Looper; import com.android.server.VcnManagementService.VcnNetworkProvider; import java.util.Objects; /** * A simple class to pass around context information. * * @hide */ public class VcnContext { @NonNull private final Context mContext; @NonNull private final Looper mLooper; @NonNull private final VcnNetworkProvider mVcnNetworkProvider; public VcnContext( @NonNull Context context, @NonNull Looper looper, @NonNull VcnNetworkProvider vcnNetworkProvider) { mContext = Objects.requireNonNull(context, "Missing context"); mLooper = Objects.requireNonNull(looper, "Missing looper"); mVcnNetworkProvider = Objects.requireNonNull(vcnNetworkProvider, "Missing networkProvider"); } @NonNull public Context getContext() { return mContext; } @NonNull public Looper getLooper() { return mLooper; } @NonNull public VcnNetworkProvider getVcnNetworkProvider() { return mVcnNetworkProvider; } }