Erik Kline | 5a7c8a0 | 2017-04-30 19:36:15 +0900 | [diff] [blame] | 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 | |
Remi NGUYEN VAN | a911e84 | 2018-03-15 11:57:14 +0900 | [diff] [blame] | 19 | import android.content.Context; |
Erik Kline | 7230290 | 2018-06-14 17:36:40 +0900 | [diff] [blame] | 20 | import android.net.NetworkRequest; |
Erik Kline | 7a4ccc6 | 2018-08-27 17:26:47 +0900 | [diff] [blame] | 21 | import android.net.ip.IpServer; |
Erik Kline | f4b6e34 | 2017-04-25 19:19:59 +0900 | [diff] [blame] | 22 | import android.net.util.SharedLog; |
markchien | b6eb2c2 | 2018-07-18 14:29:20 +0800 | [diff] [blame] | 23 | import android.os.Handler; |
markchien | 0b59507 | 2019-01-08 23:52:21 +0800 | [diff] [blame] | 24 | import android.telephony.SubscriptionManager; |
Erik Kline | f4b6e34 | 2017-04-25 19:19:59 +0900 | [diff] [blame] | 25 | |
Remi NGUYEN VAN | a911e84 | 2018-03-15 11:57:14 +0900 | [diff] [blame] | 26 | import com.android.internal.util.StateMachine; |
markchien | b6eb2c2 | 2018-07-18 14:29:20 +0800 | [diff] [blame] | 27 | import com.android.server.connectivity.MockableSystemProperties; |
Remi NGUYEN VAN | a911e84 | 2018-03-15 11:57:14 +0900 | [diff] [blame] | 28 | |
| 29 | import java.util.ArrayList; |
| 30 | |
Erik Kline | 5a7c8a0 | 2017-04-30 19:36:15 +0900 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Capture tethering dependencies, for injection. |
| 34 | * |
| 35 | * @hide |
| 36 | */ |
| 37 | public class TetheringDependencies { |
Remi NGUYEN VAN | 73105e11 | 2018-12-21 16:17:09 +0900 | [diff] [blame] | 38 | /** |
| 39 | * Get a reference to the offload hardware interface to be used by tethering. |
| 40 | */ |
Erik Kline | f4b6e34 | 2017-04-25 19:19:59 +0900 | [diff] [blame] | 41 | public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) { |
| 42 | return new OffloadHardwareInterface(h, log); |
Erik Kline | 5a7c8a0 | 2017-04-30 19:36:15 +0900 | [diff] [blame] | 43 | } |
Remi NGUYEN VAN | a911e84 | 2018-03-15 11:57:14 +0900 | [diff] [blame] | 44 | |
Remi NGUYEN VAN | 73105e11 | 2018-12-21 16:17:09 +0900 | [diff] [blame] | 45 | /** |
| 46 | * Get a reference to the UpstreamNetworkMonitor to be used by tethering. |
| 47 | */ |
Remi NGUYEN VAN | a911e84 | 2018-03-15 11:57:14 +0900 | [diff] [blame] | 48 | public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, StateMachine target, |
| 49 | SharedLog log, int what) { |
| 50 | return new UpstreamNetworkMonitor(ctx, target, log, what); |
| 51 | } |
| 52 | |
Remi NGUYEN VAN | 73105e11 | 2018-12-21 16:17:09 +0900 | [diff] [blame] | 53 | /** |
| 54 | * Get a reference to the IPv6TetheringCoordinator to be used by tethering. |
| 55 | */ |
Remi NGUYEN VAN | a911e84 | 2018-03-15 11:57:14 +0900 | [diff] [blame] | 56 | public IPv6TetheringCoordinator getIPv6TetheringCoordinator( |
Erik Kline | 7a4ccc6 | 2018-08-27 17:26:47 +0900 | [diff] [blame] | 57 | ArrayList<IpServer> notifyList, SharedLog log) { |
Remi NGUYEN VAN | a911e84 | 2018-03-15 11:57:14 +0900 | [diff] [blame] | 58 | return new IPv6TetheringCoordinator(notifyList, log); |
| 59 | } |
| 60 | |
Remi NGUYEN VAN | 73105e11 | 2018-12-21 16:17:09 +0900 | [diff] [blame] | 61 | /** |
| 62 | * Get dependencies to be used by IpServer. |
| 63 | */ |
Remi NGUYEN VAN | 5db454c | 2019-02-14 18:04:20 +0900 | [diff] [blame] | 64 | public IpServer.Dependencies getIpServerDependencies() { |
| 65 | return new IpServer.Dependencies(); |
Remi NGUYEN VAN | a911e84 | 2018-03-15 11:57:14 +0900 | [diff] [blame] | 66 | } |
Erik Kline | 465ff3a | 2018-03-09 14:18:02 +0900 | [diff] [blame] | 67 | |
Remi NGUYEN VAN | 73105e11 | 2018-12-21 16:17:09 +0900 | [diff] [blame] | 68 | /** |
| 69 | * Indicates whether tethering is supported on the device. |
| 70 | */ |
Erik Kline | 465ff3a | 2018-03-09 14:18:02 +0900 | [diff] [blame] | 71 | public boolean isTetheringSupported() { |
| 72 | return true; |
| 73 | } |
Erik Kline | 7230290 | 2018-06-14 17:36:40 +0900 | [diff] [blame] | 74 | |
Remi NGUYEN VAN | 73105e11 | 2018-12-21 16:17:09 +0900 | [diff] [blame] | 75 | /** |
| 76 | * Get the NetworkRequest that should be fulfilled by the default network. |
| 77 | */ |
Erik Kline | 7230290 | 2018-06-14 17:36:40 +0900 | [diff] [blame] | 78 | public NetworkRequest getDefaultNetworkRequest() { |
| 79 | return null; |
| 80 | } |
markchien | b6eb2c2 | 2018-07-18 14:29:20 +0800 | [diff] [blame] | 81 | |
Remi NGUYEN VAN | 73105e11 | 2018-12-21 16:17:09 +0900 | [diff] [blame] | 82 | /** |
| 83 | * Get a reference to the EntitlementManager to be used by tethering. |
| 84 | */ |
markchien | f273127 | 2019-01-16 17:44:13 +0800 | [diff] [blame] | 85 | public EntitlementManager getEntitlementManager(Context ctx, StateMachine target, |
markchien | 3b51963 | 2018-09-07 16:19:12 +0800 | [diff] [blame] | 86 | SharedLog log, int what, MockableSystemProperties systemProperties) { |
| 87 | return new EntitlementManager(ctx, target, log, what, systemProperties); |
markchien | b6eb2c2 | 2018-07-18 14:29:20 +0800 | [diff] [blame] | 88 | } |
markchien | 0b59507 | 2019-01-08 23:52:21 +0800 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Get default data subscription id to build TetheringConfiguration. |
| 92 | */ |
| 93 | public int getDefaultDataSubscriptionId() { |
| 94 | return SubscriptionManager.getDefaultDataSubscriptionId(); |
| 95 | } |
Erik Kline | 5a7c8a0 | 2017-04-30 19:36:15 +0900 | [diff] [blame] | 96 | } |