summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nathan Harold <nharold@google.com> 2018-12-06 10:55:13 -0800
committer Nathan Harold <nharold@google.com> 2018-12-26 09:45:31 -0800
commit958846fd7c5a6ad0a07cd294ad997bc1c18e8eec (patch)
tree7538ae557cb6e81e7435884a99ee67b1063a8082
parent7ce5baf9a9015dbe5f072e5bba64d89368b991ba (diff)
Add API to Retrieve Detailed SignalStrength Info
This commit adds an API to retrieve detailed CellSignalStrength from a SignalStrength instance, which permits granular attribution of signal strength details and avoids proliferating duplicate code up to the SignalStrength class (which ideally never needs to changed again except when adding a new technology or if we add CarrierAggregation support). Bug: 118166143 Test: wip Change-Id: I6bbd86ec460c3cff84f1a22348381b15c66c1065
-rwxr-xr-xapi/current.txt1
-rw-r--r--telephony/java/android/telephony/SignalStrength.java31
2 files changed, 32 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 65c988fb046e..1ccb77587321 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -42719,6 +42719,7 @@ package android.telephony {
method public int describeContents();
method public int getCdmaDbm();
method public int getCdmaEcio();
+ method public java.util.List<android.telephony.CellSignalStrength> getCellSignalStrengths();
method public int getEvdoDbm();
method public int getEvdoEcio();
method public int getEvdoSnr();
diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
index ef185c5eeaf1..72e6e00c6085 100644
--- a/telephony/java/android/telephony/SignalStrength.java
+++ b/telephony/java/android/telephony/SignalStrength.java
@@ -24,6 +24,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.PersistableBundle;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Objects;
/**
@@ -178,6 +180,35 @@ public class SignalStrength implements Parcelable {
return mLte;
}
+ /**
+ * Returns a List of CellSignalStrength Components of this SignalStrength Report.
+ *
+ * Use this API to access underlying
+ * {@link android.telephony#CellSignalStrength CellSignalStrength} objects that provide more
+ * granular information about the SignalStrength report. Only valid (non-empty)
+ * CellSignalStrengths will be returned. The order of any returned elements is not guaranteed,
+ * and the list may contain more than one instance of a CellSignalStrength type.
+ *
+ * @return a List of CellSignalStrength or an empty List if there are no valid measurements.
+ *
+ * @see android.telephony#CellSignalStrength
+ * @see android.telephony#CellSignalStrengthNr
+ * @see android.telephony#CellSignalStrengthLte
+ * @see android.telephony#CellSignalStrengthTdscdma
+ * @see android.telephony#CellSignalStrengthWcdma
+ * @see android.telephony#CellSignalStrengthCdma
+ * @see android.telephony#CellSignalStrengthGsm
+ */
+ public @NonNull List<CellSignalStrength> getCellSignalStrengths() {
+ List<CellSignalStrength> cssList = new ArrayList<>(2); // Usually have 2 or fewer elems
+ if (mLte.isValid()) cssList.add(mLte);
+ if (mCdma.isValid()) cssList.add(mCdma);
+ if (mTdscdma.isValid()) cssList.add(mTdscdma);
+ if (mWcdma.isValid()) cssList.add(mWcdma);
+ if (mGsm.isValid()) cssList.add(mGsm);
+ return cssList;
+ }
+
/** @hide */
public void updateLevel(PersistableBundle cc, ServiceState ss) {
mLteRsrpBoost = ss.getLteEarfcnRsrpBoost();