• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.app.PendingIntent;
22 import android.content.Context;
23 import android.net.IpSecManager.UdpEncapsulationSocket;
24 import android.net.SocketKeepalive.Callback;
25 import android.os.Bundle;
26 import android.os.Handler;
27 import android.os.Messenger;
28 import android.os.ParcelFileDescriptor;
29 import android.os.PersistableBundle;
30 
31 import java.net.InetAddress;
32 import java.net.InetSocketAddress;
33 import java.net.Socket;
34 import java.util.List;
35 import java.util.concurrent.Executor;
36 
37 import static android.os._Original_Build.VERSION_CODES.BASE;
38 
39 /**
40  * Stub ConnectivityManager for layoutlib
41  */
42 public class ConnectivityManager {
43     @Deprecated
44     public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
45 
46     public static final String ACTION_CAPTIVE_PORTAL_SIGN_IN = "android.net.conn.CAPTIVE_PORTAL";
47 
48     @Deprecated
49     public static final String EXTRA_NETWORK_INFO = "networkInfo";
50     @Deprecated
51     public static final String EXTRA_NETWORK_TYPE = "networkType";
52 
53     @Deprecated
54     public static final String EXTRA_IS_FAILOVER = "isFailover";
55     @Deprecated
56     public static final String EXTRA_OTHER_NETWORK_INFO = "otherNetwork";
57     public static final String EXTRA_NO_CONNECTIVITY = "noConnectivity";
58     public static final String EXTRA_REASON = "reason";
59     @Deprecated
60     public static final String EXTRA_EXTRA_INFO = "extraInfo";
61     public static final String EXTRA_INET_CONDITION = "inetCondition";
62     public static final String EXTRA_CAPTIVE_PORTAL = "android.net.extra.CAPTIVE_PORTAL";
63 
64     public static final String EXTRA_CAPTIVE_PORTAL_URL = "android.net.extra.CAPTIVE_PORTAL_URL";
65 
66     public static final String EXTRA_CAPTIVE_PORTAL_PROBE_SPEC =
67             "android.net.extra.CAPTIVE_PORTAL_PROBE_SPEC";
68 
69     public static final String EXTRA_CAPTIVE_PORTAL_USER_AGENT =
70             "android.net.extra.CAPTIVE_PORTAL_USER_AGENT";
71 
72     public static final String ACTION_DATA_ACTIVITY_CHANGE =
73             "android.net.conn.DATA_ACTIVITY_CHANGE";
74     public static final String EXTRA_DEVICE_TYPE = "deviceType";
75     public static final String EXTRA_IS_ACTIVE = "isActive";
76     public static final String EXTRA_REALTIME_NS = "tsNanos";
77 
78     @Deprecated
79     public static final String ACTION_BACKGROUND_DATA_SETTING_CHANGED =
80             "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED";
81 
82     public static final String INET_CONDITION_ACTION =
83             "android.net.conn.INET_CONDITION_ACTION";
84 
85     public static final String ACTION_TETHER_STATE_CHANGED =
86             TetheringManager.ACTION_TETHER_STATE_CHANGED;
87 
88     public static final String EXTRA_AVAILABLE_TETHER = TetheringManager.EXTRA_AVAILABLE_TETHER;
89 
90     public static final String EXTRA_ACTIVE_LOCAL_ONLY = TetheringManager.EXTRA_ACTIVE_LOCAL_ONLY;
91 
92     public static final String EXTRA_ACTIVE_TETHER = TetheringManager.EXTRA_ACTIVE_TETHER;
93 
94     public static final String EXTRA_ERRORED_TETHER = TetheringManager.EXTRA_ERRORED_TETHER;
95 
96     public static final String ACTION_CAPTIVE_PORTAL_TEST_COMPLETED =
97             "android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED";
98     public static final String EXTRA_IS_CAPTIVE_PORTAL = "captivePortal";
99 
100     public static final String ACTION_PROMPT_UNVALIDATED = "android.net.conn.PROMPT_UNVALIDATED";
101 
102     public static final String ACTION_PROMPT_LOST_VALIDATION =
103             "android.net.conn.PROMPT_LOST_VALIDATION";
104 
105     public static final String ACTION_PROMPT_PARTIAL_CONNECTIVITY =
106             "android.net.conn.PROMPT_PARTIAL_CONNECTIVITY";
107 
108     public static final int TETHERING_INVALID   = TetheringManager.TETHERING_INVALID;
109 
110     public static final int TETHERING_WIFI      = TetheringManager.TETHERING_WIFI;
111 
112     public static final int TETHERING_USB       = TetheringManager.TETHERING_USB;
113 
114     public static final int TETHERING_BLUETOOTH = TetheringManager.TETHERING_BLUETOOTH;
115 
116     public static final int TETHERING_WIFI_P2P = TetheringManager.TETHERING_WIFI_P2P;
117 
118     public static final int TYPE_NONE        = -1;
119 
120     @Deprecated
121     public static final int TYPE_MOBILE      = 0;
122 
123     @Deprecated
124     public static final int TYPE_WIFI        = 1;
125 
126     @Deprecated
127     public static final int TYPE_MOBILE_MMS  = 2;
128 
129     @Deprecated
130     public static final int TYPE_MOBILE_SUPL = 3;
131 
132     @Deprecated
133     public static final int TYPE_MOBILE_DUN  = 4;
134 
135     @Deprecated
136     public static final int TYPE_MOBILE_HIPRI = 5;
137 
138     @Deprecated
139     public static final int TYPE_WIMAX       = 6;
140 
141     @Deprecated
142     public static final int TYPE_BLUETOOTH   = 7;
143 
144     @Deprecated
145     public static final int TYPE_DUMMY       = 8;
146 
147     @Deprecated
148     public static final int TYPE_ETHERNET    = 9;
149 
150     @Deprecated
151     public static final int TYPE_MOBILE_FOTA = 10;
152 
153     @Deprecated
154     public static final int TYPE_MOBILE_IMS  = 11;
155 
156     @Deprecated
157     public static final int TYPE_MOBILE_CBS  = 12;
158 
159     @Deprecated
160     public static final int TYPE_WIFI_P2P    = 13;
161 
162     @Deprecated
163     public static final int TYPE_MOBILE_IA = 14;
164 
165     @Deprecated
166     public static final int TYPE_MOBILE_EMERGENCY = 15;
167 
168     @Deprecated
169     public static final int TYPE_PROXY = 16;
170 
171     @Deprecated
172     public static final int TYPE_VPN = 17;
173 
174     @Deprecated
175     public static final int TYPE_TEST = 18; // TODO: Remove this once NetworkTypes are unused.
176 
177     @Deprecated
178     public @interface LegacyNetworkType {}
179 
180     public static final int MAX_RADIO_TYPE = TYPE_TEST;
181 
182     public static final int MAX_NETWORK_TYPE = TYPE_TEST;
183 
184     @Deprecated
185     public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
186 
187     public static final int REQUEST_ID_UNSET = 0;
188 
189     public static final int NETID_UNSET = 0;
190     public static final String PRIVATE_DNS_MODE_OFF = "off";
191     public static final String PRIVATE_DNS_MODE_OPPORTUNISTIC = "opportunistic";
192     public static final String PRIVATE_DNS_MODE_PROVIDER_HOSTNAME = "hostname";
193     public static final String PRIVATE_DNS_DEFAULT_MODE_FALLBACK = PRIVATE_DNS_MODE_OPPORTUNISTIC;
194 
195     private static ConnectivityManager sInstance;
196 
197     @Deprecated
isNetworkTypeValid(int networkType)198     public static boolean isNetworkTypeValid(int networkType) {
199         return false;
200     }
201 
202     @Deprecated
getNetworkTypeName(int type)203     public static String getNetworkTypeName(int type) {
204         return null;
205     }
206 
207     @Deprecated
isNetworkTypeMobile(int networkType)208     public static boolean isNetworkTypeMobile(int networkType) {
209         return false;
210     }
211 
212     @Deprecated
isNetworkTypeWifi(int networkType)213     public static boolean isNetworkTypeWifi(int networkType) {
214         return false;
215     }
216 
217     @Deprecated
setNetworkPreference(int preference)218     public void setNetworkPreference(int preference) {
219     }
220 
221     @Deprecated
getNetworkPreference()222     public int getNetworkPreference() {
223         return TYPE_NONE;
224     }
225 
226     @Deprecated
227     @Nullable
getActiveNetworkInfo()228     public NetworkInfo getActiveNetworkInfo() {
229         return null;
230     }
231 
232     @Nullable
getActiveNetwork()233     public Network getActiveNetwork() {
234         return null;
235     }
236 
237     @Nullable
getActiveNetworkForUid(int uid)238     public Network getActiveNetworkForUid(int uid) {
239         return null;
240     }
241 
getActiveNetworkForUid(int uid, boolean ignoreBlocked)242     public Network getActiveNetworkForUid(int uid, boolean ignoreBlocked) {
243         return null;
244     }
245 
isAlwaysOnVpnPackageSupportedForUser(int userId, @Nullable String vpnPackage)246     public boolean isAlwaysOnVpnPackageSupportedForUser(int userId, @Nullable String vpnPackage) {
247         return false;
248     }
249 
setAlwaysOnVpnPackageForUser(int userId, @Nullable String vpnPackage, boolean lockdownEnabled, @Nullable List<String> lockdownList)250     public boolean setAlwaysOnVpnPackageForUser(int userId, @Nullable String vpnPackage,
251             boolean lockdownEnabled, @Nullable List<String> lockdownList) {
252         return false;
253     }
254 
getAlwaysOnVpnPackageForUser(int userId)255     public String getAlwaysOnVpnPackageForUser(int userId) {
256         return null;
257     }
258 
isVpnLockdownEnabled(int userId)259     public boolean isVpnLockdownEnabled(int userId) {
260         return false;
261     }
262 
getVpnLockdownWhitelist(int userId)263     public List<String> getVpnLockdownWhitelist(int userId) {
264         return null;
265     }
266 
getActiveNetworkInfoForUid(int uid)267     public NetworkInfo getActiveNetworkInfoForUid(int uid) {
268         return null;
269     }
270 
getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked)271     public NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked) {
272         return null;
273     }
274 
275     @Deprecated
276     @Nullable
getNetworkInfo(int networkType)277     public NetworkInfo getNetworkInfo(int networkType) {
278         return null;
279     }
280 
281     @Deprecated
282     @Nullable
getNetworkInfo(@ullable Network network)283     public NetworkInfo getNetworkInfo(@Nullable Network network) {
284         return null;
285     }
286 
getNetworkInfoForUid(Network network, int uid, boolean ignoreBlocked)287     public NetworkInfo getNetworkInfoForUid(Network network, int uid, boolean ignoreBlocked) {
288         return null;
289     }
290 
291     @Deprecated
292     @NonNull
getAllNetworkInfo()293     public NetworkInfo[] getAllNetworkInfo() {
294         return new NetworkInfo[0];
295     }
296 
297     @Deprecated
getNetworkForType(int networkType)298     public Network getNetworkForType(int networkType) {
299         return null;
300     }
301 
302     @NonNull
getAllNetworks()303     public Network[] getAllNetworks() {
304         return new Network[0];
305     }
306 
getDefaultNetworkCapabilitiesForUser(int userId)307     public NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId) {
308         return null;
309     }
310 
getActiveLinkProperties()311     public LinkProperties getActiveLinkProperties() {
312         return null;
313     }
314 
315     @Deprecated
getLinkProperties(int networkType)316     public LinkProperties getLinkProperties(int networkType) {
317         return null;
318     }
319 
320     @Nullable
getLinkProperties(@ullable Network network)321     public LinkProperties getLinkProperties(@Nullable Network network) {
322         return null;
323     }
324 
325     @Nullable
getNetworkCapabilities(@ullable Network network)326     public NetworkCapabilities getNetworkCapabilities(@Nullable Network network) {
327         return null;
328     }
329 
330     @Deprecated
getCaptivePortalServerUrl()331     public String getCaptivePortalServerUrl() {
332         return null;
333     }
334 
335     @Deprecated
startUsingNetworkFeature(int networkType, String feature)336     public int startUsingNetworkFeature(int networkType, String feature) {
337         return -1;
338     }
339 
340     @Deprecated
stopUsingNetworkFeature(int networkType, String feature)341     public int stopUsingNetworkFeature(int networkType, String feature) {
342         return -1;
343     }
344 
networkCapabilitiesForType(int type)345     public static NetworkCapabilities networkCapabilitiesForType(int type) {
346         return null;
347     }
348 
349     public static class PacketKeepaliveCallback {
PacketKeepaliveCallback()350         public PacketKeepaliveCallback() {
351         }
onStarted()352         public void onStarted() {}
onStopped()353         public void onStopped() {}
onError(int error)354         public void onError(int error) {}
355     }
356 
357     public class PacketKeepalive {
358         public static final int SUCCESS = 0;
359 
360         public static final int NO_KEEPALIVE = -1;
361 
362         public static final int BINDER_DIED = -10;
363 
364         public static final int ERROR_INVALID_NETWORK = -20;
365         public static final int ERROR_INVALID_IP_ADDRESS = -21;
366         public static final int ERROR_INVALID_PORT = -22;
367         public static final int ERROR_INVALID_LENGTH = -23;
368         public static final int ERROR_INVALID_INTERVAL = -24;
369 
370         public static final int ERROR_HARDWARE_UNSUPPORTED = -30;
371         public static final int ERROR_HARDWARE_ERROR = -31;
372 
373         public static final int NATT_PORT = 4500;
374 
375         public static final int MIN_INTERVAL = 10;
376 
stop()377         public void stop() {}
378     }
379 
startNattKeepalive( Network network, int intervalSeconds, PacketKeepaliveCallback callback, InetAddress srcAddr, int srcPort, InetAddress dstAddr)380     public PacketKeepalive startNattKeepalive(
381             Network network, int intervalSeconds, PacketKeepaliveCallback callback,
382             InetAddress srcAddr, int srcPort, InetAddress dstAddr) {
383         return null;
384     }
385 
createSocketKeepalive(@onNull Network network, @NonNull UdpEncapsulationSocket socket, @NonNull InetAddress source, @NonNull InetAddress destination, @NonNull Executor executor, @NonNull Callback callback)386     public @NonNull SocketKeepalive createSocketKeepalive(@NonNull Network network,
387             @NonNull UdpEncapsulationSocket socket,
388             @NonNull InetAddress source,
389             @NonNull InetAddress destination,
390             @NonNull Executor executor,
391             @NonNull Callback callback) {
392         throw new UnsupportedOperationException(
393                 "createSocketKeepalive is not supported in layoutlib");
394     }
395 
createNattKeepalive(@onNull Network network, @NonNull ParcelFileDescriptor pfd, @NonNull InetAddress source, @NonNull InetAddress destination, @NonNull Executor executor, @NonNull Callback callback)396     public @NonNull SocketKeepalive createNattKeepalive(@NonNull Network network,
397             @NonNull ParcelFileDescriptor pfd,
398             @NonNull InetAddress source,
399             @NonNull InetAddress destination,
400             @NonNull Executor executor,
401             @NonNull Callback callback) {
402         throw new UnsupportedOperationException(
403                 "createSocketKeepalive is not supported in layoutlib");
404     }
405 
createSocketKeepalive(@onNull Network network, @NonNull Socket socket, @NonNull Executor executor, @NonNull Callback callback)406     public @NonNull SocketKeepalive createSocketKeepalive(@NonNull Network network,
407             @NonNull Socket socket,
408             @NonNull Executor executor,
409             @NonNull Callback callback) {
410         throw new UnsupportedOperationException(
411                 "createSocketKeepalive is not supported in layoutlib");
412     }
413 
414     @Deprecated
requestRouteToHost(int networkType, int hostAddress)415     public boolean requestRouteToHost(int networkType, int hostAddress) {
416         return false;
417     }
418 
419     @Deprecated
requestRouteToHostAddress(int networkType, InetAddress hostAddress)420     public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) {
421         return false;
422     }
423 
424     @Deprecated
getBackgroundDataSetting()425     public boolean getBackgroundDataSetting() {
426         return false;
427     }
428 
429     @Deprecated
setBackgroundDataSetting(boolean allowBackgroundData)430     public void setBackgroundDataSetting(boolean allowBackgroundData) {}
431 
432     @Deprecated
getMobileDataEnabled()433     public boolean getMobileDataEnabled() {
434         return false;
435     }
436 
437     public interface OnNetworkActiveListener {
onNetworkActive()438         void onNetworkActive();
439     }
440 
addDefaultNetworkActiveListener(final OnNetworkActiveListener l)441     public void addDefaultNetworkActiveListener(final OnNetworkActiveListener l) {}
442 
removeDefaultNetworkActiveListener(@onNull OnNetworkActiveListener l)443     public void removeDefaultNetworkActiveListener(@NonNull OnNetworkActiveListener l) {}
444 
isDefaultNetworkActive()445     public boolean isDefaultNetworkActive() {
446         return false;
447     }
448 
ConnectivityManager(Context context, IConnectivityManager service)449     public ConnectivityManager(Context context, IConnectivityManager service) {
450         sInstance = this;
451     }
452 
from(Context context)453     public static ConnectivityManager from(Context context) {
454         return new ConnectivityManager(context, null);
455     }
456 
getDefaultRequest()457     public NetworkRequest getDefaultRequest() {
458         return null;
459     }
460 
enforceChangePermission(Context context)461     public static final void enforceChangePermission(Context context) {}
462 
463     @Deprecated
getInstanceOrNull()464     static ConnectivityManager getInstanceOrNull() {
465         return sInstance;
466     }
467 
468     @Deprecated
getInstance()469     private static ConnectivityManager getInstance() {
470         if (getInstanceOrNull() == null) {
471             throw new IllegalStateException("No ConnectivityManager yet constructed");
472         }
473         return getInstanceOrNull();
474     }
475 
476     @Deprecated
getTetherableIfaces()477     public String[] getTetherableIfaces() {
478         return null;
479     }
480 
481     @Deprecated
getTetheredIfaces()482     public String[] getTetheredIfaces() {
483         return null;
484     }
485 
486     @Deprecated
getTetheringErroredIfaces()487     public String[] getTetheringErroredIfaces() {
488         return null;
489     }
490 
491     @Deprecated
getTetheredDhcpRanges()492     public String[] getTetheredDhcpRanges() {
493         throw new UnsupportedOperationException("getTetheredDhcpRanges is not supported");
494     }
495 
496     @Deprecated
tether(String iface)497     public int tether(String iface) {
498         return 0;
499     }
500 
501     @Deprecated
untether(String iface)502     public int untether(String iface) {
503         return 0;
504     }
505 
isTetheringSupported()506     public boolean isTetheringSupported() {
507         return false;
508     }
509 
510     @Deprecated
511     public static abstract class OnStartTetheringCallback {
onTetheringStarted()512         public void onTetheringStarted() {}
513 
onTetheringFailed()514         public void onTetheringFailed() {}
515     }
516 
517     @Deprecated
startTethering(int type, boolean showProvisioningUi, final OnStartTetheringCallback callback)518     public void startTethering(int type, boolean showProvisioningUi,
519             final OnStartTetheringCallback callback) {}
520 
521     @Deprecated
startTethering(int type, boolean showProvisioningUi, final OnStartTetheringCallback callback, Handler handler)522     public void startTethering(int type, boolean showProvisioningUi,
523             final OnStartTetheringCallback callback, Handler handler) {}
524 
525     @Deprecated
stopTethering(int type)526     public void stopTethering(int type) {}
527 
528     @Deprecated
529     public abstract static class OnTetheringEventCallback {
530 
onUpstreamChanged(@ullable Network network)531         public void onUpstreamChanged(@Nullable Network network) {}
532     }
533 
534     @Deprecated
registerTetheringEventCallback( @onNull Executor executor, @NonNull final OnTetheringEventCallback callback)535     public void registerTetheringEventCallback(
536             @NonNull Executor executor,
537             @NonNull final OnTetheringEventCallback callback) {}
538 
539     @Deprecated
unregisterTetheringEventCallback( @onNull final OnTetheringEventCallback callback)540     public void unregisterTetheringEventCallback(
541             @NonNull final OnTetheringEventCallback callback) {}
542 
543 
544     @Deprecated
getTetherableUsbRegexs()545     public String[] getTetherableUsbRegexs() {
546         return null;
547     }
548 
549     @Deprecated
getTetherableWifiRegexs()550     public String[] getTetherableWifiRegexs() {
551         return null;
552     }
553 
554     @Deprecated
getTetherableBluetoothRegexs()555     public String[] getTetherableBluetoothRegexs() {
556         return null;
557     }
558 
559     @Deprecated
setUsbTethering(boolean enable)560     public int setUsbTethering(boolean enable) {
561         return 0;
562     }
563 
564     @Deprecated
565     public static final int TETHER_ERROR_NO_ERROR = TetheringManager.TETHER_ERROR_NO_ERROR;
566     @Deprecated
567     public static final int TETHER_ERROR_UNKNOWN_IFACE =
568             TetheringManager.TETHER_ERROR_UNKNOWN_IFACE;
569     @Deprecated
570     public static final int TETHER_ERROR_SERVICE_UNAVAIL =
571             TetheringManager.TETHER_ERROR_SERVICE_UNAVAIL;
572     @Deprecated
573     public static final int TETHER_ERROR_UNSUPPORTED = TetheringManager.TETHER_ERROR_UNSUPPORTED;
574     @Deprecated
575     public static final int TETHER_ERROR_UNAVAIL_IFACE =
576             TetheringManager.TETHER_ERROR_UNAVAIL_IFACE;
577     @Deprecated
578     public static final int TETHER_ERROR_MASTER_ERROR =
579             TetheringManager.TETHER_ERROR_INTERNAL_ERROR;
580     @Deprecated
581     public static final int TETHER_ERROR_TETHER_IFACE_ERROR =
582             TetheringManager.TETHER_ERROR_TETHER_IFACE_ERROR;
583     @Deprecated
584     public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR =
585             TetheringManager.TETHER_ERROR_UNTETHER_IFACE_ERROR;
586     @Deprecated
587     public static final int TETHER_ERROR_ENABLE_NAT_ERROR =
588             TetheringManager.TETHER_ERROR_ENABLE_FORWARDING_ERROR;
589     @Deprecated
590     public static final int TETHER_ERROR_DISABLE_NAT_ERROR =
591             TetheringManager.TETHER_ERROR_DISABLE_FORWARDING_ERROR;
592     @Deprecated
593     public static final int TETHER_ERROR_IFACE_CFG_ERROR =
594             TetheringManager.TETHER_ERROR_IFACE_CFG_ERROR;
595     @Deprecated
596     public static final int TETHER_ERROR_PROVISION_FAILED =
597             TetheringManager.TETHER_ERROR_PROVISIONING_FAILED;
598     @Deprecated
599     public static final int TETHER_ERROR_DHCPSERVER_ERROR =
600             TetheringManager.TETHER_ERROR_DHCPSERVER_ERROR;
601     @Deprecated
602     public static final int TETHER_ERROR_ENTITLEMENT_UNKONWN =
603             TetheringManager.TETHER_ERROR_ENTITLEMENT_UNKNOWN;
604 
605     @Deprecated
getLastTetherError(String iface)606     public int getLastTetherError(String iface) {
607         return 0;
608     }
609 
610     public @interface EntitlementResultCode {
611     }
612 
613     @Deprecated
614     public interface OnTetheringEntitlementResultListener  {
onTetheringEntitlementResult(@ntitlementResultCode int resultCode)615         void onTetheringEntitlementResult(@EntitlementResultCode int resultCode);
616     }
617 
618     @Deprecated
getLatestTetheringEntitlementResult(int type, boolean showEntitlementUi, @NonNull Executor executor, @NonNull final OnTetheringEntitlementResultListener listener)619     public void getLatestTetheringEntitlementResult(int type, boolean showEntitlementUi,
620             @NonNull Executor executor,
621             @NonNull final OnTetheringEntitlementResultListener listener) {}
622 
reportInetCondition(int networkType, int percentage)623     public void reportInetCondition(int networkType, int percentage) {}
624 
625     @Deprecated
reportBadNetwork(@ullable Network network)626     public void reportBadNetwork(@Nullable Network network) {}
627 
reportNetworkConnectivity(@ullable Network network, boolean hasConnectivity)628     public void reportNetworkConnectivity(@Nullable Network network, boolean hasConnectivity) {}
629 
setGlobalProxy(ProxyInfo p)630     public void setGlobalProxy(ProxyInfo p) {}
631 
getGlobalProxy()632     public ProxyInfo getGlobalProxy() {
633         return null;
634     }
635 
getProxyForNetwork(Network network)636     public ProxyInfo getProxyForNetwork(Network network) {
637         return null;
638     }
639 
640     @Nullable
getDefaultProxy()641     public ProxyInfo getDefaultProxy() {
642         return null;
643     }
644 
645     @Deprecated
isNetworkSupported(int networkType)646     public boolean isNetworkSupported(int networkType) {
647         return false;
648     }
649 
isActiveNetworkMetered()650     public boolean isActiveNetworkMetered() {
651         return false;
652     }
653 
updateLockdownVpn()654     public boolean updateLockdownVpn() {
655         return false;
656     }
657 
checkMobileProvisioning(int suggestedTimeOutMs)658     public int checkMobileProvisioning(int suggestedTimeOutMs) {
659         return 0;
660     }
661 
getMobileProvisioningUrl()662     public String getMobileProvisioningUrl() {
663         return null;
664     }
665 
666     @Deprecated
setProvisioningNotificationVisible(boolean visible, int networkType, String action)667     public void setProvisioningNotificationVisible(boolean visible, int networkType,
668             String action) {}
669 
setAirplaneMode(boolean enable)670     public void setAirplaneMode(boolean enable) {}
671 
registerNetworkFactory(Messenger messenger, String name)672     public int registerNetworkFactory(Messenger messenger, String name) {
673         return 0;
674     }
675 
unregisterNetworkFactory(Messenger messenger)676     public void unregisterNetworkFactory(Messenger messenger) {}
677 
registerNetworkProvider(@onNull NetworkProvider provider)678     public int registerNetworkProvider(@NonNull NetworkProvider provider) {
679         return 0;
680     }
681 
unregisterNetworkProvider(@onNull NetworkProvider provider)682     public void unregisterNetworkProvider(@NonNull NetworkProvider provider) {}
683 
declareNetworkRequestUnfulfillable(@onNull NetworkRequest request)684     public void declareNetworkRequestUnfulfillable(@NonNull NetworkRequest request) {}
685 
registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp, NetworkCapabilities nc, int score, NetworkAgentConfig config)686     public Network registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
687             NetworkCapabilities nc, int score, NetworkAgentConfig config) {
688         return null;
689     }
690 
registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp, NetworkCapabilities nc, int score, NetworkAgentConfig config, int providerId)691     public Network registerNetworkAgent(Messenger messenger, NetworkInfo ni, LinkProperties lp,
692             NetworkCapabilities nc, int score, NetworkAgentConfig config, int providerId) {
693         return null;
694     }
695 
696     public static class NetworkCallback {
onPreCheck(@onNull Network network)697         public void onPreCheck(@NonNull Network network) {}
698 
onAvailable(@onNull Network network, @NonNull NetworkCapabilities networkCapabilities, @NonNull LinkProperties linkProperties, boolean blocked)699         public void onAvailable(@NonNull Network network,
700                 @NonNull NetworkCapabilities networkCapabilities,
701                 @NonNull LinkProperties linkProperties, boolean blocked) {}
702 
onAvailable(@onNull Network network)703         public void onAvailable(@NonNull Network network) {}
704 
onLosing(@onNull Network network, int maxMsToLive)705         public void onLosing(@NonNull Network network, int maxMsToLive) {}
706 
onLost(@onNull Network network)707         public void onLost(@NonNull Network network) {}
708 
onUnavailable()709         public void onUnavailable() {}
710 
onCapabilitiesChanged(@onNull Network network, @NonNull NetworkCapabilities networkCapabilities)711         public void onCapabilitiesChanged(@NonNull Network network,
712                 @NonNull NetworkCapabilities networkCapabilities) {}
713 
onLinkPropertiesChanged(@onNull Network network, @NonNull LinkProperties linkProperties)714         public void onLinkPropertiesChanged(@NonNull Network network,
715                 @NonNull LinkProperties linkProperties) {}
716 
onNetworkSuspended(@onNull Network network)717         public void onNetworkSuspended(@NonNull Network network) {}
718 
onNetworkResumed(@onNull Network network)719         public void onNetworkResumed(@NonNull Network network) {}
720 
onBlockedStatusChanged(@onNull Network network, boolean blocked)721         public void onBlockedStatusChanged(@NonNull Network network, boolean blocked) {}
722     }
723 
724     public interface Errors {
725         int TOO_MANY_REQUESTS = 1;
726     }
727 
728     public static class TooManyRequestsException extends RuntimeException {}
729 
730     public static final int CALLBACK_PRECHECK            = BASE + 1;
731     public static final int CALLBACK_AVAILABLE           = BASE + 2;
732     public static final int CALLBACK_LOSING              = BASE + 3;
733     public static final int CALLBACK_LOST                = BASE + 4;
734     public static final int CALLBACK_UNAVAIL             = BASE + 5;
735     public static final int CALLBACK_CAP_CHANGED         = BASE + 6;
736     public static final int CALLBACK_IP_CHANGED          = BASE + 7;
737     private static final int EXPIRE_LEGACY_REQUEST       = BASE + 8;
738     public static final int CALLBACK_SUSPENDED           = BASE + 9;
739     public static final int CALLBACK_RESUMED             = BASE + 10;
740     public static final int CALLBACK_BLK_CHANGED         = BASE + 11;
741 
getCallbackName(int whichCallback)742     public static String getCallbackName(int whichCallback) {
743         switch (whichCallback) {
744             case CALLBACK_PRECHECK:     return "CALLBACK_PRECHECK";
745             case CALLBACK_AVAILABLE:    return "CALLBACK_AVAILABLE";
746             case CALLBACK_LOSING:       return "CALLBACK_LOSING";
747             case CALLBACK_LOST:         return "CALLBACK_LOST";
748             case CALLBACK_UNAVAIL:      return "CALLBACK_UNAVAIL";
749             case CALLBACK_CAP_CHANGED:  return "CALLBACK_CAP_CHANGED";
750             case CALLBACK_IP_CHANGED:   return "CALLBACK_IP_CHANGED";
751             case EXPIRE_LEGACY_REQUEST: return "EXPIRE_LEGACY_REQUEST";
752             case CALLBACK_SUSPENDED:    return "CALLBACK_SUSPENDED";
753             case CALLBACK_RESUMED:      return "CALLBACK_RESUMED";
754             case CALLBACK_BLK_CHANGED:  return "CALLBACK_BLK_CHANGED";
755             default:
756                 return Integer.toString(whichCallback);
757         }
758     }
759 
requestNetwork(@onNull NetworkRequest request, int timeoutMs, int legacyType, @NonNull Handler handler, @NonNull NetworkCallback networkCallback)760     public void requestNetwork(@NonNull NetworkRequest request,
761             int timeoutMs, int legacyType, @NonNull Handler handler,
762             @NonNull NetworkCallback networkCallback) {}
763 
requestNetwork(@onNull NetworkRequest request, @NonNull NetworkCallback networkCallback)764     public void requestNetwork(@NonNull NetworkRequest request,
765             @NonNull NetworkCallback networkCallback) {}
766 
requestNetwork(@onNull NetworkRequest request, @NonNull NetworkCallback networkCallback, @NonNull Handler handler)767     public void requestNetwork(@NonNull NetworkRequest request,
768             @NonNull NetworkCallback networkCallback, @NonNull Handler handler) {}
769 
requestNetwork(@onNull NetworkRequest request, @NonNull NetworkCallback networkCallback, int timeoutMs)770     public void requestNetwork(@NonNull NetworkRequest request,
771             @NonNull NetworkCallback networkCallback, int timeoutMs) {}
772 
requestNetwork(@onNull NetworkRequest request, @NonNull NetworkCallback networkCallback, @NonNull Handler handler, int timeoutMs)773     public void requestNetwork(@NonNull NetworkRequest request,
774             @NonNull NetworkCallback networkCallback, @NonNull Handler handler, int timeoutMs) {}
775 
776     public static final String EXTRA_NETWORK = "android.net.extra.NETWORK";
777 
778     public static final String EXTRA_NETWORK_REQUEST = "android.net.extra.NETWORK_REQUEST";
779 
780 
requestNetwork(@onNull NetworkRequest request, @NonNull PendingIntent operation)781     public void requestNetwork(@NonNull NetworkRequest request,
782             @NonNull PendingIntent operation) {}
783 
releaseNetworkRequest(@onNull PendingIntent operation)784     public void releaseNetworkRequest(@NonNull PendingIntent operation) {}
785 
registerNetworkCallback(@onNull NetworkRequest request, @NonNull NetworkCallback networkCallback)786     public void registerNetworkCallback(@NonNull NetworkRequest request,
787             @NonNull NetworkCallback networkCallback) {}
788 
registerNetworkCallback(@onNull NetworkRequest request, @NonNull NetworkCallback networkCallback, @NonNull Handler handler)789     public void registerNetworkCallback(@NonNull NetworkRequest request,
790             @NonNull NetworkCallback networkCallback, @NonNull Handler handler) {}
791 
registerNetworkCallback(@onNull NetworkRequest request, @NonNull PendingIntent operation)792     public void registerNetworkCallback(@NonNull NetworkRequest request,
793             @NonNull PendingIntent operation) {}
794 
registerDefaultNetworkCallback(@onNull NetworkCallback networkCallback)795     public void registerDefaultNetworkCallback(@NonNull NetworkCallback networkCallback) {}
796 
registerDefaultNetworkCallback(@onNull NetworkCallback networkCallback, @NonNull Handler handler)797     public void registerDefaultNetworkCallback(@NonNull NetworkCallback networkCallback,
798             @NonNull Handler handler) {}
799 
requestBandwidthUpdate(@onNull Network network)800     public boolean requestBandwidthUpdate(@NonNull Network network) {
801         return false;
802     }
803 
unregisterNetworkCallback(@onNull NetworkCallback networkCallback)804     public void unregisterNetworkCallback(@NonNull NetworkCallback networkCallback) {}
805 
unregisterNetworkCallback(@onNull PendingIntent operation)806     public void unregisterNetworkCallback(@NonNull PendingIntent operation) {}
807 
setAcceptUnvalidated(Network network, boolean accept, boolean always)808     public void setAcceptUnvalidated(Network network, boolean accept, boolean always) {}
809 
setAcceptPartialConnectivity(Network network, boolean accept, boolean always)810     public void setAcceptPartialConnectivity(Network network, boolean accept, boolean always) {}
811 
setAvoidUnvalidated(Network network)812     public void setAvoidUnvalidated(Network network) {}
813 
startCaptivePortalApp(Network network)814     public void startCaptivePortalApp(Network network) {}
815 
startCaptivePortalApp(@onNull Network network, @NonNull Bundle appExtras)816     public void startCaptivePortalApp(@NonNull Network network, @NonNull Bundle appExtras) {}
817 
shouldAvoidBadWifi()818     public boolean shouldAvoidBadWifi() {
819         return false;
820     }
821 
822     public static final int MULTIPATH_PREFERENCE_HANDOVER = 1 << 0;
823 
824     public static final int MULTIPATH_PREFERENCE_RELIABILITY = 1 << 1;
825 
826     public static final int MULTIPATH_PREFERENCE_PERFORMANCE = 1 << 2;
827 
828     public static final int MULTIPATH_PREFERENCE_UNMETERED =
829             MULTIPATH_PREFERENCE_HANDOVER |
830                     MULTIPATH_PREFERENCE_RELIABILITY |
831                     MULTIPATH_PREFERENCE_PERFORMANCE;
832 
833     public @interface MultipathPreference {
834     }
835 
getMultipathPreference(@ullable Network network)836     public @MultipathPreference int getMultipathPreference(@Nullable Network network) {
837         return 0;
838     }
839 
factoryReset()840     public void factoryReset() {}
841 
bindProcessToNetwork(@ullable Network network)842     public boolean bindProcessToNetwork(@Nullable Network network) {
843         return false;
844     }
845 
setProcessDefaultNetwork(@ullable Network network)846     public static boolean setProcessDefaultNetwork(@Nullable Network network) {
847         return false;
848     }
849 
850     @Nullable
getBoundNetworkForProcess()851     public Network getBoundNetworkForProcess() {
852         return null;
853     }
854 
855     @Deprecated
856     @Nullable
getProcessDefaultNetwork()857     public static Network getProcessDefaultNetwork() {
858         return null;
859     }
860 
861     @Deprecated
setProcessDefaultNetworkForHostResolution(Network network)862     public static boolean setProcessDefaultNetworkForHostResolution(Network network) {
863         return false;
864     }
865 
866     public static final int RESTRICT_BACKGROUND_STATUS_DISABLED = 1;
867 
868     public static final int RESTRICT_BACKGROUND_STATUS_WHITELISTED = 2;
869 
870     public static final int RESTRICT_BACKGROUND_STATUS_ENABLED = 3;
871 
872     public static final String ACTION_RESTRICT_BACKGROUND_CHANGED =
873             "android.net.conn.RESTRICT_BACKGROUND_CHANGED";
874 
875     public @interface RestrictBackgroundStatus {
876     }
877 
getRestrictBackgroundStatus()878     public @RestrictBackgroundStatus int getRestrictBackgroundStatus() {
879         return 0;
880     }
881 
882     @Nullable
getNetworkWatchlistConfigHash()883     public byte[] getNetworkWatchlistConfigHash() {
884         return null;
885     }
886 
getConnectionOwnerUid( int protocol, @NonNull InetSocketAddress local, @NonNull InetSocketAddress remote)887     public int getConnectionOwnerUid(
888             int protocol, @NonNull InetSocketAddress local, @NonNull InetSocketAddress remote) {
889         return 0;
890     }
891 
simulateDataStall(int detectionMethod, long timestampMillis, @NonNull Network network, @NonNull PersistableBundle extras)892     public void simulateDataStall(int detectionMethod, long timestampMillis,
893             @NonNull Network network, @NonNull PersistableBundle extras) {}
894 }
895 
896