10451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt/*
20451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * Copyright (C) 2008 The Android Open Source Project
30451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt *
40451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * Licensed under the Apache License, Version 2.0 (the "License");
50451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * you may not use this file except in compliance with the License.
60451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * You may obtain a copy of the License at
70451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt *
80451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt *      http://www.apache.org/licenses/LICENSE-2.0
90451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt *
100451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * Unless required by applicable law or agreed to in writing, software
110451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * distributed under the License is distributed on an "AS IS" BASIS,
120451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * See the License for the specific language governing permissions and
140451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * limitations under the License.
150451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt */
160451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
170451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwaltpackage android.net.wifi;
180451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
190451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwaltimport android.os.Parcelable;
200451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwaltimport android.os.Parcel;
210451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
220451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwaltimport java.util.ArrayList;
230451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwaltimport java.util.Collection;
240451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
250451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt/**
260451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * Describes the settings for batched wifi scans where the firmware performs many
270451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * scans and stores the timestamped results without waking the main processor each time.
280451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * This can give information over time with minimal battery impact.
290451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * @hide pending review
300451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt */
310451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwaltpublic class BatchedScanSettings implements Parcelable {
320451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    private static final String TAG = "BatchedScanSettings";
330451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
340451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** Used to indicate no preference for an int value */
350451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int UNSPECIFIED = Integer.MAX_VALUE;
360451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
37c90005d2924f305f19a37720932cb2fa34d26446Wei Wang    // TODO - make MIN/mAX as standard for wifi batch capability requirement.
380451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int MIN_SCANS_PER_BATCH = 2;
39c90005d2924f305f19a37720932cb2fa34d26446Wei Wang    public final static int MAX_SCANS_PER_BATCH = 20;
400451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int DEFAULT_SCANS_PER_BATCH = MAX_SCANS_PER_BATCH;
410451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
420451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int MIN_AP_PER_SCAN = 2;
43c90005d2924f305f19a37720932cb2fa34d26446Wei Wang    public final static int MAX_AP_PER_SCAN = 16;
440451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int DEFAULT_AP_PER_SCAN = 16;
450451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
46c90005d2924f305f19a37720932cb2fa34d26446Wei Wang    public final static int MIN_INTERVAL_SEC = 10;
47c90005d2924f305f19a37720932cb2fa34d26446Wei Wang    public final static int MAX_INTERVAL_SEC = 500;
480451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int DEFAULT_INTERVAL_SEC = 30;
490451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
500451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int MIN_AP_FOR_DISTANCE = 0;
510451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int MAX_AP_FOR_DISTANCE = MAX_AP_PER_SCAN;
520451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final static int DEFAULT_AP_FOR_DISTANCE = 0;
530451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
548e628dadc321bf49e93e482540df87431d014b01Robert Greenwalt    public final static int MAX_WIFI_CHANNEL = 196;
550451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
560451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** The expected number of scans per batch.  Note that the firmware may drop scans
570451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  leading to fewer scans during the normal batch scan duration.  This value need not
580451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  be specified (may be set to {@link UNSPECIFIED}) by the application and we will try
590451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  to scan as many times as the firmware can support.  If another app requests fewer
600451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  scans per batch we will attempt to honor that.
610451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     */
620451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int maxScansPerBatch;
630451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
640451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** The maximum desired AP listed per scan.  Fewer AP may be returned if that's all
650451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  that the driver detected.  If another application requests more AP per scan that
660451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  will take precedence.  The if more channels are detected than we request, the APs
670451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  with the lowest signal strength will be dropped.
680451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     */
690451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int maxApPerScan;
700451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
710451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** The channels used in the scan.  If all channels should be used, {@code null} may be
720451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  specified.  If another application requests more channels or all channels, that
730451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  will take precedence.
740451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     */
750451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public Collection<String> channelSet;
760451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
770451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** The time between the start of two sequential scans, in seconds.  If another
780451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  application requests more frequent scans, that will take precedence.  If this
790451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     * value is less than the duration of a scan, the next scan should start immediately.
800451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     */
810451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int scanIntervalSec;
820451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
830451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** The number of the best (strongest signal) APs for which the firmware will
840451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  attempt to get distance information (RTT).  Not all firmware supports this
850451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  feature, so it may be ignored.  If another application requests a greater
860451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     *  number, that will take precedence.
870451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt     */
880451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int maxApForDistance;
890451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
900451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public BatchedScanSettings() {
910451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        clear();
920451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
930451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
940451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public void clear() {
950451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        maxScansPerBatch = UNSPECIFIED;
960451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        maxApPerScan = UNSPECIFIED;
970451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        channelSet = null;
980451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        scanIntervalSec = UNSPECIFIED;
990451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        maxApForDistance = UNSPECIFIED;
1000451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
1010451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
1020451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public BatchedScanSettings(BatchedScanSettings source) {
1030451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        maxScansPerBatch = source.maxScansPerBatch;
1040451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        maxApPerScan = source.maxApPerScan;
1050451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (source.channelSet != null) {
1060451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            channelSet = new ArrayList(source.channelSet);
1070451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        }
1080451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        scanIntervalSec = source.scanIntervalSec;
1090451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        maxApForDistance = source.maxApForDistance;
1100451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
1110451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
1120451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    private boolean channelSetIsValid() {
1130451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (channelSet == null || channelSet.isEmpty()) return true;
1140451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        for (String channel : channelSet) {
1150451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            try {
1160451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                int i = Integer.parseInt(channel);
1178e628dadc321bf49e93e482540df87431d014b01Robert Greenwalt                if (i > 0 && i <= MAX_WIFI_CHANNEL) continue;
1180451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            } catch (NumberFormatException e) {}
1190451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            if (channel.equals("A") || channel.equals("B")) continue;
1200451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            return false;
1210451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        }
1220451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        return true;
1230451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
1240451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** @hide */
1250451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public boolean isInvalid() {
1260451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (maxScansPerBatch != UNSPECIFIED && (maxScansPerBatch < MIN_SCANS_PER_BATCH ||
1270451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                maxScansPerBatch > MAX_SCANS_PER_BATCH)) return true;
1280451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (maxApPerScan != UNSPECIFIED && (maxApPerScan < MIN_AP_PER_SCAN ||
1290451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                maxApPerScan > MAX_AP_PER_SCAN)) return true;
1300451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (channelSetIsValid() == false) return true;
1310451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (scanIntervalSec != UNSPECIFIED && (scanIntervalSec < MIN_INTERVAL_SEC ||
1320451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                scanIntervalSec > MAX_INTERVAL_SEC)) return true;
1330451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (maxApForDistance != UNSPECIFIED && (maxApForDistance < MIN_AP_FOR_DISTANCE ||
1340451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                maxApForDistance > MAX_AP_FOR_DISTANCE)) return true;
1350451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        return false;
1360451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
1370451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
13813820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt    /** @hide */
13913820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt    public void constrain() {
14013820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        if (scanIntervalSec == UNSPECIFIED) {
14113820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            scanIntervalSec = DEFAULT_INTERVAL_SEC;
14213820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        } else if (scanIntervalSec < MIN_INTERVAL_SEC) {
14313820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            scanIntervalSec = MIN_INTERVAL_SEC;
14413820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        } else if (scanIntervalSec > MAX_INTERVAL_SEC) {
14513820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            scanIntervalSec = MAX_INTERVAL_SEC;
14613820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        }
14713820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt
14813820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        if (maxScansPerBatch == UNSPECIFIED) {
14913820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxScansPerBatch = DEFAULT_SCANS_PER_BATCH;
15013820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        } else if (maxScansPerBatch < MIN_SCANS_PER_BATCH) {
15113820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxScansPerBatch = MIN_SCANS_PER_BATCH;
15213820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        } else if (maxScansPerBatch > MAX_SCANS_PER_BATCH) {
15313820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxScansPerBatch = MAX_SCANS_PER_BATCH;
15413820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        }
15513820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt
15613820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        if (maxApPerScan == UNSPECIFIED) {
15713820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxApPerScan = DEFAULT_AP_PER_SCAN;
15813820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        } else if (maxApPerScan < MIN_AP_PER_SCAN) {
15913820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxApPerScan = MIN_AP_PER_SCAN;
16013820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        } else if (maxApPerScan > MAX_AP_PER_SCAN) {
16113820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxApPerScan = MAX_AP_PER_SCAN;
16213820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        }
16313820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt
16413820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        if (maxApForDistance == UNSPECIFIED) {
16513820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxApForDistance = DEFAULT_AP_FOR_DISTANCE;
16613820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        } else if (maxApForDistance < MIN_AP_FOR_DISTANCE) {
16713820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxApForDistance = MIN_AP_FOR_DISTANCE;
16813820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        } else if (maxApForDistance > MAX_AP_FOR_DISTANCE) {
16913820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt            maxApForDistance = MAX_AP_FOR_DISTANCE;
17013820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt        }
17113820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt    }
17213820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt
17313820af302ead6b6a17b5f1b3991fcf8af252f93Robert Greenwalt
1740451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    @Override
1750451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public boolean equals(Object obj) {
1760451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (obj instanceof BatchedScanSettings == false) return false;
1770451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        BatchedScanSettings o = (BatchedScanSettings)obj;
1780451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (maxScansPerBatch != o.maxScansPerBatch ||
1790451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt              maxApPerScan != o.maxApPerScan ||
1800451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt              scanIntervalSec != o.scanIntervalSec ||
1810451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt              maxApForDistance != o.maxApForDistance) return false;
1820451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (channelSet == null) {
1830451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            return (o.channelSet == null);
1840451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        }
1850451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        return channelSet.equals(o.channelSet);
1860451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
1870451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
1880451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    @Override
1890451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int hashCode() {
1900451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        return maxScansPerBatch +
1910451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                (maxApPerScan * 3) +
1920451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                (scanIntervalSec * 5) +
1930451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                (maxApForDistance * 7) +
1940451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                (channelSet.hashCode() * 11);
1950451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
1960451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
1970451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    @Override
1980451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public String toString() {
1990451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        StringBuffer sb = new StringBuffer();
2000451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        String none = "<none>";
2010451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
2020451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        sb.append("BatchScanSettings [maxScansPerBatch: ").
2030451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append(maxScansPerBatch == UNSPECIFIED ? none : maxScansPerBatch).
2040451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append(", maxApPerScan: ").append(maxApPerScan == UNSPECIFIED? none : maxApPerScan).
2050451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append(", scanIntervalSec: ").
2060451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append(scanIntervalSec == UNSPECIFIED ? none : scanIntervalSec).
2070451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append(", maxApForDistance: ").
2080451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append(maxApForDistance == UNSPECIFIED ? none : maxApForDistance).
2090451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append(", channelSet: ");
2100451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (channelSet == null) {
2110451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            sb.append("ALL");
2120451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        } else {
2130451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            sb.append("<");
2140451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            for (String channel : channelSet) {
2150451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                sb.append(" " + channel);
2160451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            }
2170451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            sb.append(">");
2180451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        }
2190451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        sb.append("]");
2200451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        return sb.toString();
2210451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
2220451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
2230451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** Implement the Parcelable interface {@hide} */
2240451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int describeContents() {
2250451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        return 0;
2260451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
2270451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
2280451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** Implement the Parcelable interface {@hide} */
2290451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public void writeToParcel(Parcel dest, int flags) {
2300451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(maxScansPerBatch);
2310451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(maxApPerScan);
2320451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(scanIntervalSec);
2330451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(maxApForDistance);
2340451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(channelSet == null ? 0 : channelSet.size());
2350451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        if (channelSet != null) {
2360451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            for (String channel : channelSet) dest.writeString(channel);
2370451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        }
2380451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
2390451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
2400451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** Implement the Parcelable interface {@hide} */
2410451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public static final Creator<BatchedScanSettings> CREATOR =
2420451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        new Creator<BatchedScanSettings>() {
2430451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            public BatchedScanSettings createFromParcel(Parcel in) {
2440451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                BatchedScanSettings settings = new BatchedScanSettings();
2450451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                settings.maxScansPerBatch = in.readInt();
2460451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                settings.maxApPerScan = in.readInt();
2470451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                settings.scanIntervalSec = in.readInt();
2480451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                settings.maxApForDistance = in.readInt();
2490451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                int channelCount = in.readInt();
2500451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                if (channelCount > 0) {
2510451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                    settings.channelSet = new ArrayList(channelCount);
2520451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                    while (channelCount-- > 0) {
2530451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                        settings.channelSet.add(in.readString());
2540451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                    }
2550451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                }
2560451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                return settings;
2570451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            }
2580451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
2590451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            public BatchedScanSettings[] newArray(int size) {
2600451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                return new BatchedScanSettings[size];
2610451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            }
2620451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        };
2630451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt}
264