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