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.Network;
23 import android.net.NetworkStats;
24 import android.net.RouteInfo;
25 
26 /**
27  * @hide
28  */
29 interface INetworkManagementService
30 {
31     /**
32      ** GENERAL
33      **/
34 
35     /**
36      * Register an observer to receive events.
37      */
38     @UnsupportedAppUsage
registerObserver(INetworkManagementEventObserver obs)39     void registerObserver(INetworkManagementEventObserver obs);
40 
41     /**
42      * Unregister an observer from receiving events.
43      */
44     @UnsupportedAppUsage
unregisterObserver(INetworkManagementEventObserver obs)45     void unregisterObserver(INetworkManagementEventObserver obs);
46 
47     /**
48      * Returns a list of currently known network interfaces
49      */
listInterfaces()50     String[] listInterfaces();
51 
52     /**
53      * Retrieves the specified interface config
54      *
55      */
56     @UnsupportedAppUsage
getInterfaceConfig(String iface)57     InterfaceConfiguration getInterfaceConfig(String iface);
58 
59     /**
60      * Sets the configuration of the specified interface
61      */
62     @UnsupportedAppUsage
setInterfaceConfig(String iface, in InterfaceConfiguration cfg)63     void setInterfaceConfig(String iface, in InterfaceConfiguration cfg);
64 
65     /**
66      * Clear all IP addresses on the specified interface
67      */
68     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
clearInterfaceAddresses(String iface)69     void clearInterfaceAddresses(String iface);
70 
71     /**
72      * Set interface down
73      */
setInterfaceDown(String iface)74     void setInterfaceDown(String iface);
75 
76     /**
77      * Set interface up
78      */
setInterfaceUp(String iface)79     void setInterfaceUp(String iface);
80 
81     /**
82      * Set interface IPv6 privacy extensions
83      */
84     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setInterfaceIpv6PrivacyExtensions(String iface, boolean enable)85     void setInterfaceIpv6PrivacyExtensions(String iface, boolean enable);
86 
87     /**
88      * Disable IPv6 on an interface
89      */
90     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
disableIpv6(String iface)91     void disableIpv6(String iface);
92 
93     /**
94      * Enable IPv6 on an interface
95      */
96     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
enableIpv6(String iface)97     void enableIpv6(String iface);
98 
99     /**
100      * Set IPv6 autoconf address generation mode.
101      * This is a no-op if an unsupported mode is requested.
102      */
103     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setIPv6AddrGenMode(String iface, int mode)104     void setIPv6AddrGenMode(String iface, int mode);
105 
106     /**
107      * Shuts down the service
108      */
109     @EnforcePermission("SHUTDOWN")
shutdown()110     void shutdown();
111 
112     /**
113      ** TETHERING RELATED
114      **/
115 
116     /**
117      * Returns true if IP forwarding is enabled
118      */
119     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
120             publicAlternatives = "Use {@code android.net.INetd#ipfwdEnabled}")
getIpForwardingEnabled()121     boolean getIpForwardingEnabled();
122 
123     /**
124      * Enables/Disables IP Forwarding
125      */
126     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
127             publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
128             + "{@code android.net.TetheringManager#startTethering}. See also "
129             + "{@code INetd#ipfwdEnableForwarding(String)}.")
setIpForwardingEnabled(boolean enabled)130     void setIpForwardingEnabled(boolean enabled);
131 
132     /**
133      * Start tethering services with the specified dhcp server range
134      * arg is a set of start end pairs defining the ranges.
135      */
136     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
137             publicAlternatives = "{@code android.net.TetheringManager#startTethering}")
startTethering(in String[] dhcpRanges)138     void startTethering(in String[] dhcpRanges);
139 
140     /**
141      * Stop currently running tethering services
142      */
143     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
144             publicAlternatives = "{@code android.net.TetheringManager#stopTethering(int)}")
stopTethering()145     void stopTethering();
146 
147     /**
148      * Returns true if tethering services are started
149      */
150     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
151             publicAlternatives = "Generally track your own tethering requests. "
152             + "See also {@code android.net.INetd#tetherIsEnabled()}")
isTetheringStarted()153     boolean isTetheringStarted();
154 
155     /**
156      * Tethers the specified interface
157      */
158     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
159             publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
160             + "{@code android.net.TetheringManager#startTethering}. See also "
161             + "{@code com.android.net.module.util.NetdUtils#tetherInterface}.")
tetherInterface(String iface)162     void tetherInterface(String iface);
163 
164     /**
165      * Untethers the specified interface
166      */
167     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
168             publicAlternatives = "Avoid using this directly. Instead, disable "
169             + "tethering with {@code android.net.TetheringManager#stopTethering(int)}. "
170             + "See also {@code NetdUtils#untetherInterface}.")
untetherInterface(String iface)171     void untetherInterface(String iface);
172 
173     /**
174      * Returns a list of currently tethered interfaces
175      */
176     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
177             publicAlternatives = "{@code android.net.TetheringManager#getTetheredIfaces()}")
listTetheredInterfaces()178     String[] listTetheredInterfaces();
179 
180     /**
181      *  Enables Network Address Translation between two interfaces.
182      *  The address and netmask of the external interface is used for
183      *  the NAT'ed network.
184      */
185     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
186             publicAlternatives = "Avoid using this directly. Instead, enable tethering with "
187             + "{@code android.net.TetheringManager#startTethering}.")
enableNat(String internalInterface, String externalInterface)188     void enableNat(String internalInterface, String externalInterface);
189 
190     /**
191      *  Disables Network Address Translation between two interfaces.
192      */
193     @UnsupportedAppUsage(maxTargetSdk = 34, trackingBug = 170729553,
194             publicAlternatives = "Avoid using this directly. Instead, disable tethering with "
195             + "{@code android.net.TetheringManager#stopTethering(int)}.")
disableNat(String internalInterface, String externalInterface)196     void disableNat(String internalInterface, String externalInterface);
197 
198     /**
199      ** DATA USAGE RELATED
200      **/
201 
202     /**
203      * Set quota for an interface.
204      */
setInterfaceQuota(String iface, long quotaBytes)205     void setInterfaceQuota(String iface, long quotaBytes);
206 
207     /**
208      * Remove quota for an interface.
209      */
removeInterfaceQuota(String iface)210     void removeInterfaceQuota(String iface);
211 
212     /**
213      * Set alert for an interface; requires that iface already has quota.
214      */
setInterfaceAlert(String iface, long alertBytes)215     void setInterfaceAlert(String iface, long alertBytes);
216 
217     /**
218      * Remove alert for an interface.
219      */
removeInterfaceAlert(String iface)220     void removeInterfaceAlert(String iface);
221 
222     /**
223      * Control network activity of a UID over interfaces with a quota limit.
224      */
setUidOnMeteredNetworkDenylist(int uid, boolean enable)225     void setUidOnMeteredNetworkDenylist(int uid, boolean enable);
setUidOnMeteredNetworkAllowlist(int uid, boolean enable)226     void setUidOnMeteredNetworkAllowlist(int uid, boolean enable);
227     @EnforcePermission("NETWORK_SETTINGS")
setDataSaverModeEnabled(boolean enable)228     boolean setDataSaverModeEnabled(boolean enable);
229 
setUidCleartextNetworkPolicy(int uid, int policy)230     void setUidCleartextNetworkPolicy(int uid, int policy);
231 
232     /**
233      * Return status of bandwidth control module.
234      */
235     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
isBandwidthControlEnabled()236     boolean isBandwidthControlEnabled();
237 
setFirewallEnabled(boolean enabled)238     void setFirewallEnabled(boolean enabled);
isFirewallEnabled()239     boolean isFirewallEnabled();
setFirewallUidRule(int chain, int uid, int rule)240     void setFirewallUidRule(int chain, int uid, int rule);
setFirewallUidRules(int chain, in int[] uids, in int[] rules)241     void setFirewallUidRules(int chain, in int[] uids, in int[] rules);
setFirewallChainEnabled(int chain, boolean enable)242     void setFirewallChainEnabled(int chain, boolean enable);
243 
244     /**
245      * Allow UID to call protect().
246      */
allowProtect(int uid)247     void allowProtect(int uid);
248 
249     /**
250      * Deny UID from calling protect().
251      */
denyProtect(int uid)252     void denyProtect(int uid);
253 
254     @EnforcePermission("OBSERVE_NETWORK_POLICY")
isNetworkRestricted(int uid)255     boolean isNetworkRestricted(int uid);
256 }
257