blob: 0cce19222d2770c8432aebe5161886f67d4e1fef [file] [log] [blame]
San Mehat873f2142010-01-14 10:25:07 -08001/* //device/java/android/android/os/INetworkManagementService.aidl
2**
3** Copyright 2007, The Android Open Source Project
4**
5** Licensed under the Apache License, Version 2.0 (the "License");
6** you may not use this file except in compliance with the License.
7** You may obtain a copy of the License at
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
11** Unless required by applicable law or agreed to in writing, software
12** distributed under the License is distributed on an "AS IS" BASIS,
13** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14** See the License for the specific language governing permissions and
15** limitations under the License.
16*/
17
18package android.os;
19
San Mehated4fc8a2010-01-22 12:28:36 -080020import android.net.InterfaceConfiguration;
San Mehat4d02d002010-01-22 16:07:46 -080021import android.net.INetworkManagementEventObserver;
Lorenzo Colittief7b2a12017-07-10 19:06:57 +090022import android.net.ITetheringStatsProvider;
Lorenzo Colittib57edc52014-08-22 17:10:50 -070023import android.net.Network;
Jeff Sharkey9a13f362011-04-26 16:25:36 -070024import android.net.NetworkStats;
Robert Greenwalt59b1a4e2011-05-10 15:05:02 -070025import android.net.RouteInfo;
Paul Jensen6bc2c2c2014-05-07 15:27:40 -040026import android.net.UidRange;
Dianne Hackborn77b987f2014-02-26 16:20:52 -080027import android.os.INetworkActivityListener;
San Mehated4fc8a2010-01-22 12:28:36 -080028
San Mehat873f2142010-01-14 10:25:07 -080029/**
30 * @hide
31 */
32interface INetworkManagementService
33{
34 /**
35 ** GENERAL
36 **/
37
38 /**
Erik Kline4e37b702016-07-05 11:34:21 +090039 * Register an observer to receive events.
San Mehat4d02d002010-01-22 16:07:46 -080040 */
Andrei Oneadcb67732019-03-18 11:37:25 +000041 @UnsupportedAppUsage
San Mehat4d02d002010-01-22 16:07:46 -080042 void registerObserver(INetworkManagementEventObserver obs);
43
44 /**
45 * Unregister an observer from receiving events.
46 */
Andrei Oneadcb67732019-03-18 11:37:25 +000047 @UnsupportedAppUsage
San Mehat4d02d002010-01-22 16:07:46 -080048 void unregisterObserver(INetworkManagementEventObserver obs);
49
50 /**
San Mehat873f2142010-01-14 10:25:07 -080051 * Returns a list of currently known network interfaces
52 */
53 String[] listInterfaces();
54
55 /**
San Mehated4fc8a2010-01-22 12:28:36 -080056 * Retrieves the specified interface config
57 *
58 */
Andrei Oneadcb67732019-03-18 11:37:25 +000059 @UnsupportedAppUsage
San Mehated4fc8a2010-01-22 12:28:36 -080060 InterfaceConfiguration getInterfaceConfig(String iface);
61
62 /**
63 * Sets the configuration of the specified interface
64 */
Andrei Oneadcb67732019-03-18 11:37:25 +000065 @UnsupportedAppUsage
San Mehated4fc8a2010-01-22 12:28:36 -080066 void setInterfaceConfig(String iface, in InterfaceConfiguration cfg);
67
68 /**
Irfan Sherifff5600612011-06-16 10:26:28 -070069 * Clear all IP addresses on the specified interface
70 */
Andrei Oneadcb67732019-03-18 11:37:25 +000071 @UnsupportedAppUsage
Irfan Sherifff5600612011-06-16 10:26:28 -070072 void clearInterfaceAddresses(String iface);
73
74 /**
Irfan Sheriff7244c972011-08-05 20:40:45 -070075 * Set interface down
76 */
77 void setInterfaceDown(String iface);
78
79 /**
80 * Set interface up
81 */
82 void setInterfaceUp(String iface);
83
84 /**
Irfan Sheriff73293612011-09-14 12:31:56 -070085 * Set interface IPv6 privacy extensions
86 */
Andrei Oneadcb67732019-03-18 11:37:25 +000087 @UnsupportedAppUsage
Irfan Sheriff73293612011-09-14 12:31:56 -070088 void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable);
89
90 /**
repo sync7960d9f2011-09-29 12:40:02 -070091 * Disable IPv6 on an interface
92 */
Andrei Oneadcb67732019-03-18 11:37:25 +000093 @UnsupportedAppUsage
repo sync7960d9f2011-09-29 12:40:02 -070094 void disableIpv6(String iface);
95
96 /**
97 * Enable IPv6 on an interface
98 */
Andrei Oneadcb67732019-03-18 11:37:25 +000099 @UnsupportedAppUsage
repo sync7960d9f2011-09-29 12:40:02 -0700100 void enableIpv6(String iface);
101
102 /**
Joel Scherpelz3ee447c2017-06-07 15:38:38 +0900103 * Set IPv6 autoconf address generation mode.
104 * This is a no-op if an unsupported mode is requested.
105 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000106 @UnsupportedAppUsage
Joel Scherpelz3ee447c2017-06-07 15:38:38 +0900107 void setIPv6AddrGenMode(String iface, int mode);
108
109 /**
Robert Greenwalt59b1a4e2011-05-10 15:05:02 -0700110 * Add the specified route to the interface.
111 */
Sreeram Ramachandranb2829fa2014-04-15 19:07:12 -0700112 void addRoute(int netId, in RouteInfo route);
Robert Greenwalt59b1a4e2011-05-10 15:05:02 -0700113
114 /**
115 * Remove the specified route from the interface.
116 */
Sreeram Ramachandranb2829fa2014-04-15 19:07:12 -0700117 void removeRoute(int netId, in RouteInfo route);
Robert Greenwalt3b28e9a2011-11-02 14:37:19 -0700118
119 /**
sy.yun9d9b74a2013-09-02 05:24:09 +0900120 * Set the specified MTU size
121 */
122 void setMtu(String iface, int mtu);
123
124 /**
San Mehat873f2142010-01-14 10:25:07 -0800125 * Shuts down the service
126 */
127 void shutdown();
128
129 /**
130 ** TETHERING RELATED
131 **/
132
San Mehat873f2142010-01-14 10:25:07 -0800133 /**
134 * Returns true if IP forwarding is enabled
135 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000136 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800137 boolean getIpForwardingEnabled();
138
139 /**
140 * Enables/Disables IP Forwarding
141 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000142 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800143 void setIpForwardingEnabled(boolean enabled);
144
145 /**
146 * Start tethering services with the specified dhcp server range
Robert Greenwaltbfb7bfa2010-03-24 16:03:21 -0700147 * arg is a set of start end pairs defining the ranges.
San Mehat873f2142010-01-14 10:25:07 -0800148 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000149 @UnsupportedAppUsage
Robert Greenwaltbfb7bfa2010-03-24 16:03:21 -0700150 void startTethering(in String[] dhcpRanges);
San Mehat873f2142010-01-14 10:25:07 -0800151
152 /**
Luke Huangb0d52462019-03-21 14:43:08 +0800153 * Start tethering services with the specified dhcp server range and
154 * DNS proxy config.
155 * {@code boolean} is used to control legacy DNS proxy server.
156 * {@code String[]} is a set of start end pairs defining the ranges.
157 */
158 void startTetheringWithConfiguration(boolean usingLegacyDnsProxy, in String[] dhcpRanges);
159
160 /**
San Mehat873f2142010-01-14 10:25:07 -0800161 * Stop currently running tethering services
162 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000163 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800164 void stopTethering();
165
166 /**
167 * Returns true if tethering services are started
168 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000169 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800170 boolean isTetheringStarted();
171
172 /**
173 * Tethers the specified interface
174 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000175 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800176 void tetherInterface(String iface);
177
178 /**
179 * Untethers the specified interface
180 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000181 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800182 void untetherInterface(String iface);
183
184 /**
185 * Returns a list of currently tethered interfaces
186 */
Artur Satayev751e5512019-11-15 19:12:49 +0000187 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800188 String[] listTetheredInterfaces();
189
190 /**
191 * Sets the list of DNS forwarders (in order of priority)
192 */
Lorenzo Colittib57edc52014-08-22 17:10:50 -0700193 void setDnsForwarders(in Network network, in String[] dns);
San Mehat873f2142010-01-14 10:25:07 -0800194
195 /**
Lorenzo Colittib57edc52014-08-22 17:10:50 -0700196 * Returns the list of DNS forwarders (in order of priority)
San Mehat873f2142010-01-14 10:25:07 -0800197 */
198 String[] getDnsForwarders();
199
200 /**
Lorenzo Colitti35e36db2015-02-26 01:25:36 +0900201 * Enables unidirectional packet forwarding from {@code fromIface} to
202 * {@code toIface}.
203 */
204 void startInterfaceForwarding(String fromIface, String toIface);
205
206 /**
207 * Disables unidirectional packet forwarding from {@code fromIface} to
208 * {@code toIface}.
209 */
210 void stopInterfaceForwarding(String fromIface, String toIface);
211
212 /**
San Mehat873f2142010-01-14 10:25:07 -0800213 * Enables Network Address Translation between two interfaces.
214 * The address and netmask of the external interface is used for
215 * the NAT'ed network.
216 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000217 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800218 void enableNat(String internalInterface, String externalInterface);
219
220 /**
221 * Disables Network Address Translation between two interfaces.
222 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000223 @UnsupportedAppUsage
San Mehat873f2142010-01-14 10:25:07 -0800224 void disableNat(String internalInterface, String externalInterface);
San Mehat72759df2010-01-19 13:50:37 -0800225
226 /**
Lorenzo Colittief7b2a12017-07-10 19:06:57 +0900227 * Registers a {@code ITetheringStatsProvider} to provide tethering statistics.
228 * All registered providers will be called in order, and their results will be added together.
229 * Netd is always registered as a tethering stats provider.
230 */
231 void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name);
232
233 /**
234 * Unregisters a previously-registered {@code ITetheringStatsProvider}.
235 */
236 void unregisterTetheringStatsProvider(ITetheringStatsProvider provider);
237
238 /**
Lorenzo Colittid66cf562017-08-15 19:25:51 +0900239 * Reports that a tethering provider has reached a data limit.
240 *
241 * Currently triggers a global alert, which causes NetworkStatsService to poll counters and
242 * re-evaluate data usage.
243 *
244 * This does not take an interface name because:
245 * 1. The tethering offload stats provider cannot reliably determine the interface on which the
246 * limit was reached, because the HAL does not provide it.
247 * 2. Firing an interface-specific alert instead of a global alert isn't really useful since in
248 * all cases of interest, the system responds to both in the same way - it polls stats, and
249 * then notifies NetworkPolicyManagerService of the fact.
250 */
251 void tetherLimitReached(ITetheringStatsProvider provider);
252
253 /**
Jeff Sharkey9a13f362011-04-26 16:25:36 -0700254 ** DATA USAGE RELATED
255 **/
San Mehat91cac642010-03-31 14:31:36 -0700256
257 /**
Jeff Sharkeye4984be2013-09-10 21:03:27 -0700258 * Return summary of network statistics all tethering interfaces.
Jeff Sharkeycdd02c5d2011-09-16 01:52:49 -0700259 */
Lorenzo Colitti5356a352017-08-17 19:23:08 +0900260 NetworkStats getNetworkStatsTethering(int how);
Jeff Sharkeycdd02c5d2011-09-16 01:52:49 -0700261
262 /**
Jeff Sharkeyb3f19ca2011-06-29 23:54:13 -0700263 * Set quota for an interface.
Ashish Sharma50fd36d2011-06-15 19:34:53 -0700264 */
Jeff Sharkey41ff7ec2011-07-25 15:21:22 -0700265 void setInterfaceQuota(String iface, long quotaBytes);
Jeff Sharkeyb3f19ca2011-06-29 23:54:13 -0700266
267 /**
268 * Remove quota for an interface.
269 */
270 void removeInterfaceQuota(String iface);
Ashish Sharma50fd36d2011-06-15 19:34:53 -0700271
272 /**
Jeff Sharkey41ff7ec2011-07-25 15:21:22 -0700273 * Set alert for an interface; requires that iface already has quota.
274 */
275 void setInterfaceAlert(String iface, long alertBytes);
276
277 /**
278 * Remove alert for an interface.
279 */
280 void removeInterfaceAlert(String iface);
281
282 /**
283 * Set alert across all interfaces.
284 */
285 void setGlobalAlert(long alertBytes);
286
287 /**
Ashish Sharma50fd36d2011-06-15 19:34:53 -0700288 * Control network activity of a UID over interfaces with a quota limit.
289 */
Felipe Leme65be3022016-03-22 14:53:13 -0700290 void setUidMeteredNetworkBlacklist(int uid, boolean enable);
291 void setUidMeteredNetworkWhitelist(int uid, boolean enable);
292 boolean setDataSaverModeEnabled(boolean enable);
Ashish Sharma50fd36d2011-06-15 19:34:53 -0700293
Jeff Sharkey605eb792014-11-04 13:34:06 -0800294 void setUidCleartextNetworkPolicy(int uid, int policy);
295
Ashish Sharma50fd36d2011-06-15 19:34:53 -0700296 /**
Jeff Sharkey63d27a92011-08-03 17:04:22 -0700297 * Return status of bandwidth control module.
298 */
Andrei Oneadcb67732019-03-18 11:37:25 +0000299 @UnsupportedAppUsage
Jeff Sharkey63d27a92011-08-03 17:04:22 -0700300 boolean isBandwidthControlEnabled();
301
302 /**
Haoyu Bai04124232012-06-28 15:26:19 -0700303 * Sets idletimer for an interface.
304 *
305 * This either initializes a new idletimer or increases its
306 * reference-counting if an idletimer already exists for given
307 * {@code iface}.
308 *
Dianne Hackborn77b987f2014-02-26 16:20:52 -0800309 * {@code type} is the type of the interface, such as TYPE_MOBILE.
Haoyu Bai04124232012-06-28 15:26:19 -0700310 *
311 * Every {@code addIdleTimer} should be paired with a
312 * {@link removeIdleTimer} to cleanup when the network disconnects.
313 */
Dianne Hackborn77b987f2014-02-26 16:20:52 -0800314 void addIdleTimer(String iface, int timeout, int type);
Haoyu Bai04124232012-06-28 15:26:19 -0700315
316 /**
317 * Removes idletimer for an interface.
318 */
319 void removeIdleTimer(String iface);
320
Jeff Sharkeyc268f0b2012-08-24 10:25:31 -0700321 void setFirewallEnabled(boolean enabled);
322 boolean isFirewallEnabled();
Jeff Sharkey2c092982012-08-24 11:44:40 -0700323 void setFirewallInterfaceRule(String iface, boolean allow);
Xiaohui Chenb41c9f72015-06-17 15:55:37 -0700324 void setFirewallUidRule(int chain, int uid, int rule);
325 void setFirewallUidRules(int chain, in int[] uids, in int[] rules);
326 void setFirewallChainEnabled(int chain, boolean enable);
Mattias Falk8b47b362011-08-23 14:15:13 +0200327
328 /**
Paul Jensen6bc2c2c2014-05-07 15:27:40 -0400329 * Set all packets from users in ranges to go through VPN specified by netId.
Chad Brubaker3277620a2013-06-12 13:37:30 -0700330 */
Paul Jensen6bc2c2c2014-05-07 15:27:40 -0400331 void addVpnUidRanges(int netId, in UidRange[] ranges);
Chad Brubaker3277620a2013-06-12 13:37:30 -0700332
333 /**
Paul Jensen6bc2c2c2014-05-07 15:27:40 -0400334 * Clears the special VPN rules for users in ranges and VPN specified by netId.
Chad Brubaker3277620a2013-06-12 13:37:30 -0700335 */
Paul Jensen6bc2c2c2014-05-07 15:27:40 -0400336 void removeVpnUidRanges(int netId, in UidRange[] ranges);
Chad Brubaker3277620a2013-06-12 13:37:30 -0700337
338 /**
Dianne Hackborn77b987f2014-02-26 16:20:52 -0800339 * Start listening for mobile activity state changes.
340 */
341 void registerNetworkActivityListener(INetworkActivityListener listener);
342
343 /**
344 * Stop listening for mobile activity state changes.
345 */
346 void unregisterNetworkActivityListener(INetworkActivityListener listener);
347
348 /**
349 * Check whether the mobile radio is currently active.
350 */
351 boolean isNetworkActive();
Robert Greenwalt9ba9c582014-03-19 17:56:12 -0700352
353 /**
Paul Jensen992f2522014-04-28 10:33:11 -0400354 * Add an interface to a network.
355 */
356 void addInterfaceToNetwork(String iface, int netId);
357
358 /**
359 * Remove an Interface from a network.
360 */
361 void removeInterfaceFromNetwork(String iface, int netId);
362
Robert Greenwalt913c8952014-04-07 17:36:35 -0700363 void addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid);
Robert Greenwalt568891d2014-04-04 13:38:00 -0700364
Sreeram Ramachandranf047f2a2014-04-15 16:04:26 -0700365 void setDefaultNetId(int netId);
Robert Greenwalt568891d2014-04-04 13:38:00 -0700366 void clearDefaultNetId();
367
Paul Jensen487ffe72015-07-24 15:57:11 -0400368 /**
369 * Set permission for a network.
Luke Huang8a462ec2018-08-24 20:33:16 +0800370 * @param permission PERMISSION_NONE to clear permissions.
371 * PERMISSION_NETWORK or PERMISSION_SYSTEM to set permission.
Paul Jensen487ffe72015-07-24 15:57:11 -0400372 */
Luke Huang8a462ec2018-08-24 20:33:16 +0800373 void setNetworkPermission(int netId, int permission);
Paul Jensen487ffe72015-07-24 15:57:11 -0400374
Paul Jensen6bc2c2c2014-05-07 15:27:40 -0400375 /**
376 * Allow UID to call protect().
377 */
378 void allowProtect(int uid);
379
380 /**
381 * Deny UID from calling protect().
382 */
383 void denyProtect(int uid);
Sreeram Ramachandrana77760d2014-07-17 17:09:07 -0700384
385 void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes);
386 void removeInterfaceFromLocalNetwork(String iface);
Erik Kline6599ee82016-07-17 21:28:39 +0900387 int removeRoutesFromLocalNetwork(in List<RouteInfo> routes);
Robin Lee17e61832016-05-09 13:46:28 +0100388
389 void setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges);
Sudheer Shankab8f23162017-08-04 13:30:10 -0700390
391 boolean isNetworkRestricted(int uid);
San Mehat873f2142010-01-14 10:25:07 -0800392}