1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.telephony;
18 
19 import android.annotation.IntRange;
20 import android.compat.annotation.UnsupportedAppUsage;
21 import android.os.Build;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 import android.os.PersistableBundle;
25 
26 import com.android.telephony.Rlog;
27 
28 import java.util.Arrays;
29 import java.util.Objects;
30 
31 /**
32  * LTE signal strength related information.
33  */
34 public final class CellSignalStrengthLte extends CellSignalStrength implements Parcelable {
35 
36     private static final String LOG_TAG = "CellSignalStrengthLte";
37     private static final boolean DBG = false;
38 
39     /**
40      * Indicates the unknown or undetectable RSSI value in ASU.
41      *
42      * Reference: TS 27.007 8.5 - Signal quality +CSQ
43      */
44     private static final int SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN = 99;
45     /**
46      * Indicates the maximum valid RSSI value in ASU.
47      *
48      * Reference: TS 27.007 8.5 - Signal quality +CSQ
49      */
50     private static final int SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MAX_VALUE = 31;
51     /**
52      * Indicates the minimum valid RSSI value in ASU.
53      *
54      * Reference: TS 27.007 8.5 - Signal quality +CSQ
55      */
56     private static final int SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MIN_VALUE = 0;
57 
58     private static final int MAX_LTE_RSRP = -44;
59     private static final int MIN_LTE_RSRP = -140;
60 
61     /**
62      * Indicates RSRP is considered for {@link #getLevel()} and reported from modem.
63      *
64      * @hide
65      */
66     public static final int USE_RSRP = 1 << 0;
67     /**
68      * Indicates RSRQ is considered for {@link #getLevel()} and reported from modem.
69      *
70      * @hide
71      */
72     public static final int USE_RSRQ = 1 << 1;
73     /**
74      * Indicates RSSNR is considered for {@link #getLevel()} and reported from modem.
75      *
76      * @hide
77      */
78     public static final int USE_RSSNR = 1 << 2;
79 
80     @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P)
81     private int mSignalStrength; // To be removed
82     private int mRssi;
83     @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P)
84     private int mRsrp;
85     @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P)
86     private int mRsrq;
87     @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P)
88     private int mRssnr;
89     /**
90      * CSI channel quality indicator (CQI) table index. There are multiple CQI tables.
91      * The definition of CQI in each table is different.
92      *
93      * Reference: 3GPP TS 136.213 section 7.2.3.
94      *
95      * Range [1, 6].
96      */
97     private int mCqiTableIndex;
98     @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P)
99     private int mCqi;
100     @UnsupportedAppUsage(maxTargetSdk = android.os.Build.VERSION_CODES.P)
101     private int mTimingAdvance;
102     private int mLevel;
103 
104     /**
105      * Bit-field integer to determine whether to use Reference Signal Received Power (RSRP),
106      * Reference Signal Received Quality (RSRQ), and/or Reference Signal Signal to Noise Ratio
107      * (RSSNR) for the number of LTE signal bars. If multiple measures are set, the parameter
108      * whose signal level value is smallest is used to indicate the signal level.
109      *
110      *  RSRP = 1 << 0,
111      *  RSRQ = 1 << 1,
112      *  RSSNR = 1 << 2,
113      *
114      * For example, if both RSRP and RSRQ are used, the value of key is 3 (1 << 0 | 1 << 1).
115      * If the key is invalid or not configured, a default value (RSRP = 1 << 0) will apply.
116      */
117     private int mParametersUseForLevel;
118 
119     /** @hide */
120     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
CellSignalStrengthLte()121     public CellSignalStrengthLte() {
122         setDefaultValues();
123     }
124 
125     /**
126      * Construct a cell signal strength
127      *
128      * @param rssi in dBm [-113,-51], {@link CellInfo#UNAVAILABLE}
129      * @param rsrp in dBm [-140,-43], {@link CellInfo#UNAVAILABLE}
130      * @param rsrq in dB [-34, 3], {@link CellInfo#UNAVAILABLE}
131      * @param rssnr in dB [-20, +30], {@link CellInfo#UNAVAILABLE}
132      * @param cqiTableIndex [1, 6], {@link CellInfo#UNAVAILABLE}
133      * @param cqi [0, 15], {@link CellInfo#UNAVAILABLE}
134      * @param timingAdvance [0, 1282], {@link CellInfo#UNAVAILABLE}
135      *
136      */
137     /** @hide */
CellSignalStrengthLte(int rssi, int rsrp, int rsrq, int rssnr, int cqiTableIndex, int cqi, int timingAdvance)138     public CellSignalStrengthLte(int rssi, int rsrp, int rsrq, int rssnr, int cqiTableIndex,
139             int cqi, int timingAdvance) {
140         mRssi = inRangeOrUnavailable(rssi, -113, -51);
141         mSignalStrength = mRssi;
142         mRsrp = inRangeOrUnavailable(rsrp, -140, -43);
143         mRsrq = inRangeOrUnavailable(rsrq, -34, 3);
144         mRssnr = inRangeOrUnavailable(rssnr, -20, 30);
145         mCqiTableIndex = inRangeOrUnavailable(cqiTableIndex, 1, 6);
146         mCqi = inRangeOrUnavailable(cqi, 0, 15);
147         mTimingAdvance = inRangeOrUnavailable(timingAdvance, 0, 1282);
148         updateLevel(null, null);
149     }
150 
151     /**
152      * Construct a cell signal strength
153      *
154      * @param rssi in dBm [-113,-51], {@link CellInfo#UNAVAILABLE}
155      * @param rsrp in dBm [-140,-43], {@link CellInfo#UNAVAILABLE}
156      * @param rsrq in dB [-34, 3], {@link CellInfo#UNAVAILABLE}
157      * @param rssnr in dB [-20, +30], {@link CellInfo#UNAVAILABLE}
158      * @param cqi [0, 15], {@link CellInfo#UNAVAILABLE}
159      * @param timingAdvance [0, 1282], {@link CellInfo#UNAVAILABLE}
160      *
161      */
162     /** @hide */
CellSignalStrengthLte(int rssi, int rsrp, int rsrq, int rssnr, int cqi, int timingAdvance)163     public CellSignalStrengthLte(int rssi, int rsrp, int rsrq, int rssnr, int cqi,
164             int timingAdvance) {
165         this(rssi, rsrp, rsrq, rssnr, CellInfo.UNAVAILABLE, cqi, timingAdvance);
166     }
167 
168     /** @hide */
CellSignalStrengthLte(CellSignalStrengthLte s)169     public CellSignalStrengthLte(CellSignalStrengthLte s) {
170         copyFrom(s);
171     }
172 
173     /** @hide */
copyFrom(CellSignalStrengthLte s)174     protected void copyFrom(CellSignalStrengthLte s) {
175         mSignalStrength = s.mSignalStrength;
176         mRssi = s.mRssi;
177         mRsrp = s.mRsrp;
178         mRsrq = s.mRsrq;
179         mRssnr = s.mRssnr;
180         mCqiTableIndex = s.mCqiTableIndex;
181         mCqi = s.mCqi;
182         mTimingAdvance = s.mTimingAdvance;
183         mLevel = s.mLevel;
184         mParametersUseForLevel = s.mParametersUseForLevel;
185     }
186 
187     /** @hide */
188     @Override
copy()189     public CellSignalStrengthLte copy() {
190         return new CellSignalStrengthLte(this);
191     }
192 
193     /** @hide */
194     @Override
setDefaultValues()195     public void setDefaultValues() {
196         mSignalStrength = CellInfo.UNAVAILABLE;
197         mRssi = CellInfo.UNAVAILABLE;
198         mRsrp = CellInfo.UNAVAILABLE;
199         mRsrq = CellInfo.UNAVAILABLE;
200         mRssnr = CellInfo.UNAVAILABLE;
201         mCqiTableIndex = CellInfo.UNAVAILABLE;
202         mCqi = CellInfo.UNAVAILABLE;
203         mTimingAdvance = CellInfo.UNAVAILABLE;
204         mLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
205         mParametersUseForLevel = USE_RSRP;
206     }
207 
208     /** {@inheritDoc} */
209     @Override
210     @IntRange(from = SIGNAL_STRENGTH_NONE_OR_UNKNOWN, to = SIGNAL_STRENGTH_GREAT)
getLevel()211     public int getLevel() {
212         return mLevel;
213     }
214 
215     // Lifted from Default carrier configs and max range of RSRP
216     private static final int[] sRsrpThresholds = new int[] {
217             -115, /* SIGNAL_STRENGTH_POOR */
218             -105, /* SIGNAL_STRENGTH_MODERATE */
219             -95,  /* SIGNAL_STRENGTH_GOOD */
220             -85   /* SIGNAL_STRENGTH_GREAT */
221     };
222 
223     // Lifted from Default carrier configs and max range of RSRQ
224     private static final int[] sRsrqThresholds = new int[] {
225             -19, /* SIGNAL_STRENGTH_POOR */
226             -17, /* SIGNAL_STRENGTH_MODERATE */
227             -14, /* SIGNAL_STRENGTH_GOOD */
228             -12  /* SIGNAL_STRENGTH_GREAT */
229     };
230     // Lifted from Default carrier configs and max range of RSSNR
231     private static final int[] sRssnrThresholds = new int[] {
232             -3, /* SIGNAL_STRENGTH_POOR */
233             1,  /* SIGNAL_STRENGTH_MODERATE */
234             5,  /* SIGNAL_STRENGTH_GOOD */
235             13  /* SIGNAL_STRENGTH_GREAT */
236     };
237     private static final int sRsrpBoost = 0;
238 
239     /**
240      * Checks if the given parameter type is considered to use for {@link #getLevel()}.
241      *
242      * Note: if multiple parameter types are considered, the smaller level for one of the
243      * parameters would be returned by {@link #getLevel()}
244      *
245      * @param parameterType bitwise OR of {@link #USE_RSRP}, {@link #USE_RSRQ},
246      *         {@link #USE_RSSNR}
247      * @return {@code true} if the level is calculated based on the given parameter type;
248      *      {@code false} otherwise.
249      */
isLevelForParameter(int parameterType)250     private boolean isLevelForParameter(int parameterType) {
251         return (parameterType & mParametersUseForLevel) == parameterType;
252     }
253 
254     /** @hide */
255     @Override
updateLevel(PersistableBundle cc, ServiceState ss)256     public void updateLevel(PersistableBundle cc, ServiceState ss) {
257         int[] rsrpThresholds, rsrqThresholds, rssnrThresholds;
258         boolean rsrpOnly;
259         if (cc == null) {
260             mParametersUseForLevel = USE_RSRP;
261             rsrpThresholds = sRsrpThresholds;
262             rsrqThresholds = sRsrqThresholds;
263             rssnrThresholds = sRssnrThresholds;
264             rsrpOnly = false;
265         } else {
266             mParametersUseForLevel = cc.getInt(
267                     CarrierConfigManager.KEY_PARAMETERS_USED_FOR_LTE_SIGNAL_BAR_INT);
268             if (DBG) {
269                 Rlog.i(LOG_TAG, "Using signal strength level: " + mParametersUseForLevel);
270             }
271             rsrpThresholds = cc.getIntArray(
272                     CarrierConfigManager.KEY_LTE_RSRP_THRESHOLDS_INT_ARRAY);
273             if (rsrpThresholds == null) rsrpThresholds = sRsrpThresholds;
274             if (DBG) {
275                 Rlog.i(LOG_TAG, "Applying LTE RSRP Thresholds: "
276                         + Arrays.toString(rsrpThresholds));
277             }
278             rsrqThresholds = cc.getIntArray(
279                     CarrierConfigManager.KEY_LTE_RSRQ_THRESHOLDS_INT_ARRAY);
280             if (rsrqThresholds == null) rsrqThresholds = sRsrqThresholds;
281             if (DBG) {
282                 Rlog.i(LOG_TAG, "Applying LTE RSRQ Thresholds: "
283                         + Arrays.toString(rsrqThresholds));
284             }
285             rssnrThresholds = cc.getIntArray(
286                     CarrierConfigManager.KEY_LTE_RSSNR_THRESHOLDS_INT_ARRAY);
287             if (rssnrThresholds == null) rssnrThresholds = sRssnrThresholds;
288             if (DBG) {
289                 Rlog.i(LOG_TAG, "Applying LTE RSSNR Thresholds: "
290                         + Arrays.toString(rssnrThresholds));
291             }
292             rsrpOnly = cc.getBoolean(
293                     CarrierConfigManager.KEY_USE_ONLY_RSRP_FOR_LTE_SIGNAL_BAR_BOOL, false);
294         }
295 
296         int rsrpBoost = 0;
297         if (ss != null) {
298             rsrpBoost = ss.getArfcnRsrpBoost();
299         }
300 
301         int rsrp = inRangeOrUnavailable(mRsrp + rsrpBoost, MIN_LTE_RSRP, MAX_LTE_RSRP);
302 
303         if (rsrpOnly) {
304             int level = updateLevelWithMeasure(rsrp, rsrpThresholds);
305             if (DBG) log("updateLevel() - rsrp = " + level);
306             if (level != SignalStrength.INVALID) {
307                 mLevel = level;
308                 return;
309             }
310         }
311 
312         int rsrpLevel = SignalStrength.INVALID;
313         int rsrqLevel = SignalStrength.INVALID;
314         int rssnrLevel = SignalStrength.INVALID;
315 
316         if (isLevelForParameter(USE_RSRP)) {
317             rsrpLevel = updateLevelWithMeasure(rsrp, rsrpThresholds);
318             if (DBG) {
319                 Rlog.i(LOG_TAG, "Updated 4G LTE RSRP Level: " + rsrpLevel);
320             }
321         }
322         if (isLevelForParameter(USE_RSRQ)) {
323             rsrqLevel = updateLevelWithMeasure(mRsrq, rsrqThresholds);
324             if (DBG) {
325                 Rlog.i(LOG_TAG, "Updated 4G LTE RSRQ Level: " + rsrqLevel);
326             }
327         }
328         if (isLevelForParameter(USE_RSSNR)) {
329             rssnrLevel = updateLevelWithMeasure(mRssnr, rssnrThresholds);
330             if (DBG) {
331                 Rlog.i(LOG_TAG, "Updated 4G LTE RSSNR Level: " + rssnrLevel);
332             }
333         }
334         // Apply the smaller value among three levels of three measures.
335         mLevel = Math.min(Math.min(rsrpLevel, rsrqLevel), rssnrLevel);
336 
337         if (mLevel == SignalStrength.INVALID) {
338             int rssiLevel;
339             if (mRssi > -51) {
340                 rssiLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
341             } else if (mRssi >= -89) {
342                 rssiLevel = SIGNAL_STRENGTH_GREAT;
343             } else if (mRssi >= -97) {
344                 rssiLevel = SIGNAL_STRENGTH_GOOD;
345             } else if (mRssi >= -103) {
346                 rssiLevel = SIGNAL_STRENGTH_MODERATE;
347             } else if (mRssi >= -113) {
348                 rssiLevel = SIGNAL_STRENGTH_POOR;
349             } else {
350                 rssiLevel = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
351             }
352             if (DBG) log("getLteLevel - rssi:" + mRssi + " rssiIconLevel:" + rssiLevel);
353             mLevel = rssiLevel;
354         }
355     }
356 
357     /**
358      * Update level with corresponding measure and thresholds.
359      *
360      * @param measure corresponding signal measure
361      * @param thresholds corresponding signal thresholds
362      * @return level of the signal strength
363      */
updateLevelWithMeasure(int measure, int[] thresholds)364     private int updateLevelWithMeasure(int measure, int[] thresholds) {
365         int level;
366         if (measure == CellInfo.UNAVAILABLE) {
367             level = SignalStrength.INVALID;
368         } else if (measure >= thresholds[3]) {
369             level = SIGNAL_STRENGTH_GREAT;
370         } else if (measure >= thresholds[2]) {
371             level = SIGNAL_STRENGTH_GOOD;
372         } else if (measure >= thresholds[1]) {
373             level = SIGNAL_STRENGTH_MODERATE;
374         } else if (measure >= thresholds[0]) {
375             level = SIGNAL_STRENGTH_POOR;
376         } else {
377             level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
378         }
379         return level;
380     }
381 
382     /**
383      * Get reference signal received quality
384      *
385      * @return the RSRQ if available or
386      *         {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
387      */
getRsrq()388     public int getRsrq() {
389         return mRsrq;
390     }
391 
392     /**
393      * Get Received Signal Strength Indication (RSSI) in dBm
394      *
395      * The value range is [-113, -51] inclusively or {@link CellInfo#UNAVAILABLE} if unavailable.
396      *
397      * Reference: TS 27.007 8.5 Signal quality +CSQ
398      *
399      * @return the RSSI if available or {@link CellInfo#UNAVAILABLE} if unavailable.
400      */
getRssi()401     public int getRssi() {
402         return mRssi;
403     }
404 
405     /**
406      * Get reference signal signal-to-noise ratio in dB
407      * Range: -20 dB to +30 dB.
408      *
409      * @return the RSSNR if available or
410      *         {@link android.telephony.CellInfo#UNAVAILABLE} if unavailable.
411      */
getRssnr()412     public int getRssnr() {
413         return mRssnr;
414     }
415 
416     /**
417      * Get reference signal received power in dBm
418      * Range: -140 dBm to -43 dBm.
419      *
420      * @return the RSRP of the measured cell or {@link CellInfo#UNAVAILABLE} if
421      * unavailable.
422      */
getRsrp()423     public int getRsrp() {
424         return mRsrp;
425     }
426 
427     /**
428      * Get table index for channel quality indicator
429      *
430      * Reference: 3GPP TS 136.213 section 7.2.3.
431      *
432      * @return the CQI table index if available or
433      *         {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
434      */
435     @IntRange(from = 1, to = 6)
getCqiTableIndex()436     public int getCqiTableIndex() {
437         return mCqiTableIndex;
438     }
439 
440     /**
441      * Get channel quality indicator
442      *
443      * Reference: 3GPP TS 136.213 section 7.2.3.
444      *
445      * @return the CQI if available or
446      *         {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
447      */
448     @IntRange(from = 0, to = 15)
getCqi()449     public int getCqi() {
450         return mCqi;
451     }
452 
453     /**
454      * Get signal strength in dBm
455      *
456      * @return the RSRP of the measured cell.
457      */
458     @Override
getDbm()459     public int getDbm() {
460         return mRsrp;
461     }
462 
463     /**
464      * Get the RSRP in ASU.
465      *
466      * Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
467      *
468      * @return RSCP in ASU 0..97, 255, or UNAVAILABLE
469      */
470     @Override
getAsuLevel()471     public int getAsuLevel() {
472         int lteAsuLevel = 99;
473         int lteDbm = mRsrp;
474         if (lteDbm == CellInfo.UNAVAILABLE) lteAsuLevel = 99;
475         else if (lteDbm <= -140) lteAsuLevel = 0;
476         else if (lteDbm >= -43) lteAsuLevel = 97;
477         else lteAsuLevel = lteDbm + 140;
478         if (DBG) log("Lte Asu level: "+lteAsuLevel);
479         return lteAsuLevel;
480     }
481 
482     /**
483      * Get the timing advance value for LTE, as a value in range of 0..1282.
484      * {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} is reported when there is no
485      * active RRC connection. Refer to 3GPP 36.213 Sec 4.2.3
486      *
487      * @return the LTE timing advance if available or
488      *         {@link android.telephony.CellInfo#UNAVAILABLE UNAVAILABLE} if unavailable.
489      */
getTimingAdvance()490     public int getTimingAdvance() {
491         return mTimingAdvance;
492     }
493 
494     @Override
hashCode()495     public int hashCode() {
496         return Objects.hash(mRssi, mRsrp, mRsrq, mRssnr, mCqiTableIndex, mCqi, mTimingAdvance,
497                 mLevel);
498     }
499 
500     private static final CellSignalStrengthLte sInvalid = new CellSignalStrengthLte();
501 
502     /** @hide */
503     @Override
isValid()504     public boolean isValid() {
505         return !this.equals(sInvalid);
506     }
507 
508     @Override
equals(Object o)509     public boolean equals (Object o) {
510         CellSignalStrengthLte s;
511 
512         if (!(o instanceof CellSignalStrengthLte)) return false;
513         s = (CellSignalStrengthLte) o;
514 
515         return mRssi == s.mRssi
516                 && mRsrp == s.mRsrp
517                 && mRsrq == s.mRsrq
518                 && mRssnr == s.mRssnr
519                 && mCqiTableIndex == s.mCqiTableIndex
520                 && mCqi == s.mCqi
521                 && mTimingAdvance == s.mTimingAdvance
522                 && mLevel == s.mLevel;
523     }
524 
525     /**
526      * @return string representation.
527      */
528     @Override
toString()529     public String toString() {
530         return "CellSignalStrengthLte:"
531                 + " rssi=" + mRssi
532                 + " rsrp=" + mRsrp
533                 + " rsrq=" + mRsrq
534                 + " rssnr=" + mRssnr
535                 + " cqiTableIndex=" + mCqiTableIndex
536                 + " cqi=" + mCqi
537                 + " ta=" + mTimingAdvance
538                 + " level=" + mLevel
539                 + " parametersUseForLevel=" + mParametersUseForLevel;
540     }
541 
542     /** Implement the Parcelable interface */
543     @Override
writeToParcel(Parcel dest, int flags)544     public void writeToParcel(Parcel dest, int flags) {
545         if (DBG) log("writeToParcel(Parcel, int): " + toString());
546         dest.writeInt(mRssi);
547         // Need to multiply rsrp and rsrq by -1
548         // to ensure consistency when reading values written here
549         // unless the values are invalid
550         dest.writeInt(mRsrp);
551         dest.writeInt(mRsrq);
552         dest.writeInt(mRssnr);
553         dest.writeInt(mCqiTableIndex);
554         dest.writeInt(mCqi);
555         dest.writeInt(mTimingAdvance);
556         dest.writeInt(mLevel);
557     }
558 
559     /**
560      * Construct a SignalStrength object from the given parcel
561      * where the token is already been processed.
562      */
CellSignalStrengthLte(Parcel in)563     private CellSignalStrengthLte(Parcel in) {
564         mRssi = in.readInt();
565         mSignalStrength = mRssi;
566         mRsrp = in.readInt();
567         mRsrq = in.readInt();
568         mRssnr = in.readInt();
569         mCqiTableIndex = in.readInt();
570         mCqi = in.readInt();
571         mTimingAdvance = in.readInt();
572         mLevel = in.readInt();
573         if (DBG) log("CellSignalStrengthLte(Parcel): " + toString());
574     }
575 
576     /** Implement the Parcelable interface */
577     @Override
describeContents()578     public int describeContents() {
579         return 0;
580     }
581 
582     /** Implement the Parcelable interface */
583     @SuppressWarnings("hiding")
584     public static final @android.annotation.NonNull Parcelable.Creator<CellSignalStrengthLte> CREATOR =
585             new Parcelable.Creator<CellSignalStrengthLte>() {
586         @Override
587         public CellSignalStrengthLte createFromParcel(Parcel in) {
588             return new CellSignalStrengthLte(in);
589         }
590 
591         @Override
592         public CellSignalStrengthLte[] newArray(int size) {
593             return new CellSignalStrengthLte[size];
594         }
595     };
596 
597     /**
598      * log
599      */
log(String s)600     private static void log(String s) {
601         Rlog.w(LOG_TAG, s);
602     }
603 
604     /** @hide */
convertRssnrUnitFromTenDbToDB(int rssnr)605     public static int convertRssnrUnitFromTenDbToDB(int rssnr) {
606         return (int) Math.floor((float) rssnr / 10);
607     }
608 
609     /** @hide */
convertRssiAsuToDBm(int rssiAsu)610     public static int convertRssiAsuToDBm(int rssiAsu) {
611         if (rssiAsu == SIGNAL_STRENGTH_LTE_RSSI_ASU_UNKNOWN) {
612             return CellInfo.UNAVAILABLE;
613         }
614         if ((rssiAsu < SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MIN_VALUE
615                 || rssiAsu > SIGNAL_STRENGTH_LTE_RSSI_VALID_ASU_MAX_VALUE)) {
616             Rlog.e(LOG_TAG, "convertRssiAsuToDBm: invalid RSSI in ASU=" + rssiAsu);
617             return CellInfo.UNAVAILABLE;
618         }
619         return -113 + (2 * rssiAsu);
620     }
621 }
622