1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.connectivity.tethering;
18 
19 import android.content.Context;
20 import android.net.NetworkRequest;
21 import android.net.ip.IpServer;
22 import android.net.util.SharedLog;
23 import android.os.Handler;
24 import android.telephony.SubscriptionManager;
25 
26 import com.android.internal.util.StateMachine;
27 import com.android.server.connectivity.MockableSystemProperties;
28 
29 import java.util.ArrayList;
30 
31 
32 /**
33  * Capture tethering dependencies, for injection.
34  *
35  * @hide
36  */
37 public class TetheringDependencies {
38     /**
39      * Get a reference to the offload hardware interface to be used by tethering.
40      */
getOffloadHardwareInterface(Handler h, SharedLog log)41     public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) {
42         return new OffloadHardwareInterface(h, log);
43     }
44 
45     /**
46      * Get a reference to the UpstreamNetworkMonitor to be used by tethering.
47      */
getUpstreamNetworkMonitor(Context ctx, StateMachine target, SharedLog log, int what)48     public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, StateMachine target,
49             SharedLog log, int what) {
50         return new UpstreamNetworkMonitor(ctx, target, log, what);
51     }
52 
53     /**
54      * Get a reference to the IPv6TetheringCoordinator to be used by tethering.
55      */
getIPv6TetheringCoordinator( ArrayList<IpServer> notifyList, SharedLog log)56     public IPv6TetheringCoordinator getIPv6TetheringCoordinator(
57             ArrayList<IpServer> notifyList, SharedLog log) {
58         return new IPv6TetheringCoordinator(notifyList, log);
59     }
60 
61     /**
62      * Get dependencies to be used by IpServer.
63      */
getIpServerDependencies()64     public IpServer.Dependencies getIpServerDependencies() {
65         return new IpServer.Dependencies();
66     }
67 
68     /**
69      * Indicates whether tethering is supported on the device.
70      */
isTetheringSupported()71     public boolean isTetheringSupported() {
72         return true;
73     }
74 
75     /**
76      * Get the NetworkRequest that should be fulfilled by the default network.
77      */
getDefaultNetworkRequest()78     public NetworkRequest getDefaultNetworkRequest() {
79         return null;
80     }
81 
82     /**
83      * Get a reference to the EntitlementManager to be used by tethering.
84      */
getEntitlementManager(Context ctx, StateMachine target, SharedLog log, int what, MockableSystemProperties systemProperties)85     public EntitlementManager getEntitlementManager(Context ctx, StateMachine target,
86             SharedLog log, int what, MockableSystemProperties systemProperties) {
87         return new EntitlementManager(ctx, target, log, what, systemProperties);
88     }
89 
90     /**
91      * Get default data subscription id to build TetheringConfiguration.
92      */
getDefaultDataSubscriptionId()93     public int getDefaultDataSubscriptionId() {
94         return SubscriptionManager.getDefaultDataSubscriptionId();
95     }
96 }
97