Add LinkCapabilities
Change-Id: Ia1599ade936b79f12526252c0a2e6b453abb136e
This commit is contained in:
@ -307,6 +307,7 @@ public class WifiManager {
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||
public static final String CONFIG_CHANGED_ACTION = "android.net.wifi.CONFIG_CHANGED";
|
||||
|
||||
/**
|
||||
* The lookup key for a {@link android.net.LinkProperties} object associated with the
|
||||
* Wi-Fi network. Retrieve with
|
||||
@ -315,6 +316,14 @@ public class WifiManager {
|
||||
*/
|
||||
public static final String EXTRA_LINK_PROPERTIES = "linkProperties";
|
||||
|
||||
/**
|
||||
* The lookup key for a {@link android.net.LinkCapabilities} object associated with the
|
||||
* Wi-Fi network. Retrieve with
|
||||
* {@link android.content.Intent#getParcelableExtra(String)}.
|
||||
* @hide
|
||||
*/
|
||||
public static final String EXTRA_LINK_CAPABILITIES = "linkCapabilities";
|
||||
|
||||
/**
|
||||
* The network IDs of the configured networks could have changed.
|
||||
*/
|
||||
|
@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.LinkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.LinkProperties;
|
||||
import android.net.NetworkStateTracker;
|
||||
@ -48,6 +49,7 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
private AtomicBoolean mDefaultRouteSet = new AtomicBoolean(false);
|
||||
|
||||
private LinkProperties mLinkProperties;
|
||||
private LinkCapabilities mLinkCapabilities;
|
||||
private NetworkInfo mNetworkInfo;
|
||||
|
||||
/* For sending events to connectivity service handler */
|
||||
@ -59,9 +61,9 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
public WifiStateTracker() {
|
||||
mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_WIFI, 0, NETWORKTYPE, "");
|
||||
mLinkProperties = new LinkProperties();
|
||||
mLinkCapabilities = new LinkCapabilities();
|
||||
|
||||
mNetworkInfo.setIsAvailable(false);
|
||||
mLinkProperties.clear();
|
||||
setTeardownRequested(false);
|
||||
}
|
||||
|
||||
@ -195,6 +197,16 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
return new LinkProperties(mLinkProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* A capability is an Integer/String pair, the capabilities
|
||||
* are defined in the class LinkSocket#Key.
|
||||
*
|
||||
* @return a copy of this connections capabilities, may be empty but never null.
|
||||
*/
|
||||
public LinkCapabilities getLinkCapabilities() {
|
||||
return new LinkCapabilities(mLinkCapabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch default gateway address for the network
|
||||
*/
|
||||
@ -230,8 +242,16 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
|
||||
mNetworkInfo = (NetworkInfo) intent.getParcelableExtra(
|
||||
WifiManager.EXTRA_NETWORK_INFO);
|
||||
mLinkProperties = (LinkProperties) intent.getParcelableExtra(
|
||||
mLinkProperties = intent.getParcelableExtra(
|
||||
WifiManager.EXTRA_LINK_PROPERTIES);
|
||||
if (mLinkProperties == null) {
|
||||
mLinkProperties = new LinkProperties();
|
||||
}
|
||||
mLinkCapabilities = intent.getParcelableExtra(
|
||||
WifiManager.EXTRA_LINK_CAPABILITIES);
|
||||
if (mLinkCapabilities == null) {
|
||||
mLinkCapabilities = new LinkCapabilities();
|
||||
}
|
||||
Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
|
||||
msg.sendToTarget();
|
||||
} else if (intent.getAction().equals(WifiManager.CONFIG_CHANGED_ACTION)) {
|
||||
|
Reference in New Issue
Block a user