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