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.annotation.SystemApi;
20
21import android.os.Parcel;
22import android.os.Parcelable;
23
24/**
25 * Connection Statistics For a WiFi Network.
26 * @hide
27 */
28@SystemApi
29public class WifiNetworkConnectionStatistics implements Parcelable {
30    private static final String TAG = "WifiNetworkConnnectionStatistics";
31
32    public int numConnection;
33    public int numUsage;
34
35    public WifiNetworkConnectionStatistics(int connection, int usage) {
36        numConnection = connection;
37        numUsage = usage;
38    }
39
40    public WifiNetworkConnectionStatistics() { }
41
42
43    @Override
44    public String toString() {
45        StringBuilder sbuf = new StringBuilder();
46        sbuf.append("c=").append(numConnection);
47        sbuf.append(" u=").append(numUsage);
48        return sbuf.toString();
49    }
50
51
52    /** copy constructor*/
53    public WifiNetworkConnectionStatistics(WifiNetworkConnectionStatistics source) {
54        numConnection = source.numConnection;
55        numUsage = source.numUsage;
56    }
57
58    /** Implement the Parcelable interface */
59    public int describeContents() {
60        return 0;
61    }
62
63    /** Implement the Parcelable interface */
64    @Override
65    public void writeToParcel(Parcel dest, int flags) {
66        dest.writeInt(numConnection);
67        dest.writeInt(numUsage);
68    }
69
70    /** Implement the Parcelable interface */
71    public static final Creator<WifiNetworkConnectionStatistics> CREATOR =
72        new Creator<WifiNetworkConnectionStatistics>() {
73            public WifiNetworkConnectionStatistics createFromParcel(Parcel in) {
74                int numConnection = in.readInt();
75                int numUsage = in.readInt();
76                WifiNetworkConnectionStatistics stats =
77                        new WifiNetworkConnectionStatistics(numConnection, numUsage);
78                return stats;
79            }
80
81            public WifiNetworkConnectionStatistics[] newArray(int size) {
82                return new WifiNetworkConnectionStatistics[size];
83            }
84        };
85}
86