diff options
| author | 2018-11-12 16:28:57 +0000 | |
|---|---|---|
| committer | 2018-11-12 16:28:57 +0000 | |
| commit | 4a7a3934b606e5484524e190f67fe09e938613a2 (patch) | |
| tree | 1bb0f25b33a6c720cbee356b8952aa6b575acbee | |
| parent | 5f9193bdad53237a380fbf53a23aca7f3d5c8924 (diff) | |
| parent | f922b8e6ee874b4d78c5a81a0c6f3c7f75312011 (diff) | |
Merge "Add 5G NR cellInfo"
| -rwxr-xr-x | api/current.txt | 32 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellIdentity.java | 1 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellIdentityNr.java | 167 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellInfo.java | 28 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellInfoNr.java | 100 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellSignalStrengthLte.java | 1 | ||||
| -rw-r--r-- | telephony/java/android/telephony/CellSignalStrengthNr.java | 257 |
7 files changed, 578 insertions, 8 deletions
diff --git a/api/current.txt b/api/current.txt index 4654c0100d7f..baa59dc16fa9 100755 --- a/api/current.txt +++ b/api/current.txt @@ -42188,6 +42188,16 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityLte> CREATOR; } + public final class CellIdentityNr extends android.telephony.CellIdentity { + method public int getChannelNumber(); + method public java.lang.String getMccString(); + method public java.lang.String getMncString(); + method public int getPci(); + method public int getTac(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.telephony.CellIdentityNr> CREATOR; + } + public final class CellIdentityTdscdma extends android.telephony.CellIdentity { method public int getCid(); method public int getCpid(); @@ -42247,6 +42257,13 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellInfoLte> CREATOR; } + public final class CellInfoNr extends android.telephony.CellInfo { + method public android.telephony.CellIdentity getCellIdentity(); + method public android.telephony.CellSignalStrength getCellSignalStrength(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.telephony.CellInfoNr> CREATOR; + } + public final class CellInfoWcdma extends android.telephony.CellInfo implements android.os.Parcelable { method public android.telephony.CellIdentityWcdma getCellIdentity(); method public android.telephony.CellSignalStrengthWcdma getCellSignalStrength(); @@ -42314,6 +42331,21 @@ package android.telephony { field public static final android.os.Parcelable.Creator<android.telephony.CellSignalStrengthLte> CREATOR; } + public final class CellSignalStrengthNr extends android.telephony.CellSignalStrength implements android.os.Parcelable { + method public int describeContents(); + method public int getAsuLevel(); + method public int getCsiRsrp(); + method public int getCsiRsrq(); + method public int getCsiSinr(); + method public int getDbm(); + method public int getLevel(); + method public int getSsRsrp(); + method public int getSsRsrq(); + method public int getSsSinr(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator<android.telephony.CellSignalStrengthNr> CREATOR; + } + public final class CellSignalStrengthWcdma extends android.telephony.CellSignalStrength implements android.os.Parcelable { method public int describeContents(); method public int getAsuLevel(); diff --git a/telephony/java/android/telephony/CellIdentity.java b/telephony/java/android/telephony/CellIdentity.java index 76a002681710..6958d22bf5cc 100644 --- a/telephony/java/android/telephony/CellIdentity.java +++ b/telephony/java/android/telephony/CellIdentity.java @@ -190,6 +190,7 @@ public abstract class CellIdentity implements Parcelable { case CellInfo.TYPE_LTE: return CellIdentityLte.createFromParcelBody(in); case CellInfo.TYPE_TDSCDMA: return CellIdentityTdscdma.createFromParcelBody(in); + case CellInfo.TYPE_NR: return CellIdentityNr.createFromParcelBody(in); default: throw new IllegalArgumentException("Bad Cell identity Parcel"); } } diff --git a/telephony/java/android/telephony/CellIdentityNr.java b/telephony/java/android/telephony/CellIdentityNr.java new file mode 100644 index 000000000000..6b1b84cd3458 --- /dev/null +++ b/telephony/java/android/telephony/CellIdentityNr.java @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.Parcel; +import android.telephony.gsm.GsmCellLocation; + +import java.util.Objects; + +/** + * Information to represent a unique 5G NR cell. + */ +public final class CellIdentityNr extends CellIdentity { + private static final String TAG = "CellIdentityNr"; + + private final int mNrArfcn; + private final int mPci; + private final int mTac; + + /** + * + * @param pci Physical Cell Id in range [0, 1007]. + * @param tac 16-bit Tracking Area Code. + * @param nrArfcn NR Absolute Radio Frequency Channel Number, in range [0, 3279165]. + * @param mccStr 3-digit Mobile Country Code in string format. + * @param mncStr 2 or 3-digit Mobile Network Code in string format. + * @param alphal long alpha Operator Name String or Enhanced Operator Name String. + * @param alphas short alpha Operator Name String or Enhanced Operator Name String. + * + * @hide + */ + public CellIdentityNr(int pci, int tac, int nrArfcn, String mccStr, String mncStr, + String alphal, String alphas) { + super(TAG, CellInfo.TYPE_NR, mccStr, mncStr, alphal, alphas); + mPci = pci; + mTac = tac; + mNrArfcn = nrArfcn; + } + + /** + * @return a CellLocation object for this CellIdentity. + * @hide + */ + @Override + public CellLocation asCellLocation() { + return new GsmCellLocation(); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), mPci, mTac, mNrArfcn); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof CellIdentityNr)) { + return false; + } + + CellIdentityNr o = (CellIdentityNr) other; + return super.equals(o) && mPci == o.mPci && mTac == o.mTac && mNrArfcn == o.mNrArfcn; + } + + /** + * Get the Absolute Radio Frequency Channel Number. + * @return Integer value in range [0, 3279165] or {@link CellInfo#UNAVAILABLE} if unknown. + */ + @Override + public int getChannelNumber() { + return mNrArfcn; + } + + /** + * Get the physical cell id. + * @return Integer value in range [0, 1007] or {@link CellInfo#UNAVAILABLE} if unknown. + */ + public int getPci() { + return mPci; + } + + /** + * Get the tracking area code. + * @return a 16 bit integer or {@link CellInfo#UNAVAILABLE} if unknown. + */ + public int getTac() { + return mTac; + } + + /** + * @return Mobile Country Code in string format, or {@code null} if unknown. + */ + public String getMccString() { + return mMccStr; + } + + /** + * @return Mobile Network Code in string fomrat, or {@code null} if unknown. + */ + public String getMncString() { + return mMncStr; + } + + @Override + public String toString() { + return new StringBuilder(TAG + ":{") + .append(" mPci = ").append(mPci) + .append(" mTac = ").append(mTac) + .append(" mNrArfcn = ").append(mNrArfcn) + .append(" mMcc = ").append(mMccStr) + .append(" mMnc = ").append(mMncStr) + .append(" mAlphaLong = ").append(mAlphaLong) + .append(" mAlphaShort = ").append(mAlphaShort) + .append(" }") + .toString(); + } + + @Override + public void writeToParcel(Parcel dest, int type) { + super.writeToParcel(dest, CellInfo.TYPE_NR); + dest.writeInt(mPci); + dest.writeInt(mTac); + dest.writeInt(mNrArfcn); + } + + /** Construct from Parcel, type has already been processed */ + private CellIdentityNr(Parcel in) { + super(TAG, CellInfo.TYPE_NR, in); + mPci = in.readInt(); + mTac = in.readInt(); + mNrArfcn = in.readInt(); + } + + /** Implement the Parcelable interface */ + public static final Creator<CellIdentityNr> CREATOR = + new Creator<CellIdentityNr>() { + @Override + public CellIdentityNr createFromParcel(Parcel in) { + // Skip the type info. + in.readInt(); + return createFromParcelBody(in); + } + + @Override + public CellIdentityNr[] newArray(int size) { + return new CellIdentityNr[size]; + } + }; + + /** @hide */ + protected static CellIdentityNr createFromParcelBody(Parcel in) { + return new CellIdentityNr(in); + } +} diff --git a/telephony/java/android/telephony/CellInfo.java b/telephony/java/android/telephony/CellInfo.java index 1c63e8205454..d0b268766314 100644 --- a/telephony/java/android/telephony/CellInfo.java +++ b/telephony/java/android/telephony/CellInfo.java @@ -42,38 +42,51 @@ public abstract class CellInfo implements Parcelable { * @hide */ @Retention(RetentionPolicy.SOURCE) - @IntDef(prefix = "TYPE_", value = {TYPE_GSM, TYPE_CDMA, TYPE_LTE, TYPE_WCDMA, TYPE_TDSCDMA}) + @IntDef(prefix = "TYPE_", + value = {TYPE_GSM, TYPE_CDMA, TYPE_LTE, TYPE_WCDMA, TYPE_TDSCDMA, TYPE_NR}) public @interface Type {} + /** * Unknown cell identity type * @hide */ - public static final int TYPE_UNKNOWN = 0; + public static final int TYPE_UNKNOWN = 0; + /** * GSM cell identity type * @hide */ - public static final int TYPE_GSM = 1; + public static final int TYPE_GSM = 1; + /** * CDMA cell identity type * @hide */ - public static final int TYPE_CDMA = 2; + public static final int TYPE_CDMA = 2; + /** * LTE cell identity type * @hide */ - public static final int TYPE_LTE = 3; + public static final int TYPE_LTE = 3; + /** * WCDMA cell identity type * @hide */ - public static final int TYPE_WCDMA = 4; + public static final int TYPE_WCDMA = 4; + /** * TD-SCDMA cell identity type * @hide */ - public static final int TYPE_TDSCDMA = 5; + public static final int TYPE_TDSCDMA = 5; + + /** + * 5G cell identity type + * @hide + */ + public static final int TYPE_NR = 6; // Type to distinguish where time stamp gets recorded. @@ -277,6 +290,7 @@ public abstract class CellInfo implements Parcelable { case TYPE_LTE: return CellInfoLte.createFromParcelBody(in); case TYPE_WCDMA: return CellInfoWcdma.createFromParcelBody(in); case TYPE_TDSCDMA: return CellInfoTdscdma.createFromParcelBody(in); + case TYPE_NR: return CellInfoNr.createFromParcelBody(in); default: throw new RuntimeException("Bad CellInfo Parcel"); } } diff --git a/telephony/java/android/telephony/CellInfoNr.java b/telephony/java/android/telephony/CellInfoNr.java new file mode 100644 index 000000000000..11857a60783d --- /dev/null +++ b/telephony/java/android/telephony/CellInfoNr.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.Parcel; + +import java.util.Objects; + +/** + * A {@link CellInfo} representing an 5G NR cell that provides identity and measurement info. + */ +public final class CellInfoNr extends CellInfo { + private static final String TAG = "CellInfoNr"; + + private final CellIdentityNr mCellIdentity; + private final CellSignalStrengthNr mCellSignalStrength; + + private CellInfoNr(Parcel in) { + super(in); + mCellIdentity = CellIdentityNr.CREATOR.createFromParcel(in); + mCellSignalStrength = CellSignalStrengthNr.CREATOR.createFromParcel(in); + } + + @Override + public CellIdentity getCellIdentity() { + return mCellIdentity; + } + + @Override + public CellSignalStrength getCellSignalStrength() { + return mCellSignalStrength; + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), mCellIdentity, mCellSignalStrength); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof CellInfoNr)) { + return false; + } + + CellInfoNr o = (CellInfoNr) other; + return super.equals(o) && mCellIdentity.equals(o.mCellIdentity) + && mCellSignalStrength.equals(o.mCellSignalStrength); + } + + @Override + public String toString() { + return new StringBuilder() + .append(TAG + ":{") + .append(" " + super.toString()) + .append(" " + mCellIdentity) + .append(" " + mCellSignalStrength) + .append(" }") + .toString(); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + super.writeToParcel(dest, flags, TYPE_NR); + mCellIdentity.writeToParcel(dest, flags); + mCellSignalStrength.writeToParcel(dest, flags); + } + + public static final Creator<CellInfoNr> CREATOR = new Creator<CellInfoNr>() { + @Override + public CellInfoNr createFromParcel(Parcel in) { + // Skip the type info. + in.readInt(); + return new CellInfoNr(in); + } + + @Override + public CellInfoNr[] newArray(int size) { + return new CellInfoNr[size]; + } + }; + + /** @hide */ + protected static CellInfoNr createFromParcelBody(Parcel in) { + return new CellInfoNr(in); + } +} diff --git a/telephony/java/android/telephony/CellSignalStrengthLte.java b/telephony/java/android/telephony/CellSignalStrengthLte.java index 280a8d2a0020..d07539431348 100644 --- a/telephony/java/android/telephony/CellSignalStrengthLte.java +++ b/telephony/java/android/telephony/CellSignalStrengthLte.java @@ -19,7 +19,6 @@ package android.telephony; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; -import android.telephony.Rlog; import java.util.Objects; diff --git a/telephony/java/android/telephony/CellSignalStrengthNr.java b/telephony/java/android/telephony/CellSignalStrengthNr.java new file mode 100644 index 000000000000..807924222a26 --- /dev/null +++ b/telephony/java/android/telephony/CellSignalStrengthNr.java @@ -0,0 +1,257 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Objects; + +/** + * 5G NR signal strength related information. + */ +public final class CellSignalStrengthNr extends CellSignalStrength implements Parcelable { + /** + * The value is used to indicate that the asu level is unknown. + * Reference: 3GPP TS 27.007 section 8.69. + * @hide + */ + public static final int UNKNOWN_ASU_LEVEL = 99; + + private static final String TAG = "CellSignalStrengthNr"; + + /** + * These threshold values are copied from LTE. + * TODO: make it configurable via CarrierConfig. + */ + private static final int SIGNAL_GREAT_THRESHOLD = -95; + private static final int SIGNAL_GOOD_THRESHOLD = -105; + private static final int SIGNAL_MODERATE_THRESHOLD = -115; + + private int mCsiRsrp; + private int mCsiRsrq; + private int mCsiSinr; + private int mSsRsrp; + private int mSsRsrq; + private int mSsSinr; + + /** + * @param csiRsrp CSI reference signal received power. + * @param csiRsrq CSI reference signal received quality. + * @param csiSinr CSI signal-to-noise and interference ratio. + * @param ssRsrp SS reference signal received power. + * @param ssRsrq SS reference signal received quality. + * @param ssSinr SS signal-to-noise and interference ratio. + * @hide + */ + public CellSignalStrengthNr( + int csiRsrp, int csiRsrq, int csiSinr, int ssRsrp, int ssRsrq, int ssSinr) { + mCsiRsrp = csiRsrp; + mCsiRsrq = csiRsrq; + mCsiSinr = csiSinr; + mSsRsrp = ssRsrp; + mSsRsrq = ssRsrq; + mSsSinr = ssSinr; + } + + /** + * Reference: 3GPP TS 38.215. + * Range: -140 dBm to -44 dBm. + * @return SS reference signal received power, {@link CellInfo#UNAVAILABLE} means unreported + * value. + */ + public int getSsRsrp() { + return mSsRsrp; + } + + /** + * Reference: 3GPP TS 38.215. + * Range: -20 dB to -3 dB. + * @return SS reference signal received quality, {@link CellInfo#UNAVAILABLE} means unreported + * value. + */ + public int getSsRsrq() { + return mSsRsrq; + } + + /** + * Reference: 3GPP TS 38.215 Sec 5.1.*, 3GPP TS 38.133 10.1.16.1 + * Range: -23 dB to 40 dB + * @return SS signal-to-noise and interference ratio, {@link CellInfo#UNAVAILABLE} means + * unreported value. + */ + public int getSsSinr() { + return mSsSinr; + } + + /** + * Reference: 3GPP TS 38.215. + * Range: -140 dBm to -44 dBm. + * @return CSI reference signal received power, {@link CellInfo#UNAVAILABLE} means unreported + * value. + */ + public int getCsiRsrp() { + return mCsiRsrp; + } + + /** + * Reference: 3GPP TS 38.215. + * Range: -20 dB to -3 dB. + * @return CSI reference signal received quality, {@link CellInfo#UNAVAILABLE} means unreported + * value. + */ + public int getCsiRsrq() { + return mCsiRsrq; + } + + /** + * Reference: 3GPP TS 38.215 Sec 5.1.*, 3GPP TS 38.133 10.1.16.1 + * Range: -23 dB to 23 dB + * @return CSI signal-to-noise and interference ratio, {@link CellInfo#UNAVAILABLE} means + * unreported value. + */ + public int getCsiSinr() { + return mCsiSinr; + } + + @Override + public int describeContents() { + return 0; + } + + /** @hide */ + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(mCsiRsrp); + dest.writeInt(mCsiRsrq); + dest.writeInt(mCsiSinr); + dest.writeInt(mSsRsrp); + dest.writeInt(mSsRsrq); + dest.writeInt(mSsSinr); + } + + private CellSignalStrengthNr(Parcel in) { + mCsiRsrp = in.readInt(); + mCsiRsrq = in.readInt(); + mCsiSinr = in.readInt(); + mSsRsrp = in.readInt(); + mSsRsrq = in.readInt(); + mSsSinr = in.readInt(); + } + + /** @hide */ + @Override + public void setDefaultValues() { + mCsiRsrp = CellInfo.UNAVAILABLE; + mCsiRsrq = CellInfo.UNAVAILABLE; + mCsiSinr = CellInfo.UNAVAILABLE; + mSsRsrp = CellInfo.UNAVAILABLE; + mSsRsrq = CellInfo.UNAVAILABLE; + mSsSinr = CellInfo.UNAVAILABLE; + } + + @Override + public int getLevel() { + if (mCsiRsrp == CellInfo.UNAVAILABLE) { + return SIGNAL_STRENGTH_NONE_OR_UNKNOWN; + } else if (mCsiRsrp >= SIGNAL_GREAT_THRESHOLD) { + return SIGNAL_STRENGTH_GREAT; + } else if (mCsiRsrp >= SIGNAL_GOOD_THRESHOLD) { + return SIGNAL_STRENGTH_GOOD; + } else if (mCsiRsrp >= SIGNAL_MODERATE_THRESHOLD) { + return SIGNAL_STRENGTH_MODERATE; + } else { + return SIGNAL_STRENGTH_POOR; + } + } + + /** + * Calculates the NR signal as an asu value between 0..97, 99 is unknown. + * Asu is calculated based on 3GPP RSRP, refer to 3GPP TS 27.007 section 8.69. + * @return an integer represent the asu level of the signal strength. + */ + @Override + public int getAsuLevel() { + int asuLevel; + int nrDbm = getDbm(); + if (nrDbm == CellInfo.UNAVAILABLE) { + asuLevel = UNKNOWN_ASU_LEVEL; + } else if (nrDbm <= -140) { + asuLevel = 0; + } else if (nrDbm >= -43) { + asuLevel = 97; + } else { + asuLevel = nrDbm + 140; + } + return asuLevel; + } + + @Override + public int getDbm() { + return mCsiRsrp; + } + + /** @hide */ + @Override + public CellSignalStrength copy() { + return new CellSignalStrengthNr( + mCsiRsrp, mCsiRsrq, mCsiSinr, mSsRsrp, mSsRsrq, mSsSinr); + } + + @Override + public int hashCode() { + return Objects.hash(mCsiRsrp, mCsiRsrq, mCsiSinr, mSsRsrp, mSsRsrq, mSsSinr); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof CellSignalStrengthNr) { + CellSignalStrengthNr o = (CellSignalStrengthNr) obj; + return mCsiRsrp == o.mCsiRsrp && mCsiRsrq == o.mCsiRsrq && mCsiSinr == o.mCsiSinr + && mSsRsrp == o.mSsRsrp && mSsRsrq == o.mSsRsrq && mSsSinr == o.mSsSinr; + } + return false; + } + + @Override + public String toString() { + return new StringBuilder() + .append(TAG + ":{") + .append(" csiRsrp = " + mCsiRsrp) + .append(" csiRsrq = " + mCsiRsrq) + .append(" csiSinr = " + mCsiSinr) + .append(" ssRsrp = " + mSsRsrp) + .append(" ssRsrq = " + mSsRsrq) + .append(" ssSinr = " + mSsSinr) + .append(" }") + .toString(); + } + + /** Implement the Parcelable interface */ + public static final Parcelable.Creator<CellSignalStrengthNr> CREATOR = + new Parcelable.Creator<CellSignalStrengthNr>() { + @Override + public CellSignalStrengthNr createFromParcel(Parcel in) { + return new CellSignalStrengthNr(in); + } + + @Override + public CellSignalStrengthNr[] newArray(int size) { + return new CellSignalStrengthNr[size]; + } + }; +} |