public class ConnectivityService extends IConnectivityManager.Stub implements PendingIntent.OnFinished
Modifier and Type | Field and Description |
---|---|
protected HandlerThread |
mHandlerThread
Handler thread used for both of the handlers below.
|
protected int |
mLingerDelayMs |
Modifier | Constructor and Description |
---|---|
|
ConnectivityService(Context context,
INetworkManagementService netManager,
INetworkStatsService statsService,
INetworkPolicyManager policyManager) |
protected |
ConnectivityService(Context context,
INetworkManagementService netManager,
INetworkStatsService statsService,
INetworkPolicyManager policyManager,
IpConnectivityLog logger) |
Modifier and Type | Method and Description |
---|---|
boolean |
addVpnAddress(String address,
int prefixLength) |
boolean |
avoidBadWifi() |
int |
checkMobileProvisioning(int suggestedTimeOutMs) |
protected HandlerThread |
createHandlerThread() |
NetworkMonitor |
createNetworkMonitor(Context context,
Handler handler,
NetworkAgentInfo nai,
NetworkRequest defaultRequest) |
protected void |
dump(FileDescriptor fd,
PrintWriter writer,
String[] args) |
ParcelFileDescriptor |
establishVpn(VpnConfig config)
Configure a TUN interface and return its file descriptor.
|
void |
factoryReset() |
LinkProperties |
getActiveLinkProperties()
Return LinkProperties for the active (i.e., connected) default
network interface.
|
Network |
getActiveNetwork() |
Network |
getActiveNetworkForUid(int uid,
boolean ignoreBlocked) |
NetworkInfo |
getActiveNetworkInfo()
Return NetworkInfo for the active (i.e., connected) network interface.
|
NetworkInfo |
getActiveNetworkInfoForUid(int uid,
boolean ignoreBlocked) |
NetworkInfo |
getActiveNetworkInfoUnfiltered() |
NetworkQuotaInfo |
getActiveNetworkQuotaInfo() |
NetworkInfo[] |
getAllNetworkInfo() |
Network[] |
getAllNetworks() |
NetworkState[] |
getAllNetworkState() |
VpnInfo[] |
getAllVpnInfo()
Return the information of all ongoing VPNs.
|
String |
getAlwaysOnVpnPackage(int userId) |
String |
getCaptivePortalServerUrl() |
NetworkCapabilities[] |
getDefaultNetworkCapabilitiesForUser(int userId) |
protected int |
getDefaultTcpRwnd() |
ProxyInfo |
getGlobalProxy() |
int |
getLastTetherError(String iface) |
LegacyVpnInfo |
getLegacyVpnInfo(int userId)
Return the information of the ongoing legacy VPN.
|
LinkProperties |
getLinkProperties(Network network) |
LinkProperties |
getLinkPropertiesForType(int networkType) |
String |
getMobileProvisioningUrl() |
NetworkCapabilities |
getNetworkCapabilities(Network network) |
Network |
getNetworkForType(int networkType) |
NetworkInfo |
getNetworkInfo(int networkType) |
NetworkInfo |
getNetworkInfoForUid(Network network,
int uid,
boolean ignoreBlocked) |
ProxyInfo |
getProxyForNetwork(Network network) |
int |
getRestoreDefaultNetworkDelay(int networkType) |
String[] |
getTetherableBluetoothRegexs() |
String[] |
getTetherableIfaces() |
String[] |
getTetherableUsbRegexs() |
String[] |
getTetherableWifiRegexs() |
String[] |
getTetheredDhcpRanges() |
String[] |
getTetheredIfaces() |
String[] |
getTetheringErroredIfaces() |
VpnConfig |
getVpnConfig(int userId)
Returns the information of the ongoing VPN for
userId . |
boolean |
isActiveNetworkMetered() |
boolean |
isNetworkSupported(int networkType) |
boolean |
isTetheringSupported() |
NetworkRequest |
listenForNetwork(NetworkCapabilities networkCapabilities,
Messenger messenger,
IBinder binder) |
WakeupMessage |
makeWakeupMessage(Context c,
Handler h,
String s,
int cmd,
Object obj) |
protected void |
notifyNetworkCallback(NetworkAgentInfo nai,
com.android.server.ConnectivityService.NetworkRequestInfo nri) |
protected void |
notifyNetworkCallbacks(NetworkAgentInfo networkAgent,
int notifyType) |
protected void |
notifyNetworkCallbacks(NetworkAgentInfo networkAgent,
int notifyType,
int arg1) |
void |
onSendFinished(PendingIntent pendingIntent,
Intent intent,
int resultCode,
String resultData,
Bundle resultExtras)
Called when a send operation as completed.
|
void |
pendingListenForNetwork(NetworkCapabilities networkCapabilities,
PendingIntent operation) |
NetworkRequest |
pendingRequestForNetwork(NetworkCapabilities networkCapabilities,
PendingIntent operation) |
boolean |
prepareVpn(String oldPackage,
String newPackage,
int userId)
Prepare for a VPN application.
|
int |
registerNetworkAgent(Messenger messenger,
NetworkInfo networkInfo,
LinkProperties linkProperties,
NetworkCapabilities networkCapabilities,
int currentScore,
NetworkMisc networkMisc) |
void |
registerNetworkFactory(Messenger messenger,
String name) |
void |
releaseNetworkRequest(NetworkRequest networkRequest) |
void |
releasePendingNetworkRequest(PendingIntent operation) |
boolean |
removeVpnAddress(String address,
int prefixLength) |
void |
reportInetCondition(int networkType,
int percentage) |
void |
reportNetworkConnectivity(Network network,
boolean hasConnectivity) |
boolean |
requestBandwidthUpdate(Network network) |
void |
requestLinkProperties(NetworkRequest networkRequest) |
NetworkRequest |
requestNetwork(NetworkCapabilities networkCapabilities,
Messenger messenger,
int timeoutMs,
IBinder binder,
int legacyType) |
void |
requestNetworkCapabilities(NetworkRequest networkRequest) |
boolean |
requestRouteToHostAddress(int networkType,
byte[] hostAddress)
Ensure that a network route exists to deliver traffic to the specified
host via the specified network interface.
|
protected int |
reserveNetId() |
void |
sendConnectedBroadcast(NetworkInfo info) |
void |
setAcceptUnvalidated(Network network,
boolean accept,
boolean always) |
void |
setAirplaneMode(boolean enable) |
boolean |
setAlwaysOnVpnPackage(int userId,
String packageName,
boolean lockdown) |
void |
setAvoidUnvalidated(Network network) |
void |
setGlobalProxy(ProxyInfo proxyProperties) |
void |
setProvisioningNotificationVisible(boolean visible,
int networkType,
String action) |
boolean |
setUnderlyingNetworksForVpn(Network[] networks) |
int |
setUsbTethering(boolean enable) |
void |
setVpnPackageAuthorization(String packageName,
int userId,
boolean authorized)
Set whether the VPN package has the ability to launch VPNs without user intervention.
|
void |
startLegacyVpn(VpnProfile profile)
Start legacy VPN, controlling native daemons as needed.
|
void |
startNattKeepalive(Network network,
int intervalSeconds,
Messenger messenger,
IBinder binder,
String srcAddr,
int srcPort,
String dstAddr) |
void |
startTethering(int type,
ResultReceiver receiver,
boolean showProvisioningUi) |
void |
stopKeepalive(Network network,
int slot) |
void |
stopTethering(int type) |
int |
tether(String iface) |
void |
unregisterNetworkFactory(Messenger messenger) |
int |
untether(String iface) |
boolean |
updateLockdownVpn() |
protected int mLingerDelayMs
protected final HandlerThread mHandlerThread
public ConnectivityService(Context context, INetworkManagementService netManager, INetworkStatsService statsService, INetworkPolicyManager policyManager)
protected ConnectivityService(Context context, INetworkManagementService netManager, INetworkStatsService statsService, INetworkPolicyManager policyManager, IpConnectivityLog logger)
protected HandlerThread createHandlerThread()
protected int reserveNetId()
public NetworkInfo getActiveNetworkInfo()
null
if none is
activepublic Network getActiveNetwork()
public Network getActiveNetworkForUid(int uid, boolean ignoreBlocked)
public NetworkInfo getActiveNetworkInfoUnfiltered()
public NetworkInfo getActiveNetworkInfoForUid(int uid, boolean ignoreBlocked)
public NetworkInfo getNetworkInfo(int networkType)
public NetworkInfo getNetworkInfoForUid(Network network, int uid, boolean ignoreBlocked)
public NetworkInfo[] getAllNetworkInfo()
public Network getNetworkForType(int networkType)
public Network[] getAllNetworks()
public NetworkCapabilities[] getDefaultNetworkCapabilitiesForUser(int userId)
public boolean isNetworkSupported(int networkType)
public LinkProperties getActiveLinkProperties()
null
if
none is activepublic LinkProperties getLinkPropertiesForType(int networkType)
public LinkProperties getLinkProperties(Network network)
public NetworkCapabilities getNetworkCapabilities(Network network)
public NetworkState[] getAllNetworkState()
public NetworkQuotaInfo getActiveNetworkQuotaInfo()
public boolean isActiveNetworkMetered()
public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress)
networkType
- the type of the network over which traffic to the
specified host is to be routedhostAddress
- the IP address of the host to which the route is
desiredtrue
on success, false
on failurepublic void sendConnectedBroadcast(NetworkInfo info)
protected int getDefaultTcpRwnd()
public int getRestoreDefaultNetworkDelay(int networkType)
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args)
public void setAcceptUnvalidated(Network network, boolean accept, boolean always)
public void setAvoidUnvalidated(Network network)
public boolean avoidBadWifi()
public int tether(String iface)
public int untether(String iface)
public int getLastTetherError(String iface)
public String[] getTetherableUsbRegexs()
public String[] getTetherableWifiRegexs()
public String[] getTetherableBluetoothRegexs()
public int setUsbTethering(boolean enable)
public String[] getTetherableIfaces()
public String[] getTetheredIfaces()
public String[] getTetheringErroredIfaces()
public String[] getTetheredDhcpRanges()
public boolean isTetheringSupported()
public void startTethering(int type, ResultReceiver receiver, boolean showProvisioningUi)
public void stopTethering(int type)
public void reportInetCondition(int networkType, int percentage)
public void reportNetworkConnectivity(Network network, boolean hasConnectivity)
public void setGlobalProxy(ProxyInfo proxyProperties)
public ProxyInfo getGlobalProxy()
public boolean prepareVpn(String oldPackage, String newPackage, int userId)
Vpn
class. If the caller is not userId
,
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL
permission is required.oldPackage
- Package name of the application which currently controls VPN, which will
be replaced. If there is no such application, this should should either be
null
or VpnConfig.LEGACY_VPN
.newPackage
- Package name of the application which should gain control of VPN, or
null
to disable.userId
- User for whom to prepare the new VPN.public void setVpnPackageAuthorization(String packageName, int userId, boolean authorized)
Vpn
class. If the caller is not userId
,
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL
permission is required.packageName
- The package for which authorization state should change.userId
- User for whom packageName
is installed.authorized
- true
if this app should be able to start a VPN connection without
explicit user approval, false
if not.public ParcelFileDescriptor establishVpn(VpnConfig config)
public void startLegacyVpn(VpnProfile profile)
public LegacyVpnInfo getLegacyVpnInfo(int userId)
public VpnInfo[] getAllVpnInfo()
public VpnConfig getVpnConfig(int userId)
userId
. This method is used by
VpnDialogs and not available in ConnectivityManager.
Permissions are checked in Vpn class.public boolean updateLockdownVpn()
public boolean setAlwaysOnVpnPackage(int userId, String packageName, boolean lockdown)
public String getAlwaysOnVpnPackage(int userId)
public int checkMobileProvisioning(int suggestedTimeOutMs)
public String getMobileProvisioningUrl()
public void setProvisioningNotificationVisible(boolean visible, int networkType, String action)
public void setAirplaneMode(boolean enable)
public NetworkRequest requestNetwork(NetworkCapabilities networkCapabilities, Messenger messenger, int timeoutMs, IBinder binder, int legacyType)
public boolean requestBandwidthUpdate(Network network)
public NetworkRequest pendingRequestForNetwork(NetworkCapabilities networkCapabilities, PendingIntent operation)
public void releasePendingNetworkRequest(PendingIntent operation)
public NetworkRequest listenForNetwork(NetworkCapabilities networkCapabilities, Messenger messenger, IBinder binder)
public void pendingListenForNetwork(NetworkCapabilities networkCapabilities, PendingIntent operation)
public void requestLinkProperties(NetworkRequest networkRequest)
public void requestNetworkCapabilities(NetworkRequest networkRequest)
public void releaseNetworkRequest(NetworkRequest networkRequest)
public void unregisterNetworkFactory(Messenger messenger)
public int registerNetworkAgent(Messenger messenger, NetworkInfo networkInfo, LinkProperties linkProperties, NetworkCapabilities networkCapabilities, int currentScore, NetworkMisc networkMisc)
public void onSendFinished(PendingIntent pendingIntent, Intent intent, int resultCode, String resultData, Bundle resultExtras)
PendingIntent.OnFinished
onSendFinished
in interface PendingIntent.OnFinished
pendingIntent
- The PendingIntent this operation was sent through.intent
- The original Intent that was sent.resultCode
- The final result code determined by the send.resultData
- The final data collected by a broadcast.resultExtras
- The final extras collected by a broadcast.protected void notifyNetworkCallback(NetworkAgentInfo nai, com.android.server.ConnectivityService.NetworkRequestInfo nri)
protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType, int arg1)
protected void notifyNetworkCallbacks(NetworkAgentInfo networkAgent, int notifyType)
public boolean addVpnAddress(String address, int prefixLength)
public boolean removeVpnAddress(String address, int prefixLength)
public boolean setUnderlyingNetworksForVpn(Network[] networks)
public String getCaptivePortalServerUrl()
public void startNattKeepalive(Network network, int intervalSeconds, Messenger messenger, IBinder binder, String srcAddr, int srcPort, String dstAddr)
public void stopKeepalive(Network network, int slot)
public void factoryReset()
public NetworkMonitor createNetworkMonitor(Context context, Handler handler, NetworkAgentInfo nai, NetworkRequest defaultRequest)
public WakeupMessage makeWakeupMessage(Context c, Handler h, String s, int cmd, Object obj)