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