blob: 06c739d6cf956ade95332f87c1566bfd061b6dac [file] [log] [blame]
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -07001/*
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
17package android.net;
18
Mathew Inwood53f089f2018-08-08 14:44:44 +010019import android.annotation.UnsupportedAppUsage;
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -070020import android.os.Parcel;
21
22/**
23 * Class that represents useful attributes of mobile network links
24 * such as the upload/download throughput or error rate etc.
25 * @hide
26 */
27public class MobileLinkQualityInfo extends LinkQualityInfo {
28 // Represents TelephonyManager.NetworkType
29 private int mMobileNetworkType = UNKNOWN_INT;
30 private int mRssi = UNKNOWN_INT;
31 private int mGsmErrorRate = UNKNOWN_INT;
32 private int mCdmaDbm = UNKNOWN_INT;
33 private int mCdmaEcio = UNKNOWN_INT;
34 private int mEvdoDbm = UNKNOWN_INT;
35 private int mEvdoEcio = UNKNOWN_INT;
36 private int mEvdoSnr = UNKNOWN_INT;
37 private int mLteSignalStrength = UNKNOWN_INT;
38 private int mLteRsrp = UNKNOWN_INT;
39 private int mLteRsrq = UNKNOWN_INT;
40 private int mLteRssnr = UNKNOWN_INT;
41 private int mLteCqi = UNKNOWN_INT;
42
43 /**
44 * Implement the Parcelable interface.
45 * @hide
46 */
47 @Override
48 public void writeToParcel(Parcel dest, int flags) {
49 super.writeToParcel(dest, flags, OBJECT_TYPE_MOBILE_LINK_QUALITY_INFO);
50
51 dest.writeInt(mMobileNetworkType);
52 dest.writeInt(mRssi);
53 dest.writeInt(mGsmErrorRate);
54 dest.writeInt(mCdmaDbm);
55 dest.writeInt(mCdmaEcio);
56 dest.writeInt(mEvdoDbm);
57 dest.writeInt(mEvdoEcio);
58 dest.writeInt(mEvdoSnr);
59 dest.writeInt(mLteSignalStrength);
60 dest.writeInt(mLteRsrp);
61 dest.writeInt(mLteRsrq);
62 dest.writeInt(mLteRssnr);
63 dest.writeInt(mLteCqi);
64 }
65
66 /* Un-parceling helper */
67 /**
68 * @hide
69 */
70 public static MobileLinkQualityInfo createFromParcelBody(Parcel in) {
71
72 MobileLinkQualityInfo li = new MobileLinkQualityInfo();
73
74 li.initializeFromParcel(in);
75
76 li.mMobileNetworkType = in.readInt();
77 li.mRssi = in.readInt();
78 li.mGsmErrorRate = in.readInt();
79 li.mCdmaDbm = in.readInt();
80 li.mCdmaEcio = in.readInt();
81 li.mEvdoDbm = in.readInt();
82 li.mEvdoEcio = in.readInt();
83 li.mEvdoSnr = in.readInt();
84 li.mLteSignalStrength = in.readInt();
85 li.mLteRsrp = in.readInt();
86 li.mLteRsrq = in.readInt();
87 li.mLteRssnr = in.readInt();
88 li.mLteCqi = in.readInt();
89
90 return li;
91 }
92
93 /**
94 * returns mobile network type as defined by {@link android.telephony.TelephonyManager}
95 * @return network type or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
96 */
Mathew Inwood53f089f2018-08-08 14:44:44 +010097 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -070098 public int getMobileNetworkType() {
99 return mMobileNetworkType;
100 }
101
102 /**
103 * @hide
104 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100105 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700106 public void setMobileNetworkType(int mobileNetworkType) {
107 mMobileNetworkType = mobileNetworkType;
108 }
109
110 /**
111 * returns signal strength for GSM networks
112 * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
113 */
114 public int getRssi() {
115 return mRssi;
116 }
117
118 /**
119 * @hide
120 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100121 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700122 public void setRssi(int Rssi) {
123 mRssi = Rssi;
124 }
125
126 /**
127 * returns error rates for GSM networks
128 * @return error rate or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
129 */
130 public int getGsmErrorRate() {
131 return mGsmErrorRate;
132 }
133
134 /**
135 * @hide
136 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100137 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700138 public void setGsmErrorRate(int gsmErrorRate) {
139 mGsmErrorRate = gsmErrorRate;
140 }
141
142 /**
143 * returns signal strength for CDMA networks
144 * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
145 */
146 public int getCdmaDbm() {
147 return mCdmaDbm;
148 }
149
150 /**
151 * @hide
152 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100153 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700154 public void setCdmaDbm(int cdmaDbm) {
155 mCdmaDbm = cdmaDbm;
156 }
157
158 /**
159 * returns signal to noise ratio for CDMA networks
160 * @return signal to noise ratio in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
161 */
162 public int getCdmaEcio() {
163 return mCdmaEcio;
164 }
165
166 /**
167 * @hide
168 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100169 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700170 public void setCdmaEcio(int cdmaEcio) {
171 mCdmaEcio = cdmaEcio;
172 }
173
174 /**
175 * returns signal strength for EVDO networks
176 * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
177 */
178 public int getEvdoDbm() {
179 return mEvdoDbm;
180 }
181
182 /**
183 * @hide
184 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100185 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700186 public void setEvdoDbm(int evdoDbm) {
187 mEvdoDbm = evdoDbm;
188 }
189
190 /**
191 * returns signal to noise ratio for EVDO spectrum
192 * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
193 */
194 public int getEvdoEcio() {
195 return mEvdoEcio;
196 }
197
198 /**
199 * @hide
200 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100201 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700202 public void setEvdoEcio(int evdoEcio) {
203 mEvdoEcio = evdoEcio;
204 }
205
206 /**
207 * returns end-to-end signal to noise ratio for EVDO networks
208 * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
209 */
210 public int getEvdoSnr() {
211 return mEvdoSnr;
212 }
213
214 /**
215 * @hide
216 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100217 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700218 public void setEvdoSnr(int evdoSnr) {
219 mEvdoSnr = evdoSnr;
220 }
221
222 /**
223 * returns signal strength for LTE network
224 * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
225 */
226 public int getLteSignalStrength() {
227 return mLteSignalStrength;
228 }
229
230 /**
231 * @hide
232 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100233 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700234 public void setLteSignalStrength(int lteSignalStrength) {
235 mLteSignalStrength = lteSignalStrength;
236 }
237
238 /**
239 * returns RSRP (Reference Signal Received Power) for LTE network
240 * @return RSRP in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
241 */
242 public int getLteRsrp() {
243 return mLteRsrp;
244 }
245
246 /**
247 * @hide
248 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100249 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700250 public void setLteRsrp(int lteRsrp) {
251 mLteRsrp = lteRsrp;
252 }
253
254 /**
255 * returns RSRQ (Reference Signal Received Quality) for LTE network
256 * @return RSRQ ??? or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
257 */
258 public int getLteRsrq() {
259 return mLteRsrq;
260 }
261
262 /**
263 * @hide
264 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100265 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700266 public void setLteRsrq(int lteRsrq) {
267 mLteRsrq = lteRsrq;
268 }
269
270 /**
271 * returns signal to noise ratio for LTE networks
272 * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
273 */
274 public int getLteRssnr() {
275 return mLteRssnr;
276 }
277
278 /**
279 * @hide
280 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100281 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700282 public void setLteRssnr(int lteRssnr) {
283 mLteRssnr = lteRssnr;
284 }
285
286 /**
287 * returns channel quality indicator for LTE networks
288 * @return CQI or {@link android.net.LinkQualityInfo#UNKNOWN_INT}
289 */
290 public int getLteCqi() {
291 return mLteCqi;
292 }
293
294 /**
295 * @hide
296 */
Mathew Inwood53f089f2018-08-08 14:44:44 +0100297 @UnsupportedAppUsage
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -0700298 public void setLteCqi(int lteCqi) {
299 mLteCqi = lteCqi;
300 }
301}