Home | History | Annotate | Download | only in net
      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.LinkProperties;
     22 import android.net.ITetheringEventCallback;
     23 import android.net.Network;
     24 import android.net.NetworkCapabilities;
     25 import android.net.NetworkInfo;
     26 import android.net.NetworkMisc;
     27 import android.net.NetworkQuotaInfo;
     28 import android.net.NetworkRequest;
     29 import android.net.NetworkState;
     30 import android.net.ISocketKeepaliveCallback;
     31 import android.net.ProxyInfo;
     32 import android.os.Bundle;
     33 import android.os.IBinder;
     34 import android.os.Messenger;
     35 import android.os.ParcelFileDescriptor;
     36 import android.os.ResultReceiver;
     37 
     38 import com.android.internal.net.LegacyVpnInfo;
     39 import com.android.internal.net.VpnConfig;
     40 import com.android.internal.net.VpnInfo;
     41 import com.android.internal.net.VpnProfile;
     42 
     43 /**
     44  * Interface that answers queries about, and allows changing, the
     45  * state of network connectivity.
     46  */
     47 /** {@hide} */
     48 interface IConnectivityManager
     49 {
     50     Network getActiveNetwork();
     51     Network getActiveNetworkForUid(int uid, boolean ignoreBlocked);
     52     @UnsupportedAppUsage
     53     NetworkInfo getActiveNetworkInfo();
     54     NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked);
     55     NetworkInfo getNetworkInfo(int networkType);
     56     NetworkInfo getNetworkInfoForUid(in Network network, int uid, boolean ignoreBlocked);
     57     @UnsupportedAppUsage
     58     NetworkInfo[] getAllNetworkInfo();
     59     Network getNetworkForType(int networkType);
     60     Network[] getAllNetworks();
     61     NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId);
     62 
     63     boolean isNetworkSupported(int networkType);
     64 
     65     @UnsupportedAppUsage
     66     LinkProperties getActiveLinkProperties();
     67     LinkProperties getLinkPropertiesForType(int networkType);
     68     LinkProperties getLinkProperties(in Network network);
     69 
     70     NetworkCapabilities getNetworkCapabilities(in Network network);
     71 
     72     @UnsupportedAppUsage
     73     NetworkState[] getAllNetworkState();
     74 
     75     NetworkQuotaInfo getActiveNetworkQuotaInfo();
     76     boolean isActiveNetworkMetered();
     77 
     78     boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress);
     79 
     80     int tether(String iface, String callerPkg);
     81 
     82     int untether(String iface, String callerPkg);
     83 
     84     @UnsupportedAppUsage
     85     int getLastTetherError(String iface);
     86 
     87     boolean isTetheringSupported(String callerPkg);
     88 
     89     void startTethering(int type, in ResultReceiver receiver, boolean showProvisioningUi,
     90             String callerPkg);
     91 
     92     void stopTethering(int type, String callerPkg);
     93 
     94     @UnsupportedAppUsage
     95     String[] getTetherableIfaces();
     96 
     97     @UnsupportedAppUsage
     98     String[] getTetheredIfaces();
     99 
    100     @UnsupportedAppUsage
    101     String[] getTetheringErroredIfaces();
    102 
    103     String[] getTetheredDhcpRanges();
    104 
    105     @UnsupportedAppUsage
    106     String[] getTetherableUsbRegexs();
    107 
    108     @UnsupportedAppUsage
    109     String[] getTetherableWifiRegexs();
    110 
    111     String[] getTetherableBluetoothRegexs();
    112 
    113     int setUsbTethering(boolean enable, String callerPkg);
    114 
    115     void reportInetCondition(int networkType, int percentage);
    116 
    117     void reportNetworkConnectivity(in Network network, boolean hasConnectivity);
    118 
    119     ProxyInfo getGlobalProxy();
    120 
    121     void setGlobalProxy(in ProxyInfo p);
    122 
    123     ProxyInfo getProxyForNetwork(in Network nework);
    124 
    125     boolean prepareVpn(String oldPackage, String newPackage, int userId);
    126 
    127     void setVpnPackageAuthorization(String packageName, int userId, boolean authorized);
    128 
    129     ParcelFileDescriptor establishVpn(in VpnConfig config);
    130 
    131     VpnConfig getVpnConfig(int userId);
    132 
    133     @UnsupportedAppUsage
    134     void startLegacyVpn(in VpnProfile profile);
    135 
    136     LegacyVpnInfo getLegacyVpnInfo(int userId);
    137 
    138     boolean updateLockdownVpn();
    139     boolean isAlwaysOnVpnPackageSupported(int userId, String packageName);
    140     boolean setAlwaysOnVpnPackage(int userId, String packageName, boolean lockdown,
    141             in List<String> lockdownWhitelist);
    142     String getAlwaysOnVpnPackage(int userId);
    143     boolean isVpnLockdownEnabled(int userId);
    144     List<String> getVpnLockdownWhitelist(int userId);
    145 
    146     int checkMobileProvisioning(int suggestedTimeOutMs);
    147 
    148     String getMobileProvisioningUrl();
    149 
    150     void setProvisioningNotificationVisible(boolean visible, int networkType, in String action);
    151 
    152     void setAirplaneMode(boolean enable);
    153 
    154     int registerNetworkFactory(in Messenger messenger, in String name);
    155 
    156     boolean requestBandwidthUpdate(in Network network);
    157 
    158     void unregisterNetworkFactory(in Messenger messenger);
    159 
    160     int registerNetworkAgent(in Messenger messenger, in NetworkInfo ni, in LinkProperties lp,
    161             in NetworkCapabilities nc, int score, in NetworkMisc misc, in int factorySerialNumber);
    162 
    163     NetworkRequest requestNetwork(in NetworkCapabilities networkCapabilities,
    164             in Messenger messenger, int timeoutSec, in IBinder binder, int legacy);
    165 
    166     NetworkRequest pendingRequestForNetwork(in NetworkCapabilities networkCapabilities,
    167             in PendingIntent operation);
    168 
    169     void releasePendingNetworkRequest(in PendingIntent operation);
    170 
    171     NetworkRequest listenForNetwork(in NetworkCapabilities networkCapabilities,
    172             in Messenger messenger, in IBinder binder);
    173 
    174     void pendingListenForNetwork(in NetworkCapabilities networkCapabilities,
    175             in PendingIntent operation);
    176 
    177     void releaseNetworkRequest(in NetworkRequest networkRequest);
    178 
    179     void setAcceptUnvalidated(in Network network, boolean accept, boolean always);
    180     void setAcceptPartialConnectivity(in Network network, boolean accept, boolean always);
    181     void setAvoidUnvalidated(in Network network);
    182     void startCaptivePortalApp(in Network network);
    183     void startCaptivePortalAppInternal(in Network network, in Bundle appExtras);
    184 
    185     boolean shouldAvoidBadWifi();
    186     int getMultipathPreference(in Network Network);
    187 
    188     NetworkRequest getDefaultRequest();
    189 
    190     int getRestoreDefaultNetworkDelay(int networkType);
    191 
    192     boolean addVpnAddress(String address, int prefixLength);
    193     boolean removeVpnAddress(String address, int prefixLength);
    194     boolean setUnderlyingNetworksForVpn(in Network[] networks);
    195 
    196     void factoryReset();
    197 
    198     void startNattKeepalive(in Network network, int intervalSeconds,
    199             in ISocketKeepaliveCallback cb, String srcAddr, int srcPort, String dstAddr);
    200 
    201     void startNattKeepaliveWithFd(in Network network, in FileDescriptor fd, int resourceId,
    202             int intervalSeconds, in ISocketKeepaliveCallback cb, String srcAddr,
    203             String dstAddr);
    204 
    205     void startTcpKeepalive(in Network network, in FileDescriptor fd, int intervalSeconds,
    206             in ISocketKeepaliveCallback cb);
    207 
    208     void stopKeepalive(in Network network, int slot);
    209 
    210     String getCaptivePortalServerUrl();
    211 
    212     byte[] getNetworkWatchlistConfigHash();
    213 
    214     int getConnectionOwnerUid(in ConnectionInfo connectionInfo);
    215     boolean isCallerCurrentAlwaysOnVpnApp();
    216     boolean isCallerCurrentAlwaysOnVpnLockdownApp();
    217 
    218     void getLatestTetheringEntitlementResult(int type, in ResultReceiver receiver,
    219             boolean showEntitlementUi, String callerPkg);
    220 
    221     void registerTetheringEventCallback(ITetheringEventCallback callback, String callerPkg);
    222     void unregisterTetheringEventCallback(ITetheringEventCallback callback, String callerPkg);
    223 
    224     IBinder startOrGetTestNetworkService();
    225 }
    226