Build 1.0_r1(from source)

android.net.wifi
Class WifiStateTracker

java.lang.Object
  extended by android.os.Handler
      extended by android.net.NetworkStateTracker
          extended by android.net.wifi.WifiStateTracker

public class WifiStateTracker
extends NetworkStateTracker

Track the state of Wifi connectivity. All event handling is done here, and all changes in connectivity state are initiated here.


Field Summary
static int SUPPL_SCAN_HANDLING_LIST_ONLY
           
static int SUPPL_SCAN_HANDLING_NORMAL
           
 
Fields inherited from class android.net.NetworkStateTracker
EVENT_CONFIGURATION_CHANGED, EVENT_NOTIFICATION_CHANGED, EVENT_STATE_CHANGED, mNetworkInfo, mTarget
 
Constructor Summary
WifiStateTracker(Context context, Handler target)
           
 
Method Summary
 boolean addToBlacklist(String bssid)
           
 boolean clearBlacklist()
           
 DhcpInfo getDhcpInfo()
           
 String[] getNameServers()
          Return the IP addresses of the DNS servers available for the WLAN network interface.
 List<ScanResult> getScanResultsList()
           
 SupplicantState getSupplicantState()
           
 String getTcpBufferSizesPropName()
          Return the system properties name associated with the tcp buffer sizes for this network.
 void handleMessage(Message msg)
          Subclasses must implement this to receive messages.
 void interpretScanResultsAvailable()
          Interprets scan results.
 boolean isAvailable()
          Wi-Fi is considered available as long as we have a connection to the supplicant daemon and there is at least one enabled network.
 boolean isConnectionCompleted()
          Report whether the Wi-Fi connection is fully configured for data.
(package private)  void notifyDriverStarted()
          Send the tracker a notification that the Wi-Fi driver has been restarted after having been stopped.
(package private)  void notifyDriverStopped()
          Send the tracker a notification that the Wi-Fi driver has been stopped.
(package private)  void notifyPasswordKeyMayBeIncorrect()
          Send the tracker a notification that a user-entered password key may be incorrect (i.e., caused authentication to fail).
(package private)  void notifyScanResultsAvailable()
          Send the tracker a notification that a scan has completed, and results are available.
(package private)  void notifyStateChange(int networkId, SupplicantState newState)
          Send the tracker a notification that the state of the supplicant has changed.
(package private)  void notifyStateChange(NetworkInfo.DetailedState newState, String BSSID, int networkId)
          Send the tracker a notification that the state of Wifi connectivity has changed.
(package private)  void notifySupplicantConnection()
          Send the tracker a notification that a connection to the supplicant daemon has been established.
(package private)  void notifySupplicantLost()
          Send the tracker a notification that we can no longer communicate with the supplicant daemon.
 boolean reconnect()
          Reenable Wi-Fi connectivity, by iterating through the list of saved network statuses, and reenabling each network that had been enabled before teardown() was called.
 void releaseWakeLock()
          Release the wakelock, if any, that may be held while handling a disconnect operation.
 WifiInfo requestConnectionInfo()
          Get status information for the current connection, if any.
 void resetInterface()
          Resets the Wi-Fi interface by clearing any state, resetting any sockets using the interface, stopping DHCP, and disabling the interface.
 void setNotificationVisible(boolean visible, int numNetworks, boolean force, int delay)
          
 boolean setRadio(boolean turnOn)
          Turn the wireless radio off for a network.
 void setReleaseWakeLockCallback(Runnable callback)
           
 void setScanMode(boolean isScanModeActive, boolean setDueToAHiddenNetwork)
           
 void setScanResultsList(List<ScanResult> scanList)
           
 void startEventLoop()
           
 void startMonitoring()
           
 int startUsingNetworkFeature(String feature, int callingPid, int callingUid)
          Tells the underlying networking system that the caller wants to begin using the named feature.
 int stopUsingNetworkFeature(String feature, int callingPid, int callingUid)
          Tells the underlying networking system that the caller is finished using the named feature.
 boolean teardown()
          Disable Wi-Fi connectivity.
 String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 
Methods inherited from class android.net.NetworkStateTracker
getNameServerList, getNetworkInfo, requestRouteToHost, sendScanResultsAvailable, setDetailedState, setDetailedState, setDetailedStateInternal, updateNetworkSettings
 
Methods inherited from class android.os.Handler
dispatchMessage, dump, getLooper, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUPPL_SCAN_HANDLING_NORMAL

public static final int SUPPL_SCAN_HANDLING_NORMAL
See Also:
Constant Field Values

SUPPL_SCAN_HANDLING_LIST_ONLY

public static final int SUPPL_SCAN_HANDLING_LIST_ONLY
See Also:
Constant Field Values
Constructor Detail

WifiStateTracker

public WifiStateTracker(Context context,
                        Handler target)
Method Detail

getSupplicantState

public SupplicantState getSupplicantState()

getNameServers

public String[] getNameServers()
Return the IP addresses of the DNS servers available for the WLAN network interface.

Specified by:
getNameServers in class NetworkStateTracker
Returns:
a list of DNS addresses, with no holes.

getTcpBufferSizesPropName

public String getTcpBufferSizesPropName()
Return the system properties name associated with the tcp buffer sizes for this network.

Specified by:
getTcpBufferSizesPropName in class NetworkStateTracker

startMonitoring

public void startMonitoring()
Specified by:
startMonitoring in class NetworkStateTracker

startEventLoop

public void startEventLoop()

isAvailable

public boolean isAvailable()
Wi-Fi is considered available as long as we have a connection to the supplicant daemon and there is at least one enabled network.

Specified by:
isAvailable in class NetworkStateTracker
Returns:
true if Wi-Fi connections are possible

isConnectionCompleted

public boolean isConnectionCompleted()
Report whether the Wi-Fi connection is fully configured for data.

Returns:
true if the SupplicantState is COMPLETED.

notifyPasswordKeyMayBeIncorrect

void notifyPasswordKeyMayBeIncorrect()
Send the tracker a notification that a user-entered password key may be incorrect (i.e., caused authentication to fail).


notifySupplicantConnection

void notifySupplicantConnection()
Send the tracker a notification that a connection to the supplicant daemon has been established.


notifyStateChange

void notifyStateChange(int networkId,
                       SupplicantState newState)
Send the tracker a notification that the state of the supplicant has changed.

Parameters:
newState - the new SupplicantState

notifyStateChange

void notifyStateChange(NetworkInfo.DetailedState newState,
                       String BSSID,
                       int networkId)
Send the tracker a notification that the state of Wifi connectivity has changed.

Parameters:
newState - the new network state
BSSID - when the new state is NetworkInfo.DetailedState.CONNECTED, this is the MAC address of the access point. Otherwise, it is null.

notifyScanResultsAvailable

void notifyScanResultsAvailable()
Send the tracker a notification that a scan has completed, and results are available.


notifySupplicantLost

void notifySupplicantLost()
Send the tracker a notification that we can no longer communicate with the supplicant daemon.


notifyDriverStopped

void notifyDriverStopped()
Send the tracker a notification that the Wi-Fi driver has been stopped. The notification is in the form of a synthesized DISCONNECTED event.


notifyDriverStarted

void notifyDriverStarted()
Send the tracker a notification that the Wi-Fi driver has been restarted after having been stopped.


releaseWakeLock

public void releaseWakeLock()
Description copied from class: NetworkStateTracker
Release the wakelock, if any, that may be held while handling a disconnect operation.

Overrides:
releaseWakeLock in class NetworkStateTracker

setReleaseWakeLockCallback

public void setReleaseWakeLockCallback(Runnable callback)

handleMessage

public void handleMessage(Message msg)
Description copied from class: Handler
Subclasses must implement this to receive messages.

Overrides:
handleMessage in class Handler

setScanMode

public void setScanMode(boolean isScanModeActive,
                        boolean setDueToAHiddenNetwork)

resetInterface

public void resetInterface()
Resets the Wi-Fi interface by clearing any state, resetting any sockets using the interface, stopping DHCP, and disabling the interface.


getDhcpInfo

public DhcpInfo getDhcpInfo()

getScanResultsList

public List<ScanResult> getScanResultsList()

setScanResultsList

public void setScanResultsList(List<ScanResult> scanList)

requestConnectionInfo

public WifiInfo requestConnectionInfo()
Get status information for the current connection, if any.

Returns:
a WifiInfo object containing information about the current connection

teardown

public boolean teardown()
Disable Wi-Fi connectivity. We do this by going through all the configured Wi-Fi networks and disabling them, so that the supplicant will not attempt to connect to any network. We save the disabled/enabled state of the original list, so that NetworkStateTracker.reconnect() can restore it.

Specified by:
teardown in class NetworkStateTracker
Returns:
true if a teardown occurred, false if the teardown did not occur.

reconnect

public boolean reconnect()
Reenable Wi-Fi connectivity, by iterating through the list of saved network statuses, and reenabling each network that had been enabled before teardown() was called. The network that had been active at the time of the teardown() might not be the one chosen by the supplicant to connect to after being re-enabled.

Specified by:
reconnect in class NetworkStateTracker

setRadio

public boolean setRadio(boolean turnOn)
Description copied from class: NetworkStateTracker
Turn the wireless radio off for a network.

Specified by:
setRadio in class NetworkStateTracker
Parameters:
turnOn - true to turn the radio on, false

startUsingNetworkFeature

public int startUsingNetworkFeature(String feature,
                                    int callingPid,
                                    int callingUid)
Tells the underlying networking system that the caller wants to begin using the named feature. The interpretation of feature is completely up to each networking implementation. There are currently no Wi-Fi-specific features supported.

Specified by:
startUsingNetworkFeature in class NetworkStateTracker
Parameters:
feature - the name of the feature
callingPid - the process ID of the process that is issuing this request
callingUid - the user ID of the process that is issuing this request
Returns:
-1 indicating failure, always

stopUsingNetworkFeature

public int stopUsingNetworkFeature(String feature,
                                   int callingPid,
                                   int callingUid)
Tells the underlying networking system that the caller is finished using the named feature. The interpretation of feature is completely up to each networking implementation. There are currently no Wi-Fi-specific features supported.

Specified by:
stopUsingNetworkFeature in class NetworkStateTracker
Parameters:
feature - the name of the feature
callingPid - the process ID of the process that is issuing this request
callingUid - the user ID of the process that is issuing this request
Returns:
-1 indicating failure, always

interpretScanResultsAvailable

public void interpretScanResultsAvailable()
Description copied from class: NetworkStateTracker
Interprets scan results. This will be called at a safe time for processing, and from a safe thread.

Overrides:
interpretScanResultsAvailable in class NetworkStateTracker

setNotificationVisible

public void setNotificationVisible(boolean visible,
                                   int numNetworks,
                                   boolean force,
                                   int delay)


addToBlacklist

public boolean addToBlacklist(String bssid)

clearBlacklist

public boolean clearBlacklist()

toString

public String toString()
Description copied from class: Object
Returns a string containing a concise, human-readable description of the receiver.

Overrides:
toString in class Handler
Returns:
String a printable representation for the receiver.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature