• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 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 
17 package android.net;
18 
19 import android.os.Parcel;
20 
21 /**
22  *  Class that represents useful attributes of wifi network links
23  *  such as the upload/download throughput or error rate etc.
24  *  @hide
25  */
26 public class WifiLinkQualityInfo extends LinkQualityInfo {
27 
28     /* Indicates Wifi network type such as b/g etc*/
29     private int  mType = UNKNOWN_INT;
30 
31     private String mBssid;
32 
33     /* Rssi found by scans */
34     private int  mRssi = UNKNOWN_INT;
35 
36     /* packet statistics */
37     private long mTxGood = UNKNOWN_LONG;
38     private long mTxBad = UNKNOWN_LONG;
39 
40     /**
41      * Implement the Parcelable interface.
42      * @hide
43      */
44     @Override
writeToParcel(Parcel dest, int flags)45     public void writeToParcel(Parcel dest, int flags) {
46         super.writeToParcel(dest, flags, OBJECT_TYPE_WIFI_LINK_QUALITY_INFO);
47 
48         dest.writeInt(mType);
49         dest.writeInt(mRssi);
50         dest.writeLong(mTxGood);
51         dest.writeLong(mTxBad);
52 
53         dest.writeString(mBssid);
54     }
55 
56     /* Un-parceling helper */
57     /**
58      * @hide
59      */
createFromParcelBody(Parcel in)60     public static WifiLinkQualityInfo createFromParcelBody(Parcel in) {
61         WifiLinkQualityInfo li = new WifiLinkQualityInfo();
62 
63         li.initializeFromParcel(in);
64 
65         li.mType =  in.readInt();
66         li.mRssi =  in.readInt();
67         li.mTxGood =  in.readLong();
68         li.mTxBad =  in.readLong();
69 
70         li.mBssid =  in.readString();
71 
72         return li;
73     }
74 
75     /**
76      * returns Wifi network type
77      * @return network type or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
78      */
getType()79     public int getType() {
80         return mType;
81     }
82 
83     /**
84      * @hide
85      */
setType(int type)86     public void setType(int type) {
87         mType = type;
88     }
89 
90     /**
91      * returns BSSID of the access point
92      * @return the BSSID, in the form of a six-byte MAC address: {@code XX:XX:XX:XX:XX:XX} or null
93      */
getBssid()94     public String getBssid() {
95         return mBssid;
96     }
97 
98     /**
99      * @hide
100      */
setBssid(String bssid)101     public void setBssid(String bssid) {
102         mBssid = bssid;
103     }
104 
105     /**
106      * returns RSSI of the network in raw form
107      * @return un-normalized RSSI or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
108      */
getRssi()109     public int getRssi() {
110         return mRssi;
111     }
112 
113     /**
114      * @hide
115      */
setRssi(int rssi)116     public void setRssi(int rssi) {
117         mRssi = rssi;
118     }
119 
120     /**
121      * returns number of packets transmitted without error
122      * @return number of packets or {@link android.net.LinkQualityInfo#UNKNOWN_LONG}
123      */
getTxGood()124     public long getTxGood() {
125         return mTxGood;
126     }
127 
128     /**
129      * @hide
130      */
setTxGood(long txGood)131     public void setTxGood(long txGood) {
132         mTxGood = txGood;
133     }
134 
135     /**
136      * returns number of transmitted packets that encountered errors
137      * @return number of packets or {@link android.net.LinkQualityInfo#UNKNOWN_LONG}
138      */
getTxBad()139     public long getTxBad() {
140         return mTxBad;
141     }
142 
143     /**
144      * @hide
145      */
setTxBad(long txBad)146     public void setTxBad(long txBad) {
147         mTxBad = txBad;
148     }
149 }
150