FileDocCategorySizeDatePackage
InterfaceConfiguration.javaAPI DocAndroid 5.1 API4470Thu Mar 12 22:22:10 GMT 2015android.net

InterfaceConfiguration

public class InterfaceConfiguration extends Object implements android.os.Parcelable
Configuration details for a network interface.
hide

Fields Summary
private String
mHwAddr
private LinkAddress
mAddr
private HashSet
mFlags
private static final String
FLAG_UP
private static final String
FLAG_DOWN
public static final Creator
CREATOR
Constructors Summary
Methods Summary
public voidclearFlag(java.lang.String flag)

        validateFlag(flag);
        mFlags.remove(flag);
    
public intdescribeContents()
{@inheritDoc}

        return 0;
    
public java.lang.IterablegetFlags()

        return mFlags;
    
public java.lang.StringgetHardwareAddress()

        return mHwAddr;
    
public LinkAddressgetLinkAddress()

        return mAddr;
    
public booleanhasFlag(java.lang.String flag)

        validateFlag(flag);
        return mFlags.contains(flag);
    
public booleanisActive()
This function determines if the interface is up and has a valid IP configuration (IP address has a non zero octet). Note: It is supposed to be quick and hence should not initiate any network activity

        try {
            if (hasFlag(FLAG_UP)) {
                for (byte b : mAddr.getAddress().getAddress()) {
                    if (b != 0) return true;
                }
            }
        } catch (NullPointerException e) {
            return false;
        }
        return false;
    
public voidsetFlag(java.lang.String flag)

        validateFlag(flag);
        mFlags.add(flag);
    
public voidsetHardwareAddress(java.lang.String hwAddr)

        mHwAddr = hwAddr;
    
public voidsetInterfaceDown()
Set flags to mark interface as down.

        mFlags.remove(FLAG_UP);
        mFlags.add(FLAG_DOWN);
    
public voidsetInterfaceUp()
Set flags to mark interface as up.

        mFlags.remove(FLAG_DOWN);
        mFlags.add(FLAG_UP);
    
public voidsetLinkAddress(LinkAddress addr)

        mAddr = addr;
    
public java.lang.StringtoString()


    
       
        final StringBuilder builder = new StringBuilder();
        builder.append("mHwAddr=").append(mHwAddr);
        builder.append(" mAddr=").append(String.valueOf(mAddr));
        builder.append(" mFlags=").append(getFlags());
        return builder.toString();
    
private static voidvalidateFlag(java.lang.String flag)


         
        if (flag.indexOf(' ") >= 0) {
            throw new IllegalArgumentException("flag contains space: " + flag);
        }
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
{@inheritDoc}

        dest.writeString(mHwAddr);
        if (mAddr != null) {
            dest.writeByte((byte)1);
            dest.writeParcelable(mAddr, flags);
        } else {
            dest.writeByte((byte)0);
        }
        dest.writeInt(mFlags.size());
        for (String flag : mFlags) {
            dest.writeString(flag);
        }