Implement physicalChannelConfig framework/base

Bug: 111453000
Test: atest FrameworksTelephonyTests
Merged-In: I390958aeed7182242d5623c10b6fd552ba35005a
Change-Id: I390958aeed7182242d5623c10b6fd552ba35005a
This commit is contained in:
Pengquan Meng
2018-11-16 16:02:39 -08:00
parent c96a716a54
commit d24193dcf5

View File

@@ -16,11 +16,15 @@
package android.telephony;
import android.annotation.IntDef;
import android.os.Parcel;
import android.os.Parcelable;
import android.annotation.IntDef;
import android.telephony.TelephonyManager.NetworkType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.Objects;
/**
* @hide
@@ -50,6 +54,7 @@ public final class PhysicalChannelConfig implements Parcelable {
*
* <p>One of {@link #CONNECTION_PRIMARY_SERVING}, {@link #CONNECTION_SECONDARY_SERVING}.
*/
@ConnectionStatus
private int mCellConnectionStatus;
/**
@@ -57,15 +62,33 @@ public final class PhysicalChannelConfig implements Parcelable {
*/
private int mCellBandwidthDownlinkKhz;
public PhysicalChannelConfig(int status, int bandwidth) {
mCellConnectionStatus = status;
mCellBandwidthDownlinkKhz = bandwidth;
}
/**
* The radio technology for this physical channel.
*/
@NetworkType
private int mRat;
public PhysicalChannelConfig(Parcel in) {
mCellConnectionStatus = in.readInt();
mCellBandwidthDownlinkKhz = in.readInt();
}
/**
* The rough frequency range for this physical channel.
*/
@ServiceState.FrequencyRange
private int mFrequencyRange;
/**
* The absolute radio frequency channel number, {@link Integer#MAX_VALUE} if unknown.
*/
private int mChannelNumber;
/**
* A list of data calls mapped to this physical channel. An empty list means the physical
* channel has no data call mapped to it.
*/
private int[] mContextIds;
/**
* The physical cell identifier for this cell - PCI, PSC, {@link Integer#MAX_VALUE} if known.
*/
private int mPhysicalCellId;
@Override
public int describeContents() {
@@ -76,6 +99,11 @@ public final class PhysicalChannelConfig implements Parcelable {
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mCellConnectionStatus);
dest.writeInt(mCellBandwidthDownlinkKhz);
dest.writeInt(mRat);
dest.writeInt(mChannelNumber);
dest.writeInt(mFrequencyRange);
dest.writeIntArray(mContextIds);
dest.writeInt(mPhysicalCellId);
}
/**
@@ -85,6 +113,60 @@ public final class PhysicalChannelConfig implements Parcelable {
return mCellBandwidthDownlinkKhz;
}
/**
* Get the list of data call ids mapped to this physical channel. This list is sorted into
* ascending numerical order. Each id in this list must match the id in
* {@link com.android.internal.telephony.dataconnection.DataConnection}. An empty list means the
* physical channel has no data call mapped to it.
*
* @return an integer list indicates the data call ids.
*/
public int[] getContextIds() {
return mContextIds;
}
/**
* @return the rough frequency range for this physical channel.
* @see {@link ServiceState#FREQUENCY_RANGE_LOW}
* @see {@link ServiceState#FREQUENCY_RANGE_MID}
* @see {@link ServiceState#FREQUENCY_RANGE_HIGH}
* @see {@link ServiceState#FREQUENCY_RANGE_MMWAVE}
*/
@ServiceState.FrequencyRange
public int getFrequencyRange() {
return mFrequencyRange;
}
/**
* @return the absolute radio frequency channel number for this physical channel,
* {@link Integer#MAX_VALUE} if unknown.
*/
public int getChannelNumber() {
return mChannelNumber;
}
/**
* In UTRAN, this value is primary scrambling code. The range is [0, 511].
* Reference: 3GPP TS 25.213 section 5.2.2.
*
* In EUTRAN, this value is physical layer cell identity. The range is [0, 503].
* Reference: 3GPP TS 36.211 section 6.11.
*
* In 5G RAN, this value is physical layer cell identity. The range is [0, 1008].
* Reference: 3GPP TS 38.211 section 7.4.2.1.
*
* @return the physical cell identifier for this cell, {@link Integer#MAX_VALUE} if unknown.
*/
public int getPhysicalCellId() {
return mPhysicalCellId;
}
/**The radio technology for this physical channel. */
@NetworkType
public int getRat() {
return mRat;
}
/**
* Gets the connection status of the cell.
*
@@ -125,12 +207,19 @@ public final class PhysicalChannelConfig implements Parcelable {
PhysicalChannelConfig config = (PhysicalChannelConfig) o;
return mCellConnectionStatus == config.mCellConnectionStatus
&& mCellBandwidthDownlinkKhz == config.mCellBandwidthDownlinkKhz;
&& mCellBandwidthDownlinkKhz == config.mCellBandwidthDownlinkKhz
&& mRat == config.mRat
&& mFrequencyRange == config.mFrequencyRange
&& mChannelNumber == config.mChannelNumber
&& mPhysicalCellId == config.mPhysicalCellId
&& Arrays.equals(mContextIds, config.mContextIds);
}
@Override
public int hashCode() {
return (mCellBandwidthDownlinkKhz * 29) + (mCellConnectionStatus * 31);
return Objects.hash(
mCellConnectionStatus, mCellBandwidthDownlinkKhz, mRat, mFrequencyRange,
mChannelNumber, mPhysicalCellId, mContextIds);
}
public static final Parcelable.Creator<PhysicalChannelConfig> CREATOR =
@@ -147,11 +236,111 @@ public final class PhysicalChannelConfig implements Parcelable {
@Override
public String toString() {
return new StringBuilder()
.append("{mConnectionStatus=")
.append(getConnectionStatusString())
.append(",mCellBandwidthDownlinkKhz=")
.append(mCellBandwidthDownlinkKhz)
.append("}")
.toString();
.append("{mConnectionStatus=")
.append(getConnectionStatusString())
.append(",mCellBandwidthDownlinkKhz=")
.append(mCellBandwidthDownlinkKhz)
.append(",mRat=")
.append(mRat)
.append(",mFrequencyRange=")
.append(mFrequencyRange)
.append(",mChannelNumber=")
.append(mChannelNumber)
.append(",mContextIds=")
.append(mContextIds.toString())
.append(",mPhysicalCellId=")
.append(mPhysicalCellId)
.append("}")
.toString();
}
private PhysicalChannelConfig(Parcel in) {
mCellConnectionStatus = in.readInt();
mCellBandwidthDownlinkKhz = in.readInt();
mRat = in.readInt();
mChannelNumber = in.readInt();
mFrequencyRange = in.readInt();
mContextIds = in.createIntArray();
mPhysicalCellId = in.readInt();
}
private PhysicalChannelConfig(Builder builder) {
mCellConnectionStatus = builder.mCellConnectionStatus;
mCellBandwidthDownlinkKhz = builder.mCellBandwidthDownlinkKhz;
mRat = builder.mRat;
mChannelNumber = builder.mChannelNumber;
mFrequencyRange = builder.mFrequencyRange;
mContextIds = builder.mContextIds;
mPhysicalCellId = builder.mPhysicalCellId;
}
/** The builder of {@code PhysicalChannelConfig}. */
public static final class Builder {
private int mRat;
private int mFrequencyRange;
private int mChannelNumber;
private int mCellBandwidthDownlinkKhz;
private int mCellConnectionStatus;
private int[] mContextIds;
private int mPhysicalCellId;
/** @hide */
public Builder() {
mRat = ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN;
mFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN;
mChannelNumber = Integer.MAX_VALUE;
mCellBandwidthDownlinkKhz = 0;
mCellConnectionStatus = CONNECTION_UNKNOWN;
mContextIds = new int[0];
mPhysicalCellId = Integer.MAX_VALUE;
}
/** @hide */
public PhysicalChannelConfig build() {
return new PhysicalChannelConfig(this);
}
/** @hide */
public Builder setRat(int rat) {
this.mRat = rat;
return this;
}
/** @hide */
public Builder setFrequencyRange(int frequencyRange) {
this.mFrequencyRange = frequencyRange;
return this;
}
/** @hide */
public Builder setChannelNumber(int channelNumber) {
this.mChannelNumber = channelNumber;
return this;
}
/** @hide */
public Builder setCellBandwidthDownlinkKhz(int cellBandwidthDownlinkKhz) {
this.mCellBandwidthDownlinkKhz = cellBandwidthDownlinkKhz;
return this;
}
/** @hide */
public Builder setCellConnectionStatus(int connectionStatus) {
this.mCellConnectionStatus = connectionStatus;
return this;
}
/** @hide */
public Builder setContextIds(int[] contextIds) {
if (contextIds != null) Arrays.sort(contextIds);
this.mContextIds = contextIds;
return this;
}
/** @hide */
public Builder setPhysicalCellId(int physicalCellId) {
this.mPhysicalCellId = physicalCellId;
return this;
}
}
}