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.annotation.UnsupportedAppUsage; 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 43 /** 44 * Implement the Parcelable interface. 45 * @hide 46 */ 47 @Override writeToParcel(Parcel dest, int flags)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 */ createFromParcelBody(Parcel in)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 */ 97 @UnsupportedAppUsage getMobileNetworkType()98 public int getMobileNetworkType() { 99 return mMobileNetworkType; 100 } 101 102 /** 103 * @hide 104 */ 105 @UnsupportedAppUsage setMobileNetworkType(int mobileNetworkType)106 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 */ getRssi()114 public int getRssi() { 115 return mRssi; 116 } 117 118 /** 119 * @hide 120 */ 121 @UnsupportedAppUsage setRssi(int Rssi)122 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 */ getGsmErrorRate()130 public int getGsmErrorRate() { 131 return mGsmErrorRate; 132 } 133 134 /** 135 * @hide 136 */ 137 @UnsupportedAppUsage setGsmErrorRate(int gsmErrorRate)138 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 */ getCdmaDbm()146 public int getCdmaDbm() { 147 return mCdmaDbm; 148 } 149 150 /** 151 * @hide 152 */ 153 @UnsupportedAppUsage setCdmaDbm(int cdmaDbm)154 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 */ getCdmaEcio()162 public int getCdmaEcio() { 163 return mCdmaEcio; 164 } 165 166 /** 167 * @hide 168 */ 169 @UnsupportedAppUsage setCdmaEcio(int cdmaEcio)170 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 */ getEvdoDbm()178 public int getEvdoDbm() { 179 return mEvdoDbm; 180 } 181 182 /** 183 * @hide 184 */ 185 @UnsupportedAppUsage setEvdoDbm(int evdoDbm)186 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 */ getEvdoEcio()194 public int getEvdoEcio() { 195 return mEvdoEcio; 196 } 197 198 /** 199 * @hide 200 */ 201 @UnsupportedAppUsage setEvdoEcio(int evdoEcio)202 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 */ getEvdoSnr()210 public int getEvdoSnr() { 211 return mEvdoSnr; 212 } 213 214 /** 215 * @hide 216 */ 217 @UnsupportedAppUsage setEvdoSnr(int evdoSnr)218 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 */ getLteSignalStrength()226 public int getLteSignalStrength() { 227 return mLteSignalStrength; 228 } 229 230 /** 231 * @hide 232 */ 233 @UnsupportedAppUsage setLteSignalStrength(int lteSignalStrength)234 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 */ getLteRsrp()242 public int getLteRsrp() { 243 return mLteRsrp; 244 } 245 246 /** 247 * @hide 248 */ 249 @UnsupportedAppUsage setLteRsrp(int lteRsrp)250 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 */ getLteRsrq()258 public int getLteRsrq() { 259 return mLteRsrq; 260 } 261 262 /** 263 * @hide 264 */ 265 @UnsupportedAppUsage setLteRsrq(int lteRsrq)266 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 */ getLteRssnr()274 public int getLteRssnr() { 275 return mLteRssnr; 276 } 277 278 /** 279 * @hide 280 */ 281 @UnsupportedAppUsage setLteRssnr(int lteRssnr)282 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 */ getLteCqi()290 public int getLteCqi() { 291 return mLteCqi; 292 } 293 294 /** 295 * @hide 296 */ 297 @UnsupportedAppUsage setLteCqi(int lteCqi)298 public void setLteCqi(int lteCqi) { 299 mLteCqi = lteCqi; 300 } 301 } 302