Merge changes from topics "nr_band", "nw_sel"

* changes:
  Manual network selection by RAN type
  Added NR band support
This commit is contained in:
Sarah Chin
2020-01-22 20:03:33 +00:00
committed by Android (Google) Code Review
7 changed files with 273 additions and 25 deletions

View File

@@ -46246,6 +46246,7 @@ package android.telephony {
public final class CellIdentityNr extends android.telephony.CellIdentity {
method @NonNull public java.util.List<java.lang.String> getAdditionalPlmns();
method public int getBand();
method @Nullable public String getMccString();
method @Nullable public String getMncString();
method public long getNci();

View File

@@ -10736,6 +10736,13 @@ package android.telephony {
field public static final int TRANSPORT_TYPE_INVALID = -1; // 0xffffffff
}
public static final class AccessNetworkConstants.NgranBands {
method public static int getFrequencyRangeGroup(int);
field public static final int FREQUENCY_RANGE_GROUP_1 = 1; // 0x1
field public static final int FREQUENCY_RANGE_GROUP_2 = 2; // 0x2
field public static final int FREQUENCY_RANGE_GROUP_UNKNOWN = 0; // 0x0
}
public final class BarringInfo implements android.os.Parcelable {
ctor public BarringInfo();
method @NonNull public android.telephony.BarringInfo createLocationInfoSanitizedCopy();
@@ -11981,6 +11988,7 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataRoamingEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setIccLockEnabled(boolean, @NonNull String);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setMultiSimCarrierRestriction(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setNetworkSelectionModeManual(@NonNull String, int, boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setOpportunisticNetworkState(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPolicyDataEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setPreferredNetworkTypeBitmask(long);

View File

@@ -3195,6 +3195,13 @@ package android.telephony {
field public static final int TRANSPORT_TYPE_INVALID = -1; // 0xffffffff
}
public static final class AccessNetworkConstants.NgranBands {
method public static int getFrequencyRangeGroup(int);
field public static final int FREQUENCY_RANGE_GROUP_1 = 1; // 0x1
field public static final int FREQUENCY_RANGE_GROUP_2 = 2; // 0x2
field public static final int FREQUENCY_RANGE_GROUP_UNKNOWN = 0; // 0x0
}
public final class BarringInfo implements android.os.Parcelable {
ctor public BarringInfo();
ctor public BarringInfo(@Nullable android.telephony.CellIdentity, @NonNull android.util.SparseArray<android.telephony.BarringInfo.BarringServiceInfo>);

View File

@@ -317,6 +317,159 @@ public final class AccessNetworkConstants {
public static final int BAND_260 = 260;
public static final int BAND_261 = 261;
/**
* NR Bands
*
* @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"BAND_"},
value = {BAND_1,
BAND_2,
BAND_3,
BAND_5,
BAND_7,
BAND_8,
BAND_12,
BAND_14,
BAND_18,
BAND_20,
BAND_25,
BAND_28,
BAND_29,
BAND_30,
BAND_34,
BAND_38,
BAND_39,
BAND_40,
BAND_41,
BAND_48,
BAND_50,
BAND_51,
BAND_65,
BAND_66,
BAND_70,
BAND_71,
BAND_74,
BAND_75,
BAND_76,
BAND_77,
BAND_78,
BAND_79,
BAND_80,
BAND_81,
BAND_82,
BAND_83,
BAND_84,
BAND_86,
BAND_90,
BAND_257,
BAND_258,
BAND_260,
BAND_261})
public @interface NgranBand {}
/**
* Unknown NR frequency.
*
* @hide
*/
@SystemApi
@TestApi
public static final int FREQUENCY_RANGE_GROUP_UNKNOWN = 0;
/**
* NR frequency group 1 defined in 3GPP TS 38.101-1 table 5.2-1
*
* @hide
*/
@SystemApi
@TestApi
public static final int FREQUENCY_RANGE_GROUP_1 = 1;
/**
* NR frequency group 2 defined in 3GPP TS 38.101-2 table 5.2-1
*
* @hide
*/
@SystemApi
@TestApi
public static final int FREQUENCY_RANGE_GROUP_2 = 2;
/**
* Radio frequency range group
*
* @hide
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"FREQUENCY_RANGE_GROUP_"},
value = {
FREQUENCY_RANGE_GROUP_UNKNOWN,
FREQUENCY_RANGE_GROUP_1,
FREQUENCY_RANGE_GROUP_2})
public @interface FrequencyRangeGroup {}
/**
* Get frequency range group
*
* @param band NR band
* @return The frequency range group
*
* @hide
*/
@SystemApi
@TestApi
public static @FrequencyRangeGroup int getFrequencyRangeGroup(@NgranBand int band) {
switch (band) {
case BAND_1:
case BAND_2:
case BAND_3:
case BAND_5:
case BAND_7:
case BAND_8:
case BAND_12:
case BAND_14:
case BAND_18:
case BAND_20:
case BAND_25:
case BAND_28:
case BAND_29:
case BAND_30:
case BAND_34:
case BAND_38:
case BAND_39:
case BAND_40:
case BAND_41:
case BAND_48:
case BAND_50:
case BAND_51:
case BAND_65:
case BAND_66:
case BAND_70:
case BAND_71:
case BAND_74:
case BAND_75:
case BAND_76:
case BAND_77:
case BAND_78:
case BAND_79:
case BAND_80:
case BAND_81:
case BAND_82:
case BAND_83:
case BAND_84:
case BAND_86:
case BAND_90:
return FREQUENCY_RANGE_GROUP_1;
case BAND_257:
case BAND_258:
case BAND_260:
case BAND_261:
return FREQUENCY_RANGE_GROUP_2;
default:
return FREQUENCY_RANGE_GROUP_UNKNOWN;
}
};
/** @hide */
private NgranBands() {}
}

View File

@@ -20,6 +20,7 @@ import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.telephony.AccessNetworkConstants.NgranBands.NgranBand;
import android.telephony.gsm.GsmCellLocation;
import java.util.Collections;
@@ -41,6 +42,7 @@ public final class CellIdentityNr extends CellIdentity {
private final int mPci;
private final int mTac;
private final long mNci;
private final int mBand;
// a list of additional PLMN-IDs reported for this cell
private final List<String> mAdditionalPlmns;
@@ -50,6 +52,7 @@ public final class CellIdentityNr extends CellIdentity {
* @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 band Band number defined in 3GPP TS 38.101-1 and TS 38.101-2.
* @param mccStr 3-digit Mobile Country Code in string format.
* @param mncStr 2 or 3-digit Mobile Network Code in string format.
* @param nci The 36-bit NR Cell Identity in range [0, 68719476735].
@@ -59,25 +62,28 @@ public final class CellIdentityNr extends CellIdentity {
*
* @hide
*/
public CellIdentityNr(int pci, int tac, int nrArfcn, String mccStr, String mncStr,
long nci, String alphal, String alphas, List<String> additionalPlmns) {
public CellIdentityNr(int pci, int tac, int nrArfcn, @NgranBand int band, String mccStr,
String mncStr, long nci, String alphal, String alphas, List<String> additionalPlmns) {
super(TAG, CellInfo.TYPE_NR, mccStr, mncStr, alphal, alphas);
mPci = inRangeOrUnavailable(pci, 0, MAX_PCI);
mTac = inRangeOrUnavailable(tac, 0, MAX_TAC);
mNrArfcn = inRangeOrUnavailable(nrArfcn, 0, MAX_NRARFCN);
mBand = inRangeOrUnavailable(band, AccessNetworkConstants.NgranBands.BAND_1,
AccessNetworkConstants.NgranBands.BAND_261);
mNci = inRangeOrUnavailable(nci, 0, MAX_NCI);
mAdditionalPlmns = additionalPlmns;
}
/** @hide */
public CellIdentityNr(android.hardware.radio.V1_4.CellIdentityNr cid) {
this(cid.pci, cid.tac, cid.nrarfcn, cid.mcc, cid.mnc, cid.nci, cid.operatorNames.alphaLong,
cid.operatorNames.alphaShort, Collections.emptyList());
this(cid.pci, cid.tac, cid.nrarfcn, 0, cid.mcc, cid.mnc, cid.nci,
cid.operatorNames.alphaLong, cid.operatorNames.alphaShort,
Collections.emptyList());
}
/** @hide */
public CellIdentityNr(android.hardware.radio.V1_5.CellIdentityNr cid) {
this(cid.base.pci, cid.base.tac, cid.base.nrarfcn, cid.base.mcc, cid.base.mnc,
this(cid.base.pci, cid.base.tac, cid.base.nrarfcn, cid.band, cid.base.mcc, cid.base.mnc,
cid.base.nci, cid.base.operatorNames.alphaLong,
cid.base.operatorNames.alphaShort, cid.additionalPlmns);
}
@@ -85,8 +91,9 @@ public final class CellIdentityNr extends CellIdentity {
/** @hide */
@Override
public @NonNull CellIdentityNr sanitizeLocationInfo() {
return new CellIdentityNr(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
mMccStr, mMncStr, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort, mAdditionalPlmns);
return new CellIdentityNr(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, mNrArfcn,
mBand, mMccStr, mMncStr, CellInfo.UNAVAILABLE, mAlphaLong, mAlphaShort,
mAdditionalPlmns);
}
/**
@@ -102,7 +109,7 @@ public final class CellIdentityNr extends CellIdentity {
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), mPci, mTac,
mNrArfcn, mNci, mAdditionalPlmns.hashCode());
mNrArfcn, mBand, mNci, mAdditionalPlmns.hashCode());
}
@Override
@@ -113,7 +120,8 @@ public final class CellIdentityNr extends CellIdentity {
CellIdentityNr o = (CellIdentityNr) other;
return super.equals(o) && mPci == o.mPci && mTac == o.mTac && mNrArfcn == o.mNrArfcn
&& mNci == o.mNci && mAdditionalPlmns.equals(o.mAdditionalPlmns);
&& mBand == o.mBand && mNci == o.mNci
&& mAdditionalPlmns.equals(o.mAdditionalPlmns);
}
/**
@@ -139,6 +147,19 @@ public final class CellIdentityNr extends CellIdentity {
return mNrArfcn;
}
/**
* Get band of the cell
*
* Reference: TS 38.101-1 table 5.2-1
* Reference: TS 38.101-2 table 5.2-1
*
* @return band number or {@link CellInfo@UNAVAILABLE} if not available.
*/
@NgranBand
public int getBand() {
return mBand;
}
/**
* Get the physical cell id.
* @return Integer value in range [0, 1007] or {@link CellInfo#UNAVAILABLE} if unknown.
@@ -193,6 +214,7 @@ public final class CellIdentityNr extends CellIdentity {
.append(" mPci = ").append(mPci)
.append(" mTac = ").append(mTac)
.append(" mNrArfcn = ").append(mNrArfcn)
.append(" mBand = ").append(mBand)
.append(" mMcc = ").append(mMccStr)
.append(" mMnc = ").append(mMncStr)
.append(" mNci = ").append(mNci)
@@ -209,6 +231,7 @@ public final class CellIdentityNr extends CellIdentity {
dest.writeInt(mPci);
dest.writeInt(mTac);
dest.writeInt(mNrArfcn);
dest.writeInt(mBand);
dest.writeLong(mNci);
dest.writeList(mAdditionalPlmns);
}
@@ -219,6 +242,7 @@ public final class CellIdentityNr extends CellIdentity {
mPci = in.readInt();
mTac = in.readInt();
mNrArfcn = in.readInt();
mBand = in.readInt();
mNci = in.readLong();
mAdditionalPlmns = in.readArrayList(null);
}

View File

@@ -7928,6 +7928,36 @@ public class TelephonyManager {
persistSelection);
}
/**
* Ask the radio to connect to the input network and change selection mode to manual.
*
* <p>If this object has been created with {@link #createForSubscriptionId}, applies to the
* given subId. Otherwise, applies to {@link SubscriptionManager#getDefaultSubscriptionId()}
*
* <p>Requires Permission:
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling
* app has carrier privileges (see {@link #hasCarrierPrivileges}).
*
* @param operatorNumeric the PLMN ID of the network to select.
* @param ran the initial suggested radio access network type.
* If registration fails, the RAN is not available after, the RAN is not within the
* network types specified by {@link #setPreferredNetworkTypeBitmask}, or the value is
* {@link AccessNetworkConstants.AccessNetworkType#UNKNOWN}, modem will select
* the next best RAN for network registration.
* @param persistSelection whether the selection will persist until reboot.
* If true, only allows attaching to the selected PLMN until reboot; otherwise,
* attach to the chosen PLMN and resume normal network selection next time.
* @return {@code true} on success; {@code false} on any failure.
* @hide
*/
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
@SystemApi
public boolean setNetworkSelectionModeManual(@NonNull String operatorNumeric,
@AccessNetworkConstants.RadioAccessNetworkType int ran, boolean persistSelection) {
return setNetworkSelectionModeManual(new OperatorInfo("" /* operatorAlphaLong */,
"" /* operatorAlphaShort */, operatorNumeric, ran), persistSelection);
}
/**
* Ask the radio to connect to the input network and change selection mode to manual.
*

View File

@@ -20,6 +20,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.AccessNetworkConstants.AccessNetworkType;
/**
* @hide
@@ -43,6 +44,7 @@ public class OperatorInfo implements Parcelable {
@UnsupportedAppUsage
private State mState = State.UNKNOWN;
private int mRan = AccessNetworkType.UNKNOWN;
@UnsupportedAppUsage
@@ -69,6 +71,10 @@ public class OperatorInfo implements Parcelable {
return mState;
}
public int getRan() {
return mRan;
}
@UnsupportedAppUsage
OperatorInfo(String operatorAlphaLong,
String operatorAlphaShort,
@@ -82,6 +88,14 @@ public class OperatorInfo implements Parcelable {
mState = state;
}
OperatorInfo(String operatorAlphaLong,
String operatorAlphaShort,
String operatorNumeric,
State state,
int ran) {
this (operatorAlphaLong, operatorAlphaShort, operatorNumeric, state);
mRan = ran;
}
@UnsupportedAppUsage
public OperatorInfo(String operatorAlphaLong,
@@ -92,6 +106,14 @@ public class OperatorInfo implements Parcelable {
operatorNumeric, rilStateToState(stateString));
}
public OperatorInfo(String operatorAlphaLong,
String operatorAlphaShort,
String operatorNumeric,
int ran) {
this (operatorAlphaLong, operatorAlphaShort, operatorNumeric);
mRan = ran;
}
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
public OperatorInfo(String operatorAlphaLong,
String operatorAlphaShort,
@@ -124,7 +146,8 @@ public class OperatorInfo implements Parcelable {
return "OperatorInfo " + mOperatorAlphaLong
+ "/" + mOperatorAlphaShort
+ "/" + mOperatorNumeric
+ "/" + mState;
+ "/" + mState
+ "/" + mRan;
}
/**
@@ -150,6 +173,7 @@ public class OperatorInfo implements Parcelable {
dest.writeString(mOperatorAlphaShort);
dest.writeString(mOperatorNumeric);
dest.writeSerializable(mState);
dest.writeInt(mRan);
}
/**
@@ -158,20 +182,21 @@ public class OperatorInfo implements Parcelable {
*/
@UnsupportedAppUsage
public static final Creator<OperatorInfo> CREATOR =
new Creator<OperatorInfo>() {
@Override
public OperatorInfo createFromParcel(Parcel in) {
OperatorInfo opInfo = new OperatorInfo(
in.readString(), /*operatorAlphaLong*/
in.readString(), /*operatorAlphaShort*/
in.readString(), /*operatorNumeric*/
(State) in.readSerializable()); /*state*/
return opInfo;
}
new Creator<OperatorInfo>() {
@Override
public OperatorInfo createFromParcel(Parcel in) {
OperatorInfo opInfo = new OperatorInfo(
in.readString(), /*operatorAlphaLong*/
in.readString(), /*operatorAlphaShort*/
in.readString(), /*operatorNumeric*/
(State) in.readSerializable(), /*state*/
in.readInt()); /*ran*/
return opInfo;
}
@Override
public OperatorInfo[] newArray(int size) {
return new OperatorInfo[size];
}
};
@Override
public OperatorInfo[] newArray(int size) {
return new OperatorInfo[size];
}
};
}