Build 1.0_r1(from source)

android.net
Class NetworkStateTracker

java.lang.Object
  extended by android.os.Handler
      extended by android.net.NetworkStateTracker
Direct Known Subclasses:
MobileDataStateTracker, WifiStateTracker

public abstract class NetworkStateTracker
extends Handler

Each subclass of this class keeps track of the state of connectivity of a network interface. All state information for a network should be kept in a Tracker class. This superclass manages the network-type-independent aspects of network state.


Field Summary
static int EVENT_CONFIGURATION_CHANGED
           
static int EVENT_NOTIFICATION_CHANGED
          arg1: 1 to show, 0 to hide arg2: ID of the notification obj: Notification (if showing)
static int EVENT_SCAN_RESULTS_AVAILABLE
           
static int EVENT_STATE_CHANGED
           
protected  Context mContext
           
protected  NetworkInfo mNetworkInfo
           
protected  Handler mTarget
           
 
Constructor Summary
NetworkStateTracker(Context context, Handler target, int networkType)
           
 
Method Summary
protected static String[] getNameServerList(String[] propertyNames)
          Return the IP addresses of the DNS servers available for this network interface.
abstract  String[] getNameServers()
          Return the list of DNS servers associated with this network.
 NetworkInfo getNetworkInfo()
           
abstract  String getTcpBufferSizesPropName()
          Return the system properties name associated with the tcp buffer sizes for this network.
 void interpretScanResultsAvailable()
          Interprets scan results.
abstract  boolean isAvailable()
          Returns an indication of whether this network is available for connections.
abstract  boolean reconnect()
          Reenable connectivity to a network after a teardown().
 void releaseWakeLock()
          Release the wakelock, if any, that may be held while handling a disconnect operation.
 boolean requestRouteToHost(int hostAddress)
          Ensure that a network route exists to deliver traffic to the specified host via this network interface.
protected  void sendScanResultsAvailable()
          Send a notification that the results of a scan for network access points has completed, and results are available.
 void setDetailedState(NetworkInfo.DetailedState state)
          Record the detailed state of a network, and if it is a change from the previous state, send a notification to any listeners.
 void setDetailedState(NetworkInfo.DetailedState state, String reason, String extraInfo)
          Record the detailed state of a network, and if it is a change from the previous state, send a notification to any listeners.
protected  void setDetailedStateInternal(NetworkInfo.DetailedState state)
           
abstract  boolean setRadio(boolean turnOn)
          Turn the wireless radio off for a network.
abstract  void startMonitoring()
           
abstract  int startUsingNetworkFeature(String feature, int callingPid, int callingUid)
          Tells the underlying networking system that the caller wants to begin using the named feature.
abstract  int stopUsingNetworkFeature(String feature, int callingPid, int callingUid)
          Tells the underlying networking system that the caller is finished using the named feature.
abstract  boolean teardown()
          Disable connectivity to a network
 void updateNetworkSettings()
          Reads the network specific TCP buffer sizes from SystemProperties net.tcp.buffersize.[default|wifi|umts|edge|gprs] and set them for system wide use
 
Methods inherited from class android.os.Handler
dispatchMessage, dump, getLooper, handleMessage, hasMessages, hasMessages, obtainMessage, obtainMessage, obtainMessage, obtainMessage, obtainMessage, post, postAtFrontOfQueue, postAtTime, postAtTime, postDelayed, removeCallbacks, removeCallbacks, removeCallbacksAndMessages, removeMessages, removeMessages, sendEmptyMessage, sendEmptyMessageAtTime, sendEmptyMessageDelayed, sendMessage, sendMessageAtFrontOfQueue, sendMessageAtTime, sendMessageDelayed, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mNetworkInfo

protected NetworkInfo mNetworkInfo

mContext

protected Context mContext

mTarget

protected Handler mTarget

EVENT_STATE_CHANGED

public static final int EVENT_STATE_CHANGED
See Also:
Constant Field Values

EVENT_SCAN_RESULTS_AVAILABLE

public static final int EVENT_SCAN_RESULTS_AVAILABLE
See Also:
Constant Field Values

EVENT_NOTIFICATION_CHANGED

public static final int EVENT_NOTIFICATION_CHANGED
arg1: 1 to show, 0 to hide arg2: ID of the notification obj: Notification (if showing)

See Also:
Constant Field Values

EVENT_CONFIGURATION_CHANGED

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

NetworkStateTracker

public NetworkStateTracker(Context context,
                           Handler target,
                           int networkType)
Method Detail

getNetworkInfo

public NetworkInfo getNetworkInfo()

getNameServers

public abstract String[] getNameServers()
Return the list of DNS servers associated with this network.

Returns:
a list of the IP addresses of the DNS servers available for the network.

getTcpBufferSizesPropName

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


getNameServerList

protected static String[] getNameServerList(String[] propertyNames)
Return the IP addresses of the DNS servers available for this network interface.

Parameters:
propertyNames - the names of the system properties whose values give the IP addresses. Properties with no values are skipped.
Returns:
an array of Strings containing the IP addresses of the DNS servers, in dot-notation. This may have fewer non-null entries than the list of names passed in, since some of the passed-in names may have empty values.

updateNetworkSettings

public void updateNetworkSettings()
Reads the network specific TCP buffer sizes from SystemProperties net.tcp.buffersize.[default|wifi|umts|edge|gprs] and set them for system wide use


releaseWakeLock

public void releaseWakeLock()
Release the wakelock, if any, that may be held while handling a disconnect operation.


setDetailedState

public void setDetailedState(NetworkInfo.DetailedState state)
Record the detailed state of a network, and if it is a change from the previous state, send a notification to any listeners.

Parameters:
state - the new @{code DetailedState}

setDetailedState

public void setDetailedState(NetworkInfo.DetailedState state,
                             String reason,
                             String extraInfo)
Record the detailed state of a network, and if it is a change from the previous state, send a notification to any listeners.

Parameters:
state - the new @{code DetailedState}
reason - a String indicating a reason for the state change, if one was supplied. May be null.
extraInfo - optional String providing extra information about the state change

setDetailedStateInternal

protected void setDetailedStateInternal(NetworkInfo.DetailedState state)

sendScanResultsAvailable

protected void sendScanResultsAvailable()
Send a notification that the results of a scan for network access points has completed, and results are available.


startMonitoring

public abstract void startMonitoring()

teardown

public abstract boolean teardown()
Disable connectivity to a network

Returns:
true if a teardown occurred, false if the teardown did not occur.

reconnect

public abstract boolean reconnect()
Reenable connectivity to a network after a teardown().


setRadio

public abstract boolean setRadio(boolean turnOn)
Turn the wireless radio off for a network.

Parameters:
turnOn - true to turn the radio on, false

isAvailable

public abstract boolean isAvailable()
Returns an indication of whether this network is available for connections. A value of false means that some quasi-permanent condition prevents connectivity to this network.


startUsingNetworkFeature

public abstract 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.

Parameters:
feature - the name of the feature to be used
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:
an integer value representing the outcome of the request. The interpretation of this value is specific to each networking implementation+feature combination, except that the value -1 always indicates failure.

stopUsingNetworkFeature

public abstract 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.

Parameters:
feature - the name of the feature that is no longer needed.
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:
an integer value representing the outcome of the request. The interpretation of this value is specific to each networking implementation+feature combination, except that the value -1 always indicates failure.

requestRouteToHost

public boolean requestRouteToHost(int hostAddress)
Ensure that a network route exists to deliver traffic to the specified host via this network interface.

Parameters:
hostAddress - the IP address of the host to which the route is desired
Returns:
true on success, false on failure

interpretScanResultsAvailable

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


Build 1.0_r1(from source)

Please submit a feedback, bug or feature