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.ConnectivityDiagnosticsManager; 22 import android.net.IConnectivityDiagnosticsCallback; 23 import android.net.INetworkAgent; 24 import android.net.IOnCompleteListener; 25 import android.net.INetworkActivityListener; 26 import android.net.INetworkOfferCallback; 27 import android.net.IQosCallback; 28 import android.net.ISocketKeepaliveCallback; 29 import android.net.LinkProperties; 30 import android.net.Network; 31 import android.net.NetworkAgentConfig; 32 import android.net.NetworkCapabilities; 33 import android.net.NetworkInfo; 34 import android.net.NetworkRequest; 35 import android.net.NetworkScore; 36 import android.net.NetworkState; 37 import android.net.NetworkStateSnapshot; 38 import android.net.OemNetworkPreferences; 39 import android.net.ProxyInfo; 40 import android.net.UidRange; 41 import android.net.QosSocketInfo; 42 import android.os.Bundle; 43 import android.os.IBinder; 44 import android.os.Messenger; 45 import android.os.ParcelFileDescriptor; 46 import android.os.PersistableBundle; 47 import android.os.ResultReceiver; 48 import android.os.UserHandle; 49 50 /** 51 * Interface that answers queries about, and allows changing, the 52 * state of network connectivity. 53 */ 54 /** {@hide} */ 55 interface IConnectivityManager 56 { getActiveNetwork()57 Network getActiveNetwork(); getActiveNetworkForUid(int uid, boolean ignoreBlocked)58 Network getActiveNetworkForUid(int uid, boolean ignoreBlocked); 59 @UnsupportedAppUsage getActiveNetworkInfo()60 NetworkInfo getActiveNetworkInfo(); getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked)61 NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked); 62 @UnsupportedAppUsage(maxTargetSdk = 28) getNetworkInfo(int networkType)63 NetworkInfo getNetworkInfo(int networkType); getNetworkInfoForUid(in Network network, int uid, boolean ignoreBlocked)64 NetworkInfo getNetworkInfoForUid(in Network network, int uid, boolean ignoreBlocked); 65 @UnsupportedAppUsage getAllNetworkInfo()66 NetworkInfo[] getAllNetworkInfo(); getNetworkForType(int networkType)67 Network getNetworkForType(int networkType); getAllNetworks()68 Network[] getAllNetworks(); getDefaultNetworkCapabilitiesForUser( int userId, String callingPackageName, String callingAttributionTag)69 NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser( 70 int userId, String callingPackageName, String callingAttributionTag); 71 isNetworkSupported(int networkType)72 boolean isNetworkSupported(int networkType); 73 74 @UnsupportedAppUsage getActiveLinkProperties()75 LinkProperties getActiveLinkProperties(); getLinkPropertiesForType(int networkType)76 LinkProperties getLinkPropertiesForType(int networkType); getLinkProperties(in Network network)77 LinkProperties getLinkProperties(in Network network); 78 getNetworkCapabilities(in Network network, String callingPackageName, String callingAttributionTag)79 NetworkCapabilities getNetworkCapabilities(in Network network, String callingPackageName, 80 String callingAttributionTag); 81 82 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) getAllNetworkState()83 NetworkState[] getAllNetworkState(); 84 getAllNetworkStateSnapshots()85 List<NetworkStateSnapshot> getAllNetworkStateSnapshots(); 86 isActiveNetworkMetered()87 boolean isActiveNetworkMetered(); 88 requestRouteToHostAddress(int networkType, in byte[] hostAddress, String callingPackageName, String callingAttributionTag)89 boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, 90 String callingPackageName, String callingAttributionTag); 91 92 @UnsupportedAppUsage(maxTargetSdk = 29, 93 publicAlternatives = "Use {@code TetheringManager#getLastTetherError} as alternative") getLastTetherError(String iface)94 int getLastTetherError(String iface); 95 96 @UnsupportedAppUsage(maxTargetSdk = 29, 97 publicAlternatives = "Use {@code TetheringManager#getTetherableIfaces} as alternative") getTetherableIfaces()98 String[] getTetherableIfaces(); 99 100 @UnsupportedAppUsage(maxTargetSdk = 29, 101 publicAlternatives = "Use {@code TetheringManager#getTetheredIfaces} as alternative") getTetheredIfaces()102 String[] getTetheredIfaces(); 103 104 @UnsupportedAppUsage(maxTargetSdk = 29, 105 publicAlternatives = "Use {@code TetheringManager#getTetheringErroredIfaces} " 106 + "as Alternative") getTetheringErroredIfaces()107 String[] getTetheringErroredIfaces(); 108 109 @UnsupportedAppUsage(maxTargetSdk = 29, 110 publicAlternatives = "Use {@code TetheringManager#getTetherableUsbRegexs} as alternative") getTetherableUsbRegexs()111 String[] getTetherableUsbRegexs(); 112 113 @UnsupportedAppUsage(maxTargetSdk = 29, 114 publicAlternatives = "Use {@code TetheringManager#getTetherableWifiRegexs} as alternative") getTetherableWifiRegexs()115 String[] getTetherableWifiRegexs(); 116 117 @UnsupportedAppUsage(maxTargetSdk = 28) reportInetCondition(int networkType, int percentage)118 void reportInetCondition(int networkType, int percentage); 119 reportNetworkConnectivity(in Network network, boolean hasConnectivity)120 void reportNetworkConnectivity(in Network network, boolean hasConnectivity); 121 getGlobalProxy()122 ProxyInfo getGlobalProxy(); 123 setGlobalProxy(in ProxyInfo p)124 void setGlobalProxy(in ProxyInfo p); 125 getProxyForNetwork(in Network nework)126 ProxyInfo getProxyForNetwork(in Network nework); 127 setRequireVpnForUids(boolean requireVpn, in UidRange[] ranges)128 void setRequireVpnForUids(boolean requireVpn, in UidRange[] ranges); setLegacyLockdownVpnEnabled(boolean enabled)129 void setLegacyLockdownVpnEnabled(boolean enabled); 130 setProvisioningNotificationVisible(boolean visible, int networkType, in String action)131 void setProvisioningNotificationVisible(boolean visible, int networkType, in String action); 132 setAirplaneMode(boolean enable)133 void setAirplaneMode(boolean enable); 134 requestBandwidthUpdate(in Network network)135 boolean requestBandwidthUpdate(in Network network); 136 registerNetworkProvider(in Messenger messenger, in String name)137 int registerNetworkProvider(in Messenger messenger, in String name); unregisterNetworkProvider(in Messenger messenger)138 void unregisterNetworkProvider(in Messenger messenger); 139 declareNetworkRequestUnfulfillable(in NetworkRequest request)140 void declareNetworkRequestUnfulfillable(in NetworkRequest request); 141 registerNetworkAgent(in INetworkAgent na, in NetworkInfo ni, in LinkProperties lp, in NetworkCapabilities nc, in NetworkScore score, in NetworkAgentConfig config, in int factorySerialNumber)142 Network registerNetworkAgent(in INetworkAgent na, in NetworkInfo ni, in LinkProperties lp, 143 in NetworkCapabilities nc, in NetworkScore score, in NetworkAgentConfig config, 144 in int factorySerialNumber); 145 requestNetwork(int uid, in NetworkCapabilities networkCapabilities, int reqType, in Messenger messenger, int timeoutSec, in IBinder binder, int legacy, int callbackFlags, String callingPackageName, String callingAttributionTag)146 NetworkRequest requestNetwork(int uid, in NetworkCapabilities networkCapabilities, int reqType, 147 in Messenger messenger, int timeoutSec, in IBinder binder, int legacy, 148 int callbackFlags, String callingPackageName, String callingAttributionTag); 149 pendingRequestForNetwork(in NetworkCapabilities networkCapabilities, in PendingIntent operation, String callingPackageName, String callingAttributionTag)150 NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities, 151 in PendingIntent operation, String callingPackageName, String callingAttributionTag); 152 releasePendingNetworkRequest(in PendingIntent operation)153 void releasePendingNetworkRequest(in PendingIntent operation); 154 listenForNetwork(in NetworkCapabilities networkCapabilities, in Messenger messenger, in IBinder binder, int callbackFlags, String callingPackageName, String callingAttributionTag)155 NetworkRequest listenForNetwork(in NetworkCapabilities networkCapabilities, 156 in Messenger messenger, in IBinder binder, int callbackFlags, String callingPackageName, 157 String callingAttributionTag); 158 pendingListenForNetwork(in NetworkCapabilities networkCapabilities, in PendingIntent operation, String callingPackageName, String callingAttributionTag)159 void pendingListenForNetwork(in NetworkCapabilities networkCapabilities, 160 in PendingIntent operation, String callingPackageName, 161 String callingAttributionTag); 162 releaseNetworkRequest(in NetworkRequest networkRequest)163 void releaseNetworkRequest(in NetworkRequest networkRequest); 164 setAcceptUnvalidated(in Network network, boolean accept, boolean always)165 void setAcceptUnvalidated(in Network network, boolean accept, boolean always); setAcceptPartialConnectivity(in Network network, boolean accept, boolean always)166 void setAcceptPartialConnectivity(in Network network, boolean accept, boolean always); setAvoidUnvalidated(in Network network)167 void setAvoidUnvalidated(in Network network); startCaptivePortalApp(in Network network)168 void startCaptivePortalApp(in Network network); startCaptivePortalAppInternal(in Network network, in Bundle appExtras)169 void startCaptivePortalAppInternal(in Network network, in Bundle appExtras); 170 shouldAvoidBadWifi()171 boolean shouldAvoidBadWifi(); getMultipathPreference(in Network Network)172 int getMultipathPreference(in Network Network); 173 getDefaultRequest()174 NetworkRequest getDefaultRequest(); 175 getRestoreDefaultNetworkDelay(int networkType)176 int getRestoreDefaultNetworkDelay(int networkType); 177 factoryReset()178 void factoryReset(); 179 startNattKeepalive(in Network network, int intervalSeconds, in ISocketKeepaliveCallback cb, String srcAddr, int srcPort, String dstAddr)180 void startNattKeepalive(in Network network, int intervalSeconds, 181 in ISocketKeepaliveCallback cb, String srcAddr, int srcPort, String dstAddr); 182 startNattKeepaliveWithFd(in Network network, in ParcelFileDescriptor pfd, int resourceId, int intervalSeconds, in ISocketKeepaliveCallback cb, String srcAddr, String dstAddr)183 void startNattKeepaliveWithFd(in Network network, in ParcelFileDescriptor pfd, int resourceId, 184 int intervalSeconds, in ISocketKeepaliveCallback cb, String srcAddr, 185 String dstAddr); 186 startTcpKeepalive(in Network network, in ParcelFileDescriptor pfd, int intervalSeconds, in ISocketKeepaliveCallback cb)187 void startTcpKeepalive(in Network network, in ParcelFileDescriptor pfd, int intervalSeconds, 188 in ISocketKeepaliveCallback cb); 189 stopKeepalive(in Network network, int slot)190 void stopKeepalive(in Network network, int slot); 191 getCaptivePortalServerUrl()192 String getCaptivePortalServerUrl(); 193 getNetworkWatchlistConfigHash()194 byte[] getNetworkWatchlistConfigHash(); 195 getConnectionOwnerUid(in ConnectionInfo connectionInfo)196 int getConnectionOwnerUid(in ConnectionInfo connectionInfo); 197 registerConnectivityDiagnosticsCallback(in IConnectivityDiagnosticsCallback callback, in NetworkRequest request, String callingPackageName)198 void registerConnectivityDiagnosticsCallback(in IConnectivityDiagnosticsCallback callback, 199 in NetworkRequest request, String callingPackageName); unregisterConnectivityDiagnosticsCallback(in IConnectivityDiagnosticsCallback callback)200 void unregisterConnectivityDiagnosticsCallback(in IConnectivityDiagnosticsCallback callback); 201 startOrGetTestNetworkService()202 IBinder startOrGetTestNetworkService(); 203 simulateDataStall(int detectionMethod, long timestampMillis, in Network network, in PersistableBundle extras)204 void simulateDataStall(int detectionMethod, long timestampMillis, in Network network, 205 in PersistableBundle extras); 206 systemReady()207 void systemReady(); 208 registerNetworkActivityListener(in INetworkActivityListener l)209 void registerNetworkActivityListener(in INetworkActivityListener l); 210 unregisterNetworkActivityListener(in INetworkActivityListener l)211 void unregisterNetworkActivityListener(in INetworkActivityListener l); 212 isDefaultNetworkActive()213 boolean isDefaultNetworkActive(); 214 registerQosSocketCallback(in QosSocketInfo socketInfo, in IQosCallback callback)215 void registerQosSocketCallback(in QosSocketInfo socketInfo, in IQosCallback callback); unregisterQosCallback(in IQosCallback callback)216 void unregisterQosCallback(in IQosCallback callback); 217 setOemNetworkPreference(in OemNetworkPreferences preference, in IOnCompleteListener listener)218 void setOemNetworkPreference(in OemNetworkPreferences preference, 219 in IOnCompleteListener listener); 220 setProfileNetworkPreference(in UserHandle profile, int preference, in IOnCompleteListener listener)221 void setProfileNetworkPreference(in UserHandle profile, int preference, 222 in IOnCompleteListener listener); 223 getRestrictBackgroundStatusByCaller()224 int getRestrictBackgroundStatusByCaller(); 225 offerNetwork(int providerId, in NetworkScore score, in NetworkCapabilities caps, in INetworkOfferCallback callback)226 void offerNetwork(int providerId, in NetworkScore score, 227 in NetworkCapabilities caps, in INetworkOfferCallback callback); unofferNetwork(in INetworkOfferCallback callback)228 void unofferNetwork(in INetworkOfferCallback callback); 229 setTestAllowBadWifiUntil(long timeMs)230 void setTestAllowBadWifiUntil(long timeMs); 231 } 232