Merge "Add shell VcnManagementService"
This commit is contained in:
@@ -131,6 +131,8 @@ import android.net.lowpan.ILowpanManager;
|
||||
import android.net.lowpan.LowpanManager;
|
||||
import android.net.nsd.INsdManager;
|
||||
import android.net.nsd.NsdManager;
|
||||
import android.net.vcn.IVcnManagementService;
|
||||
import android.net.vcn.VcnManager;
|
||||
import android.net.wifi.WifiFrameworkInitializer;
|
||||
import android.net.wifi.nl80211.WifiNl80211Manager;
|
||||
import android.nfc.NfcManager;
|
||||
@@ -371,6 +373,14 @@ public final class SystemServiceRegistry {
|
||||
ctx, () -> ServiceManager.getService(Context.TETHERING_SERVICE));
|
||||
}});
|
||||
|
||||
registerService(Context.VCN_MANAGEMENT_SERVICE, VcnManager.class,
|
||||
new CachedServiceFetcher<VcnManager>() {
|
||||
@Override
|
||||
public VcnManager createService(ContextImpl ctx) throws ServiceNotFoundException {
|
||||
IBinder b = ServiceManager.getService(Context.VCN_MANAGEMENT_SERVICE);
|
||||
IVcnManagementService service = IVcnManagementService.Stub.asInterface(b);
|
||||
return new VcnManager(ctx, service);
|
||||
}});
|
||||
|
||||
registerService(Context.IPSEC_SERVICE, IpSecManager.class,
|
||||
new CachedServiceFetcher<IpSecManager>() {
|
||||
|
||||
@@ -3402,6 +3402,7 @@ public abstract class Context {
|
||||
VIBRATOR_SERVICE,
|
||||
//@hide: STATUS_BAR_SERVICE,
|
||||
CONNECTIVITY_SERVICE,
|
||||
VCN_MANAGEMENT_SERVICE,
|
||||
//@hide: IP_MEMORY_STORE_SERVICE,
|
||||
IPSEC_SERVICE,
|
||||
VPN_MANAGEMENT_SERVICE,
|
||||
@@ -3965,6 +3966,16 @@ public abstract class Context {
|
||||
*/
|
||||
public static final String CONNECTIVITY_SERVICE = "connectivity";
|
||||
|
||||
/**
|
||||
* Use with {@link #getSystemService(String)} to retrieve a {@link android.net.vcn.VcnManager}
|
||||
* for managing Virtual Carrier Networks
|
||||
*
|
||||
* @see #getSystemService(String)
|
||||
* @see android.net.vcn.VcnManager
|
||||
* @hide
|
||||
*/
|
||||
public static final String VCN_MANAGEMENT_SERVICE = "vcn_management";
|
||||
|
||||
/**
|
||||
* Use with {@link #getSystemService(String)} to retrieve a
|
||||
* {@link android.net.INetd} for communicating with the network stack
|
||||
|
||||
23
core/java/android/net/vcn/IVcnManagementService.aidl
Normal file
23
core/java/android/net/vcn/IVcnManagementService.aidl
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 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
|
||||
*/
|
||||
interface IVcnManagementService {
|
||||
}
|
||||
48
core/java/android/net/vcn/VcnManager.java
Normal file
48
core/java/android/net/vcn/VcnManager.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 static java.util.Objects.requireNonNull;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemService;
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* VcnManager publishes APIs for applications to configure and manage Virtual Carrier Networks
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemService(Context.VCN_MANAGEMENT_SERVICE)
|
||||
public final class VcnManager {
|
||||
@NonNull private static final String TAG = VcnManager.class.getSimpleName();
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
@NonNull private final IVcnManagementService mService;
|
||||
|
||||
/**
|
||||
* Construct an instance of VcnManager within an application context.
|
||||
*
|
||||
* @param ctx the application context for this manager
|
||||
* @param service the VcnManagementService binder backing this manager
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public VcnManager(@NonNull Context ctx, @NonNull IVcnManagementService service) {
|
||||
mContext = requireNonNull(ctx, "missing context");
|
||||
mService = requireNonNull(service, "missing service");
|
||||
}
|
||||
}
|
||||
103
services/core/java/com/android/server/VcnManagementService.java
Normal file
103
services/core/java/com/android/server/VcnManagementService.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.net.vcn.IVcnManagementService;
|
||||
|
||||
/**
|
||||
* VcnManagementService manages Virtual Carrier Network profiles and lifecycles.
|
||||
*
|
||||
* <pre>The internal structure of the VCN Management subsystem is as follows:
|
||||
*
|
||||
* +------------------------+ 1:1 +--------------------------------+
|
||||
* | VcnManagementService | ------------ Creates -------------> | TelephonySubscriptionManager |
|
||||
* | | | |
|
||||
* | Manages configs and | | Tracks subscriptions, carrier |
|
||||
* | VcnInstance lifecycles | <--- Notifies of subscription & --- | privilege changes, caches maps |
|
||||
* +------------------------+ carrier privilege changes +--------------------------------+
|
||||
* | 1:N ^
|
||||
* | |
|
||||
* | +-------------------------------+
|
||||
* +---------------+ |
|
||||
* | |
|
||||
* Creates when config present, |
|
||||
* subscription group active, and |
|
||||
* providing app is carrier privileged Notifies of safe
|
||||
* | mode state changes
|
||||
* v |
|
||||
* +-----------------------------------------------------------------------+
|
||||
* | VcnInstance |
|
||||
* | |
|
||||
* | Manages tunnel lifecycles based on fulfillable NetworkRequest(s) |
|
||||
* | and overall safe-mode |
|
||||
* +-----------------------------------------------------------------------+
|
||||
* | 1:N ^
|
||||
* Creates to fulfill |
|
||||
* NetworkRequest(s), tears Notifies of VcnTunnel
|
||||
* down when no longer needed teardown (e.g. Network reaped)
|
||||
* | and safe-mode timer changes
|
||||
* v |
|
||||
* +-----------------------------------------------------------------------+
|
||||
* | VcnTunnel |
|
||||
* | |
|
||||
* | Manages a single (IKEv2) tunnel session and NetworkAgent, |
|
||||
* | handles mobility events, (IPsec) Tunnel setup and safe-mode timers |
|
||||
* +-----------------------------------------------------------------------+
|
||||
* | 1:1 ^
|
||||
* | |
|
||||
* Creates upon instantiation Notifies of changes in
|
||||
* | selected underlying network
|
||||
* | or its properties
|
||||
* v |
|
||||
* +-----------------------------------------------------------------------+
|
||||
* | UnderlyingNetworkTracker |
|
||||
* | |
|
||||
* | Manages lifecycle of underlying physical networks, filing requests to |
|
||||
* | bring them up, and releasing them as they become no longer necessary |
|
||||
* +-----------------------------------------------------------------------+
|
||||
* </pre>
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class VcnManagementService extends IVcnManagementService.Stub {
|
||||
@NonNull private static final String TAG = VcnManagementService.class.getSimpleName();
|
||||
|
||||
public static final boolean VDBG = false; // STOPSHIP: if true
|
||||
|
||||
/* Binder context for this service */
|
||||
@NonNull private final Context mContext;
|
||||
@NonNull private final Dependencies mDeps;
|
||||
|
||||
private VcnManagementService(@NonNull Context context, @NonNull Dependencies deps) {
|
||||
mContext = requireNonNull(context, "Missing context");
|
||||
mDeps = requireNonNull(deps, "Missing dependencies");
|
||||
}
|
||||
|
||||
// Package-visibility for SystemServer to create instances.
|
||||
static VcnManagementService create(@NonNull Context context) {
|
||||
return new VcnManagementService(context, new Dependencies());
|
||||
}
|
||||
|
||||
private static class Dependencies {}
|
||||
|
||||
/** Notifies the VcnManagementService that external dependencies can be set up */
|
||||
public void systemReady() {}
|
||||
}
|
||||
@@ -1018,6 +1018,7 @@ public final class SystemServer {
|
||||
IStorageManager storageManager = null;
|
||||
NetworkManagementService networkManagement = null;
|
||||
IpSecService ipSecService = null;
|
||||
VcnManagementService vcnManagement = null;
|
||||
NetworkStatsService networkStats = null;
|
||||
NetworkPolicyManagerService networkPolicy = null;
|
||||
IConnectivityManager connectivity = null;
|
||||
@@ -1453,6 +1454,15 @@ public final class SystemServer {
|
||||
}
|
||||
t.traceEnd();
|
||||
|
||||
t.traceBegin("StartVcnManagementService");
|
||||
try {
|
||||
vcnManagement = VcnManagementService.create(context);
|
||||
ServiceManager.addService(Context.VCN_MANAGEMENT_SERVICE, vcnManagement);
|
||||
} catch (Throwable e) {
|
||||
reportWtf("starting VCN Management Service", e);
|
||||
}
|
||||
t.traceEnd();
|
||||
|
||||
t.traceBegin("StartTextServicesManager");
|
||||
mSystemServiceManager.startService(TextServicesManagerService.Lifecycle.class);
|
||||
t.traceEnd();
|
||||
@@ -2228,6 +2238,7 @@ public final class SystemServer {
|
||||
final MediaRouterService mediaRouterF = mediaRouter;
|
||||
final MmsServiceBroker mmsServiceF = mmsService;
|
||||
final IpSecService ipSecServiceF = ipSecService;
|
||||
final VcnManagementService vcnManagementF = vcnManagement;
|
||||
final WindowManagerService windowManagerF = wm;
|
||||
final ConnectivityManager connectivityF = (ConnectivityManager)
|
||||
context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
@@ -2316,6 +2327,15 @@ public final class SystemServer {
|
||||
reportWtf("making IpSec Service ready", e);
|
||||
}
|
||||
t.traceEnd();
|
||||
t.traceBegin("MakeVcnManagementServiceReady");
|
||||
try {
|
||||
if (vcnManagementF != null) {
|
||||
vcnManagementF.systemReady();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
reportWtf("making VcnManagementService ready", e);
|
||||
}
|
||||
t.traceEnd();
|
||||
t.traceBegin("MakeNetworkStatsServiceReady");
|
||||
try {
|
||||
if (networkStatsF != null) {
|
||||
|
||||
Reference in New Issue
Block a user