From 16e5d2a0f3e20b06157597a0f84fbfc172fb9e6c Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Fri, 21 Feb 2020 11:14:53 -0800 Subject: [PATCH] Added bands from HAL 1.5 Test: Manual Change-Id: Ib155ee5c2f660c8866a7be91e7f62a8c90e78d8e Fix: 149475773 --- .../android/telephony/CellIdentityLte.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index e4198d1c519c5..d672c77bed01d 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -25,6 +25,7 @@ import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; import android.util.ArraySet; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -54,6 +55,8 @@ public final class CellIdentityLte extends CellIdentity { private final int mEarfcn; // cell bandwidth, in kHz private final int mBandwidth; + // cell bands + private final List mBands; // a list of additional PLMN-IDs reported for this cell private final ArraySet mAdditionalPlmns; @@ -70,6 +73,7 @@ public final class CellIdentityLte extends CellIdentity { mPci = CellInfo.UNAVAILABLE; mTac = CellInfo.UNAVAILABLE; mEarfcn = CellInfo.UNAVAILABLE; + mBands = Collections.emptyList(); mBandwidth = CellInfo.UNAVAILABLE; mAdditionalPlmns = new ArraySet<>(); mCsgInfo = null; @@ -87,8 +91,9 @@ public final class CellIdentityLte extends CellIdentity { */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) public CellIdentityLte(int mcc, int mnc, int ci, int pci, int tac) { - this(ci, pci, tac, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, String.valueOf(mcc), - String.valueOf(mnc), null, null, new ArraySet<>(), null); + this(ci, pci, tac, CellInfo.UNAVAILABLE, Collections.emptyList(), CellInfo.UNAVAILABLE, + String.valueOf(mcc), String.valueOf(mnc), null, null, new ArraySet<>(), + null); } /** @@ -107,7 +112,7 @@ public final class CellIdentityLte extends CellIdentity { * * @hide */ - public CellIdentityLte(int ci, int pci, int tac, int earfcn, int bandwidth, + public CellIdentityLte(int ci, int pci, int tac, int earfcn, List bands, int bandwidth, @Nullable String mccStr, @Nullable String mncStr, @Nullable String alphal, @Nullable String alphas, @NonNull Collection additionalPlmns, @Nullable ClosedSubscriberGroupInfo csgInfo) { @@ -116,6 +121,7 @@ public final class CellIdentityLte extends CellIdentity { mPci = inRangeOrUnavailable(pci, 0, MAX_PCI); mTac = inRangeOrUnavailable(tac, 0, MAX_TAC); mEarfcn = inRangeOrUnavailable(earfcn, 0, MAX_EARFCN); + mBands = new ArrayList<>(bands); mBandwidth = inRangeOrUnavailable(bandwidth, 0, MAX_BANDWIDTH); mAdditionalPlmns = new ArraySet<>(additionalPlmns.size()); for (String plmn : additionalPlmns) { @@ -128,28 +134,28 @@ public final class CellIdentityLte extends CellIdentity { /** @hide */ public CellIdentityLte(@NonNull android.hardware.radio.V1_0.CellIdentityLte cid) { - this(cid.ci, cid.pci, cid.tac, cid.earfcn, + this(cid.ci, cid.pci, cid.tac, cid.earfcn, Collections.emptyList(), CellInfo.UNAVAILABLE, cid.mcc, cid.mnc, "", "", new ArraySet<>(), null); } /** @hide */ public CellIdentityLte(@NonNull android.hardware.radio.V1_2.CellIdentityLte cid) { - this(cid.base.ci, cid.base.pci, cid.base.tac, cid.base.earfcn, cid.bandwidth, - cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong, + this(cid.base.ci, cid.base.pci, cid.base.tac, cid.base.earfcn, Collections.emptyList(), + cid.bandwidth, cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort, new ArraySet<>(), null); } /** @hide */ public CellIdentityLte(@NonNull android.hardware.radio.V1_5.CellIdentityLte cid) { this(cid.base.base.ci, cid.base.base.pci, cid.base.base.tac, cid.base.base.earfcn, - cid.base.bandwidth, cid.base.base.mcc, cid.base.base.mnc, + cid.bands, cid.base.bandwidth, cid.base.base.mcc, cid.base.base.mnc, cid.base.operatorNames.alphaLong, cid.base.operatorNames.alphaShort, cid.additionalPlmns, cid.optionalCsgInfo.csgInfo() != null ? new ClosedSubscriberGroupInfo(cid.optionalCsgInfo.csgInfo()) : null); } private CellIdentityLte(@NonNull CellIdentityLte cid) { - this(cid.mCi, cid.mPci, cid.mTac, cid.mEarfcn, cid.mBandwidth, cid.mMccStr, + this(cid.mCi, cid.mPci, cid.mTac, cid.mEarfcn, cid.mBands, cid.mBandwidth, cid.mMccStr, cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort, cid.mAdditionalPlmns, cid.mCsgInfo); } @@ -157,7 +163,7 @@ public final class CellIdentityLte extends CellIdentity { @Override public @NonNull CellIdentityLte sanitizeLocationInfo() { return new CellIdentityLte(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, - CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, + CellInfo.UNAVAILABLE, mBands, CellInfo.UNAVAILABLE, mMccStr, mMncStr, mAlphaLong, mAlphaShort, mAdditionalPlmns, null); } @@ -226,8 +232,7 @@ public final class CellIdentityLte extends CellIdentity { */ @NonNull public List getBands() { - // Todo: Add actual support - return Collections.emptyList(); + return Collections.unmodifiableList(mBands); } /** @@ -343,6 +348,7 @@ public final class CellIdentityLte extends CellIdentity { .append(" mPci=").append(mPci) .append(" mTac=").append(mTac) .append(" mEarfcn=").append(mEarfcn) + .append(" mBands=").append(mBands) .append(" mBandwidth=").append(mBandwidth) .append(" mMcc=").append(mMccStr) .append(" mMnc=").append(mMncStr) @@ -362,6 +368,7 @@ public final class CellIdentityLte extends CellIdentity { dest.writeInt(mPci); dest.writeInt(mTac); dest.writeInt(mEarfcn); + dest.writeList(mBands); dest.writeInt(mBandwidth); dest.writeArraySet(mAdditionalPlmns); dest.writeParcelable(mCsgInfo, flags); @@ -374,6 +381,7 @@ public final class CellIdentityLte extends CellIdentity { mPci = in.readInt(); mTac = in.readInt(); mEarfcn = in.readInt(); + mBands = in.readArrayList(null); mBandwidth = in.readInt(); mAdditionalPlmns = (ArraySet) in.readArraySet(null); mCsgInfo = in.readParcelable(null);