1 /**
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 
17 package android.net;
18 
19 import android.app.PendingIntent;
20 import android.net.LinkProperties;
21 import android.net.Network;
22 import android.net.NetworkCapabilities;
23 import android.net.NetworkInfo;
24 import android.net.NetworkMisc;
25 import android.net.NetworkQuotaInfo;
26 import android.net.NetworkRequest;
27 import android.net.NetworkState;
28 import android.net.ProxyInfo;
29 import android.os.IBinder;
30 import android.os.Messenger;
31 import android.os.ParcelFileDescriptor;
32 import android.os.ResultReceiver;
33 
34 import com.android.internal.net.LegacyVpnInfo;
35 import com.android.internal.net.VpnConfig;
36 import com.android.internal.net.VpnInfo;
37 import com.android.internal.net.VpnProfile;
38 
39 /**
40  * Interface that answers queries about, and allows changing, the
41  * state of network connectivity.
42  */
43 /** {@hide} */
44 interface IConnectivityManager
45 {
getActiveNetwork()46     Network getActiveNetwork();
getActiveNetworkForUid(int uid, boolean ignoreBlocked)47     Network getActiveNetworkForUid(int uid, boolean ignoreBlocked);
getActiveNetworkInfo()48     NetworkInfo getActiveNetworkInfo();
getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked)49     NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked);
getNetworkInfo(int networkType)50     NetworkInfo getNetworkInfo(int networkType);
getNetworkInfoForUid(in Network network, int uid, boolean ignoreBlocked)51     NetworkInfo getNetworkInfoForUid(in Network network, int uid, boolean ignoreBlocked);
getAllNetworkInfo()52     NetworkInfo[] getAllNetworkInfo();
getNetworkForType(int networkType)53     Network getNetworkForType(int networkType);
getAllNetworks()54     Network[] getAllNetworks();
getDefaultNetworkCapabilitiesForUser(int userId)55     NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId);
56 
isNetworkSupported(int networkType)57     boolean isNetworkSupported(int networkType);
58 
getActiveLinkProperties()59     LinkProperties getActiveLinkProperties();
getLinkPropertiesForType(int networkType)60     LinkProperties getLinkPropertiesForType(int networkType);
getLinkProperties(in Network network)61     LinkProperties getLinkProperties(in Network network);
62 
getNetworkCapabilities(in Network network)63     NetworkCapabilities getNetworkCapabilities(in Network network);
64 
getAllNetworkState()65     NetworkState[] getAllNetworkState();
66 
getActiveNetworkQuotaInfo()67     NetworkQuotaInfo getActiveNetworkQuotaInfo();
isActiveNetworkMetered()68     boolean isActiveNetworkMetered();
69 
requestRouteToHostAddress(int networkType, in byte[] hostAddress)70     boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress);
71 
tether(String iface, String callerPkg)72     int tether(String iface, String callerPkg);
73 
untether(String iface, String callerPkg)74     int untether(String iface, String callerPkg);
75 
getLastTetherError(String iface)76     int getLastTetherError(String iface);
77 
isTetheringSupported(String callerPkg)78     boolean isTetheringSupported(String callerPkg);
79 
startTethering(int type, in ResultReceiver receiver, boolean showProvisioningUi, String callerPkg)80     void startTethering(int type, in ResultReceiver receiver, boolean showProvisioningUi,
81             String callerPkg);
82 
stopTethering(int type, String callerPkg)83     void stopTethering(int type, String callerPkg);
84 
getTetherableIfaces()85     String[] getTetherableIfaces();
86 
getTetheredIfaces()87     String[] getTetheredIfaces();
88 
getTetheringErroredIfaces()89     String[] getTetheringErroredIfaces();
90 
getTetheredDhcpRanges()91     String[] getTetheredDhcpRanges();
92 
getTetherableUsbRegexs()93     String[] getTetherableUsbRegexs();
94 
getTetherableWifiRegexs()95     String[] getTetherableWifiRegexs();
96 
getTetherableBluetoothRegexs()97     String[] getTetherableBluetoothRegexs();
98 
setUsbTethering(boolean enable, String callerPkg)99     int setUsbTethering(boolean enable, String callerPkg);
100 
reportInetCondition(int networkType, int percentage)101     void reportInetCondition(int networkType, int percentage);
102 
reportNetworkConnectivity(in Network network, boolean hasConnectivity)103     void reportNetworkConnectivity(in Network network, boolean hasConnectivity);
104 
getGlobalProxy()105     ProxyInfo getGlobalProxy();
106 
setGlobalProxy(in ProxyInfo p)107     void setGlobalProxy(in ProxyInfo p);
108 
getProxyForNetwork(in Network nework)109     ProxyInfo getProxyForNetwork(in Network nework);
110 
prepareVpn(String oldPackage, String newPackage, int userId)111     boolean prepareVpn(String oldPackage, String newPackage, int userId);
112 
setVpnPackageAuthorization(String packageName, int userId, boolean authorized)113     void setVpnPackageAuthorization(String packageName, int userId, boolean authorized);
114 
establishVpn(in VpnConfig config)115     ParcelFileDescriptor establishVpn(in VpnConfig config);
116 
getVpnConfig(int userId)117     VpnConfig getVpnConfig(int userId);
118 
startLegacyVpn(in VpnProfile profile)119     void startLegacyVpn(in VpnProfile profile);
120 
getLegacyVpnInfo(int userId)121     LegacyVpnInfo getLegacyVpnInfo(int userId);
122 
getAllVpnInfo()123     VpnInfo[] getAllVpnInfo();
124 
updateLockdownVpn()125     boolean updateLockdownVpn();
isAlwaysOnVpnPackageSupported(int userId, String packageName)126     boolean isAlwaysOnVpnPackageSupported(int userId, String packageName);
setAlwaysOnVpnPackage(int userId, String packageName, boolean lockdown)127     boolean setAlwaysOnVpnPackage(int userId, String packageName, boolean lockdown);
getAlwaysOnVpnPackage(int userId)128     String getAlwaysOnVpnPackage(int userId);
129 
checkMobileProvisioning(int suggestedTimeOutMs)130     int checkMobileProvisioning(int suggestedTimeOutMs);
131 
getMobileProvisioningUrl()132     String getMobileProvisioningUrl();
133 
setProvisioningNotificationVisible(boolean visible, int networkType, in String action)134     void setProvisioningNotificationVisible(boolean visible, int networkType, in String action);
135 
setAirplaneMode(boolean enable)136     void setAirplaneMode(boolean enable);
137 
registerNetworkFactory(in Messenger messenger, in String name)138     void registerNetworkFactory(in Messenger messenger, in String name);
139 
requestBandwidthUpdate(in Network network)140     boolean requestBandwidthUpdate(in Network network);
141 
unregisterNetworkFactory(in Messenger messenger)142     void unregisterNetworkFactory(in Messenger messenger);
143 
registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp, in NetworkCapabilities nc, int score, in NetworkMisc misc)144     int registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp,
145             in NetworkCapabilities nc, int score, in NetworkMisc misc);
146 
requestNetwork(in NetworkCapabilities networkCapabilities, in Messenger messenger, int timeoutSec, in IBinder binder, int legacy)147     NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities,
148             in Messenger messenger, int timeoutSec, in IBinder binder, int legacy);
149 
pendingRequestForNetwork(in NetworkCapabilities networkCapabilities, in PendingIntent operation)150     NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities,
151             in PendingIntent operation);
152 
releasePendingNetworkRequest(in PendingIntent operation)153     void releasePendingNetworkRequest(in PendingIntent operation);
154 
listenForNetwork(in NetworkCapabilities networkCapabilities, in Messenger messenger, in IBinder binder)155     NetworkRequest listenForNetwork(in NetworkCapabilities networkCapabilities,
156             in Messenger messenger, in IBinder binder);
157 
pendingListenForNetwork(in NetworkCapabilities networkCapabilities, in PendingIntent operation)158     void pendingListenForNetwork(in NetworkCapabilities networkCapabilities,
159             in PendingIntent operation);
160 
releaseNetworkRequest(in NetworkRequest networkRequest)161     void releaseNetworkRequest(in NetworkRequest networkRequest);
162 
setAcceptUnvalidated(in Network network, boolean accept, boolean always)163     void setAcceptUnvalidated(in Network network, boolean accept, boolean always);
setAvoidUnvalidated(in Network network)164     void setAvoidUnvalidated(in Network network);
startCaptivePortalApp(in Network network)165     void startCaptivePortalApp(in Network network);
166 
getMultipathPreference(in Network Network)167     int getMultipathPreference(in Network Network);
168 
getRestoreDefaultNetworkDelay(int networkType)169     int getRestoreDefaultNetworkDelay(int networkType);
170 
addVpnAddress(String address, int prefixLength)171     boolean addVpnAddress(String address, int prefixLength);
removeVpnAddress(String address, int prefixLength)172     boolean removeVpnAddress(String address, int prefixLength);
setUnderlyingNetworksForVpn(in Network[] networks)173     boolean setUnderlyingNetworksForVpn(in Network[] networks);
174 
factoryReset()175     void factoryReset();
176 
startNattKeepalive(in Network network, int intervalSeconds, in Messenger messenger, in IBinder binder, String srcAddr, int srcPort, String dstAddr)177     void startNattKeepalive(in Network network, int intervalSeconds, in Messenger messenger,
178             in IBinder binder, String srcAddr, int srcPort, String dstAddr);
179 
stopKeepalive(in Network network, int slot)180     void stopKeepalive(in Network network, int slot);
181 
getCaptivePortalServerUrl()182     String getCaptivePortalServerUrl();
183 
getNetworkWatchlistConfigHash()184     byte[] getNetworkWatchlistConfigHash();
185 }
186