Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1 | /* |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 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.telephony; |
| 18 | |
Mingming Cai | 385af08 | 2020-01-30 16:32:31 -0800 | [diff] [blame] | 19 | import android.annotation.ElapsedRealtimeLong; |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 20 | import android.annotation.NonNull; |
Artur Satayev | 74cb719 | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 21 | import android.compat.annotation.UnsupportedAppUsage; |
Nathan Harold | a6d893e | 2018-11-14 11:51:51 -0800 | [diff] [blame] | 22 | import android.os.Build; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 23 | import android.os.Bundle; |
| 24 | import android.os.Parcel; |
| 25 | import android.os.Parcelable; |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 26 | import android.os.PersistableBundle; |
Mingming Cai | f1a6294 | 2020-01-08 16:26:46 -0800 | [diff] [blame] | 27 | import android.os.SystemClock; |
| 28 | |
| 29 | import com.android.telephony.Rlog; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 30 | |
Nathan Harold | 958846f | 2018-12-06 10:55:13 -0800 | [diff] [blame] | 31 | import java.util.ArrayList; |
| 32 | import java.util.List; |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 33 | import java.util.Objects; |
Kitta Koutarou | dad385a | 2017-12-01 19:19:49 +0900 | [diff] [blame] | 34 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 35 | /** |
| 36 | * Contains phone signal strength related information. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 37 | */ |
| 38 | public class SignalStrength implements Parcelable { |
| 39 | |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 40 | private static final String LOG_TAG = "SignalStrength"; |
Robert Greenwalt | 432139b | 2012-07-27 15:44:16 -0700 | [diff] [blame] | 41 | private static final boolean DBG = false; |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 42 | |
| 43 | /** @hide */ |
Nathan Harold | a6d893e | 2018-11-14 11:51:51 -0800 | [diff] [blame] | 44 | @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 Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 47 | /** @hide */ |
Nathan Harold | a6d893e | 2018-11-14 11:51:51 -0800 | [diff] [blame] | 48 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 49 | public static final int SIGNAL_STRENGTH_POOR = |
| 50 | CellSignalStrength.SIGNAL_STRENGTH_POOR; // = 1 |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 51 | /** @hide */ |
Nathan Harold | a6d893e | 2018-11-14 11:51:51 -0800 | [diff] [blame] | 52 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 53 | public static final int SIGNAL_STRENGTH_MODERATE = |
| 54 | CellSignalStrength.SIGNAL_STRENGTH_MODERATE; // = 2 |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 55 | /** @hide */ |
Nathan Harold | a6d893e | 2018-11-14 11:51:51 -0800 | [diff] [blame] | 56 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 57 | public static final int SIGNAL_STRENGTH_GOOD = |
| 58 | CellSignalStrength.SIGNAL_STRENGTH_GOOD; // = 3 |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 59 | /** @hide */ |
Nathan Harold | a6d893e | 2018-11-14 11:51:51 -0800 | [diff] [blame] | 60 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 61 | public static final int SIGNAL_STRENGTH_GREAT = |
| 62 | CellSignalStrength.SIGNAL_STRENGTH_GREAT; // = 4 |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 63 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 64 | @UnsupportedAppUsage |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 65 | public static final int NUM_SIGNAL_STRENGTH_BINS = 5; |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 66 | |
Nathan Harold | 9becf4b33 | 2018-01-18 16:45:40 -0800 | [diff] [blame] | 67 | /** |
sqian | 61524e1 | 2018-10-19 16:47:52 -0700 | [diff] [blame] | 68 | * Indicates the invalid measures of signal strength. |
| 69 | * |
| 70 | * For example, this can be returned by {@link #getEvdoDbm()} or {@link #getCdmaDbm()} |
Nathan Harold | 9becf4b33 | 2018-01-18 16:45:40 -0800 | [diff] [blame] | 71 | */ |
| 72 | public static final int INVALID = Integer.MAX_VALUE; |
John Wang | 5e39519 | 2012-01-30 18:45:56 -0800 | [diff] [blame] | 73 | |
Jordan Liu | 407b479 | 2018-02-26 15:50:21 -0800 | [diff] [blame] | 74 | private static final int LTE_RSRP_THRESHOLDS_NUM = 4; |
Kitta Koutarou | dad385a | 2017-12-01 19:19:49 +0900 | [diff] [blame] | 75 | |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 76 | private static final int WCDMA_RSCP_THRESHOLDS_NUM = 4; |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 77 | |
| 78 | /* The type of signal measurement */ |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 79 | private static final String MEASUREMENT_TYPE_RSCP = "rscp"; |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 80 | |
Mingming Cai | 385af08 | 2020-01-30 16:32:31 -0800 | [diff] [blame] | 81 | // Timestamp of SignalStrength since boot |
| 82 | // Effectively final. Timestamp is set during construction of SignalStrength |
| 83 | private long mTimestampMillis; |
Mingming Cai | f1a6294 | 2020-01-08 16:26:46 -0800 | [diff] [blame] | 84 | |
SongFerngWang | 68c58a5 | 2020-04-13 18:13:04 +0800 | [diff] [blame] | 85 | private boolean mLteAsPrimaryInNrNsa = true; |
| 86 | |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 87 | CellSignalStrengthCdma mCdma; |
| 88 | CellSignalStrengthGsm mGsm; |
| 89 | CellSignalStrengthWcdma mWcdma; |
| 90 | CellSignalStrengthTdscdma mTdscdma; |
| 91 | CellSignalStrengthLte mLte; |
Pengquan Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 92 | CellSignalStrengthNr mNr; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 93 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 94 | /** |
| 95 | * Create a new SignalStrength from a intent notifier Bundle |
| 96 | * |
Jayachandran C | 4eda57e | 2020-01-07 16:20:33 -0800 | [diff] [blame] | 97 | * This method may be used by external applications. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 98 | * |
| 99 | * @param m Bundle from intent notifier |
| 100 | * @return newly created SignalStrength |
| 101 | * |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 102 | * @hide |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 103 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 104 | @UnsupportedAppUsage |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 105 | 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 Ramalingam | a44b1376 | 2012-07-10 13:54:10 -0700 | [diff] [blame] | 113 | * This constructor is used to create SignalStrength with default |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 114 | * values. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 115 | * |
Uma Maheswari Ramalingam | a44b1376 | 2012-07-10 13:54:10 -0700 | [diff] [blame] | 116 | * @return newly created SignalStrength |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 117 | * @hide |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 118 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 119 | @UnsupportedAppUsage |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 120 | public SignalStrength() { |
| 121 | this(new CellSignalStrengthCdma(), new CellSignalStrengthGsm(), |
| 122 | new CellSignalStrengthWcdma(), new CellSignalStrengthTdscdma(), |
Pengquan Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 123 | new CellSignalStrengthLte(), new CellSignalStrengthNr()); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /** |
Nathan Harold | 9becf4b33 | 2018-01-18 16:45:40 -0800 | [diff] [blame] | 127 | * Constructor with all fields present |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 128 | * |
| 129 | * @hide |
| 130 | */ |
Nathan Harold | 9becf4b33 | 2018-01-18 16:45:40 -0800 | [diff] [blame] | 131 | public SignalStrength( |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 132 | @NonNull CellSignalStrengthCdma cdma, |
| 133 | @NonNull CellSignalStrengthGsm gsm, |
| 134 | @NonNull CellSignalStrengthWcdma wcdma, |
| 135 | @NonNull CellSignalStrengthTdscdma tdscdma, |
Pengquan Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 136 | @NonNull CellSignalStrengthLte lte, |
| 137 | @NonNull CellSignalStrengthNr nr) { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 138 | mCdma = cdma; |
| 139 | mGsm = gsm; |
| 140 | mWcdma = wcdma; |
| 141 | mTdscdma = tdscdma; |
| 142 | mLte = lte; |
Pengquan Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 143 | mNr = nr; |
Mingming Cai | 385af08 | 2020-01-30 16:32:31 -0800 | [diff] [blame] | 144 | mTimestampMillis = SystemClock.elapsedRealtime(); |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /** |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 148 | * Constructor for Radio HAL V1.0 |
Nathan Harold | 9becf4b33 | 2018-01-18 16:45:40 -0800 | [diff] [blame] | 149 | * |
| 150 | * @hide |
| 151 | */ |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 152 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 157 | new CellSignalStrengthLte(signalStrength.lte), |
| 158 | new CellSignalStrengthNr()); |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | /** |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 162 | * Constructor for Radio HAL V1.2 |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 163 | * |
| 164 | * @hide |
| 165 | */ |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 166 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 171 | 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 Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 188 | } |
| 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. |
SongFerngWang | 68c58a5 | 2020-04-13 18:13:04 +0800 | [diff] [blame] | 193 | |
| 194 | if (mLteAsPrimaryInNrNsa) { |
| 195 | if (mLte.isValid()) return mLte; |
| 196 | } |
Rambo Wang | 8e56e11 | 2020-03-26 12:35:38 -0700 | [diff] [blame] | 197 | if (mNr.isValid()) return mNr; |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 198 | 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 Harold | 958846f | 2018-12-06 10:55:13 -0800 | [diff] [blame] | 206 | /** |
| 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 Harold | bbe345f | 2019-03-06 11:10:40 -0800 | [diff] [blame] | 225 | @NonNull public List<CellSignalStrength> getCellSignalStrengths() { |
Nathan Harold | 7e992ec | 2019-02-12 13:25:47 -0800 | [diff] [blame] | 226 | 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 Harold | bbe345f | 2019-03-06 11:10:40 -0800 | [diff] [blame] | 251 | @NonNull public <T extends CellSignalStrength> List<T> getCellSignalStrengths( |
Nathan Harold | 7e992ec | 2019-02-12 13:25:47 -0800 | [diff] [blame] | 252 | @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 Harold | 958846f | 2018-12-06 10:55:13 -0800 | [diff] [blame] | 272 | return cssList; |
| 273 | } |
| 274 | |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 275 | /** @hide */ |
| 276 | public void updateLevel(PersistableBundle cc, ServiceState ss) { |
SongFerngWang | 68c58a5 | 2020-04-13 18:13:04 +0800 | [diff] [blame] | 277 | if (cc != null) { |
| 278 | mLteAsPrimaryInNrNsa = cc.getBoolean( |
| 279 | CarrierConfigManager.KEY_SIGNAL_STRENGTH_NR_NSA_USE_LTE_AS_PRIMARY_BOOL, true); |
| 280 | } |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 281 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 286 | mNr.updateLevel(cc, ss); |
Nathan Harold | 9becf4b33 | 2018-01-18 16:45:40 -0800 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /** |
| 290 | * Copy constructors |
| 291 | * |
| 292 | * @param s Source SignalStrength |
| 293 | * |
| 294 | * @hide |
| 295 | */ |
Sooraj Sasindran | 89e4e0c | 2019-12-17 09:20:51 -0800 | [diff] [blame] | 296 | public SignalStrength(@NonNull SignalStrength s) { |
Nathan Harold | 9becf4b33 | 2018-01-18 16:45:40 -0800 | [diff] [blame] | 297 | copyFrom(s); |
| 298 | } |
| 299 | |
| 300 | /** |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 301 | * @hide |
| 302 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 303 | @UnsupportedAppUsage |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 304 | protected void copyFrom(SignalStrength s) { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 305 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 310 | mNr = new CellSignalStrengthNr(s.mNr); |
Mingming Cai | 385af08 | 2020-01-30 16:32:31 -0800 | [diff] [blame] | 311 | mTimestampMillis = s.getTimestampMillis(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Construct a SignalStrength object from the given parcel. |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 316 | * |
| 317 | * @hide |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 318 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 319 | @UnsupportedAppUsage |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 320 | public SignalStrength(Parcel in) { |
Wink Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 321 | if (DBG) log("Size of signalstrength parcel:" + in.dataSize()); |
| 322 | |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 323 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 328 | mNr = in.readParcelable(CellSignalStrengthLte.class.getClassLoader()); |
Mingming Cai | 385af08 | 2020-01-30 16:32:31 -0800 | [diff] [blame] | 329 | mTimestampMillis = in.readLong(); |
Wink Saville | efbca4d | 2013-04-08 11:35:47 -0700 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /** |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 333 | * {@link Parcelable#writeToParcel} |
| 334 | */ |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 335 | public void writeToParcel(Parcel out, int flags) { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 336 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 341 | out.writeParcelable(mNr, flags); |
Mingming Cai | 385af08 | 2020-01-30 16:32:31 -0800 | [diff] [blame] | 342 | out.writeLong(mTimestampMillis); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 345 | /** |
Mingming Cai | 385af08 | 2020-01-30 16:32:31 -0800 | [diff] [blame] | 346 | * @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 Cai | f1a6294 | 2020-01-08 16:26:46 -0800 | [diff] [blame] | 349 | */ |
Mingming Cai | 385af08 | 2020-01-30 16:32:31 -0800 | [diff] [blame] | 350 | @ElapsedRealtimeLong |
| 351 | public long getTimestampMillis() { |
| 352 | return mTimestampMillis; |
Mingming Cai | f1a6294 | 2020-01-08 16:26:46 -0800 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | /** |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 356 | * {@link Parcelable#describeContents} |
| 357 | */ |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 358 | public int describeContents() { |
| 359 | return 0; |
| 360 | } |
| 361 | |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 362 | /** |
| 363 | * {@link Parcelable.Creator} |
| 364 | * |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 365 | */ |
Hall Liu | e00ad76 | 2019-12-26 12:48:09 -0800 | [diff] [blame] | 366 | 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 Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 371 | |
Hall Liu | e00ad76 | 2019-12-26 12:48:09 -0800 | [diff] [blame] | 372 | public SignalStrength[] newArray(int size) { |
| 373 | return new SignalStrength[size]; |
| 374 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 375 | }; |
| 376 | |
| 377 | /** |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 378 | * Get the GSM RSSI in ASU. |
Uma Maheswari Ramalingam | a44b1376 | 2012-07-10 13:54:10 -0700 | [diff] [blame] | 379 | * |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 380 | * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69 |
Pengquan Meng | 7082ef0 | 2017-10-18 18:07:58 -0700 | [diff] [blame] | 381 | * |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 382 | * @return RSSI in ASU 0..31, 99, or UNAVAILABLE |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 383 | * |
| 384 | * @deprecated this information should be retrieved from |
| 385 | * {@link CellSignalStrengthGsm#getAsuLevel}. |
| 386 | * @see android.telephony#CellSignalStrengthGsm |
| 387 | * @see android.telephony.SignalStrength#getCellSignalStrengths |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 388 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 389 | @Deprecated |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 390 | public int getGsmSignalStrength() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 391 | return mGsm.getAsuLevel(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | /** |
| 395 | * Get the GSM bit error rate (0-7, 99) as defined in TS 27.007 8.5 |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 396 | * |
| 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 Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 402 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 403 | @Deprecated |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 404 | public int getGsmBitErrorRate() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 405 | return mGsm.getBitErrorRate(); |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | /** |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 409 | * Get the CDMA RSSI value in dBm |
sqian | 61524e1 | 2018-10-19 16:47:52 -0700 | [diff] [blame] | 410 | * |
| 411 | * @return the CDMA RSSI value or {@link #INVALID} if invalid |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 412 | * |
| 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 Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 418 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 419 | @Deprecated |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 420 | public int getCdmaDbm() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 421 | return mCdma.getCdmaDbm(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Get the CDMA Ec/Io value in dB*10 |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 426 | * |
| 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 Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 432 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 433 | @Deprecated |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 434 | public int getCdmaEcio() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 435 | return mCdma.getCdmaEcio(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | /** |
| 439 | * Get the EVDO RSSI value in dBm |
sqian | 61524e1 | 2018-10-19 16:47:52 -0700 | [diff] [blame] | 440 | * |
| 441 | * @return the EVDO RSSI value or {@link #INVALID} if invalid |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 442 | * |
| 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 Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 448 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 449 | @Deprecated |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 450 | public int getEvdoDbm() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 451 | return mCdma.getEvdoDbm(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Get the EVDO Ec/Io value in dB*10 |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 456 | * |
| 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 Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 462 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 463 | @Deprecated |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 464 | public int getEvdoEcio() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 465 | return mCdma.getEvdoEcio(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | /** |
| 469 | * Get the signal to noise ratio. Valid values are 0-8. 8 is the highest. |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 470 | * |
| 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 Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 476 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 477 | @Deprecated |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 478 | public int getEvdoSnr() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 479 | return mCdma.getEvdoSnr(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 480 | } |
| 481 | |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 482 | /** |
| 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 Saville | 29c8b00 | 2013-06-21 09:58:11 -0700 | [diff] [blame] | 492 | public int getLteSignalStrength() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 493 | return mLte.getRssi(); |
Wink Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 494 | } |
| 495 | |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 496 | /** |
| 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 Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 506 | public int getLteRsrp() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 507 | return mLte.getRsrp(); |
Wink Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 508 | } |
| 509 | |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 510 | /** |
| 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 Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 520 | public int getLteRsrq() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 521 | return mLte.getRsrq(); |
Wink Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 522 | } |
| 523 | |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 524 | /** |
| 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 Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 534 | public int getLteRssnr() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 535 | return mLte.getRssnr(); |
Wink Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 536 | } |
| 537 | |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 538 | /** |
| 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 Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 548 | public int getLteCqi() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 549 | return mLte.getCqi(); |
Wink Saville | 2900a3fa | 2012-08-13 16:50:30 -0700 | [diff] [blame] | 550 | } |
| 551 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 552 | /** |
Robert Greenwalt | 46982c5 | 2015-06-10 15:46:09 -0700 | [diff] [blame] | 553 | * 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 Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 559 | */ |
| 560 | public int getLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 561 | int level = getPrimary().getLevel(); |
| 562 | if (level < SIGNAL_STRENGTH_NONE_OR_UNKNOWN || level > SIGNAL_STRENGTH_GREAT) { |
Nathan Harold | 5472d80 | 2019-01-08 15:02:55 -0800 | [diff] [blame] | 563 | loge("Invalid Level " + level + ", this=" + this); |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 564 | return SIGNAL_STRENGTH_NONE_OR_UNKNOWN; |
| 565 | } |
| 566 | return getPrimary().getLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | /** |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 570 | * Get the signal level as an asu value with a range dependent on the underlying technology. |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 571 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 572 | * @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 Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 577 | * @hide |
| 578 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 579 | @Deprecated |
| 580 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 581 | public int getAsuLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 582 | return getPrimary().getAsuLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | /** |
| 586 | * Get the signal strength as dBm |
| 587 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 588 | * @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 Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 593 | * @hide |
| 594 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 595 | @Deprecated |
| 596 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 597 | public int getDbm() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 598 | return getPrimary().getDbm(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /** |
| 602 | * Get Gsm signal strength as dBm |
| 603 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 604 | * @deprecated this information should be retrieved from |
| 605 | * {@link CellSignalStrengthGsm#getDbm}. |
| 606 | * |
| 607 | * @see android.telephony#CellSignalStrengthGsm |
| 608 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 609 | * @hide |
| 610 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 611 | @Deprecated |
| 612 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 613 | public int getGsmDbm() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 614 | return mGsm.getDbm(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | /** |
| 618 | * Get gsm as level 0..4 |
| 619 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 620 | * @deprecated this information should be retrieved from |
| 621 | * {@link CellSignalStrengthGsm#getLevel}. |
| 622 | * |
| 623 | * @see android.telephony#CellSignalStrengthGsm |
| 624 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 625 | * @hide |
| 626 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 627 | @Deprecated |
| 628 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 629 | public int getGsmLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 630 | return mGsm.getLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | /** |
| 634 | * Get the gsm signal level as an asu value between 0..31, 99 is unknown |
| 635 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 636 | * @deprecated this information should be retrieved from |
| 637 | * {@link CellSignalStrengthGsm#getAsuLevel}. |
| 638 | * |
| 639 | * @see android.telephony#CellSignalStrengthGsm |
| 640 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 641 | * @hide |
| 642 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 643 | @Deprecated |
| 644 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 645 | public int getGsmAsuLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 646 | return mGsm.getAsuLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /** |
| 650 | * Get cdma as level 0..4 |
| 651 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 652 | * @deprecated this information should be retrieved from |
| 653 | * {@link CellSignalStrengthCdma#getLevel}. |
| 654 | * |
| 655 | * @see android.telephony#CellSignalStrengthCdma |
| 656 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 657 | * @hide |
| 658 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 659 | @Deprecated |
| 660 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 661 | public int getCdmaLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 662 | return mCdma.getLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Get the cdma signal level as an asu value between 0..31, 99 is unknown |
| 667 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 668 | * @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 Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 675 | * @hide |
| 676 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 677 | @Deprecated |
| 678 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 679 | public int getCdmaAsuLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 680 | return mCdma.getAsuLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | /** |
| 684 | * Get Evdo as level 0..4 |
| 685 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 686 | * @deprecated this information should be retrieved from |
| 687 | * {@link CellSignalStrengthCdma#getEvdoLevel}. |
| 688 | * |
| 689 | * @see android.telephony#CellSignalStrengthCdma |
| 690 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 691 | * @hide |
| 692 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 693 | @Deprecated |
| 694 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 695 | public int getEvdoLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 696 | return mCdma.getEvdoLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | /** |
| 700 | * Get the evdo signal level as an asu value between 0..31, 99 is unknown |
| 701 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 702 | * @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 Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 709 | * @hide |
| 710 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 711 | @Deprecated |
| 712 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 713 | public int getEvdoAsuLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 714 | return mCdma.getEvdoAsuLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | /** |
| 718 | * Get LTE as dBm |
| 719 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 720 | * @deprecated this information should be retrieved from |
| 721 | * {@link CellSignalStrengthLte#getDbm}. |
| 722 | * |
| 723 | * @see android.telephony#CellSignalStrengthLte |
| 724 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 725 | * @hide |
| 726 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 727 | @Deprecated |
| 728 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 729 | public int getLteDbm() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 730 | return mLte.getRsrp(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 731 | } |
| 732 | |
| 733 | /** |
| 734 | * Get LTE as level 0..4 |
| 735 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 736 | * @deprecated this information should be retrieved from |
| 737 | * {@link CellSignalStrengthLte#getLevel}. |
| 738 | * |
| 739 | * @see android.telephony#CellSignalStrengthLte |
| 740 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 741 | * @hide |
| 742 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 743 | @Deprecated |
| 744 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 745 | public int getLteLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 746 | return mLte.getLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 747 | } |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 748 | |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 749 | /** |
Ramesh Sudini | 5d7b927 | 2011-05-09 09:45:26 -0500 | [diff] [blame] | 750 | * 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 Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 752 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 753 | * @deprecated this information should be retrieved from |
| 754 | * {@link CellSignalStrengthLte#getAsuLevel}. |
| 755 | * |
| 756 | * @see android.telephony#CellSignalStrengthLte |
| 757 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 758 | * @hide |
| 759 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 760 | @Deprecated |
| 761 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 762 | public int getLteAsuLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 763 | return mLte.getAsuLevel(); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 764 | } |
| 765 | |
| 766 | /** |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 767 | * @return true if this is for GSM |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 768 | * |
| 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 Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 775 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 776 | @Deprecated |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 777 | public boolean isGsm() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 778 | return !(getPrimary() instanceof CellSignalStrengthCdma); |
Wenting Xiong | cb35e99 | 2017-10-18 15:05:49 +0900 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | /** |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 782 | * @return get TD-SCDMA dBm |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 783 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 784 | * @deprecated this information should be retrieved from |
| 785 | * {@link CellSignalStrengthTdscdma#getDbm}. |
| 786 | * |
| 787 | * @see android.telephony#CellSignalStrengthTdscdma |
| 788 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 789 | * @hide |
| 790 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 791 | @Deprecated |
| 792 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 793 | public int getTdScdmaDbm() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 794 | return mTdscdma.getRscp(); |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 795 | } |
| 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 Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 803 | * @deprecated this information should be retrieved from |
| 804 | * {@link CellSignalStrengthTdscdma#getLevel}. |
| 805 | * |
| 806 | * @see android.telephony#CellSignalStrengthTdscdma |
| 807 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 808 | * @hide |
| 809 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 810 | @Deprecated |
| 811 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 812 | public int getTdScdmaLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 813 | return mTdscdma.getLevel(); |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | /** |
| 817 | * Get the TD-SCDMA signal level as an asu value. |
| 818 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 819 | * @deprecated this information should be retrieved from |
| 820 | * {@link CellSignalStrengthTdscdma#getAsuLevel}. |
| 821 | * |
| 822 | * @see android.telephony#CellSignalStrengthTdscdma |
| 823 | * @see android.telephony.SignalStrength#getCellSignalStrengths() |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 824 | * @hide |
| 825 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 826 | @Deprecated |
| 827 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 828 | public int getTdScdmaAsuLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 829 | return mTdscdma.getAsuLevel(); |
Sungmin Choi | 3698086 | 2015-08-26 11:05:46 -0700 | [diff] [blame] | 830 | } |
| 831 | |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 832 | /** |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 833 | * Gets WCDMA RSCP as a dBm value between -120 and -24, as defined in TS 27.007 8.69. |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 834 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 835 | * @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 X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 840 | * @hide |
| 841 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 842 | @Deprecated |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 843 | public int getWcdmaRscp() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 844 | return mWcdma.getRscp(); |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | /** |
| 848 | * Get the WCDMA signal level as an ASU value between 0-96, 255 is unknown |
| 849 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 850 | * @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 X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 855 | * @hide |
| 856 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 857 | @Deprecated |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 858 | 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 Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 867 | return mWcdma.getAsuLevel(); |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | /** |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 871 | * Gets WCDMA signal strength as a dBm value between -120 and -24, as defined in TS 27.007 8.69. |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 872 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 873 | * @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 X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 878 | * @hide |
| 879 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 880 | @Deprecated |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 881 | public int getWcdmaDbm() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 882 | return mWcdma.getDbm(); |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | /** |
| 886 | * Get WCDMA as level 0..4 |
| 887 | * |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 888 | * @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 X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 893 | * @hide |
| 894 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 895 | @Deprecated |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 896 | public int getWcdmaLevel() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 897 | return mWcdma.getLevel(); |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 898 | } |
| 899 | |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 900 | /** |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 901 | * @return hash code |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 902 | */ |
| 903 | @Override |
| 904 | public int hashCode() { |
Pengquan Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 905 | return Objects.hash(mCdma, mGsm, mWcdma, mTdscdma, mLte, mNr); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | /** |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 909 | * @return true if the signal strengths are the same |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 910 | */ |
| 911 | @Override |
| 912 | public boolean equals (Object o) { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 913 | if (!(o instanceof SignalStrength)) return false; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 914 | |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 915 | SignalStrength s = (SignalStrength) o; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 916 | |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 917 | return mCdma.equals(s.mCdma) |
| 918 | && mGsm.equals(s.mGsm) |
| 919 | && mWcdma.equals(s.mWcdma) |
| 920 | && mTdscdma.equals(s.mTdscdma) |
Pengquan Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 921 | && mLte.equals(s.mLte) |
| 922 | && mNr.equals(s.mNr); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | /** |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 926 | * @return string representation. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 927 | */ |
| 928 | @Override |
| 929 | public String toString() { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 930 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 936 | .append(",mNr=").append(mNr) |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 937 | .append(",primary=").append(getPrimary().getClass().getSimpleName()) |
| 938 | .append("}") |
| 939 | .toString(); |
Pengquan Meng | 7082ef0 | 2017-10-18 18:07:58 -0700 | [diff] [blame] | 940 | } |
| 941 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 942 | /** |
| 943 | * Set SignalStrength based on intent notifier map |
| 944 | * |
| 945 | * @param m intent notifier map |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 946 | * |
| 947 | * @deprecated this method relies on non-stable implementation details, and full access to |
| 948 | * internal storage is available via {@link getCellSignalStrengths()}. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 949 | * @hide |
| 950 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 951 | @Deprecated |
| 952 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 953 | private void setFromNotifierBundle(Bundle m) { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 954 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 959 | mNr = m.getParcelable("Nr"); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 960 | } |
| 961 | |
| 962 | /** |
| 963 | * Set intent notifier Bundle based on SignalStrength |
| 964 | * |
| 965 | * @param m intent notifier Bundle |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 966 | * |
| 967 | * @deprecated this method relies on non-stable implementation details, and full access to |
| 968 | * internal storage is available via {@link getCellSignalStrengths()}. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 969 | * @hide |
| 970 | */ |
Nathan Harold | d261a31 | 2019-01-14 14:30:08 -0800 | [diff] [blame] | 971 | @Deprecated |
| 972 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 973 | public void fillInNotifierBundle(Bundle m) { |
Nathan Harold | f23153f | 2018-11-19 18:09:40 -0800 | [diff] [blame] | 974 | 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 Meng | 45fcd30 | 2019-01-31 16:29:43 -0800 | [diff] [blame] | 979 | m.putParcelable("Nr", mNr); |
Tomita, Ryounosuke X | f99e1c8 | 2017-12-13 18:46:12 +0900 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | /** |
Nathan Harold | 5472d80 | 2019-01-08 15:02:55 -0800 | [diff] [blame] | 983 | * log warning |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 984 | */ |
| 985 | private static void log(String s) { |
Wink Saville | 22b1e80 | 2012-12-07 10:26:41 -0800 | [diff] [blame] | 986 | Rlog.w(LOG_TAG, s); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 987 | } |
Nathan Harold | 5472d80 | 2019-01-08 15:02:55 -0800 | [diff] [blame] | 988 | |
| 989 | /** |
| 990 | * log error |
| 991 | */ |
| 992 | private static void loge(String s) { |
| 993 | Rlog.e(LOG_TAG, s); |
| 994 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 995 | } |