FileDocCategorySizeDatePackage
BatchedScanSettings.javaAPI DocAndroid 5.1 API10394Thu Mar 12 22:22:44 GMT 2015android.net.wifi

BatchedScanSettings

public class BatchedScanSettings extends Object implements android.os.Parcelable
Describes the settings for batched wifi scans where the firmware performs many scans and stores the timestamped results without waking the main processor each time. This can give information over time with minimal battery impact.
hide
pending review

Fields Summary
private static final String
TAG
public static final int
UNSPECIFIED
Used to indicate no preference for an int value
public static final int
MIN_SCANS_PER_BATCH
public static final int
MAX_SCANS_PER_BATCH
public static final int
DEFAULT_SCANS_PER_BATCH
public static final int
MIN_AP_PER_SCAN
public static final int
MAX_AP_PER_SCAN
public static final int
DEFAULT_AP_PER_SCAN
public static final int
MIN_INTERVAL_SEC
public static final int
MAX_INTERVAL_SEC
public static final int
DEFAULT_INTERVAL_SEC
public static final int
MIN_AP_FOR_DISTANCE
public static final int
MAX_AP_FOR_DISTANCE
public static final int
DEFAULT_AP_FOR_DISTANCE
public static final int
MAX_WIFI_CHANNEL
public int
maxScansPerBatch
The expected number of scans per batch. Note that the firmware may drop scans leading to fewer scans during the normal batch scan duration. This value need not be specified (may be set to {@link UNSPECIFIED}) by the application and we will try to scan as many times as the firmware can support. If another app requests fewer scans per batch we will attempt to honor that.
public int
maxApPerScan
The maximum desired AP listed per scan. Fewer AP may be returned if that's all that the driver detected. If another application requests more AP per scan that will take precedence. The if more channels are detected than we request, the APs with the lowest signal strength will be dropped.
public Collection
channelSet
The channels used in the scan. If all channels should be used, {@code null} may be specified. If another application requests more channels or all channels, that will take precedence.
public int
scanIntervalSec
The time between the start of two sequential scans, in seconds. If another application requests more frequent scans, that will take precedence. If this value is less than the duration of a scan, the next scan should start immediately.
public int
maxApForDistance
The number of the best (strongest signal) APs for which the firmware will attempt to get distance information (RTT). Not all firmware supports this feature, so it may be ignored. If another application requests a greater number, that will take precedence.
public static final Creator
CREATOR
Implement the Parcelable interface {@hide}
Constructors Summary
public BatchedScanSettings()


      
        clear();
    
public BatchedScanSettings(BatchedScanSettings source)

        maxScansPerBatch = source.maxScansPerBatch;
        maxApPerScan = source.maxApPerScan;
        if (source.channelSet != null) {
            channelSet = new ArrayList(source.channelSet);
        }
        scanIntervalSec = source.scanIntervalSec;
        maxApForDistance = source.maxApForDistance;
    
Methods Summary
private booleanchannelSetIsValid()

        if (channelSet == null || channelSet.isEmpty()) return true;
        for (String channel : channelSet) {
            try {
                int i = Integer.parseInt(channel);
                if (i > 0 && i <= MAX_WIFI_CHANNEL) continue;
            } catch (NumberFormatException e) {}
            if (channel.equals("A") || channel.equals("B")) continue;
            return false;
        }
        return true;
    
public voidclear()

        maxScansPerBatch = UNSPECIFIED;
        maxApPerScan = UNSPECIFIED;
        channelSet = null;
        scanIntervalSec = UNSPECIFIED;
        maxApForDistance = UNSPECIFIED;
    
public voidconstrain()

hide

        if (scanIntervalSec == UNSPECIFIED) {
            scanIntervalSec = DEFAULT_INTERVAL_SEC;
        } else if (scanIntervalSec < MIN_INTERVAL_SEC) {
            scanIntervalSec = MIN_INTERVAL_SEC;
        } else if (scanIntervalSec > MAX_INTERVAL_SEC) {
            scanIntervalSec = MAX_INTERVAL_SEC;
        }

        if (maxScansPerBatch == UNSPECIFIED) {
            maxScansPerBatch = DEFAULT_SCANS_PER_BATCH;
        } else if (maxScansPerBatch < MIN_SCANS_PER_BATCH) {
            maxScansPerBatch = MIN_SCANS_PER_BATCH;
        } else if (maxScansPerBatch > MAX_SCANS_PER_BATCH) {
            maxScansPerBatch = MAX_SCANS_PER_BATCH;
        }

        if (maxApPerScan == UNSPECIFIED) {
            maxApPerScan = DEFAULT_AP_PER_SCAN;
        } else if (maxApPerScan < MIN_AP_PER_SCAN) {
            maxApPerScan = MIN_AP_PER_SCAN;
        } else if (maxApPerScan > MAX_AP_PER_SCAN) {
            maxApPerScan = MAX_AP_PER_SCAN;
        }

        if (maxApForDistance == UNSPECIFIED) {
            maxApForDistance = DEFAULT_AP_FOR_DISTANCE;
        } else if (maxApForDistance < MIN_AP_FOR_DISTANCE) {
            maxApForDistance = MIN_AP_FOR_DISTANCE;
        } else if (maxApForDistance > MAX_AP_FOR_DISTANCE) {
            maxApForDistance = MAX_AP_FOR_DISTANCE;
        }
    
public intdescribeContents()
Implement the Parcelable interface {@hide}

        return 0;
    
public booleanequals(java.lang.Object obj)

        if (obj instanceof BatchedScanSettings == false) return false;
        BatchedScanSettings o = (BatchedScanSettings)obj;
        if (maxScansPerBatch != o.maxScansPerBatch ||
              maxApPerScan != o.maxApPerScan ||
              scanIntervalSec != o.scanIntervalSec ||
              maxApForDistance != o.maxApForDistance) return false;
        if (channelSet == null) {
            return (o.channelSet == null);
        }
        return channelSet.equals(o.channelSet);
    
public inthashCode()

        return maxScansPerBatch +
                (maxApPerScan * 3) +
                (scanIntervalSec * 5) +
                (maxApForDistance * 7) +
                (channelSet.hashCode() * 11);
    
public booleanisInvalid()

hide

        if (maxScansPerBatch != UNSPECIFIED && (maxScansPerBatch < MIN_SCANS_PER_BATCH ||
                maxScansPerBatch > MAX_SCANS_PER_BATCH)) return true;
        if (maxApPerScan != UNSPECIFIED && (maxApPerScan < MIN_AP_PER_SCAN ||
                maxApPerScan > MAX_AP_PER_SCAN)) return true;
        if (channelSetIsValid() == false) return true;
        if (scanIntervalSec != UNSPECIFIED && (scanIntervalSec < MIN_INTERVAL_SEC ||
                scanIntervalSec > MAX_INTERVAL_SEC)) return true;
        if (maxApForDistance != UNSPECIFIED && (maxApForDistance < MIN_AP_FOR_DISTANCE ||
                maxApForDistance > MAX_AP_FOR_DISTANCE)) return true;
        return false;
    
public java.lang.StringtoString()

        StringBuffer sb = new StringBuffer();
        String none = "<none>";

        sb.append("BatchScanSettings [maxScansPerBatch: ").
                append(maxScansPerBatch == UNSPECIFIED ? none : maxScansPerBatch).
                append(", maxApPerScan: ").append(maxApPerScan == UNSPECIFIED? none : maxApPerScan).
                append(", scanIntervalSec: ").
                append(scanIntervalSec == UNSPECIFIED ? none : scanIntervalSec).
                append(", maxApForDistance: ").
                append(maxApForDistance == UNSPECIFIED ? none : maxApForDistance).
                append(", channelSet: ");
        if (channelSet == null) {
            sb.append("ALL");
        } else {
            sb.append("<");
            for (String channel : channelSet) {
                sb.append(" " + channel);
            }
            sb.append(">");
        }
        sb.append("]");
        return sb.toString();
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Implement the Parcelable interface {@hide}

        dest.writeInt(maxScansPerBatch);
        dest.writeInt(maxApPerScan);
        dest.writeInt(scanIntervalSec);
        dest.writeInt(maxApForDistance);
        dest.writeInt(channelSet == null ? 0 : channelSet.size());
        if (channelSet != null) {
            for (String channel : channelSet) dest.writeString(channel);
        }