1/* 2 * Copyright (c) 2014, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.net.wifi; 18 19import android.os.Parcel; 20import android.os.Parcelable; 21 22import java.util.ArrayList; 23import java.util.Collection; 24 25/** 26 * Bundle of customized scan settings 27 * 28 * @see WifiManager#startCustomizedScan 29 * 30 * @hide 31 */ 32public class ScanSettings implements Parcelable { 33 34 /** channel set to scan. this can be null or empty, indicating a full scan */ 35 public Collection<WifiChannel> channelSet; 36 37 /** public constructor */ 38 public ScanSettings() { } 39 40 /** copy constructor */ 41 public ScanSettings(ScanSettings source) { 42 if (source.channelSet != null) 43 channelSet = new ArrayList<WifiChannel>(source.channelSet); 44 } 45 46 /** check for validity */ 47 public boolean isValid() { 48 for (WifiChannel channel : channelSet) 49 if (!channel.isValid()) return false; 50 return true; 51 } 52 53 /** implement Parcelable interface */ 54 @Override 55 public int describeContents() { 56 return 0; 57 } 58 59 /** implement Parcelable interface */ 60 @Override 61 public void writeToParcel(Parcel out, int flags) { 62 out.writeInt(channelSet == null ? 0 : channelSet.size()); 63 if (channelSet != null) 64 for (WifiChannel channel : channelSet) channel.writeToParcel(out, flags); 65 } 66 67 /** implement Parcelable interface */ 68 public static final Parcelable.Creator<ScanSettings> CREATOR = 69 new Parcelable.Creator<ScanSettings>() { 70 @Override 71 public ScanSettings createFromParcel(Parcel in) { 72 ScanSettings settings = new ScanSettings(); 73 int size = in.readInt(); 74 if (size > 0) { 75 settings.channelSet = new ArrayList<WifiChannel>(size); 76 while (size-- > 0) 77 settings.channelSet.add(WifiChannel.CREATOR.createFromParcel(in)); 78 } 79 return settings; 80 } 81 82 @Override 83 public ScanSettings[] newArray(int size) { 84 return new ScanSettings[size]; 85 } 86 }; 87} 88