1 /* //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 18 package android.os; 19 20 import android.net.InterfaceConfiguration; 21 import android.net.INetworkManagementEventObserver; 22 import android.net.ITetheringStatsProvider; 23 import android.net.Network; 24 import android.net.NetworkStats; 25 import android.net.RouteInfo; 26 import android.net.UidRange; 27 import android.os.INetworkActivityListener; 28 29 /** 30 * @hide 31 */ 32 interface INetworkManagementService 33 { 34 /** 35 ** GENERAL 36 **/ 37 38 /** 39 * Register an observer to receive events. 40 */ 41 @UnsupportedAppUsage registerObserver(INetworkManagementEventObserver obs)42 void registerObserver(INetworkManagementEventObserver obs); 43 44 /** 45 * Unregister an observer from receiving events. 46 */ 47 @UnsupportedAppUsage unregisterObserver(INetworkManagementEventObserver obs)48 void unregisterObserver(INetworkManagementEventObserver obs); 49 50 /** 51 * Returns a list of currently known network interfaces 52 */ listInterfaces()53 String[] listInterfaces(); 54 55 /** 56 * Retrieves the specified interface config 57 * 58 */ 59 @UnsupportedAppUsage getInterfaceConfig(String iface)60 InterfaceConfiguration getInterfaceConfig(String iface); 61 62 /** 63 * Sets the configuration of the specified interface 64 */ 65 @UnsupportedAppUsage setInterfaceConfig(String iface, in InterfaceConfiguration cfg)66 void setInterfaceConfig(String iface, in InterfaceConfiguration cfg); 67 68 /** 69 * Clear all IP addresses on the specified interface 70 */ 71 @UnsupportedAppUsage clearInterfaceAddresses(String iface)72 void clearInterfaceAddresses(String iface); 73 74 /** 75 * Set interface down 76 */ setInterfaceDown(String iface)77 void setInterfaceDown(String iface); 78 79 /** 80 * Set interface up 81 */ setInterfaceUp(String iface)82 void setInterfaceUp(String iface); 83 84 /** 85 * Set interface IPv6 privacy extensions 86 */ 87 @UnsupportedAppUsage setInterfaceIpv6PrivacyExtensions(String iface, boolean enable)88 void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable); 89 90 /** 91 * Disable IPv6 on an interface 92 */ 93 @UnsupportedAppUsage disableIpv6(String iface)94 void disableIpv6(String iface); 95 96 /** 97 * Enable IPv6 on an interface 98 */ 99 @UnsupportedAppUsage enableIpv6(String iface)100 void enableIpv6(String iface); 101 102 /** 103 * Set IPv6 autoconf address generation mode. 104 * This is a no-op if an unsupported mode is requested. 105 */ 106 @UnsupportedAppUsage setIPv6AddrGenMode(String iface, int mode)107 void setIPv6AddrGenMode(String iface, int mode); 108 109 /** 110 * Add the specified route to the interface. 111 */ addRoute(int netId, in RouteInfo route)112 void addRoute(int netId, in RouteInfo route); 113 114 /** 115 * Remove the specified route from the interface. 116 */ removeRoute(int netId, in RouteInfo route)117 void removeRoute(int netId, in RouteInfo route); 118 119 /** 120 * Set the specified MTU size 121 */ setMtu(String iface, int mtu)122 void setMtu(String iface, int mtu); 123 124 /** 125 * Shuts down the service 126 */ shutdown()127 void shutdown(); 128 129 /** 130 ** TETHERING RELATED 131 **/ 132 133 /** 134 * Returns true if IP forwarding is enabled 135 */ 136 @UnsupportedAppUsage getIpForwardingEnabled()137 boolean getIpForwardingEnabled(); 138 139 /** 140 * Enables/Disables IP Forwarding 141 */ 142 @UnsupportedAppUsage setIpForwardingEnabled(boolean enabled)143 void setIpForwardingEnabled(boolean enabled); 144 145 /** 146 * Start tethering services with the specified dhcp server range 147 * arg is a set of start end pairs defining the ranges. 148 */ 149 @UnsupportedAppUsage startTethering(in String[] dhcpRanges)150 void startTethering(in String[] dhcpRanges); 151 152 /** 153 * 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 */ startTetheringWithConfiguration(boolean usingLegacyDnsProxy, in String[] dhcpRanges)158 void startTetheringWithConfiguration(boolean usingLegacyDnsProxy, in String[] dhcpRanges); 159 160 /** 161 * Stop currently running tethering services 162 */ 163 @UnsupportedAppUsage stopTethering()164 void stopTethering(); 165 166 /** 167 * Returns true if tethering services are started 168 */ 169 @UnsupportedAppUsage isTetheringStarted()170 boolean isTetheringStarted(); 171 172 /** 173 * Tethers the specified interface 174 */ 175 @UnsupportedAppUsage tetherInterface(String iface)176 void tetherInterface(String iface); 177 178 /** 179 * Untethers the specified interface 180 */ 181 @UnsupportedAppUsage untetherInterface(String iface)182 void untetherInterface(String iface); 183 184 /** 185 * Returns a list of currently tethered interfaces 186 */ 187 @UnsupportedAppUsage listTetheredInterfaces()188 String[] listTetheredInterfaces(); 189 190 /** 191 * Sets the list of DNS forwarders (in order of priority) 192 */ setDnsForwarders(in Network network, in String[] dns)193 void setDnsForwarders(in Network network, in String[] dns); 194 195 /** 196 * Returns the list of DNS forwarders (in order of priority) 197 */ getDnsForwarders()198 String[] getDnsForwarders(); 199 200 /** 201 * Enables unidirectional packet forwarding from {@code fromIface} to 202 * {@code toIface}. 203 */ startInterfaceForwarding(String fromIface, String toIface)204 void startInterfaceForwarding(String fromIface, String toIface); 205 206 /** 207 * Disables unidirectional packet forwarding from {@code fromIface} to 208 * {@code toIface}. 209 */ stopInterfaceForwarding(String fromIface, String toIface)210 void stopInterfaceForwarding(String fromIface, String toIface); 211 212 /** 213 * 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 */ 217 @UnsupportedAppUsage enableNat(String internalInterface, String externalInterface)218 void enableNat(String internalInterface, String externalInterface); 219 220 /** 221 * Disables Network Address Translation between two interfaces. 222 */ 223 @UnsupportedAppUsage disableNat(String internalInterface, String externalInterface)224 void disableNat(String internalInterface, String externalInterface); 225 226 /** 227 * 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 */ registerTetheringStatsProvider(ITetheringStatsProvider provider, String name)231 void registerTetheringStatsProvider(ITetheringStatsProvider provider, String name); 232 233 /** 234 * Unregisters a previously-registered {@code ITetheringStatsProvider}. 235 */ unregisterTetheringStatsProvider(ITetheringStatsProvider provider)236 void unregisterTetheringStatsProvider(ITetheringStatsProvider provider); 237 238 /** 239 * 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 */ tetherLimitReached(ITetheringStatsProvider provider)251 void tetherLimitReached(ITetheringStatsProvider provider); 252 253 /** 254 ** DATA USAGE RELATED 255 **/ 256 257 /** 258 * Return summary of network statistics all tethering interfaces. 259 */ getNetworkStatsTethering(int how)260 NetworkStats getNetworkStatsTethering(int how); 261 262 /** 263 * Set quota for an interface. 264 */ setInterfaceQuota(String iface, long quotaBytes)265 void setInterfaceQuota(String iface, long quotaBytes); 266 267 /** 268 * Remove quota for an interface. 269 */ removeInterfaceQuota(String iface)270 void removeInterfaceQuota(String iface); 271 272 /** 273 * Set alert for an interface; requires that iface already has quota. 274 */ setInterfaceAlert(String iface, long alertBytes)275 void setInterfaceAlert(String iface, long alertBytes); 276 277 /** 278 * Remove alert for an interface. 279 */ removeInterfaceAlert(String iface)280 void removeInterfaceAlert(String iface); 281 282 /** 283 * Set alert across all interfaces. 284 */ setGlobalAlert(long alertBytes)285 void setGlobalAlert(long alertBytes); 286 287 /** 288 * Control network activity of a UID over interfaces with a quota limit. 289 */ setUidMeteredNetworkBlacklist(int uid, boolean enable)290 void setUidMeteredNetworkBlacklist(int uid, boolean enable); setUidMeteredNetworkWhitelist(int uid, boolean enable)291 void setUidMeteredNetworkWhitelist(int uid, boolean enable); setDataSaverModeEnabled(boolean enable)292 boolean setDataSaverModeEnabled(boolean enable); 293 setUidCleartextNetworkPolicy(int uid, int policy)294 void setUidCleartextNetworkPolicy(int uid, int policy); 295 296 /** 297 * Return status of bandwidth control module. 298 */ 299 @UnsupportedAppUsage isBandwidthControlEnabled()300 boolean isBandwidthControlEnabled(); 301 302 /** 303 * 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 * 309 * {@code type} is the type of the interface, such as TYPE_MOBILE. 310 * 311 * Every {@code addIdleTimer} should be paired with a 312 * {@link removeIdleTimer} to cleanup when the network disconnects. 313 */ addIdleTimer(String iface, int timeout, int type)314 void addIdleTimer(String iface, int timeout, int type); 315 316 /** 317 * Removes idletimer for an interface. 318 */ removeIdleTimer(String iface)319 void removeIdleTimer(String iface); 320 setFirewallEnabled(boolean enabled)321 void setFirewallEnabled(boolean enabled); isFirewallEnabled()322 boolean isFirewallEnabled(); setFirewallInterfaceRule(String iface, boolean allow)323 void setFirewallInterfaceRule(String iface, boolean allow); setFirewallUidRule(int chain, int uid, int rule)324 void setFirewallUidRule(int chain, int uid, int rule); setFirewallUidRules(int chain, in int[] uids, in int[] rules)325 void setFirewallUidRules(int chain, in int[] uids, in int[] rules); setFirewallChainEnabled(int chain, boolean enable)326 void setFirewallChainEnabled(int chain, boolean enable); 327 328 /** 329 * Set all packets from users in ranges to go through VPN specified by netId. 330 */ addVpnUidRanges(int netId, in UidRange[] ranges)331 void addVpnUidRanges(int netId, in UidRange[] ranges); 332 333 /** 334 * Clears the special VPN rules for users in ranges and VPN specified by netId. 335 */ removeVpnUidRanges(int netId, in UidRange[] ranges)336 void removeVpnUidRanges(int netId, in UidRange[] ranges); 337 338 /** 339 * Start listening for mobile activity state changes. 340 */ registerNetworkActivityListener(INetworkActivityListener listener)341 void registerNetworkActivityListener(INetworkActivityListener listener); 342 343 /** 344 * Stop listening for mobile activity state changes. 345 */ unregisterNetworkActivityListener(INetworkActivityListener listener)346 void unregisterNetworkActivityListener(INetworkActivityListener listener); 347 348 /** 349 * Check whether the mobile radio is currently active. 350 */ isNetworkActive()351 boolean isNetworkActive(); 352 353 /** 354 * Add an interface to a network. 355 */ addInterfaceToNetwork(String iface, int netId)356 void addInterfaceToNetwork(String iface, int netId); 357 358 /** 359 * Remove an Interface from a network. 360 */ removeInterfaceFromNetwork(String iface, int netId)361 void removeInterfaceFromNetwork(String iface, int netId); 362 addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid)363 void addLegacyRouteForNetId(int netId, in RouteInfo routeInfo, int uid); 364 setDefaultNetId(int netId)365 void setDefaultNetId(int netId); clearDefaultNetId()366 void clearDefaultNetId(); 367 368 /** 369 * Set permission for a network. 370 * @param permission PERMISSION_NONE to clear permissions. 371 * PERMISSION_NETWORK or PERMISSION_SYSTEM to set permission. 372 */ setNetworkPermission(int netId, int permission)373 void setNetworkPermission(int netId, int permission); 374 375 /** 376 * Allow UID to call protect(). 377 */ allowProtect(int uid)378 void allowProtect(int uid); 379 380 /** 381 * Deny UID from calling protect(). 382 */ denyProtect(int uid)383 void denyProtect(int uid); 384 addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes)385 void addInterfaceToLocalNetwork(String iface, in List<RouteInfo> routes); removeInterfaceFromLocalNetwork(String iface)386 void removeInterfaceFromLocalNetwork(String iface); removeRoutesFromLocalNetwork(in List<RouteInfo> routes)387 int removeRoutesFromLocalNetwork(in List<RouteInfo> routes); 388 setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges)389 void setAllowOnlyVpnForUids(boolean enable, in UidRange[] uidRanges); 390 isNetworkRestricted(int uid)391 boolean isNetworkRestricted(int uid); 392 } 393