1/* 2 * Copyright (C) 2008 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.Parcelable; 20import android.os.Parcel; 21 22import java.util.ArrayList; 23import java.util.List; 24 25/** 26 * Describes the Results of a batched set of wifi scans where the firmware performs many 27 * scans and stores the timestamped results without waking the main processor each time. 28 * @hide pending review 29 */ 30public class BatchedScanResult implements Parcelable { 31 private static final String TAG = "BatchedScanResult"; 32 33 /** Inidcates this scan was interrupted and may only have partial results. */ 34 public boolean truncated; 35 36 /** The result of this particular scan. */ 37 public final List<ScanResult> scanResults = new ArrayList<ScanResult>(); 38 39 40 public BatchedScanResult() { 41 } 42 43 public BatchedScanResult(BatchedScanResult source) { 44 truncated = source.truncated; 45 for (ScanResult s : source.scanResults) scanResults.add(new ScanResult(s)); 46 } 47 48 @Override 49 public String toString() { 50 StringBuffer sb = new StringBuffer(); 51 52 sb.append("BatchedScanResult: "). 53 append("truncated: ").append(String.valueOf(truncated)). 54 append("scanResults: ["); 55 for (ScanResult s : scanResults) { 56 sb.append(" <").append(s.toString()).append("> "); 57 } 58 sb.append(" ]"); 59 return sb.toString(); 60 } 61 62 /** Implement the Parcelable interface {@hide} */ 63 public int describeContents() { 64 return 0; 65 } 66 67 /** Implement the Parcelable interface {@hide} */ 68 public void writeToParcel(Parcel dest, int flags) { 69 dest.writeInt(truncated ? 1 : 0); 70 dest.writeInt(scanResults.size()); 71 for (ScanResult s : scanResults) { 72 s.writeToParcel(dest, flags); 73 } 74 } 75 76 /** Implement the Parcelable interface {@hide} */ 77 public static final Creator<BatchedScanResult> CREATOR = 78 new Creator<BatchedScanResult>() { 79 public BatchedScanResult createFromParcel(Parcel in) { 80 BatchedScanResult result = new BatchedScanResult(); 81 result.truncated = (in.readInt() == 1); 82 int count = in.readInt(); 83 while (count-- > 0) { 84 result.scanResults.add(ScanResult.CREATOR.createFromParcel(in)); 85 } 86 return result; 87 } 88 89 public BatchedScanResult[] newArray(int size) { 90 return new BatchedScanResult[size]; 91 } 92 }; 93} 94