FileDocCategorySizeDatePackage
BaseNetworkStateTracker.javaAPI DocAndroid 5.1 API5812Thu Mar 12 22:22:10 GMT 2015android.net

BaseNetworkStateTracker

public abstract class BaseNetworkStateTracker extends Object implements NetworkStateTracker
Interface to control and observe state of a specific network, hiding network-specific details from {@link ConnectivityManager}. Surfaces events through the registered {@link Handler} to enable {@link ConnectivityManager} to respond to state changes over time.
hide

Fields Summary
public static final String
PROP_TCP_BUFFER_UNKNOWN
public static final String
PROP_TCP_BUFFER_WIFI
protected android.content.Context
mContext
private android.os.Handler
mTarget
protected NetworkInfo
mNetworkInfo
protected LinkProperties
mLinkProperties
protected NetworkCapabilities
mNetworkCapabilities
protected Network
mNetwork
private AtomicBoolean
mTeardownRequested
private AtomicBoolean
mPrivateDnsRouteSet
private AtomicBoolean
mDefaultRouteSet
Constructors Summary
public BaseNetworkStateTracker(int networkType)


       
        mNetworkInfo = new NetworkInfo(
                networkType, -1, ConnectivityManager.getNetworkTypeName(networkType), null);
        mLinkProperties = new LinkProperties();
        mNetworkCapabilities = new NetworkCapabilities();
    
protected BaseNetworkStateTracker()

        // By default, let the sub classes construct everything
    
Methods Summary
public voidcaptivePortalCheckCompleted(boolean isCaptivePortal)

        // not implemented
    
public voiddefaultRouteSet(boolean enabled)

        mDefaultRouteSet.set(enabled);
    
protected final voiddispatchConfigurationChanged()

        // TODO: include snapshot of other fields when sending
        mTarget.obtainMessage(EVENT_CONFIGURATION_CHANGED, getNetworkInfo()).sendToTarget();
    
protected final voiddispatchStateChanged()

        // TODO: include snapshot of other fields when sending
        mTarget.obtainMessage(EVENT_STATE_CHANGED, getNetworkInfo()).sendToTarget();
    
public LinkPropertiesgetLinkProperties()

        return new LinkProperties(mLinkProperties);
    
public LinkQualityInfogetLinkQualityInfo()

        return null;
    
public NetworkgetNetwork()

        return mNetwork;
    
public NetworkCapabilitiesgetNetworkCapabilities()

        return new NetworkCapabilities(mNetworkCapabilities);
    
public NetworkInfogetNetworkInfo()

        return new NetworkInfo(mNetworkInfo);
    
public java.lang.StringgetNetworkInterfaceName()

        if (mLinkProperties != null) {
            return mLinkProperties.getInterfaceName();
        } else {
            return null;
        }
    
protected android.os.HandlergetTargetHandler()

        return mTarget;
    
public booleanisAvailable()

        return mNetworkInfo.isAvailable();
    
public booleanisDefaultRouteSet()

        return mDefaultRouteSet.get();
    
public booleanisPrivateDnsRouteSet()

        return mPrivateDnsRouteSet.get();
    
public booleanisTeardownRequested()

        return mTeardownRequested.get();
    
public voidprivateDnsRouteSet(boolean enabled)

        mPrivateDnsRouteSet.set(enabled);
    
public voidsetDependencyMet(boolean met)

        // Base tracker doesn't handle dependencies
    
public voidsetNetId(int netId)

        mNetwork = new Network(netId);
    
public voidsetPolicyDataEnable(boolean enabled)

        // Base tracker doesn't handle enabled flags
    
public booleansetRadio(boolean turnOn)

        // Base tracker doesn't handle radios
        return true;
    
public voidsetTeardownRequested(boolean isRequested)

        mTeardownRequested.set(isRequested);
    
public voidsetUserDataEnable(boolean enabled)

        // Base tracker doesn't handle enabled flags
    
public voidstartMonitoring(android.content.Context context, android.os.Handler target)

        mContext = Preconditions.checkNotNull(context);
        mTarget = Preconditions.checkNotNull(target);
        startMonitoringInternal();
    
protected voidstartMonitoringInternal()


    
public voidstartSampling(SamplingDataTracker.SamplingSnapshot s)

        // nothing to do
    
public voidstopSampling(SamplingDataTracker.SamplingSnapshot s)

        // nothing to do
    
public voidsupplyMessenger(android.os.Messenger messenger)

        // not supported on this network