The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 2008, The Android Open Source Project |
| 3 | * |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 7 | * |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 9 | * |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.net; |
| 18 | |
Robert Greenwalt | 9258c64 | 2014-03-26 16:47:06 -0700 | [diff] [blame] | 19 | import android.app.PendingIntent; |
Jeff Vander Stoep | 0ac2c09 | 2018-07-23 10:57:53 -0700 | [diff] [blame] | 20 | import android.net.ConnectionInfo; |
Robert Greenwalt | d192dad | 2010-09-14 09:18:02 -0700 | [diff] [blame] | 21 | import android.net.LinkProperties; |
Robert Greenwalt | 9258c64 | 2014-03-26 16:47:06 -0700 | [diff] [blame] | 22 | import android.net.Network; |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 23 | import android.net.NetworkCapabilities; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.net.NetworkInfo; |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 25 | import android.net.NetworkMisc; |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 26 | import android.net.NetworkQuotaInfo; |
Robert Greenwalt | 9258c64 | 2014-03-26 16:47:06 -0700 | [diff] [blame] | 27 | import android.net.NetworkRequest; |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 28 | import android.net.NetworkState; |
Jason Monk | 207900c | 2014-04-25 15:00:09 -0400 | [diff] [blame] | 29 | import android.net.ProxyInfo; |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 30 | import android.os.IBinder; |
Robert Greenwalt | 665e1ae | 2012-08-21 19:27:00 -0700 | [diff] [blame] | 31 | import android.os.Messenger; |
Chia-chi Yeh | ff3bdca | 2011-05-23 17:26:46 -0700 | [diff] [blame] | 32 | import android.os.ParcelFileDescriptor; |
Wink Saville | ab9321d | 2013-06-29 21:10:57 -0700 | [diff] [blame] | 33 | import android.os.ResultReceiver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
Chia-chi Yeh | 2e46764 | 2011-07-04 03:23:12 -0700 | [diff] [blame] | 35 | import com.android.internal.net.LegacyVpnInfo; |
Chia-chi Yeh | 04ba25c | 2011-06-15 17:07:27 -0700 | [diff] [blame] | 36 | import com.android.internal.net.VpnConfig; |
Wenchao Tong | f5ea340 | 2015-03-04 13:26:38 -0800 | [diff] [blame] | 37 | import com.android.internal.net.VpnInfo; |
Jeff Sharkey | 82f8521 | 2012-08-24 11:17:25 -0700 | [diff] [blame] | 38 | import com.android.internal.net.VpnProfile; |
Chia-chi Yeh | 04ba25c | 2011-06-15 17:07:27 -0700 | [diff] [blame] | 39 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | /** |
| 41 | * Interface that answers queries about, and allows changing, the |
| 42 | * state of network connectivity. |
| 43 | */ |
| 44 | /** {@hide} */ |
| 45 | interface IConnectivityManager |
| 46 | { |
Paul Jensen | 31a94f4 | 2015-02-13 14:18:39 -0500 | [diff] [blame] | 47 | Network getActiveNetwork(); |
Jeff Sharkey | 1b6519b | 2016-04-28 15:33:18 -0600 | [diff] [blame] | 48 | Network getActiveNetworkForUid(int uid, boolean ignoreBlocked); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | NetworkInfo getActiveNetworkInfo(); |
Jeff Sharkey | 1b6519b | 2016-04-28 15:33:18 -0600 | [diff] [blame] | 50 | NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | NetworkInfo getNetworkInfo(int networkType); |
Jeff Sharkey | 1b6519b | 2016-04-28 15:33:18 -0600 | [diff] [blame] | 52 | NetworkInfo getNetworkInfoForUid(in Network network, int uid, boolean ignoreBlocked); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | NetworkInfo[] getAllNetworkInfo(); |
Lorenzo Colitti | b57edc5 | 2014-08-22 17:10:50 -0700 | [diff] [blame] | 54 | Network getNetworkForType(int networkType); |
Robert Greenwalt | 73b6cbae | 2014-06-23 11:40:00 -0700 | [diff] [blame] | 55 | Network[] getAllNetworks(); |
Lorenzo Colitti | 403aa26 | 2014-11-28 11:21:30 +0900 | [diff] [blame] | 56 | NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | |
Robert Greenwalt | 9b2886e | 2011-08-31 11:46:42 -0700 | [diff] [blame] | 58 | boolean isNetworkSupported(int networkType); |
| 59 | |
Robert Greenwalt | d192dad | 2010-09-14 09:18:02 -0700 | [diff] [blame] | 60 | LinkProperties getActiveLinkProperties(); |
Robert Greenwalt | 9258c64 | 2014-03-26 16:47:06 -0700 | [diff] [blame] | 61 | LinkProperties getLinkPropertiesForType(int networkType); |
| 62 | LinkProperties getLinkProperties(in Network network); |
| 63 | |
| 64 | NetworkCapabilities getNetworkCapabilities(in Network network); |
Robert Greenwalt | d192dad | 2010-09-14 09:18:02 -0700 | [diff] [blame] | 65 | |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 66 | NetworkState[] getAllNetworkState(); |
| 67 | |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 68 | NetworkQuotaInfo getActiveNetworkQuotaInfo(); |
Jeff Sharkey | 9f7cbf0 | 2012-04-12 18:34:54 -0700 | [diff] [blame] | 69 | boolean isActiveNetworkMetered(); |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 70 | |
Sreeram Ramachandran | 03666c7 | 2014-07-19 23:21:46 -0700 | [diff] [blame] | 71 | boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress); |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 72 | |
Tetsutoki Shiozawa | 335d2ed | 2016-03-16 23:30:57 +0900 | [diff] [blame] | 73 | int tether(String iface, String callerPkg); |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 74 | |
Tetsutoki Shiozawa | 335d2ed | 2016-03-16 23:30:57 +0900 | [diff] [blame] | 75 | int untether(String iface, String callerPkg); |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 76 | |
| 77 | int getLastTetherError(String iface); |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 78 | |
Udam Saini | 0e94c36 | 2017-06-07 12:06:28 -0700 | [diff] [blame] | 79 | boolean isTetheringSupported(String callerPkg); |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 80 | |
Tetsutoki Shiozawa | 335d2ed | 2016-03-16 23:30:57 +0900 | [diff] [blame] | 81 | void startTethering(int type, in ResultReceiver receiver, boolean showProvisioningUi, |
| 82 | String callerPkg); |
Jeremy Klein | 36c7aa0 | 2016-01-22 14:11:45 -0800 | [diff] [blame] | 83 | |
Tetsutoki Shiozawa | 335d2ed | 2016-03-16 23:30:57 +0900 | [diff] [blame] | 84 | void stopTethering(int type, String callerPkg); |
Jeremy Klein | 36c7aa0 | 2016-01-22 14:11:45 -0800 | [diff] [blame] | 85 | |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 86 | String[] getTetherableIfaces(); |
| 87 | |
| 88 | String[] getTetheredIfaces(); |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 89 | |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 90 | String[] getTetheringErroredIfaces(); |
| 91 | |
Robert Greenwalt | 9c7e2c2 | 2014-06-23 14:53:42 -0700 | [diff] [blame] | 92 | String[] getTetheredDhcpRanges(); |
| 93 | |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 94 | String[] getTetherableUsbRegexs(); |
| 95 | |
| 96 | String[] getTetherableWifiRegexs(); |
Robert Greenwalt | 14f2ef4 | 2010-06-15 12:19:37 -0700 | [diff] [blame] | 97 | |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 98 | String[] getTetherableBluetoothRegexs(); |
| 99 | |
Tetsutoki Shiozawa | 335d2ed | 2016-03-16 23:30:57 +0900 | [diff] [blame] | 100 | int setUsbTethering(boolean enable, String callerPkg); |
Mike Lockwood | 6c2260b | 2011-07-19 13:04:47 -0700 | [diff] [blame] | 101 | |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 102 | void reportInetCondition(int networkType, int percentage); |
Robert Greenwalt | 434203a | 2010-10-11 16:00:27 -0700 | [diff] [blame] | 103 | |
Paul Jensen | bfd17b7 | 2015-04-07 12:43:13 -0400 | [diff] [blame] | 104 | void reportNetworkConnectivity(in Network network, boolean hasConnectivity); |
Robert Greenwalt | 9258c64 | 2014-03-26 16:47:06 -0700 | [diff] [blame] | 105 | |
Jason Monk | 207900c | 2014-04-25 15:00:09 -0400 | [diff] [blame] | 106 | ProxyInfo getGlobalProxy(); |
Robert Greenwalt | 434203a | 2010-10-11 16:00:27 -0700 | [diff] [blame] | 107 | |
Jason Monk | 207900c | 2014-04-25 15:00:09 -0400 | [diff] [blame] | 108 | void setGlobalProxy(in ProxyInfo p); |
Robert Greenwalt | 434203a | 2010-10-11 16:00:27 -0700 | [diff] [blame] | 109 | |
Paul Jensen | cee9b51 | 2015-05-06 07:32:40 -0400 | [diff] [blame] | 110 | ProxyInfo getProxyForNetwork(in Network nework); |
Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 111 | |
Robin Lee | 3b3dd94 | 2015-05-12 18:14:58 +0100 | [diff] [blame] | 112 | boolean prepareVpn(String oldPackage, String newPackage, int userId); |
Chia-chi Yeh | ff3bdca | 2011-05-23 17:26:46 -0700 | [diff] [blame] | 113 | |
Robin Lee | 3b3dd94 | 2015-05-12 18:14:58 +0100 | [diff] [blame] | 114 | void setVpnPackageAuthorization(String packageName, int userId, boolean authorized); |
Jeff Davidson | 0554260 | 2014-08-11 14:07:27 -0700 | [diff] [blame] | 115 | |
Chia-chi Yeh | 04ba25c | 2011-06-15 17:07:27 -0700 | [diff] [blame] | 116 | ParcelFileDescriptor establishVpn(in VpnConfig config); |
Chia-chi Yeh | 77fd485 | 2011-07-02 17:15:00 -0700 | [diff] [blame] | 117 | |
Robin Lee | 3b3dd94 | 2015-05-12 18:14:58 +0100 | [diff] [blame] | 118 | VpnConfig getVpnConfig(int userId); |
Chad Brubaker | bf6ff2c | 2013-07-16 18:59:12 -0700 | [diff] [blame] | 119 | |
Jeff Sharkey | 82f8521 | 2012-08-24 11:17:25 -0700 | [diff] [blame] | 120 | void startLegacyVpn(in VpnProfile profile); |
Chia-chi Yeh | 2e46764 | 2011-07-04 03:23:12 -0700 | [diff] [blame] | 121 | |
Robin Lee | 3eed5ec | 2015-07-07 12:28:13 -0700 | [diff] [blame] | 122 | LegacyVpnInfo getLegacyVpnInfo(int userId); |
Jeff Sharkey | 69ddab4 | 2012-08-25 00:05:46 -0700 | [diff] [blame] | 123 | |
Wenchao Tong | f5ea340 | 2015-03-04 13:26:38 -0800 | [diff] [blame] | 124 | VpnInfo[] getAllVpnInfo(); |
| 125 | |
Jeff Sharkey | 69ddab4 | 2012-08-25 00:05:46 -0700 | [diff] [blame] | 126 | boolean updateLockdownVpn(); |
Charles He | 3673863 | 2017-05-15 17:07:18 +0100 | [diff] [blame] | 127 | boolean isAlwaysOnVpnPackageSupported(int userId, String packageName); |
Pavel Grafov | bb9cef0 | 2018-12-05 10:40:23 +0000 | [diff] [blame^] | 128 | boolean setAlwaysOnVpnPackage(int userId, String packageName, boolean lockdown, |
| 129 | in List<String> lockdownWhitelist); |
Robin Lee | 244ce8e | 2016-01-05 18:03:46 +0000 | [diff] [blame] | 130 | String getAlwaysOnVpnPackage(int userId); |
Pavel Grafov | bb9cef0 | 2018-12-05 10:40:23 +0000 | [diff] [blame^] | 131 | boolean isVpnLockdownEnabled(int userId); |
| 132 | List<String> getVpnLockdownWhitelist(int userId); |
Irfan Sheriff | da6da09 | 2012-08-16 12:49:23 -0700 | [diff] [blame] | 133 | |
Wink Saville | 948282b | 2013-08-29 08:55:16 -0700 | [diff] [blame] | 134 | int checkMobileProvisioning(int suggestedTimeOutMs); |
Robert Greenwalt | e182bfe | 2013-07-16 12:06:09 -0700 | [diff] [blame] | 135 | |
| 136 | String getMobileProvisioningUrl(); |
Wink Saville | 42d4f08 | 2013-07-20 20:31:59 -0700 | [diff] [blame] | 137 | |
Paul Jensen | 89e0f09 | 2014-09-15 15:59:36 -0400 | [diff] [blame] | 138 | void setProvisioningNotificationVisible(boolean visible, int networkType, in String action); |
Yuhao Zheng | 5cd1a0e | 2013-09-09 17:00:04 -0700 | [diff] [blame] | 139 | |
| 140 | void setAirplaneMode(boolean enable); |
Robert Greenwalt | e049c23 | 2014-04-11 15:53:27 -0700 | [diff] [blame] | 141 | |
Robert Greenwalt | a67be03 | 2014-05-16 15:49:14 -0700 | [diff] [blame] | 142 | void registerNetworkFactory(in Messenger messenger, in String name); |
| 143 | |
fenglu | db57147 | 2015-04-21 17:12:05 -0700 | [diff] [blame] | 144 | boolean requestBandwidthUpdate(in Network network); |
fenglu | b15e72b | 2015-03-20 11:29:56 -0700 | [diff] [blame] | 145 | |
Robert Greenwalt | a67be03 | 2014-05-16 15:49:14 -0700 | [diff] [blame] | 146 | void unregisterNetworkFactory(in Messenger messenger); |
Robert Greenwalt | 7b81602 | 2014-04-18 15:25:25 -0700 | [diff] [blame] | 147 | |
Paul Jensen | 31a94f4 | 2015-02-13 14:18:39 -0500 | [diff] [blame] | 148 | int registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp, |
Sreeram Ramachandran | 8cd33ed | 2014-07-23 15:23:15 -0700 | [diff] [blame] | 149 | in NetworkCapabilities nc, int score, in NetworkMisc misc); |
Robert Greenwalt | 9258c64 | 2014-03-26 16:47:06 -0700 | [diff] [blame] | 150 | |
| 151 | NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities, |
Robert Greenwalt | b90b20b | 2014-06-02 15:32:02 -0700 | [diff] [blame] | 152 | in Messenger messenger, int timeoutSec, in IBinder binder, int legacy); |
Robert Greenwalt | 9258c64 | 2014-03-26 16:47:06 -0700 | [diff] [blame] | 153 | |
| 154 | NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities, |
| 155 | in PendingIntent operation); |
| 156 | |
Jeremy Joslin | 46e3ac8 | 2014-11-05 10:32:09 -0800 | [diff] [blame] | 157 | void releasePendingNetworkRequest(in PendingIntent operation); |
| 158 | |
Robert Greenwalt | 9258c64 | 2014-03-26 16:47:06 -0700 | [diff] [blame] | 159 | NetworkRequest listenForNetwork(in NetworkCapabilities networkCapabilities, |
| 160 | in Messenger messenger, in IBinder binder); |
| 161 | |
| 162 | void pendingListenForNetwork(in NetworkCapabilities networkCapabilities, |
| 163 | in PendingIntent operation); |
| 164 | |
| 165 | void releaseNetworkRequest(in NetworkRequest networkRequest); |
Robert Greenwalt | 71bf33a | 2014-05-15 18:07:26 -0700 | [diff] [blame] | 166 | |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 167 | void setAcceptUnvalidated(in Network network, boolean accept, boolean always); |
Lorenzo Colitti | 165c51c | 2016-09-19 01:00:19 +0900 | [diff] [blame] | 168 | void setAvoidUnvalidated(in Network network); |
Lorenzo Colitti | 4734cdb | 2017-04-27 14:30:21 +0900 | [diff] [blame] | 169 | void startCaptivePortalApp(in Network network); |
Lorenzo Colitti | e03c3c7 | 2015-04-03 16:38:52 +0900 | [diff] [blame] | 170 | |
Lorenzo Colitti | 46aa9c0 | 2017-01-24 18:08:41 +0900 | [diff] [blame] | 171 | int getMultipathPreference(in Network Network); |
| 172 | |
Remi NGUYEN VAN | e67b0c3 | 2018-12-27 16:43:56 +0900 | [diff] [blame] | 173 | NetworkRequest getDefaultRequest(); |
| 174 | |
Robert Greenwalt | 71bf33a | 2014-05-15 18:07:26 -0700 | [diff] [blame] | 175 | int getRestoreDefaultNetworkDelay(int networkType); |
Sreeram Ramachandran | f4e0c0c | 2014-07-27 14:18:26 -0700 | [diff] [blame] | 176 | |
| 177 | boolean addVpnAddress(String address, int prefixLength); |
| 178 | boolean removeVpnAddress(String address, int prefixLength); |
Sreeram Ramachandran | c2c0bea | 2014-11-11 16:09:21 -0800 | [diff] [blame] | 179 | boolean setUnderlyingNetworksForVpn(in Network[] networks); |
Stuart Scott | f1fb397 | 2015-04-02 18:00:02 -0700 | [diff] [blame] | 180 | |
| 181 | void factoryReset(); |
Lorenzo Colitti | 8bf977d | 2015-06-15 14:29:22 +0900 | [diff] [blame] | 182 | |
| 183 | void startNattKeepalive(in Network network, int intervalSeconds, in Messenger messenger, |
| 184 | in IBinder binder, String srcAddr, int srcPort, String dstAddr); |
| 185 | |
| 186 | void stopKeepalive(in Network network, int slot); |
Udam Saini | b7c2487 | 2016-01-04 12:16:14 -0800 | [diff] [blame] | 187 | |
| 188 | String getCaptivePortalServerUrl(); |
Ricky Wai | 44dcbde | 2018-01-23 04:09:45 +0000 | [diff] [blame] | 189 | |
| 190 | byte[] getNetworkWatchlistConfigHash(); |
Jeff Vander Stoep | 0ac2c09 | 2018-07-23 10:57:53 -0700 | [diff] [blame] | 191 | |
| 192 | int getConnectionOwnerUid(in ConnectionInfo connectionInfo); |
Pavel Grafov | cb3b895 | 2018-12-14 13:51:07 +0000 | [diff] [blame] | 193 | boolean isCallerCurrentAlwaysOnVpnApp(); |
| 194 | boolean isCallerCurrentAlwaysOnVpnLockdownApp(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | } |