blob: cd49258d1c47b99904c4e0a41d6098117b3b6ffa [file] [log] [blame]
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +09001/**
2 * Copyright (c) 2008, 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
17package android.net;
18
19import android.app.PendingIntent;
20import android.net.ConnectionInfo;
21import android.net.ConnectivityDiagnosticsManager;
22import android.net.IConnectivityDiagnosticsCallback;
James Mattis12aeab82021-01-10 14:24:24 -080023import android.net.IOnSetOemNetworkPreferenceListener;
Chiachang Wangcea06a62021-02-04 17:29:59 +080024import android.net.INetworkActivityListener;
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +090025import android.net.IQosCallback;
26import android.net.ISocketKeepaliveCallback;
27import android.net.LinkProperties;
28import android.net.Network;
29import android.net.NetworkAgentConfig;
30import android.net.NetworkCapabilities;
31import android.net.NetworkInfo;
32import android.net.NetworkRequest;
33import android.net.NetworkState;
junyulaib1211372021-03-03 12:09:05 +080034import android.net.NetworkStateSnapshot;
James Mattis452c6ff2021-01-01 14:13:35 -080035import android.net.OemNetworkPreferences;
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +090036import android.net.ProxyInfo;
37import android.net.UidRange;
38import android.net.QosSocketInfo;
39import android.os.Bundle;
40import android.os.IBinder;
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +090041import android.os.Messenger;
42import android.os.ParcelFileDescriptor;
43import android.os.PersistableBundle;
44import android.os.ResultReceiver;
45
46import com.android.connectivity.aidl.INetworkAgent;
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +090047
48/**
49 * Interface that answers queries about, and allows changing, the
50 * state of network connectivity.
51 */
52/** {@hide} */
53interface IConnectivityManager
54{
55 Network getActiveNetwork();
56 Network getActiveNetworkForUid(int uid, boolean ignoreBlocked);
57 @UnsupportedAppUsage
58 NetworkInfo getActiveNetworkInfo();
59 NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked);
60 @UnsupportedAppUsage(maxTargetSdk = 28)
61 NetworkInfo getNetworkInfo(int networkType);
62 NetworkInfo getNetworkInfoForUid(in Network network, int uid, boolean ignoreBlocked);
63 @UnsupportedAppUsage
64 NetworkInfo[] getAllNetworkInfo();
65 Network getNetworkForType(int networkType);
66 Network[] getAllNetworks();
67 NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(
Roshan Piusa8a477b2020-12-17 14:53:09 -080068 int userId, String callingPackageName, String callingAttributionTag);
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +090069
70 boolean isNetworkSupported(int networkType);
71
72 @UnsupportedAppUsage
73 LinkProperties getActiveLinkProperties();
74 LinkProperties getLinkPropertiesForType(int networkType);
75 LinkProperties getLinkProperties(in Network network);
76
Roshan Piusa8a477b2020-12-17 14:53:09 -080077 NetworkCapabilities getNetworkCapabilities(in Network network, String callingPackageName,
78 String callingAttributionTag);
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +090079
80 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
81 NetworkState[] getAllNetworkState();
82
junyulaib1211372021-03-03 12:09:05 +080083 List<NetworkStateSnapshot> getAllNetworkStateSnapshot();
84
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +090085 boolean isActiveNetworkMetered();
86
87 boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress,
88 String callingPackageName, String callingAttributionTag);
89
90 @UnsupportedAppUsage(maxTargetSdk = 29,
91 publicAlternatives = "Use {@code TetheringManager#getLastTetherError} as alternative")
92 int getLastTetherError(String iface);
93
94 @UnsupportedAppUsage(maxTargetSdk = 29,
95 publicAlternatives = "Use {@code TetheringManager#getTetherableIfaces} as alternative")
96 String[] getTetherableIfaces();
97
98 @UnsupportedAppUsage(maxTargetSdk = 29,
99 publicAlternatives = "Use {@code TetheringManager#getTetheredIfaces} as alternative")
100 String[] getTetheredIfaces();
101
102 @UnsupportedAppUsage(maxTargetSdk = 29,
103 publicAlternatives = "Use {@code TetheringManager#getTetheringErroredIfaces} "
104 + "as Alternative")
105 String[] getTetheringErroredIfaces();
106
107 @UnsupportedAppUsage(maxTargetSdk = 29,
108 publicAlternatives = "Use {@code TetheringManager#getTetherableUsbRegexs} as alternative")
109 String[] getTetherableUsbRegexs();
110
111 @UnsupportedAppUsage(maxTargetSdk = 29,
112 publicAlternatives = "Use {@code TetheringManager#getTetherableWifiRegexs} as alternative")
113 String[] getTetherableWifiRegexs();
114
115 @UnsupportedAppUsage(maxTargetSdk = 28)
116 void reportInetCondition(int networkType, int percentage);
117
118 void reportNetworkConnectivity(in Network network, boolean hasConnectivity);
119
120 ProxyInfo getGlobalProxy();
121
122 void setGlobalProxy(in ProxyInfo p);
123
124 ProxyInfo getProxyForNetwork(in Network nework);
125
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +0900126 void setRequireVpnForUids(boolean requireVpn, in UidRange[] ranges);
Lorenzo Colittic71cff82021-01-15 01:29:01 +0900127 void setLegacyLockdownVpnEnabled(boolean enabled);
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +0900128
129 void setProvisioningNotificationVisible(boolean visible, int networkType, in String action);
130
131 void setAirplaneMode(boolean enable);
132
133 boolean requestBandwidthUpdate(in Network network);
134
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +0900135 int registerNetworkProvider(in Messenger messenger, in String name);
136 void unregisterNetworkProvider(in Messenger messenger);
137
138 void declareNetworkRequestUnfulfillable(in NetworkRequest request);
139
140 Network registerNetworkAgent(in INetworkAgent na, in NetworkInfo ni, in LinkProperties lp,
141 in NetworkCapabilities nc, int score, in NetworkAgentConfig config,
142 in int factorySerialNumber);
143
144 NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities, int reqType,
145 in Messenger messenger, int timeoutSec, in IBinder binder, int legacy,
146 String callingPackageName, String callingAttributionTag);
147
148 NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities,
149 in PendingIntent operation, String callingPackageName, String callingAttributionTag);
150
151 void releasePendingNetworkRequest(in PendingIntent operation);
152
153 NetworkRequest listenForNetwork(in NetworkCapabilities networkCapabilities,
Roshan Piusa8a477b2020-12-17 14:53:09 -0800154 in Messenger messenger, in IBinder binder, String callingPackageName,
155 String callingAttributionTag);
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +0900156
157 void pendingListenForNetwork(in NetworkCapabilities networkCapabilities,
Roshan Piusa8a477b2020-12-17 14:53:09 -0800158 in PendingIntent operation, String callingPackageName,
159 String callingAttributionTag);
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +0900160
161 void releaseNetworkRequest(in NetworkRequest networkRequest);
162
163 void setAcceptUnvalidated(in Network network, boolean accept, boolean always);
164 void setAcceptPartialConnectivity(in Network network, boolean accept, boolean always);
165 void setAvoidUnvalidated(in Network network);
166 void startCaptivePortalApp(in Network network);
167 void startCaptivePortalAppInternal(in Network network, in Bundle appExtras);
168
169 boolean shouldAvoidBadWifi();
170 int getMultipathPreference(in Network Network);
171
172 NetworkRequest getDefaultRequest();
173
174 int getRestoreDefaultNetworkDelay(int networkType);
175
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +0900176 void factoryReset();
177
178 void startNattKeepalive(in Network network, int intervalSeconds,
179 in ISocketKeepaliveCallback cb, String srcAddr, int srcPort, String dstAddr);
180
181 void startNattKeepaliveWithFd(in Network network, in ParcelFileDescriptor pfd, int resourceId,
182 int intervalSeconds, in ISocketKeepaliveCallback cb, String srcAddr,
183 String dstAddr);
184
185 void startTcpKeepalive(in Network network, in ParcelFileDescriptor pfd, int intervalSeconds,
186 in ISocketKeepaliveCallback cb);
187
188 void stopKeepalive(in Network network, int slot);
189
190 String getCaptivePortalServerUrl();
191
192 byte[] getNetworkWatchlistConfigHash();
193
194 int getConnectionOwnerUid(in ConnectionInfo connectionInfo);
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +0900195
196 void registerConnectivityDiagnosticsCallback(in IConnectivityDiagnosticsCallback callback,
197 in NetworkRequest request, String callingPackageName);
198 void unregisterConnectivityDiagnosticsCallback(in IConnectivityDiagnosticsCallback callback);
199
200 IBinder startOrGetTestNetworkService();
201
202 void simulateDataStall(int detectionMethod, long timestampMillis, in Network network,
203 in PersistableBundle extras);
204
205 void systemReady();
206
207 void registerNetworkActivityListener(in INetworkActivityListener l);
208
209 void unregisterNetworkActivityListener(in INetworkActivityListener l);
210
211 boolean isDefaultNetworkActive();
212
213 void registerQosSocketCallback(in QosSocketInfo socketInfo, in IQosCallback callback);
214 void unregisterQosCallback(in IQosCallback callback);
James Mattis452c6ff2021-01-01 14:13:35 -0800215
James Mattis12aeab82021-01-10 14:24:24 -0800216 void setOemNetworkPreference(in OemNetworkPreferences preference,
217 in IOnSetOemNetworkPreferenceListener listener);
Remi NGUYEN VANfbbccbc2021-01-15 18:08:24 +0900218}