blob: 1376cddbc41fb2d55a35e58886d42a0666006a82 [file] [log] [blame]
Wink Savillee9b06d72009-05-18 21:47:50 -07001/*
Wink Savilleb208a242012-07-25 14:08:09 -07002 * Copyright (C) 2012 The Android Open Source Project
Wink Savillee9b06d72009-05-18 21:47:50 -07003 *
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.telephony;
18
Mingming Cai385af082020-01-30 16:32:31 -080019import android.annotation.ElapsedRealtimeLong;
Nathan Haroldf23153f2018-11-19 18:09:40 -080020import android.annotation.NonNull;
Artur Satayev74cb7192019-12-10 17:47:56 +000021import android.compat.annotation.UnsupportedAppUsage;
Nathan Harolda6d893e2018-11-14 11:51:51 -080022import android.os.Build;
Wink Savillee9b06d72009-05-18 21:47:50 -070023import android.os.Bundle;
24import android.os.Parcel;
25import android.os.Parcelable;
Nathan Haroldf23153f2018-11-19 18:09:40 -080026import android.os.PersistableBundle;
Mingming Caif1a62942020-01-08 16:26:46 -080027import android.os.SystemClock;
28
29import com.android.telephony.Rlog;
Wink Savillee9b06d72009-05-18 21:47:50 -070030
Nathan Harold958846f2018-12-06 10:55:13 -080031import java.util.ArrayList;
32import java.util.List;
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +090033import java.util.Objects;
Kitta Koutaroudad385a2017-12-01 19:19:49 +090034
Wink Savillee9b06d72009-05-18 21:47:50 -070035/**
36 * Contains phone signal strength related information.
Wink Savillee9b06d72009-05-18 21:47:50 -070037 */
38public class SignalStrength implements Parcelable {
39
Wink Saville52840902011-02-18 12:40:47 -080040 private static final String LOG_TAG = "SignalStrength";
Robert Greenwalt432139b2012-07-27 15:44:16 -070041 private static final boolean DBG = false;
Wink Saville52840902011-02-18 12:40:47 -080042
43 /** @hide */
Nathan Harolda6d893e2018-11-14 11:51:51 -080044 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
45 public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN =
46 CellSignalStrength.SIGNAL_STRENGTH_NONE_OR_UNKNOWN; // = 0
Wink Saville52840902011-02-18 12:40:47 -080047 /** @hide */
Nathan Harolda6d893e2018-11-14 11:51:51 -080048 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
49 public static final int SIGNAL_STRENGTH_POOR =
50 CellSignalStrength.SIGNAL_STRENGTH_POOR; // = 1
Wink Saville52840902011-02-18 12:40:47 -080051 /** @hide */
Nathan Harolda6d893e2018-11-14 11:51:51 -080052 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
53 public static final int SIGNAL_STRENGTH_MODERATE =
54 CellSignalStrength.SIGNAL_STRENGTH_MODERATE; // = 2
Wink Saville52840902011-02-18 12:40:47 -080055 /** @hide */
Nathan Harolda6d893e2018-11-14 11:51:51 -080056 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
57 public static final int SIGNAL_STRENGTH_GOOD =
58 CellSignalStrength.SIGNAL_STRENGTH_GOOD; // = 3
Wink Saville52840902011-02-18 12:40:47 -080059 /** @hide */
Nathan Harolda6d893e2018-11-14 11:51:51 -080060 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
61 public static final int SIGNAL_STRENGTH_GREAT =
62 CellSignalStrength.SIGNAL_STRENGTH_GREAT; // = 4
Wink Saville52840902011-02-18 12:40:47 -080063 /** @hide */
Mathew Inwooda8382062018-08-16 17:01:12 +010064 @UnsupportedAppUsage
Wink Saville52840902011-02-18 12:40:47 -080065 public static final int NUM_SIGNAL_STRENGTH_BINS = 5;
Nathan Haroldf23153f2018-11-19 18:09:40 -080066
Nathan Harold9becf4b332018-01-18 16:45:40 -080067 /**
sqian61524e12018-10-19 16:47:52 -070068 * Indicates the invalid measures of signal strength.
69 *
70 * For example, this can be returned by {@link #getEvdoDbm()} or {@link #getCdmaDbm()}
Nathan Harold9becf4b332018-01-18 16:45:40 -080071 */
72 public static final int INVALID = Integer.MAX_VALUE;
John Wang5e395192012-01-30 18:45:56 -080073
Jordan Liu407b4792018-02-26 15:50:21 -080074 private static final int LTE_RSRP_THRESHOLDS_NUM = 4;
Kitta Koutaroudad385a2017-12-01 19:19:49 +090075
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +090076 private static final int WCDMA_RSCP_THRESHOLDS_NUM = 4;
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +090077
78 /* The type of signal measurement */
Nathan Haroldf23153f2018-11-19 18:09:40 -080079 private static final String MEASUREMENT_TYPE_RSCP = "rscp";
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +090080
Mingming Cai385af082020-01-30 16:32:31 -080081 // Timestamp of SignalStrength since boot
82 // Effectively final. Timestamp is set during construction of SignalStrength
83 private long mTimestampMillis;
Mingming Caif1a62942020-01-08 16:26:46 -080084
SongFerngWang68c58a52020-04-13 18:13:04 +080085 private boolean mLteAsPrimaryInNrNsa = true;
86
Nathan Haroldf23153f2018-11-19 18:09:40 -080087 CellSignalStrengthCdma mCdma;
88 CellSignalStrengthGsm mGsm;
89 CellSignalStrengthWcdma mWcdma;
90 CellSignalStrengthTdscdma mTdscdma;
91 CellSignalStrengthLte mLte;
Pengquan Meng45fcd302019-01-31 16:29:43 -080092 CellSignalStrengthNr mNr;
Wink Savillee9b06d72009-05-18 21:47:50 -070093
Wink Savillee9b06d72009-05-18 21:47:50 -070094 /**
95 * Create a new SignalStrength from a intent notifier Bundle
96 *
Jayachandran C4eda57e2020-01-07 16:20:33 -080097 * This method may be used by external applications.
Wink Savillee9b06d72009-05-18 21:47:50 -070098 *
99 * @param m Bundle from intent notifier
100 * @return newly created SignalStrength
101 *
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800102 * @hide
Wink Savillee9b06d72009-05-18 21:47:50 -0700103 */
Mathew Inwooda8382062018-08-16 17:01:12 +0100104 @UnsupportedAppUsage
Wink Savillee9b06d72009-05-18 21:47:50 -0700105 public static SignalStrength newFromBundle(Bundle m) {
106 SignalStrength ret;
107 ret = new SignalStrength();
108 ret.setFromNotifierBundle(m);
109 return ret;
110 }
111
112 /**
Uma Maheswari Ramalingama44b13762012-07-10 13:54:10 -0700113 * This constructor is used to create SignalStrength with default
Nathan Haroldf23153f2018-11-19 18:09:40 -0800114 * values.
Wink Savillee9b06d72009-05-18 21:47:50 -0700115 *
Uma Maheswari Ramalingama44b13762012-07-10 13:54:10 -0700116 * @return newly created SignalStrength
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800117 * @hide
Wink Savillee9b06d72009-05-18 21:47:50 -0700118 */
Mathew Inwooda8382062018-08-16 17:01:12 +0100119 @UnsupportedAppUsage
Nathan Haroldf23153f2018-11-19 18:09:40 -0800120 public SignalStrength() {
121 this(new CellSignalStrengthCdma(), new CellSignalStrengthGsm(),
122 new CellSignalStrengthWcdma(), new CellSignalStrengthTdscdma(),
Pengquan Meng45fcd302019-01-31 16:29:43 -0800123 new CellSignalStrengthLte(), new CellSignalStrengthNr());
Wink Savillee9b06d72009-05-18 21:47:50 -0700124 }
125
126 /**
Nathan Harold9becf4b332018-01-18 16:45:40 -0800127 * Constructor with all fields present
Wink Saville52840902011-02-18 12:40:47 -0800128 *
129 * @hide
130 */
Nathan Harold9becf4b332018-01-18 16:45:40 -0800131 public SignalStrength(
Nathan Haroldf23153f2018-11-19 18:09:40 -0800132 @NonNull CellSignalStrengthCdma cdma,
133 @NonNull CellSignalStrengthGsm gsm,
134 @NonNull CellSignalStrengthWcdma wcdma,
135 @NonNull CellSignalStrengthTdscdma tdscdma,
Pengquan Meng45fcd302019-01-31 16:29:43 -0800136 @NonNull CellSignalStrengthLte lte,
137 @NonNull CellSignalStrengthNr nr) {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800138 mCdma = cdma;
139 mGsm = gsm;
140 mWcdma = wcdma;
141 mTdscdma = tdscdma;
142 mLte = lte;
Pengquan Meng45fcd302019-01-31 16:29:43 -0800143 mNr = nr;
Mingming Cai385af082020-01-30 16:32:31 -0800144 mTimestampMillis = SystemClock.elapsedRealtime();
Wink Savilleb208a242012-07-25 14:08:09 -0700145 }
146
147 /**
Nathan Haroldf23153f2018-11-19 18:09:40 -0800148 * Constructor for Radio HAL V1.0
Nathan Harold9becf4b332018-01-18 16:45:40 -0800149 *
150 * @hide
151 */
Nathan Haroldf23153f2018-11-19 18:09:40 -0800152 public SignalStrength(android.hardware.radio.V1_0.SignalStrength signalStrength) {
153 this(new CellSignalStrengthCdma(signalStrength.cdma, signalStrength.evdo),
154 new CellSignalStrengthGsm(signalStrength.gw),
155 new CellSignalStrengthWcdma(),
156 new CellSignalStrengthTdscdma(signalStrength.tdScdma),
Pengquan Meng45fcd302019-01-31 16:29:43 -0800157 new CellSignalStrengthLte(signalStrength.lte),
158 new CellSignalStrengthNr());
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900159 }
160
161 /**
Nathan Haroldf23153f2018-11-19 18:09:40 -0800162 * Constructor for Radio HAL V1.2
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900163 *
164 * @hide
165 */
Nathan Haroldf23153f2018-11-19 18:09:40 -0800166 public SignalStrength(android.hardware.radio.V1_2.SignalStrength signalStrength) {
167 this(new CellSignalStrengthCdma(signalStrength.cdma, signalStrength.evdo),
168 new CellSignalStrengthGsm(signalStrength.gsm),
169 new CellSignalStrengthWcdma(signalStrength.wcdma),
170 new CellSignalStrengthTdscdma(signalStrength.tdScdma),
Pengquan Meng45fcd302019-01-31 16:29:43 -0800171 new CellSignalStrengthLte(signalStrength.lte),
172 new CellSignalStrengthNr());
173 }
174
175 /**
176 * Constructor for Radio HAL V1.4.
177 *
178 * @param signalStrength signal strength reported from modem.
179 * @hide
180 */
181 public SignalStrength(android.hardware.radio.V1_4.SignalStrength signalStrength) {
182 this(new CellSignalStrengthCdma(signalStrength.cdma, signalStrength.evdo),
183 new CellSignalStrengthGsm(signalStrength.gsm),
184 new CellSignalStrengthWcdma(signalStrength.wcdma),
185 new CellSignalStrengthTdscdma(signalStrength.tdscdma),
186 new CellSignalStrengthLte(signalStrength.lte),
187 new CellSignalStrengthNr(signalStrength.nr));
Nathan Haroldf23153f2018-11-19 18:09:40 -0800188 }
189
190 private CellSignalStrength getPrimary() {
191 // This behavior is intended to replicate the legacy behavior of getLevel() by prioritizing
192 // newer faster RATs for default/for display purposes.
SongFerngWang68c58a52020-04-13 18:13:04 +0800193
194 if (mLteAsPrimaryInNrNsa) {
195 if (mLte.isValid()) return mLte;
196 }
Rambo Wang8e56e112020-03-26 12:35:38 -0700197 if (mNr.isValid()) return mNr;
Nathan Haroldf23153f2018-11-19 18:09:40 -0800198 if (mLte.isValid()) return mLte;
199 if (mCdma.isValid()) return mCdma;
200 if (mTdscdma.isValid()) return mTdscdma;
201 if (mWcdma.isValid()) return mWcdma;
202 if (mGsm.isValid()) return mGsm;
203 return mLte;
204 }
205
Nathan Harold958846f2018-12-06 10:55:13 -0800206 /**
207 * Returns a List of CellSignalStrength Components of this SignalStrength Report.
208 *
209 * Use this API to access underlying
210 * {@link android.telephony#CellSignalStrength CellSignalStrength} objects that provide more
211 * granular information about the SignalStrength report. Only valid (non-empty)
212 * CellSignalStrengths will be returned. The order of any returned elements is not guaranteed,
213 * and the list may contain more than one instance of a CellSignalStrength type.
214 *
215 * @return a List of CellSignalStrength or an empty List if there are no valid measurements.
216 *
217 * @see android.telephony#CellSignalStrength
218 * @see android.telephony#CellSignalStrengthNr
219 * @see android.telephony#CellSignalStrengthLte
220 * @see android.telephony#CellSignalStrengthTdscdma
221 * @see android.telephony#CellSignalStrengthWcdma
222 * @see android.telephony#CellSignalStrengthCdma
223 * @see android.telephony#CellSignalStrengthGsm
224 */
Nathan Haroldbbe345f2019-03-06 11:10:40 -0800225 @NonNull public List<CellSignalStrength> getCellSignalStrengths() {
Nathan Harold7e992ec2019-02-12 13:25:47 -0800226 return getCellSignalStrengths(CellSignalStrength.class);
227 }
228
229 /**
230 * Returns a List of CellSignalStrength Components of this SignalStrength Report.
231 *
232 * Use this API to access underlying
233 * {@link android.telephony#CellSignalStrength CellSignalStrength} objects that provide more
234 * granular information about the SignalStrength report. Only valid (non-empty)
235 * CellSignalStrengths will be returned. The order of any returned elements is not guaranteed,
236 * and the list may contain more than one instance of a CellSignalStrength type.
237 *
238 * @param clazz a class type that extends
239 * {@link android.telephony.CellSignalStrength CellSignalStrength} to filter possible
240 * return values.
241 * @return a List of CellSignalStrength or an empty List if there are no valid measurements.
242 *
243 * @see android.telephony#CellSignalStrength
244 * @see android.telephony#CellSignalStrengthNr
245 * @see android.telephony#CellSignalStrengthLte
246 * @see android.telephony#CellSignalStrengthTdscdma
247 * @see android.telephony#CellSignalStrengthWcdma
248 * @see android.telephony#CellSignalStrengthCdma
249 * @see android.telephony#CellSignalStrengthGsm
250 */
Nathan Haroldbbe345f2019-03-06 11:10:40 -0800251 @NonNull public <T extends CellSignalStrength> List<T> getCellSignalStrengths(
Nathan Harold7e992ec2019-02-12 13:25:47 -0800252 @NonNull Class<T> clazz) {
253 List<T> cssList = new ArrayList<>(2); // Usually have 2 or fewer elems
254 if (mLte.isValid() && clazz.isAssignableFrom(CellSignalStrengthLte.class)) {
255 cssList.add((T) mLte);
256 }
257 if (mCdma.isValid() && clazz.isAssignableFrom(CellSignalStrengthCdma.class)) {
258 cssList.add((T) mCdma);
259 }
260 if (mTdscdma.isValid() && clazz.isAssignableFrom(CellSignalStrengthTdscdma.class)) {
261 cssList.add((T) mTdscdma);
262 }
263 if (mWcdma.isValid() && clazz.isAssignableFrom(CellSignalStrengthWcdma.class)) {
264 cssList.add((T) mWcdma);
265 }
266 if (mGsm.isValid() && clazz.isAssignableFrom(CellSignalStrengthGsm.class)) {
267 cssList.add((T) mGsm);
268 }
269 if (mNr.isValid() && clazz.isAssignableFrom(CellSignalStrengthNr.class)) {
270 cssList.add((T) mNr);
271 }
Nathan Harold958846f2018-12-06 10:55:13 -0800272 return cssList;
273 }
274
Nathan Haroldf23153f2018-11-19 18:09:40 -0800275 /** @hide */
276 public void updateLevel(PersistableBundle cc, ServiceState ss) {
SongFerngWang68c58a52020-04-13 18:13:04 +0800277 if (cc != null) {
278 mLteAsPrimaryInNrNsa = cc.getBoolean(
279 CarrierConfigManager.KEY_SIGNAL_STRENGTH_NR_NSA_USE_LTE_AS_PRIMARY_BOOL, true);
280 }
Nathan Haroldf23153f2018-11-19 18:09:40 -0800281 mCdma.updateLevel(cc, ss);
282 mGsm.updateLevel(cc, ss);
283 mWcdma.updateLevel(cc, ss);
284 mTdscdma.updateLevel(cc, ss);
285 mLte.updateLevel(cc, ss);
Pengquan Meng45fcd302019-01-31 16:29:43 -0800286 mNr.updateLevel(cc, ss);
Nathan Harold9becf4b332018-01-18 16:45:40 -0800287 }
288
289 /**
290 * Copy constructors
291 *
292 * @param s Source SignalStrength
293 *
294 * @hide
295 */
Sooraj Sasindran89e4e0c2019-12-17 09:20:51 -0800296 public SignalStrength(@NonNull SignalStrength s) {
Nathan Harold9becf4b332018-01-18 16:45:40 -0800297 copyFrom(s);
298 }
299
300 /**
Wink Savillee9b06d72009-05-18 21:47:50 -0700301 * @hide
302 */
Mathew Inwooda8382062018-08-16 17:01:12 +0100303 @UnsupportedAppUsage
Wink Savillee9b06d72009-05-18 21:47:50 -0700304 protected void copyFrom(SignalStrength s) {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800305 mCdma = new CellSignalStrengthCdma(s.mCdma);
306 mGsm = new CellSignalStrengthGsm(s.mGsm);
307 mWcdma = new CellSignalStrengthWcdma(s.mWcdma);
308 mTdscdma = new CellSignalStrengthTdscdma(s.mTdscdma);
309 mLte = new CellSignalStrengthLte(s.mLte);
Pengquan Meng45fcd302019-01-31 16:29:43 -0800310 mNr = new CellSignalStrengthNr(s.mNr);
Mingming Cai385af082020-01-30 16:32:31 -0800311 mTimestampMillis = s.getTimestampMillis();
Wink Savillee9b06d72009-05-18 21:47:50 -0700312 }
313
314 /**
315 * Construct a SignalStrength object from the given parcel.
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800316 *
317 * @hide
Wink Savillee9b06d72009-05-18 21:47:50 -0700318 */
Mathew Inwooda8382062018-08-16 17:01:12 +0100319 @UnsupportedAppUsage
Wink Savillee9b06d72009-05-18 21:47:50 -0700320 public SignalStrength(Parcel in) {
Wink Saville2900a3fa2012-08-13 16:50:30 -0700321 if (DBG) log("Size of signalstrength parcel:" + in.dataSize());
322
Nathan Haroldf23153f2018-11-19 18:09:40 -0800323 mCdma = in.readParcelable(CellSignalStrengthCdma.class.getClassLoader());
324 mGsm = in.readParcelable(CellSignalStrengthGsm.class.getClassLoader());
325 mWcdma = in.readParcelable(CellSignalStrengthWcdma.class.getClassLoader());
326 mTdscdma = in.readParcelable(CellSignalStrengthTdscdma.class.getClassLoader());
327 mLte = in.readParcelable(CellSignalStrengthLte.class.getClassLoader());
Pengquan Meng45fcd302019-01-31 16:29:43 -0800328 mNr = in.readParcelable(CellSignalStrengthLte.class.getClassLoader());
Mingming Cai385af082020-01-30 16:32:31 -0800329 mTimestampMillis = in.readLong();
Wink Savilleefbca4d2013-04-08 11:35:47 -0700330 }
331
332 /**
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800333 * {@link Parcelable#writeToParcel}
334 */
Wink Savillee9b06d72009-05-18 21:47:50 -0700335 public void writeToParcel(Parcel out, int flags) {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800336 out.writeParcelable(mCdma, flags);
337 out.writeParcelable(mGsm, flags);
338 out.writeParcelable(mWcdma, flags);
339 out.writeParcelable(mTdscdma, flags);
340 out.writeParcelable(mLte, flags);
Pengquan Meng45fcd302019-01-31 16:29:43 -0800341 out.writeParcelable(mNr, flags);
Mingming Cai385af082020-01-30 16:32:31 -0800342 out.writeLong(mTimestampMillis);
Wink Savillee9b06d72009-05-18 21:47:50 -0700343 }
344
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800345 /**
Mingming Cai385af082020-01-30 16:32:31 -0800346 * @return timestamp in milliseconds since boot for {@link SignalStrength}.
347 * This timestamp reports the approximate time that the signal was measured and reported
348 * by the modem. It can be used to compare the recency of {@link SignalStrength} instances.
Mingming Caif1a62942020-01-08 16:26:46 -0800349 */
Mingming Cai385af082020-01-30 16:32:31 -0800350 @ElapsedRealtimeLong
351 public long getTimestampMillis() {
352 return mTimestampMillis;
Mingming Caif1a62942020-01-08 16:26:46 -0800353 }
354
355 /**
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800356 * {@link Parcelable#describeContents}
357 */
Wink Savillee9b06d72009-05-18 21:47:50 -0700358 public int describeContents() {
359 return 0;
360 }
361
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800362 /**
363 * {@link Parcelable.Creator}
364 *
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800365 */
Hall Liue00ad762019-12-26 12:48:09 -0800366 public static final @android.annotation.NonNull Parcelable.Creator<SignalStrength> CREATOR =
367 new Parcelable.Creator<SignalStrength>() {
368 public SignalStrength createFromParcel(Parcel in) {
369 return new SignalStrength(in);
370 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700371
Hall Liue00ad762019-12-26 12:48:09 -0800372 public SignalStrength[] newArray(int size) {
373 return new SignalStrength[size];
374 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700375 };
376
377 /**
Nathan Haroldf23153f2018-11-19 18:09:40 -0800378 * Get the GSM RSSI in ASU.
Uma Maheswari Ramalingama44b13762012-07-10 13:54:10 -0700379 *
Nathan Haroldf23153f2018-11-19 18:09:40 -0800380 * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
Pengquan Meng7082ef02017-10-18 18:07:58 -0700381 *
Nathan Haroldf23153f2018-11-19 18:09:40 -0800382 * @return RSSI in ASU 0..31, 99, or UNAVAILABLE
Nathan Haroldd261a312019-01-14 14:30:08 -0800383 *
384 * @deprecated this information should be retrieved from
385 * {@link CellSignalStrengthGsm#getAsuLevel}.
386 * @see android.telephony#CellSignalStrengthGsm
387 * @see android.telephony.SignalStrength#getCellSignalStrengths
Wink Savillee9b06d72009-05-18 21:47:50 -0700388 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800389 @Deprecated
Wink Savillee9b06d72009-05-18 21:47:50 -0700390 public int getGsmSignalStrength() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800391 return mGsm.getAsuLevel();
Wink Savillee9b06d72009-05-18 21:47:50 -0700392 }
393
394 /**
395 * Get the GSM bit error rate (0-7, 99) as defined in TS 27.007 8.5
Nathan Haroldd261a312019-01-14 14:30:08 -0800396 *
397 * @deprecated this information should be retrieved from
398 * {@link CellSignalStrengthGsm#getBitErrorRate}.
399 *
400 * @see android.telephony#CellSignalStrengthGsm
401 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Savillee9b06d72009-05-18 21:47:50 -0700402 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800403 @Deprecated
Wink Savillee9b06d72009-05-18 21:47:50 -0700404 public int getGsmBitErrorRate() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800405 return mGsm.getBitErrorRate();
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900406 }
407
408 /**
Wink Savillee9b06d72009-05-18 21:47:50 -0700409 * Get the CDMA RSSI value in dBm
sqian61524e12018-10-19 16:47:52 -0700410 *
411 * @return the CDMA RSSI value or {@link #INVALID} if invalid
Nathan Haroldd261a312019-01-14 14:30:08 -0800412 *
413 * @deprecated this information should be retrieved from
414 * {@link CellSignalStrengthCdma#getCdmaDbm}.
415 *
416 * @see android.telephony#CellSignalStrengthCdma
417 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Savillee9b06d72009-05-18 21:47:50 -0700418 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800419 @Deprecated
Wink Savillee9b06d72009-05-18 21:47:50 -0700420 public int getCdmaDbm() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800421 return mCdma.getCdmaDbm();
Wink Savillee9b06d72009-05-18 21:47:50 -0700422 }
423
424 /**
425 * Get the CDMA Ec/Io value in dB*10
Nathan Haroldd261a312019-01-14 14:30:08 -0800426 *
427 * @deprecated this information should be retrieved from
428 * {@link CellSignalStrengthCdma#getCdmaEcio}.
429 *
430 * @see android.telephony#CellSignalStrengthCdma
431 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Savillee9b06d72009-05-18 21:47:50 -0700432 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800433 @Deprecated
Wink Savillee9b06d72009-05-18 21:47:50 -0700434 public int getCdmaEcio() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800435 return mCdma.getCdmaEcio();
Wink Savillee9b06d72009-05-18 21:47:50 -0700436 }
437
438 /**
439 * Get the EVDO RSSI value in dBm
sqian61524e12018-10-19 16:47:52 -0700440 *
441 * @return the EVDO RSSI value or {@link #INVALID} if invalid
Nathan Haroldd261a312019-01-14 14:30:08 -0800442 *
443 * @deprecated this information should be retrieved from
444 * {@link CellSignalStrengthCdma#getEvdoDbm}.
445 *
446 * @see android.telephony#CellSignalStrengthCdma
447 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Savillee9b06d72009-05-18 21:47:50 -0700448 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800449 @Deprecated
Wink Savillee9b06d72009-05-18 21:47:50 -0700450 public int getEvdoDbm() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800451 return mCdma.getEvdoDbm();
Wink Savillee9b06d72009-05-18 21:47:50 -0700452 }
453
454 /**
455 * Get the EVDO Ec/Io value in dB*10
Nathan Haroldd261a312019-01-14 14:30:08 -0800456 *
457 * @deprecated this information should be retrieved from
458 * {@link CellSignalStrengthCdma#getEvdoEcio}.
459 *
460 * @see android.telephony#CellSignalStrengthCdma
461 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Savillee9b06d72009-05-18 21:47:50 -0700462 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800463 @Deprecated
Wink Savillee9b06d72009-05-18 21:47:50 -0700464 public int getEvdoEcio() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800465 return mCdma.getEvdoEcio();
Wink Savillee9b06d72009-05-18 21:47:50 -0700466 }
467
468 /**
469 * Get the signal to noise ratio. Valid values are 0-8. 8 is the highest.
Nathan Haroldd261a312019-01-14 14:30:08 -0800470 *
471 * @deprecated this information should be retrieved from
472 * {@link CellSignalStrengthCdma#getEvdoSnr}.
473 *
474 * @see android.telephony#CellSignalStrengthCdma
475 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Savillee9b06d72009-05-18 21:47:50 -0700476 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800477 @Deprecated
Wink Savillee9b06d72009-05-18 21:47:50 -0700478 public int getEvdoSnr() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800479 return mCdma.getEvdoSnr();
Wink Savillee9b06d72009-05-18 21:47:50 -0700480 }
481
Nathan Haroldd261a312019-01-14 14:30:08 -0800482 /**
483 * @deprecated this information should be retrieved from
484 * {@link CellSignalStrengthLte#getRssi}.
485 *
486 * @see android.telephony#CellSignalStrengthLte
487 * @see android.telephony.SignalStrength#getCellSignalStrengths()
488 * @hide
489 */
490 @Deprecated
491 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville29c8b002013-06-21 09:58:11 -0700492 public int getLteSignalStrength() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800493 return mLte.getRssi();
Wink Saville2900a3fa2012-08-13 16:50:30 -0700494 }
495
Nathan Haroldd261a312019-01-14 14:30:08 -0800496 /**
497 * @deprecated this information should be retrieved from
498 * {@link CellSignalStrengthLte#getRsrp}.
499 *
500 * @see android.telephony#CellSignalStrengthLte
501 * @see android.telephony.SignalStrength#getCellSignalStrengths()
502 * @hide
503 */
504 @Deprecated
505 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville2900a3fa2012-08-13 16:50:30 -0700506 public int getLteRsrp() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800507 return mLte.getRsrp();
Wink Saville2900a3fa2012-08-13 16:50:30 -0700508 }
509
Nathan Haroldd261a312019-01-14 14:30:08 -0800510 /**
511 * @deprecated this information should be retrieved from
512 * {@link CellSignalStrengthLte#getRsrq}.
513 *
514 * @see android.telephony#CellSignalStrengthLte
515 * @see android.telephony.SignalStrength#getCellSignalStrengths()
516 * @hide
517 */
518 @Deprecated
519 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville2900a3fa2012-08-13 16:50:30 -0700520 public int getLteRsrq() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800521 return mLte.getRsrq();
Wink Saville2900a3fa2012-08-13 16:50:30 -0700522 }
523
Nathan Haroldd261a312019-01-14 14:30:08 -0800524 /**
525 * @deprecated this information should be retrieved from
526 * {@link CellSignalStrengthLte#getRssnr}.
527 *
528 * @see android.telephony#CellSignalStrengthLte
529 * @see android.telephony.SignalStrength#getCellSignalStrengths()
530 * @hide
531 */
532 @Deprecated
533 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville2900a3fa2012-08-13 16:50:30 -0700534 public int getLteRssnr() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800535 return mLte.getRssnr();
Wink Saville2900a3fa2012-08-13 16:50:30 -0700536 }
537
Nathan Haroldd261a312019-01-14 14:30:08 -0800538 /**
539 * @deprecated this information should be retrieved from
540 * {@link CellSignalStrengthLte#getCqi}.
541 *
542 * @see android.telephony#CellSignalStrengthLte
543 * @see android.telephony.SignalStrength#getCellSignalStrengths()
544 * @hide
545 */
546 @Deprecated
547 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville2900a3fa2012-08-13 16:50:30 -0700548 public int getLteCqi() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800549 return mLte.getCqi();
Wink Saville2900a3fa2012-08-13 16:50:30 -0700550 }
551
Wink Savillee9b06d72009-05-18 21:47:50 -0700552 /**
Robert Greenwalt46982c52015-06-10 15:46:09 -0700553 * Retrieve an abstract level value for the overall signal strength.
554 *
555 * @return a single integer from 0 to 4 representing the general signal quality.
556 * This may take into account many different radio technology inputs.
557 * 0 represents very poor signal strength
558 * while 4 represents a very strong signal strength.
Wink Saville52840902011-02-18 12:40:47 -0800559 */
560 public int getLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800561 int level = getPrimary().getLevel();
562 if (level < SIGNAL_STRENGTH_NONE_OR_UNKNOWN || level > SIGNAL_STRENGTH_GREAT) {
Nathan Harold5472d802019-01-08 15:02:55 -0800563 loge("Invalid Level " + level + ", this=" + this);
Nathan Haroldf23153f2018-11-19 18:09:40 -0800564 return SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
565 }
566 return getPrimary().getLevel();
Wink Saville52840902011-02-18 12:40:47 -0800567 }
568
569 /**
Nathan Haroldd261a312019-01-14 14:30:08 -0800570 * Get the signal level as an asu value with a range dependent on the underlying technology.
Wink Saville52840902011-02-18 12:40:47 -0800571 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800572 * @deprecated this information should be retrieved from
573 * {@link CellSignalStrength#getAsuLevel}. Because the levels vary by technology,
574 * this method is misleading and should not be used.
575 * @see android.telephony#CellSignalStrength
576 * @see android.telephony.SignalStrength#getCellSignalStrengths
Wink Saville52840902011-02-18 12:40:47 -0800577 * @hide
578 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800579 @Deprecated
580 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800581 public int getAsuLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800582 return getPrimary().getAsuLevel();
Wink Saville52840902011-02-18 12:40:47 -0800583 }
584
585 /**
586 * Get the signal strength as dBm
587 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800588 * @deprecated this information should be retrieved from
589 * {@link CellSignalStrength#getDbm()}. Because the levels vary by technology,
590 * this method is misleading and should not be used.
591 * @see android.telephony#CellSignalStrength
592 * @see android.telephony.SignalStrength#getCellSignalStrengths
Wink Saville52840902011-02-18 12:40:47 -0800593 * @hide
594 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800595 @Deprecated
596 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800597 public int getDbm() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800598 return getPrimary().getDbm();
Wink Saville52840902011-02-18 12:40:47 -0800599 }
600
601 /**
602 * Get Gsm signal strength as dBm
603 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800604 * @deprecated this information should be retrieved from
605 * {@link CellSignalStrengthGsm#getDbm}.
606 *
607 * @see android.telephony#CellSignalStrengthGsm
608 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800609 * @hide
610 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800611 @Deprecated
612 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800613 public int getGsmDbm() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800614 return mGsm.getDbm();
Wink Saville52840902011-02-18 12:40:47 -0800615 }
616
617 /**
618 * Get gsm as level 0..4
619 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800620 * @deprecated this information should be retrieved from
621 * {@link CellSignalStrengthGsm#getLevel}.
622 *
623 * @see android.telephony#CellSignalStrengthGsm
624 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800625 * @hide
626 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800627 @Deprecated
628 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800629 public int getGsmLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800630 return mGsm.getLevel();
Wink Saville52840902011-02-18 12:40:47 -0800631 }
632
633 /**
634 * Get the gsm signal level as an asu value between 0..31, 99 is unknown
635 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800636 * @deprecated this information should be retrieved from
637 * {@link CellSignalStrengthGsm#getAsuLevel}.
638 *
639 * @see android.telephony#CellSignalStrengthGsm
640 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800641 * @hide
642 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800643 @Deprecated
644 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800645 public int getGsmAsuLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800646 return mGsm.getAsuLevel();
Wink Saville52840902011-02-18 12:40:47 -0800647 }
648
649 /**
650 * Get cdma as level 0..4
651 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800652 * @deprecated this information should be retrieved from
653 * {@link CellSignalStrengthCdma#getLevel}.
654 *
655 * @see android.telephony#CellSignalStrengthCdma
656 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800657 * @hide
658 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800659 @Deprecated
660 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800661 public int getCdmaLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800662 return mCdma.getLevel();
Wink Saville52840902011-02-18 12:40:47 -0800663 }
664
665 /**
666 * Get the cdma signal level as an asu value between 0..31, 99 is unknown
667 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800668 * @deprecated this information should be retrieved from
669 * {@link CellSignalStrengthCdma#getAsuLevel}. Since there is no definition of
670 * ASU for CDMA, the resultant value is Android-specific and is not recommended
671 * for use.
672 *
673 * @see android.telephony#CellSignalStrengthCdma
674 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800675 * @hide
676 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800677 @Deprecated
678 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800679 public int getCdmaAsuLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800680 return mCdma.getAsuLevel();
Wink Saville52840902011-02-18 12:40:47 -0800681 }
682
683 /**
684 * Get Evdo as level 0..4
685 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800686 * @deprecated this information should be retrieved from
687 * {@link CellSignalStrengthCdma#getEvdoLevel}.
688 *
689 * @see android.telephony#CellSignalStrengthCdma
690 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800691 * @hide
692 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800693 @Deprecated
694 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800695 public int getEvdoLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800696 return mCdma.getEvdoLevel();
Wink Saville52840902011-02-18 12:40:47 -0800697 }
698
699 /**
700 * Get the evdo signal level as an asu value between 0..31, 99 is unknown
701 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800702 * @deprecated this information should be retrieved from
703 * {@link CellSignalStrengthCdma#getEvdoAsuLevel}. Since there is no definition of
704 * ASU for EvDO, the resultant value is Android-specific and is not recommended
705 * for use.
706 *
707 * @see android.telephony#CellSignalStrengthCdma
708 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800709 * @hide
710 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800711 @Deprecated
712 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800713 public int getEvdoAsuLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800714 return mCdma.getEvdoAsuLevel();
Wink Saville52840902011-02-18 12:40:47 -0800715 }
716
717 /**
718 * Get LTE as dBm
719 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800720 * @deprecated this information should be retrieved from
721 * {@link CellSignalStrengthLte#getDbm}.
722 *
723 * @see android.telephony#CellSignalStrengthLte
724 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800725 * @hide
726 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800727 @Deprecated
728 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800729 public int getLteDbm() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800730 return mLte.getRsrp();
Wink Saville52840902011-02-18 12:40:47 -0800731 }
732
733 /**
734 * Get LTE as level 0..4
735 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800736 * @deprecated this information should be retrieved from
737 * {@link CellSignalStrengthLte#getLevel}.
738 *
739 * @see android.telephony#CellSignalStrengthLte
740 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800741 * @hide
742 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800743 @Deprecated
744 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800745 public int getLteLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800746 return mLte.getLevel();
Wink Saville52840902011-02-18 12:40:47 -0800747 }
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900748
Wink Saville52840902011-02-18 12:40:47 -0800749 /**
Ramesh Sudini5d7b9272011-05-09 09:45:26 -0500750 * Get the LTE signal level as an asu value between 0..97, 99 is unknown
751 * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
Wink Saville52840902011-02-18 12:40:47 -0800752 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800753 * @deprecated this information should be retrieved from
754 * {@link CellSignalStrengthLte#getAsuLevel}.
755 *
756 * @see android.telephony#CellSignalStrengthLte
757 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Wink Saville52840902011-02-18 12:40:47 -0800758 * @hide
759 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800760 @Deprecated
761 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Saville52840902011-02-18 12:40:47 -0800762 public int getLteAsuLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800763 return mLte.getAsuLevel();
Wink Saville52840902011-02-18 12:40:47 -0800764 }
765
766 /**
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800767 * @return true if this is for GSM
Nathan Haroldd261a312019-01-14 14:30:08 -0800768 *
769 * @deprecated This method returns true if there are any 3gpp type SignalStrength elements in
770 * this SignalStrength report or if the report contains no valid SignalStrength
771 * information. Instead callers should use
772 * {@link android.telephony.SignalStrength#getCellSignalStrengths
773 * getCellSignalStrengths()} to determine which types of information are contained
774 * in the SignalStrength report.
Wink Savillee9b06d72009-05-18 21:47:50 -0700775 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800776 @Deprecated
Wink Savillee9b06d72009-05-18 21:47:50 -0700777 public boolean isGsm() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800778 return !(getPrimary() instanceof CellSignalStrengthCdma);
Wenting Xiongcb35e992017-10-18 15:05:49 +0900779 }
780
781 /**
Nathan Haroldd261a312019-01-14 14:30:08 -0800782 * @return get TD-SCDMA dBm
Sungmin Choi36980862015-08-26 11:05:46 -0700783 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800784 * @deprecated this information should be retrieved from
785 * {@link CellSignalStrengthTdscdma#getDbm}.
786 *
787 * @see android.telephony#CellSignalStrengthTdscdma
788 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Sungmin Choi36980862015-08-26 11:05:46 -0700789 * @hide
790 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800791 @Deprecated
792 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Sungmin Choi36980862015-08-26 11:05:46 -0700793 public int getTdScdmaDbm() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800794 return mTdscdma.getRscp();
Sungmin Choi36980862015-08-26 11:05:46 -0700795 }
796
797 /**
798 * Get TD-SCDMA as level 0..4
799 * Range : 25 to 120
800 * INT_MAX: 0x7FFFFFFF denotes invalid value
801 * Reference: 3GPP TS 25.123, section 9.1.1.1
802 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800803 * @deprecated this information should be retrieved from
804 * {@link CellSignalStrengthTdscdma#getLevel}.
805 *
806 * @see android.telephony#CellSignalStrengthTdscdma
807 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Sungmin Choi36980862015-08-26 11:05:46 -0700808 * @hide
809 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800810 @Deprecated
811 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Sungmin Choi36980862015-08-26 11:05:46 -0700812 public int getTdScdmaLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800813 return mTdscdma.getLevel();
Sungmin Choi36980862015-08-26 11:05:46 -0700814 }
815
816 /**
817 * Get the TD-SCDMA signal level as an asu value.
818 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800819 * @deprecated this information should be retrieved from
820 * {@link CellSignalStrengthTdscdma#getAsuLevel}.
821 *
822 * @see android.telephony#CellSignalStrengthTdscdma
823 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Sungmin Choi36980862015-08-26 11:05:46 -0700824 * @hide
825 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800826 @Deprecated
827 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Sungmin Choi36980862015-08-26 11:05:46 -0700828 public int getTdScdmaAsuLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800829 return mTdscdma.getAsuLevel();
Sungmin Choi36980862015-08-26 11:05:46 -0700830 }
831
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900832 /**
Nathan Haroldd261a312019-01-14 14:30:08 -0800833 * Gets WCDMA RSCP as a dBm value between -120 and -24, as defined in TS 27.007 8.69.
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900834 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800835 * @deprecated this information should be retrieved from
836 * {@link CellSignalStrengthWcdma#getRscp}.
837 *
838 * @see android.telephony#CellSignalStrengthWcdma
839 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900840 * @hide
841 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800842 @Deprecated
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900843 public int getWcdmaRscp() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800844 return mWcdma.getRscp();
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900845 }
846
847 /**
848 * Get the WCDMA signal level as an ASU value between 0-96, 255 is unknown
849 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800850 * @deprecated this information should be retrieved from
851 * {@link CellSignalStrengthWcdma#getAsuLevel}.
852 *
853 * @see android.telephony#CellSignalStrengthWcdma
854 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900855 * @hide
856 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800857 @Deprecated
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900858 public int getWcdmaAsuLevel() {
859 /*
860 * 3GPP 27.007 (Ver 10.3.0) Sec 8.69
861 * 0 -120 dBm or less
862 * 1 -119 dBm
863 * 2...95 -118... -25 dBm
864 * 96 -24 dBm or greater
865 * 255 not known or not detectable
866 */
Nathan Haroldf23153f2018-11-19 18:09:40 -0800867 return mWcdma.getAsuLevel();
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900868 }
869
870 /**
Nathan Haroldd261a312019-01-14 14:30:08 -0800871 * Gets WCDMA signal strength as a dBm value between -120 and -24, as defined in TS 27.007 8.69.
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900872 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800873 * @deprecated this information should be retrieved from
874 * {@link CellSignalStrengthWcdma#getDbm}.
875 *
876 * @see android.telephony#CellSignalStrengthWcdma
877 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900878 * @hide
879 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800880 @Deprecated
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900881 public int getWcdmaDbm() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800882 return mWcdma.getDbm();
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900883 }
884
885 /**
886 * Get WCDMA as level 0..4
887 *
Nathan Haroldd261a312019-01-14 14:30:08 -0800888 * @deprecated this information should be retrieved from
889 * {@link CellSignalStrengthWcdma#getDbm}.
890 *
891 * @see android.telephony#CellSignalStrengthWcdma
892 * @see android.telephony.SignalStrength#getCellSignalStrengths()
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900893 * @hide
894 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800895 @Deprecated
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900896 public int getWcdmaLevel() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800897 return mWcdma.getLevel();
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900898 }
899
Nathan Haroldd261a312019-01-14 14:30:08 -0800900 /**
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800901 * @return hash code
Wink Savillee9b06d72009-05-18 21:47:50 -0700902 */
903 @Override
904 public int hashCode() {
Pengquan Meng45fcd302019-01-31 16:29:43 -0800905 return Objects.hash(mCdma, mGsm, mWcdma, mTdscdma, mLte, mNr);
Wink Savillee9b06d72009-05-18 21:47:50 -0700906 }
907
908 /**
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800909 * @return true if the signal strengths are the same
Wink Savillee9b06d72009-05-18 21:47:50 -0700910 */
911 @Override
912 public boolean equals (Object o) {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800913 if (!(o instanceof SignalStrength)) return false;
Wink Savillee9b06d72009-05-18 21:47:50 -0700914
Nathan Haroldf23153f2018-11-19 18:09:40 -0800915 SignalStrength s = (SignalStrength) o;
Wink Savillee9b06d72009-05-18 21:47:50 -0700916
Nathan Haroldf23153f2018-11-19 18:09:40 -0800917 return mCdma.equals(s.mCdma)
918 && mGsm.equals(s.mGsm)
919 && mWcdma.equals(s.mWcdma)
920 && mTdscdma.equals(s.mTdscdma)
Pengquan Meng45fcd302019-01-31 16:29:43 -0800921 && mLte.equals(s.mLte)
922 && mNr.equals(s.mNr);
Wink Savillee9b06d72009-05-18 21:47:50 -0700923 }
924
925 /**
Wink Savillecc6ff2b2009-12-02 09:46:38 -0800926 * @return string representation.
Wink Savillee9b06d72009-05-18 21:47:50 -0700927 */
928 @Override
929 public String toString() {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800930 return new StringBuilder().append("SignalStrength:{")
931 .append("mCdma=").append(mCdma)
932 .append(",mGsm=").append(mGsm)
933 .append(",mWcdma=").append(mWcdma)
934 .append(",mTdscdma=").append(mTdscdma)
935 .append(",mLte=").append(mLte)
Pengquan Meng45fcd302019-01-31 16:29:43 -0800936 .append(",mNr=").append(mNr)
Nathan Haroldf23153f2018-11-19 18:09:40 -0800937 .append(",primary=").append(getPrimary().getClass().getSimpleName())
938 .append("}")
939 .toString();
Pengquan Meng7082ef02017-10-18 18:07:58 -0700940 }
941
Wink Savillee9b06d72009-05-18 21:47:50 -0700942 /**
943 * Set SignalStrength based on intent notifier map
944 *
945 * @param m intent notifier map
Nathan Haroldd261a312019-01-14 14:30:08 -0800946 *
947 * @deprecated this method relies on non-stable implementation details, and full access to
948 * internal storage is available via {@link getCellSignalStrengths()}.
Wink Savillee9b06d72009-05-18 21:47:50 -0700949 * @hide
950 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800951 @Deprecated
952 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Savillee9b06d72009-05-18 21:47:50 -0700953 private void setFromNotifierBundle(Bundle m) {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800954 mCdma = m.getParcelable("Cdma");
955 mGsm = m.getParcelable("Gsm");
956 mWcdma = m.getParcelable("Wcdma");
957 mTdscdma = m.getParcelable("Tdscdma");
958 mLte = m.getParcelable("Lte");
Pengquan Meng45fcd302019-01-31 16:29:43 -0800959 mNr = m.getParcelable("Nr");
Wink Savillee9b06d72009-05-18 21:47:50 -0700960 }
961
962 /**
963 * Set intent notifier Bundle based on SignalStrength
964 *
965 * @param m intent notifier Bundle
Nathan Haroldd261a312019-01-14 14:30:08 -0800966 *
967 * @deprecated this method relies on non-stable implementation details, and full access to
968 * internal storage is available via {@link getCellSignalStrengths()}.
Wink Savillee9b06d72009-05-18 21:47:50 -0700969 * @hide
970 */
Nathan Haroldd261a312019-01-14 14:30:08 -0800971 @Deprecated
972 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
Wink Savillee9b06d72009-05-18 21:47:50 -0700973 public void fillInNotifierBundle(Bundle m) {
Nathan Haroldf23153f2018-11-19 18:09:40 -0800974 m.putParcelable("Cdma", mCdma);
975 m.putParcelable("Gsm", mGsm);
976 m.putParcelable("Wcdma", mWcdma);
977 m.putParcelable("Tdscdma", mTdscdma);
978 m.putParcelable("Lte", mLte);
Pengquan Meng45fcd302019-01-31 16:29:43 -0800979 m.putParcelable("Nr", mNr);
Tomita, Ryounosuke Xf99e1c82017-12-13 18:46:12 +0900980 }
981
982 /**
Nathan Harold5472d802019-01-08 15:02:55 -0800983 * log warning
Wink Saville52840902011-02-18 12:40:47 -0800984 */
985 private static void log(String s) {
Wink Saville22b1e802012-12-07 10:26:41 -0800986 Rlog.w(LOG_TAG, s);
Wink Saville52840902011-02-18 12:40:47 -0800987 }
Nathan Harold5472d802019-01-08 15:02:55 -0800988
989 /**
990 * log error
991 */
992 private static void loge(String s) {
993 Rlog.e(LOG_TAG, s);
994 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700995}