blob: 893c5823dce19f893b2b5c06d8ca6cf8f847b11e [file] [log] [blame]
markchien0df2ebc42019-09-30 14:40:57 +08001/*
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
markchien503be612020-04-12 21:41:29 +080017package com.android.networkstack.tethering;
markchien0df2ebc42019-09-30 14:40:57 +080018
markchien3fe660b2019-12-05 12:04:59 +080019import android.bluetooth.BluetoothAdapter;
markchien0df2ebc42019-09-30 14:40:57 +080020import android.content.Context;
21import android.net.INetd;
markchien0df2ebc42019-09-30 14:40:57 +080022import android.net.NetworkRequest;
23import android.net.ip.IpServer;
24import android.net.util.SharedLog;
25import android.os.Handler;
26import android.os.IBinder;
markchien0df2ebc42019-09-30 14:40:57 +080027import android.os.Looper;
markchien0df2ebc42019-09-30 14:40:57 +080028
Automerger Merge Worker2d7bacc2020-03-09 08:54:00 +000029import androidx.annotation.NonNull;
30
markchien0df2ebc42019-09-30 14:40:57 +080031import com.android.internal.util.StateMachine;
32
33import java.util.ArrayList;
34
35
36/**
37 * Capture tethering dependencies, for injection.
38 *
39 * @hide
40 */
markchien6d06f6d2019-12-16 20:15:20 +080041public abstract class TetheringDependencies {
markchien0df2ebc42019-09-30 14:40:57 +080042 /**
43 * Get a reference to the offload hardware interface to be used by tethering.
44 */
45 public OffloadHardwareInterface getOffloadHardwareInterface(Handler h, SharedLog log) {
46 return new OffloadHardwareInterface(h, log);
47 }
48
49 /**
50 * Get a reference to the UpstreamNetworkMonitor to be used by tethering.
51 */
52 public UpstreamNetworkMonitor getUpstreamNetworkMonitor(Context ctx, StateMachine target,
53 SharedLog log, int what) {
54 return new UpstreamNetworkMonitor(ctx, target, log, what);
55 }
56
57 /**
58 * Get a reference to the IPv6TetheringCoordinator to be used by tethering.
59 */
60 public IPv6TetheringCoordinator getIPv6TetheringCoordinator(
61 ArrayList<IpServer> notifyList, SharedLog log) {
62 return new IPv6TetheringCoordinator(notifyList, log);
63 }
64
65 /**
66 * Get dependencies to be used by IpServer.
67 */
markchien6d06f6d2019-12-16 20:15:20 +080068 public abstract IpServer.Dependencies getIpServerDependencies();
markchien0df2ebc42019-09-30 14:40:57 +080069
70 /**
71 * Indicates whether tethering is supported on the device.
72 */
73 public boolean isTetheringSupported() {
74 return true;
75 }
76
77 /**
78 * Get the NetworkRequest that should be fulfilled by the default network.
79 */
markchien6d06f6d2019-12-16 20:15:20 +080080 public abstract NetworkRequest getDefaultNetworkRequest();
markchien0df2ebc42019-09-30 14:40:57 +080081
82 /**
83 * Get a reference to the EntitlementManager to be used by tethering.
84 */
85 public EntitlementManager getEntitlementManager(Context ctx, StateMachine target,
86 SharedLog log, int what) {
87 return new EntitlementManager(ctx, target, log, what);
88 }
89
90 /**
91 * Generate a new TetheringConfiguration according to input sub Id.
92 */
93 public TetheringConfiguration generateTetheringConfiguration(Context ctx, SharedLog log,
94 int subId) {
95 return new TetheringConfiguration(ctx, log, subId);
96 }
97
98 /**
markchien0df2ebc42019-09-30 14:40:57 +080099 * Get a reference to INetd to be used by tethering.
100 */
101 public INetd getINetd(Context context) {
102 return INetd.Stub.asInterface(
103 (IBinder) context.getSystemService(Context.NETD_SERVICE));
104 }
105
106 /**
Automerger Merge Worker2d7bacc2020-03-09 08:54:00 +0000107 * Get a reference to the TetheringNotificationUpdater to be used by tethering.
108 */
109 public TetheringNotificationUpdater getNotificationUpdater(@NonNull final Context ctx) {
110 return new TetheringNotificationUpdater(ctx);
111 }
112
113 /**
markchien0df2ebc42019-09-30 14:40:57 +0800114 * Get tethering thread looper.
115 */
markchien6d06f6d2019-12-16 20:15:20 +0800116 public abstract Looper getTetheringLooper();
markchien0df2ebc42019-09-30 14:40:57 +0800117
118 /**
119 * Get Context of TetheringSerice.
120 */
markchien6d06f6d2019-12-16 20:15:20 +0800121 public abstract Context getContext();
markchien3fe660b2019-12-05 12:04:59 +0800122
123 /**
124 * Get a reference to BluetoothAdapter to be used by tethering.
125 */
126 public abstract BluetoothAdapter getBluetoothAdapter();
markchien0df2ebc42019-09-30 14:40:57 +0800127}