Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 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 | |
Artur Satayev | 2695800 | 2019-12-10 17:47:52 +0000 | [diff] [blame] | 19 | import android.compat.annotation.UnsupportedAppUsage; |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 20 | import 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 | */ |
| 27 | public 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 | |
Artur Satayev | 751e551 | 2019-11-15 19:12:49 +0000 | [diff] [blame] | 43 | @UnsupportedAppUsage |
| 44 | public MobileLinkQualityInfo() { |
| 45 | } |
| 46 | |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 47 | /** |
| 48 | * Implement the Parcelable interface. |
| 49 | * @hide |
| 50 | */ |
| 51 | @Override |
| 52 | public void writeToParcel(Parcel dest, int flags) { |
| 53 | super.writeToParcel(dest, flags, OBJECT_TYPE_MOBILE_LINK_QUALITY_INFO); |
| 54 | |
| 55 | dest.writeInt(mMobileNetworkType); |
| 56 | dest.writeInt(mRssi); |
| 57 | dest.writeInt(mGsmErrorRate); |
| 58 | dest.writeInt(mCdmaDbm); |
| 59 | dest.writeInt(mCdmaEcio); |
| 60 | dest.writeInt(mEvdoDbm); |
| 61 | dest.writeInt(mEvdoEcio); |
| 62 | dest.writeInt(mEvdoSnr); |
| 63 | dest.writeInt(mLteSignalStrength); |
| 64 | dest.writeInt(mLteRsrp); |
| 65 | dest.writeInt(mLteRsrq); |
| 66 | dest.writeInt(mLteRssnr); |
| 67 | dest.writeInt(mLteCqi); |
| 68 | } |
| 69 | |
| 70 | /* Un-parceling helper */ |
| 71 | /** |
| 72 | * @hide |
| 73 | */ |
| 74 | public static MobileLinkQualityInfo createFromParcelBody(Parcel in) { |
| 75 | |
| 76 | MobileLinkQualityInfo li = new MobileLinkQualityInfo(); |
| 77 | |
| 78 | li.initializeFromParcel(in); |
| 79 | |
| 80 | li.mMobileNetworkType = in.readInt(); |
| 81 | li.mRssi = in.readInt(); |
| 82 | li.mGsmErrorRate = in.readInt(); |
| 83 | li.mCdmaDbm = in.readInt(); |
| 84 | li.mCdmaEcio = in.readInt(); |
| 85 | li.mEvdoDbm = in.readInt(); |
| 86 | li.mEvdoEcio = in.readInt(); |
| 87 | li.mEvdoSnr = in.readInt(); |
| 88 | li.mLteSignalStrength = in.readInt(); |
| 89 | li.mLteRsrp = in.readInt(); |
| 90 | li.mLteRsrq = in.readInt(); |
| 91 | li.mLteRssnr = in.readInt(); |
| 92 | li.mLteCqi = in.readInt(); |
| 93 | |
| 94 | return li; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * returns mobile network type as defined by {@link android.telephony.TelephonyManager} |
| 99 | * @return network type or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 100 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 101 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 102 | public int getMobileNetworkType() { |
| 103 | return mMobileNetworkType; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * @hide |
| 108 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 109 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 110 | public void setMobileNetworkType(int mobileNetworkType) { |
| 111 | mMobileNetworkType = mobileNetworkType; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * returns signal strength for GSM networks |
| 116 | * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 117 | */ |
| 118 | public int getRssi() { |
| 119 | return mRssi; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * @hide |
| 124 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 125 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 126 | public void setRssi(int Rssi) { |
| 127 | mRssi = Rssi; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * returns error rates for GSM networks |
| 132 | * @return error rate or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 133 | */ |
| 134 | public int getGsmErrorRate() { |
| 135 | return mGsmErrorRate; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * @hide |
| 140 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 141 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 142 | public void setGsmErrorRate(int gsmErrorRate) { |
| 143 | mGsmErrorRate = gsmErrorRate; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * returns signal strength for CDMA networks |
| 148 | * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 149 | */ |
| 150 | public int getCdmaDbm() { |
| 151 | return mCdmaDbm; |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * @hide |
| 156 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 157 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 158 | public void setCdmaDbm(int cdmaDbm) { |
| 159 | mCdmaDbm = cdmaDbm; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * returns signal to noise ratio for CDMA networks |
| 164 | * @return signal to noise ratio in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 165 | */ |
| 166 | public int getCdmaEcio() { |
| 167 | return mCdmaEcio; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * @hide |
| 172 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 173 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 174 | public void setCdmaEcio(int cdmaEcio) { |
| 175 | mCdmaEcio = cdmaEcio; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * returns signal strength for EVDO networks |
| 180 | * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 181 | */ |
| 182 | public int getEvdoDbm() { |
| 183 | return mEvdoDbm; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * @hide |
| 188 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 189 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 190 | public void setEvdoDbm(int evdoDbm) { |
| 191 | mEvdoDbm = evdoDbm; |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * returns signal to noise ratio for EVDO spectrum |
| 196 | * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 197 | */ |
| 198 | public int getEvdoEcio() { |
| 199 | return mEvdoEcio; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * @hide |
| 204 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 205 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 206 | public void setEvdoEcio(int evdoEcio) { |
| 207 | mEvdoEcio = evdoEcio; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * returns end-to-end signal to noise ratio for EVDO networks |
| 212 | * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 213 | */ |
| 214 | public int getEvdoSnr() { |
| 215 | return mEvdoSnr; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * @hide |
| 220 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 221 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 222 | public void setEvdoSnr(int evdoSnr) { |
| 223 | mEvdoSnr = evdoSnr; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * returns signal strength for LTE network |
| 228 | * @return signal strength in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 229 | */ |
| 230 | public int getLteSignalStrength() { |
| 231 | return mLteSignalStrength; |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * @hide |
| 236 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 237 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 238 | public void setLteSignalStrength(int lteSignalStrength) { |
| 239 | mLteSignalStrength = lteSignalStrength; |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * returns RSRP (Reference Signal Received Power) for LTE network |
| 244 | * @return RSRP in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 245 | */ |
| 246 | public int getLteRsrp() { |
| 247 | return mLteRsrp; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * @hide |
| 252 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 253 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 254 | public void setLteRsrp(int lteRsrp) { |
| 255 | mLteRsrp = lteRsrp; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * returns RSRQ (Reference Signal Received Quality) for LTE network |
| 260 | * @return RSRQ ??? or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 261 | */ |
| 262 | public int getLteRsrq() { |
| 263 | return mLteRsrq; |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * @hide |
| 268 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 269 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 270 | public void setLteRsrq(int lteRsrq) { |
| 271 | mLteRsrq = lteRsrq; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * returns signal to noise ratio for LTE networks |
| 276 | * @return signal to noise ration in db or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 277 | */ |
| 278 | public int getLteRssnr() { |
| 279 | return mLteRssnr; |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * @hide |
| 284 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 285 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 286 | public void setLteRssnr(int lteRssnr) { |
| 287 | mLteRssnr = lteRssnr; |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * returns channel quality indicator for LTE networks |
| 292 | * @return CQI or {@link android.net.LinkQualityInfo#UNKNOWN_INT} |
| 293 | */ |
| 294 | public int getLteCqi() { |
| 295 | return mLteCqi; |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * @hide |
| 300 | */ |
Mathew Inwood | 53f089f | 2018-08-08 14:44:44 +0100 | [diff] [blame] | 301 | @UnsupportedAppUsage |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 302 | public void setLteCqi(int lteCqi) { |
| 303 | mLteCqi = lteCqi; |
| 304 | } |
| 305 | } |