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.LinkQualityInfo;
21 import android.net.LinkProperties;
22 import android.net.Network;
23 import android.net.NetworkCapabilities;
24 import android.net.NetworkInfo;
25 import android.net.NetworkQuotaInfo;
26 import android.net.NetworkRequest;
27 import android.net.NetworkState;
28 import android.net.ProxyInfo;
29 import android.os.IBinder;
30 import android.os.Messenger;
31 import android.os.ParcelFileDescriptor;
32 import android.os.ResultReceiver;
33 
34 import com.android.internal.net.LegacyVpnInfo;
35 import com.android.internal.net.VpnConfig;
36 import com.android.internal.net.VpnProfile;
37 
38 /**
39  * Interface that answers queries about, and allows changing, the
40  * state of network connectivity.
41  */
42 /** {@hide} */
43 interface IConnectivityManager
44 {
45     // Keep this in sync with framework/native/services/connectivitymanager/ConnectivityManager.h
46     void markSocketAsUser(in ParcelFileDescriptor socket, int uid);
47 
48     NetworkInfo getActiveNetworkInfo();
49     NetworkInfo getActiveNetworkInfoForUid(int uid);
50     NetworkInfo getNetworkInfo(int networkType);
51     NetworkInfo[] getAllNetworkInfo();
52 
53     NetworkInfo getProvisioningOrActiveNetworkInfo();
54 
55     boolean isNetworkSupported(int networkType);
56 
57     LinkProperties getActiveLinkProperties();
58     LinkProperties getLinkPropertiesForType(int networkType);
59     LinkProperties getLinkProperties(in Network network);
60 
61     NetworkCapabilities getNetworkCapabilities(in Network network);
62 
63     NetworkState[] getAllNetworkState();
64 
65     NetworkQuotaInfo getActiveNetworkQuotaInfo();
66     boolean isActiveNetworkMetered();
67 
68     int startUsingNetworkFeature(int networkType, in String feature,
69             in IBinder binder);
70 
71     int stopUsingNetworkFeature(int networkType, in String feature);
72 
73     boolean requestRouteToHost(int networkType, int hostAddress, String packageName);
74 
75     boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress, String packageName);
76 
77     /** Policy control over specific {@link NetworkStateTracker}. */
78     void setPolicyDataEnable(int networkType, boolean enabled);
79 
80     int tether(String iface);
81 
82     int untether(String iface);
83 
84     int getLastTetherError(String iface);
85 
86     boolean isTetheringSupported();
87 
88     String[] getTetherableIfaces();
89 
90     String[] getTetheredIfaces();
91 
92     String[] getTetheringErroredIfaces();
93 
94     String[] getTetherableUsbRegexs();
95 
96     String[] getTetherableWifiRegexs();
97 
98     String[] getTetherableBluetoothRegexs();
99 
100     int setUsbTethering(boolean enable);
101 
102     void requestNetworkTransitionWakelock(in String forWhom);
103 
104     void reportInetCondition(int networkType, int percentage);
105 
106     void reportBadNetwork(in Network network);
107 
108     ProxyInfo getGlobalProxy();
109 
110     void setGlobalProxy(in ProxyInfo p);
111 
112     ProxyInfo getProxy();
113 
114     void setDataDependency(int networkType, boolean met);
115 
116     boolean protectVpn(in ParcelFileDescriptor socket);
117 
118     boolean prepareVpn(String oldPackage, String newPackage);
119 
120     ParcelFileDescriptor establishVpn(in VpnConfig config);
121 
122     VpnConfig getVpnConfig();
123 
124     void startLegacyVpn(in VpnProfile profile);
125 
126     LegacyVpnInfo getLegacyVpnInfo();
127 
128     boolean updateLockdownVpn();
129 
130     void captivePortalCheckCompleted(in NetworkInfo info, boolean isCaptivePortal);
131 
132     void supplyMessenger(int networkType, in Messenger messenger);
133 
134     int findConnectionTypeForIface(in String iface);
135 
136     int checkMobileProvisioning(int suggestedTimeOutMs);
137 
138     String getMobileProvisioningUrl();
139 
140     String getMobileRedirectedProvisioningUrl();
141 
142     LinkQualityInfo getLinkQualityInfo(int networkType);
143 
144     LinkQualityInfo getActiveLinkQualityInfo();
145 
146     LinkQualityInfo[] getAllLinkQualityInfo();
147 
148     void setProvisioningNotificationVisible(boolean visible, int networkType, in String extraInfo,
149             in String url);
150 
151     void setAirplaneMode(boolean enable);
152 
153     void registerNetworkFactory(in Messenger messenger, in String name);
154 
155     void unregisterNetworkFactory(in Messenger messenger);
156 
157     void registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp,
158             in NetworkCapabilities nc, int score);
159 
160     NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities,
161             in Messenger messenger, int timeoutSec, in IBinder binder, int legacy);
162 
163     NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities,
164             in PendingIntent operation);
165 
166     NetworkRequest listenForNetwork(in NetworkCapabilities networkCapabilities,
167             in Messenger messenger, in IBinder binder);
168 
169     void pendingListenForNetwork(in NetworkCapabilities networkCapabilities,
170             in PendingIntent operation);
171 
172     void releaseNetworkRequest(in NetworkRequest networkRequest);
173 
174     int getRestoreDefaultNetworkDelay(int networkType);
175 }
176