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
29 */
30@Deprecated
31public class BatchedScanResult implements Parcelable {
32    private static final String TAG = "BatchedScanResult";
33
34    /** Inidcates this scan was interrupted and may only have partial results. */
35    public boolean truncated;
36
37    /** The result of this particular scan. */
38    public final List<ScanResult> scanResults = new ArrayList<ScanResult>();
39
40
41    public BatchedScanResult() {
42    }
43
44    public BatchedScanResult(BatchedScanResult source) {
45        truncated = source.truncated;
46        for (ScanResult s : source.scanResults) scanResults.add(new ScanResult(s));
47    }
48
49    @Override
50    public String toString() {
51        StringBuffer sb = new StringBuffer();
52
53        sb.append("BatchedScanResult: ").
54                append("truncated: ").append(String.valueOf(truncated)).
55                append("scanResults: [");
56        for (ScanResult s : scanResults) {
57            sb.append(" <").append(s.toString()).append("> ");
58        }
59        sb.append(" ]");
60        return sb.toString();
61    }
62
63    /** Implement the Parcelable interface {@hide} */
64    public int describeContents() {
65        return 0;
66    }
67
68    /** Implement the Parcelable interface {@hide} */
69    public void writeToParcel(Parcel dest, int flags) {
70        dest.writeInt(truncated ? 1 : 0);
71        dest.writeInt(scanResults.size());
72        for (ScanResult s : scanResults) {
73            s.writeToParcel(dest, flags);
74        }
75    }
76
77    /** Implement the Parcelable interface {@hide} */
78    public static final Creator<BatchedScanResult> CREATOR =
79        new Creator<BatchedScanResult>() {
80            public BatchedScanResult createFromParcel(Parcel in) {
81                BatchedScanResult result = new BatchedScanResult();
82                result.truncated = (in.readInt() == 1);
83                int count = in.readInt();
84                while (count-- > 0) {
85                    result.scanResults.add(ScanResult.CREATOR.createFromParcel(in));
86                }
87                return result;
88            }
89
90            public BatchedScanResult[] newArray(int size) {
91                return new BatchedScanResult[size];
92            }
93        };
94}
95