Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3bb160af authored by Eric Schwarzenbach's avatar Eric Schwarzenbach Committed by android-build-merger
Browse files

Merge "Add Duplex mode to ServiceState."

am: 908bf936

Change-Id: Ied5fe88d7301ce3573be35c48101c25a6ccfea5c
parents 0cd805a3 908bf936
Loading
Loading
Loading
Loading
+167 −0
Original line number Original line Diff line number Diff line
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;
    }
}
+13 −0
Original line number Original line Diff line number Diff line
@@ -68,6 +68,9 @@ public abstract class CellIdentity implements Parcelable {
     */
     */
    public static final int TYPE_TDSCDMA        = 5;
    public static final int TYPE_TDSCDMA        = 5;


    /** @hide */
    public static final int INVALID_CHANNEL_NUMBER = -1;

    // Log tag
    // Log tag
    /** @hide */
    /** @hide */
    protected final String mTag;
    protected final String mTag;
@@ -124,6 +127,16 @@ public abstract class CellIdentity implements Parcelable {
     */
     */
    public @Type int getType() { return mType; }
    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.
     * Used by child classes for parceling.
     *
     *
+5 −0
Original line number Original line Diff line number Diff line
@@ -203,6 +203,11 @@ public final class CellIdentityGsm extends CellIdentity {
        return mAlphaShort;
        return mAlphaShort;
    }
    }


    /** @hide */
    @Override
    public int getChannelNumber() {
        return mArfcn;
    }


    /**
    /**
     * @deprecated Primary Scrambling Code is not applicable to GSM.
     * @deprecated Primary Scrambling Code is not applicable to GSM.
+6 −0
Original line number Original line Diff line number Diff line
@@ -213,6 +213,12 @@ public final class CellIdentityLte extends CellIdentity {
        return mAlphaShort;
        return mAlphaShort;
    }
    }


    /** @hide */
    @Override
    public int getChannelNumber() {
        return mEarfcn;
    }

    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(mMccStr, mMncStr, mCi, mPci, mTac, mAlphaLong, mAlphaShort);
        return Objects.hash(mMccStr, mMncStr, mCi, mPci, mTac, mAlphaLong, mAlphaShort);
+6 −0
Original line number Original line Diff line number Diff line
@@ -206,6 +206,12 @@ public final class CellIdentityWcdma extends CellIdentity {
        return mUarfcn;
        return mUarfcn;
    }
    }


    /** @hide */
    @Override
    public int getChannelNumber() {
        return mUarfcn;
    }

    @Override
    @Override
    public boolean equals(Object other) {
    public boolean equals(Object other) {
        if (this == other) {
        if (this == other) {
Loading