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 Greenwaltimport java.util.List;
250451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
260451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt/**
270451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * Describes the Results of a batched set of wifi scans where the firmware performs many
280451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * scans and stores the timestamped results without waking the main processor each time.
290451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt * @hide pending review
300451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt */
310451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwaltpublic class BatchedScanResult implements Parcelable {
320451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    private static final String TAG = "BatchedScanResult";
330451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
340451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** Inidcates this scan was interrupted and may only have partial results. */
350451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public boolean truncated;
360451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
370451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** The result of this particular scan. */
380451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public final List<ScanResult> scanResults = new ArrayList<ScanResult>();
390451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
400451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
410451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public BatchedScanResult() {
420451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
430451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
440451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public BatchedScanResult(BatchedScanResult source) {
450451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        truncated = source.truncated;
460451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        for (ScanResult s : source.scanResults) scanResults.add(new ScanResult(s));
470451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
480451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
490451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    @Override
500451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public String toString() {
510451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        StringBuffer sb = new StringBuffer();
520451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
530451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        sb.append("BatchedScanResult: ").
540451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append("truncated: ").append(String.valueOf(truncated)).
550451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                append("scanResults: [");
560451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        for (ScanResult s : scanResults) {
570451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            sb.append(" <").append(s.toString()).append("> ");
580451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        }
590451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        sb.append(" ]");
600451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        return sb.toString();
610451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
620451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
630451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** Implement the Parcelable interface {@hide} */
640451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public int describeContents() {
650451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        return 0;
660451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
670451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
680451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** Implement the Parcelable interface {@hide} */
690451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public void writeToParcel(Parcel dest, int flags) {
700451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(truncated ? 1 : 0);
710451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        dest.writeInt(scanResults.size());
720451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        for (ScanResult s : scanResults) {
730451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            s.writeToParcel(dest, flags);
740451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        }
750451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    }
760451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
770451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    /** Implement the Parcelable interface {@hide} */
780451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt    public static final Creator<BatchedScanResult> CREATOR =
790451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        new Creator<BatchedScanResult>() {
800451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            public BatchedScanResult createFromParcel(Parcel in) {
810451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                BatchedScanResult result = new BatchedScanResult();
820451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                result.truncated = (in.readInt() == 1);
830451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                int count = in.readInt();
840451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                while (count-- > 0) {
850451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                    result.scanResults.add(ScanResult.CREATOR.createFromParcel(in));
860451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                }
870451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                return result;
880451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            }
890451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt
900451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            public BatchedScanResult[] newArray(int size) {
910451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt                return new BatchedScanResult[size];
920451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt            }
930451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt        };
940451d59ba2d768e7653752028910f00a6c96e64eRobert Greenwalt}
95