diff options
author | Eric Schwarzenbach <easchwar@google.com> | 2018-03-09 21:19:10 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-03-09 21:19:10 +0000 |
commit | 908bf936a555e38b2835dcc6ac957dbe7eb39571 (patch) | |
tree | 24e1f479d7b889c51128a5505b2c2350de63782d | |
parent | fdbc592178f1637bc64a40b1caa8e322639431ac (diff) | |
parent | a483ce3bfd2df3b0c88382d59e67bb2bfcd361d8 (diff) |
Merge "Add Duplex mode to ServiceState."
6 files changed, 205 insertions, 3 deletions
diff --git a/telephony/java/android/telephony/AccessNetworkUtils.java b/telephony/java/android/telephony/AccessNetworkUtils.java new file mode 100644 index 000000000000..5d2c225f28ec --- /dev/null +++ b/telephony/java/android/telephony/AccessNetworkUtils.java @@ -0,0 +1,167 @@ +package android.telephony; + +import static android.telephony.ServiceState.DUPLEX_MODE_FDD; +import static android.telephony.ServiceState.DUPLEX_MODE_TDD; +import static android.telephony.ServiceState.DUPLEX_MODE_UNKNOWN; + +import android.telephony.AccessNetworkConstants.EutranBand; +import android.telephony.ServiceState.DuplexMode; + + +/** + * Utilities to map between radio constants. + * + * @hide + */ +public class AccessNetworkUtils { + + // do not instantiate + private AccessNetworkUtils() {} + + public static final int INVALID_BAND = -1; + + /** + * Gets the duplex mode for the given EUTRAN operating band. + * + * <p>See 3GPP 36.101 sec 5.5-1 for calculation + * + * @param band The EUTRAN band number + * @return The duplex mode of the given EUTRAN band + */ + @DuplexMode + public static int getDuplexModeForEutranBand(int band) { + if (band == INVALID_BAND) { + return DUPLEX_MODE_UNKNOWN; + } + + if (band >= EutranBand.BAND_68) { + return DUPLEX_MODE_UNKNOWN; + } else if (band >= EutranBand.BAND_65) { + return DUPLEX_MODE_FDD; + } else if (band >= EutranBand.BAND_47) { + return DUPLEX_MODE_UNKNOWN; + } else if (band >= EutranBand.BAND_33) { + return DUPLEX_MODE_TDD; + } else if (band >= EutranBand.BAND_1) { + return DUPLEX_MODE_FDD; + } + + return DUPLEX_MODE_UNKNOWN; + } + + /** + * Gets the EUTRAN Operating band for a given downlink EARFCN. + * + * <p>See 3GPP 36.101 sec 5.7.3-1 for calculation. + * + * @param earfcn The downlink EARFCN + * @return Operating band number, or {@link #INVALID_BAND} if no corresponding band exists + */ + public static int getOperatingBandForEarfcn(int earfcn) { + if (earfcn > 67535) { + return INVALID_BAND; + } else if (earfcn >= 67366) { + return INVALID_BAND; // band 67 only for CarrierAgg + } else if (earfcn >= 66436) { + return EutranBand.BAND_66; + } else if (earfcn >= 65536) { + return EutranBand.BAND_65; + } else if (earfcn > 54339) { + return INVALID_BAND; + } else if (earfcn >= 46790 /* inferred from the end range of BAND_45 */) { + return EutranBand.BAND_46; + } else if (earfcn >= 46590) { + return EutranBand.BAND_45; + } else if (earfcn >= 45590) { + return EutranBand.BAND_44; + } else if (earfcn >= 43590) { + return EutranBand.BAND_43; + } else if (earfcn >= 41590) { + return EutranBand.BAND_42; + } else if (earfcn >= 39650) { + return EutranBand.BAND_41; + } else if (earfcn >= 38650) { + return EutranBand.BAND_40; + } else if (earfcn >= 38250) { + return EutranBand.BAND_39; + } else if (earfcn >= 37750) { + return EutranBand.BAND_38; + } else if (earfcn >= 37550) { + return EutranBand.BAND_37; + } else if (earfcn >= 36950) { + return EutranBand.BAND_36; + } else if (earfcn >= 36350) { + return EutranBand.BAND_35; + } else if (earfcn >= 36200) { + return EutranBand.BAND_34; + } else if (earfcn >= 36000) { + return EutranBand.BAND_33; + } else if (earfcn > 10359) { + return INVALID_BAND; + } else if (earfcn >= 9920) { + return INVALID_BAND; // band 32 only for CarrierAgg + } else if (earfcn >= 9870) { + return EutranBand.BAND_31; + } else if (earfcn >= 9770) { + return EutranBand.BAND_30; + } else if (earfcn >= 9660) { + return INVALID_BAND; // band 29 only for CarrierAgg + } else if (earfcn >= 9210) { + return EutranBand.BAND_28; + } else if (earfcn >= 9040) { + return EutranBand.BAND_27; + } else if (earfcn >= 8690) { + return EutranBand.BAND_26; + } else if (earfcn >= 8040) { + return EutranBand.BAND_25; + } else if (earfcn >= 7700) { + return EutranBand.BAND_24; + } else if (earfcn >= 7500) { + return EutranBand.BAND_23; + } else if (earfcn >= 6600) { + return EutranBand.BAND_22; + } else if (earfcn >= 6450) { + return EutranBand.BAND_21; + } else if (earfcn >= 6150) { + return EutranBand.BAND_20; + } else if (earfcn >= 6000) { + return EutranBand.BAND_19; + } else if (earfcn >= 5850) { + return EutranBand.BAND_18; + } else if (earfcn >= 5730) { + return EutranBand.BAND_17; + } else if (earfcn > 5379) { + return INVALID_BAND; + } else if (earfcn >= 5280) { + return EutranBand.BAND_14; + } else if (earfcn >= 5180) { + return EutranBand.BAND_13; + } else if (earfcn >= 5010) { + return EutranBand.BAND_12; + } else if (earfcn >= 4750) { + return EutranBand.BAND_11; + } else if (earfcn >= 4150) { + return EutranBand.BAND_10; + } else if (earfcn >= 3800) { + return EutranBand.BAND_9; + } else if (earfcn >= 3450) { + return EutranBand.BAND_8; + } else if (earfcn >= 2750) { + return EutranBand.BAND_7; + } else if (earfcn >= 2650) { + return EutranBand.BAND_6; + } else if (earfcn >= 2400) { + return EutranBand.BAND_5; + } else if (earfcn >= 1950) { + return EutranBand.BAND_4; + } else if (earfcn >= 1200) { + return EutranBand.BAND_3; + } else if (earfcn >= 600) { + return EutranBand.BAND_2; + } else if (earfcn >= 0) { + return EutranBand.BAND_1; + } + + return INVALID_BAND; + } +} diff --git a/telephony/java/android/telephony/CellIdentity.java b/telephony/java/android/telephony/CellIdentity.java index e092d52d91bc..08f8bb6494a0 100644 --- a/telephony/java/android/telephony/CellIdentity.java +++ b/telephony/java/android/telephony/CellIdentity.java @@ -68,6 +68,9 @@ public abstract class CellIdentity implements Parcelable { */ public static final int TYPE_TDSCDMA = 5; + /** @hide */ + public static final int INVALID_CHANNEL_NUMBER = -1; + // Log tag /** @hide */ protected final String mTag; @@ -125,6 +128,16 @@ public abstract class CellIdentity implements Parcelable { public @Type int getType() { return mType; } /** + * Returns the channel number of the cell identity. + * + * @hide + * @return The channel number, or {@link #INVALID_CHANNEL_NUMBER} if not implemented + */ + public int getChannelNumber() { + return INVALID_CHANNEL_NUMBER; + } + + /** * Used by child classes for parceling. * * @hide diff --git a/telephony/java/android/telephony/CellIdentityGsm.java b/telephony/java/android/telephony/CellIdentityGsm.java index d35eb60916f3..52944a8ac261 100644 --- a/telephony/java/android/telephony/CellIdentityGsm.java +++ b/telephony/java/android/telephony/CellIdentityGsm.java @@ -203,6 +203,11 @@ public final class CellIdentityGsm extends CellIdentity { return mAlphaShort; } + /** @hide */ + @Override + public int getChannelNumber() { + return mArfcn; + } /** * @deprecated Primary Scrambling Code is not applicable to GSM. diff --git a/telephony/java/android/telephony/CellIdentityLte.java b/telephony/java/android/telephony/CellIdentityLte.java index 2b8eb5f3cca6..37fb07521b0e 100644 --- a/telephony/java/android/telephony/CellIdentityLte.java +++ b/telephony/java/android/telephony/CellIdentityLte.java @@ -213,6 +213,12 @@ public final class CellIdentityLte extends CellIdentity { return mAlphaShort; } + /** @hide */ + @Override + public int getChannelNumber() { + return mEarfcn; + } + @Override public int hashCode() { return Objects.hash(mMccStr, mMncStr, mCi, mPci, mTac, mAlphaLong, mAlphaShort); diff --git a/telephony/java/android/telephony/CellIdentityWcdma.java b/telephony/java/android/telephony/CellIdentityWcdma.java index a5fd7dd97941..affa0c15862d 100644 --- a/telephony/java/android/telephony/CellIdentityWcdma.java +++ b/telephony/java/android/telephony/CellIdentityWcdma.java @@ -206,6 +206,12 @@ public final class CellIdentityWcdma extends CellIdentity { return mUarfcn; } + /** @hide */ + @Override + public int getChannelNumber() { + return mUarfcn; + } + @Override public boolean equals(Object other) { if (this == other) { diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index b6be3c5b6a03..d2e7ae58073e 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -470,9 +470,13 @@ public class ServiceState implements Parcelable { */ @DuplexMode public int getDuplexMode() { - // TODO(b/72117602) determine duplex mode from channel number, using 3GPP 36.101 sections - // 5.7.3-1 and 5.5-1 - return DUPLEX_MODE_UNKNOWN; + // only support LTE duplex mode + if (!isLte(mRilDataRadioTechnology)) { + return DUPLEX_MODE_UNKNOWN; + } + + int band = AccessNetworkUtils.getOperatingBandForEarfcn(mChannelNumber); + return AccessNetworkUtils.getDuplexModeForEutranBand(band); } /** @@ -890,6 +894,7 @@ public class ServiceState implements Parcelable { .append(", mDataRegState=").append(mDataRegState) .append("(" + rilServiceStateToString(mDataRegState) + ")") .append(", mChannelNumber=").append(mChannelNumber) + .append(", duplexMode()=").append(getDuplexMode()) .append(", mCellBandwidths=").append(Arrays.toString(mCellBandwidths)) .append(", mVoiceRoamingType=").append(getRoamingLogString(mVoiceRoamingType)) .append(", mDataRoamingType=").append(getRoamingLogString(mDataRoamingType)) |