Merge "Refactor CellInfo Constructors" am: bd9da6de04

am: 1d2825ce8e

Change-Id: I98f792d178813cc93c0123ba73486d3d18a4874f
This commit is contained in:
Nathan Harold
2018-12-26 15:40:04 -08:00
committed by android-build-merger
11 changed files with 192 additions and 120 deletions

View File

@@ -16,7 +16,6 @@
package android.telephony;
import android.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.telephony.cdma.CdmaCellLocation;
@@ -62,23 +61,6 @@ public final class CellIdentityCdma extends CellIdentity {
mLatitude = CellInfo.UNAVAILABLE;
}
/**
* public constructor
* @param nid Network Id 0..65535
* @param sid CDMA System Id 0..32767
* @param bid Base Station Id 0..65535
* @param lon Longitude is a decimal number ranges from -2592000
* to 2592000
* @param lat Latitude is a decimal number ranges from -1296000
* to 1296000
*
* @hide
*/
@UnsupportedAppUsage
public CellIdentityCdma(int nid, int sid, int bid, int lon, int lat) {
this(nid, sid, bid, lon, lat, null, null);
}
/**
* public constructor
* @param nid Network Id 0..65535
@@ -93,8 +75,8 @@ public final class CellIdentityCdma extends CellIdentity {
*
* @hide
*/
public CellIdentityCdma(int nid, int sid, int bid, int lon, int lat, String alphal,
String alphas) {
public CellIdentityCdma(
int nid, int sid, int bid, int lon, int lat, String alphal, String alphas) {
super(TAG, CellInfo.TYPE_CDMA, null, null, alphal, alphas);
mNetworkId = nid;
mSystemId = sid;
@@ -107,6 +89,17 @@ public final class CellIdentityCdma extends CellIdentity {
}
}
/** @hide */
public CellIdentityCdma(android.hardware.radio.V1_0.CellIdentityCdma cid) {
this(cid.networkId, cid.systemId, cid.baseStationId, cid.longitude, cid.latitude, "", "");
}
/** @hide */
public CellIdentityCdma(android.hardware.radio.V1_2.CellIdentityCdma cid) {
this(cid.base.networkId, cid.base.systemId, cid.base.baseStationId, cid.base.longitude,
cid.base.latitude, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort);
}
private CellIdentityCdma(CellIdentityCdma cid) {
this(cid.mNetworkId, cid.mSystemId, cid.mBasestationId, cid.mLongitude, cid.mLatitude,
cid.mAlphaLong, cid.mAlphaShort);

View File

@@ -36,10 +36,8 @@ public final class CellIdentityGsm extends CellIdentity {
// 16-bit GSM Cell Identity described in TS 27.007, 0..65535
private final int mCid;
// 16-bit GSM Absolute RF Channel Number
@UnsupportedAppUsage
private final int mArfcn;
// 6-bit Base Station Identity Code
@UnsupportedAppUsage
private final int mBsic;
/**
@@ -53,34 +51,6 @@ public final class CellIdentityGsm extends CellIdentity {
mArfcn = CellInfo.UNAVAILABLE;
mBsic = CellInfo.UNAVAILABLE;
}
/**
* public constructor
* @param mcc 3-digit Mobile Country Code, 0..999
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
* @param lac 16-bit Location Area Code, 0..65535
* @param cid 16-bit GSM Cell Identity or 28-bit UMTS Cell Identity
*
* @hide
*/
public CellIdentityGsm(int mcc, int mnc, int lac, int cid) {
this(lac, cid, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE,
String.valueOf(mcc), String.valueOf(mnc), null, null);
}
/**
* public constructor
* @param mcc 3-digit Mobile Country Code, 0..999
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
* @param lac 16-bit Location Area Code, 0..65535
* @param cid 16-bit GSM Cell Identity or 28-bit UMTS Cell Identity
* @param arfcn 16-bit GSM Absolute RF Channel Number
* @param bsic 6-bit Base Station Identity Code
*
* @hide
*/
public CellIdentityGsm(int mcc, int mnc, int lac, int cid, int arfcn, int bsic) {
this(lac, cid, arfcn, bsic, String.valueOf(mcc), String.valueOf(mnc), null, null);
}
/**
* public constructor
@@ -101,9 +71,20 @@ public final class CellIdentityGsm extends CellIdentity {
mLac = lac;
mCid = cid;
mArfcn = arfcn;
// In RIL BSIC is a UINT8, so 0xFF is the 'INVALID' designator
// for inbound parcels
mBsic = (bsic == 0xFF) ? CellInfo.UNAVAILABLE : bsic;
mBsic = bsic;
}
/** @hide */
public CellIdentityGsm(android.hardware.radio.V1_0.CellIdentityGsm cid) {
this(cid.lac, cid.cid, cid.arfcn,
cid.bsic == 0xFF ? CellInfo.UNAVAILABLE : cid.bsic, cid.mcc, cid.mnc, "", "");
}
/** @hide */
public CellIdentityGsm(android.hardware.radio.V1_2.CellIdentityGsm cid) {
this(cid.base.lac, cid.base.cid, cid.base.arfcn,
cid.base.bsic == 0xFF ? CellInfo.UNAVAILABLE : cid.base.bsic, cid.base.mcc,
cid.base.mnc, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort);
}
private CellIdentityGsm(CellIdentityGsm cid) {

View File

@@ -38,7 +38,6 @@ public final class CellIdentityLte extends CellIdentity {
// 16-bit tracking area code
private final int mTac;
// 18-bit Absolute RF Channel Number
@UnsupportedAppUsage
private final int mEarfcn;
// cell bandwidth, in kHz
private final int mBandwidth;
@@ -72,22 +71,6 @@ public final class CellIdentityLte extends CellIdentity {
String.valueOf(mnc), null, null);
}
/**
*
* @param mcc 3-digit Mobile Country Code, 0..999
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
* @param ci 28-bit Cell Identity
* @param pci Physical Cell Id 0..503
* @param tac 16-bit Tracking Area Code
* @param earfcn 18-bit LTE Absolute RF Channel Number
*
* @hide
*/
public CellIdentityLte(int mcc, int mnc, int ci, int pci, int tac, int earfcn) {
this(ci, pci, tac, earfcn, CellInfo.UNAVAILABLE, String.valueOf(mcc), String.valueOf(mnc),
null, null);
}
/**
*
* @param ci 28-bit Cell Identity
@@ -112,6 +95,18 @@ public final class CellIdentityLte extends CellIdentity {
mBandwidth = bandwidth;
}
/** @hide */
public CellIdentityLte(android.hardware.radio.V1_0.CellIdentityLte cid) {
this(cid.ci, cid.pci, cid.tac, cid.earfcn, CellInfo.UNAVAILABLE, cid.mcc, cid.mnc, "", "");
}
/** @hide */
public CellIdentityLte(android.hardware.radio.V1_2.CellIdentityLte cid) {
this(cid.base.ci, cid.base.pci, cid.base.tac, cid.base.earfcn, cid.bandwidth,
cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong,
cid.operatorNames.alphaShort);
}
private CellIdentityLte(CellIdentityLte cid) {
this(cid.mCi, cid.mPci, cid.mTac, cid.mEarfcn, cid.mBandwidth, cid.mMccStr,
cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort);

View File

@@ -50,22 +50,6 @@ public final class CellIdentityTdscdma extends CellIdentity {
mUarfcn = CellInfo.UNAVAILABLE;
}
/**
* @param mcc 3-digit Mobile Country Code, 0..999
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
* @param lac 16-bit Location Area Code, 0..65535, CellInfo.UNAVAILABLE if unknown
* @param cid 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, CellInfo.
* UNAVAILABLE if unknown
* @param cpid 8-bit Cell Parameters ID described in TS 25.331, 0..127, CellInfo.UNAVAILABLE
* if unknown
* @param uarfcn 16-bit UMTS Absolute RF Channel Number described in TS 25.101 sec. 5.4.3
*
* @hide
*/
public CellIdentityTdscdma(int mcc, int mnc, int lac, int cid, int cpid, int uarfcn) {
this(String.valueOf(mcc), String.valueOf(mnc), lac, cid, cpid, uarfcn, null, null);
}
/**
* @param mcc 3-digit Mobile Country Code in string format
* @param mnc 2 or 3-digit Mobile Network Code in string format
@@ -94,6 +78,17 @@ public final class CellIdentityTdscdma extends CellIdentity {
cid.mCpid, cid.mUarfcn, cid.mAlphaLong, cid.mAlphaShort);
}
/** @hide */
public CellIdentityTdscdma(android.hardware.radio.V1_0.CellIdentityTdscdma cid) {
this(cid.mcc, cid.mnc, cid.lac, cid.cid, cid.cpid, CellInfo.UNAVAILABLE, "", "");
}
/** @hide */
public CellIdentityTdscdma(android.hardware.radio.V1_2.CellIdentityTdscdma cid) {
this(cid.base.mcc, cid.base.mnc, cid.base.lac, cid.base.cid, cid.base.cpid,
cid.uarfcn, cid.operatorNames.alphaLong, cid.operatorNames.alphaShort);
}
CellIdentityTdscdma copy() {
return new CellIdentityTdscdma(this);
}

View File

@@ -51,35 +51,6 @@ public final class CellIdentityWcdma extends CellIdentity {
mPsc = CellInfo.UNAVAILABLE;
mUarfcn = CellInfo.UNAVAILABLE;
}
/**
* public constructor
* @param mcc 3-digit Mobile Country Code, 0..999
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
* @param lac 16-bit Location Area Code, 0..65535
* @param cid 28-bit UMTS Cell Identity
* @param psc 9-bit UMTS Primary Scrambling Code
*
* @hide
*/
public CellIdentityWcdma (int mcc, int mnc, int lac, int cid, int psc) {
this(lac, cid, psc, CellInfo.UNAVAILABLE, String.valueOf(mcc), String.valueOf(mnc),
null, null);
}
/**
* public constructor
* @param mcc 3-digit Mobile Country Code, 0..999
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
* @param lac 16-bit Location Area Code, 0..65535
* @param cid 28-bit UMTS Cell Identity
* @param psc 9-bit UMTS Primary Scrambling Code
* @param uarfcn 16-bit UMTS Absolute RF Channel Number described in TS 25.101 sec. 5.4.3
*
* @hide
*/
public CellIdentityWcdma (int mcc, int mnc, int lac, int cid, int psc, int uarfcn) {
this(lac, cid, psc, uarfcn, String.valueOf(mcc), String.valueOf(mnc), null, null);
}
/**
* public constructor
@@ -103,6 +74,18 @@ public final class CellIdentityWcdma extends CellIdentity {
mUarfcn = uarfcn;
}
/** @hide */
public CellIdentityWcdma(android.hardware.radio.V1_0.CellIdentityWcdma cid) {
this(cid.lac, cid.cid, cid.psc, cid.uarfcn, cid.mcc, cid.mnc, "", "");
}
/** @hide */
public CellIdentityWcdma(android.hardware.radio.V1_2.CellIdentityWcdma cid) {
this(cid.base.lac, cid.base.cid, cid.base.psc, cid.base.uarfcn,
cid.base.mcc, cid.base.mnc, cid.operatorNames.alphaLong,
cid.operatorNames.alphaShort);
}
private CellIdentityWcdma(CellIdentityWcdma cid) {
this(cid.mLac, cid.mCid, cid.mPsc, cid.mUarfcn, cid.mMccStr,
cid.mMncStr, cid.mAlphaLong, cid.mAlphaShort);

View File

@@ -132,7 +132,8 @@ public abstract class CellInfo implements Parcelable {
/** Connection status is unknown. */
public static final int CONNECTION_UNKNOWN = Integer.MAX_VALUE;
private int mCellConnectionStatus = CONNECTION_NONE;
/** A cell connection status */
private int mCellConnectionStatus;
// True if device is mRegistered to the mobile network
private boolean mRegistered;
@@ -144,6 +145,7 @@ public abstract class CellInfo implements Parcelable {
protected CellInfo() {
this.mRegistered = false;
this.mTimeStamp = Long.MAX_VALUE;
mCellConnectionStatus = CONNECTION_NONE;
}
/** @hide */
@@ -300,4 +302,44 @@ public abstract class CellInfo implements Parcelable {
return new CellInfo[size];
}
};
/** @hide */
protected CellInfo(android.hardware.radio.V1_0.CellInfo ci) {
this.mRegistered = ci.registered;
this.mTimeStamp = ci.timeStamp;
this.mCellConnectionStatus = CONNECTION_UNKNOWN;
}
/** @hide */
protected CellInfo(android.hardware.radio.V1_2.CellInfo ci) {
this.mRegistered = ci.registered;
this.mTimeStamp = ci.timeStamp;
this.mCellConnectionStatus = ci.connectionStatus;
}
/** @hide */
public static CellInfo create(android.hardware.radio.V1_0.CellInfo ci) {
if (ci == null) return null;
switch(ci.cellInfoType) {
case android.hardware.radio.V1_0.CellInfoType.GSM: return new CellInfoGsm(ci);
case android.hardware.radio.V1_0.CellInfoType.CDMA: return new CellInfoCdma(ci);
case android.hardware.radio.V1_0.CellInfoType.LTE: return new CellInfoLte(ci);
case android.hardware.radio.V1_0.CellInfoType.WCDMA: return new CellInfoWcdma(ci);
case android.hardware.radio.V1_0.CellInfoType.TD_SCDMA: return new CellInfoTdscdma(ci);
default: return null;
}
}
/** @hide */
public static CellInfo create(android.hardware.radio.V1_2.CellInfo ci) {
if (ci == null) return null;
switch(ci.cellInfoType) {
case android.hardware.radio.V1_0.CellInfoType.GSM: return new CellInfoGsm(ci);
case android.hardware.radio.V1_0.CellInfoType.CDMA: return new CellInfoCdma(ci);
case android.hardware.radio.V1_0.CellInfoType.LTE: return new CellInfoLte(ci);
case android.hardware.radio.V1_0.CellInfoType.WCDMA: return new CellInfoWcdma(ci);
case android.hardware.radio.V1_0.CellInfoType.TD_SCDMA: return new CellInfoTdscdma(ci);
default: return null;
}
}
}

View File

@@ -48,6 +48,24 @@ public final class CellInfoCdma extends CellInfo implements Parcelable {
this.mCellSignalStrengthCdma = ci.mCellSignalStrengthCdma.copy();
}
/** @hide */
public CellInfoCdma(android.hardware.radio.V1_0.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_0.CellInfoCdma cic = ci.cdma.get(0);
mCellIdentityCdma = new CellIdentityCdma(cic.cellIdentityCdma);
mCellSignalStrengthCdma =
new CellSignalStrengthCdma(cic.signalStrengthCdma, cic.signalStrengthEvdo);
}
/** @hide */
public CellInfoCdma(android.hardware.radio.V1_2.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_2.CellInfoCdma cic = ci.cdma.get(0);
mCellIdentityCdma = new CellIdentityCdma(cic.cellIdentityCdma);
mCellSignalStrengthCdma =
new CellSignalStrengthCdma(cic.signalStrengthCdma, cic.signalStrengthEvdo);
}
@Override
public CellIdentityCdma getCellIdentity() {
return mCellIdentityCdma;

View File

@@ -43,8 +43,24 @@ public final class CellInfoGsm extends CellInfo implements Parcelable {
/** @hide */
public CellInfoGsm(CellInfoGsm ci) {
super(ci);
this.mCellIdentityGsm = ci.mCellIdentityGsm.copy();
this.mCellSignalStrengthGsm = ci.mCellSignalStrengthGsm.copy();
mCellIdentityGsm = ci.mCellIdentityGsm.copy();
mCellSignalStrengthGsm = ci.mCellSignalStrengthGsm.copy();
}
/** @hide */
public CellInfoGsm(android.hardware.radio.V1_0.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_0.CellInfoGsm cig = ci.gsm.get(0);
mCellIdentityGsm = new CellIdentityGsm(cig.cellIdentityGsm);
mCellSignalStrengthGsm = new CellSignalStrengthGsm(cig.signalStrengthGsm);
}
/** @hide */
public CellInfoGsm(android.hardware.radio.V1_2.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_2.CellInfoGsm cig = ci.gsm.get(0);
mCellIdentityGsm = new CellIdentityGsm(cig.cellIdentityGsm);
mCellSignalStrengthGsm = new CellSignalStrengthGsm(cig.signalStrengthGsm);
}
@Override

View File

@@ -51,6 +51,24 @@ public final class CellInfoLte extends CellInfo implements Parcelable {
this.mCellConfig = new CellConfigLte(ci.mCellConfig);
}
/** @hide */
public CellInfoLte(android.hardware.radio.V1_0.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_0.CellInfoLte cil = ci.lte.get(0);
mCellIdentityLte = new CellIdentityLte(cil.cellIdentityLte);
mCellSignalStrengthLte = new CellSignalStrengthLte(cil.signalStrengthLte);
mCellConfig = new CellConfigLte();
}
/** @hide */
public CellInfoLte(android.hardware.radio.V1_2.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_2.CellInfoLte cil = ci.lte.get(0);
mCellIdentityLte = new CellIdentityLte(cil.cellIdentityLte);
mCellSignalStrengthLte = new CellSignalStrengthLte(cil.signalStrengthLte);
mCellConfig = new CellConfigLte();
}
@Override
public CellIdentityLte getCellIdentity() {
if (DBG) log("getCellIdentity: " + mCellIdentityLte);

View File

@@ -48,8 +48,23 @@ public final class CellInfoTdscdma extends CellInfo implements Parcelable {
this.mCellSignalStrengthTdscdma = ci.mCellSignalStrengthTdscdma.copy();
}
@Override
public CellIdentityTdscdma getCellIdentity() {
/** @hide */
public CellInfoTdscdma(android.hardware.radio.V1_0.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_0.CellInfoTdscdma cit = ci.tdscdma.get(0);
mCellIdentityTdscdma = new CellIdentityTdscdma(cit.cellIdentityTdscdma);
mCellSignalStrengthTdscdma = new CellSignalStrengthTdscdma(cit.signalStrengthTdscdma);
}
/** @hide */
public CellInfoTdscdma(android.hardware.radio.V1_2.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_2.CellInfoTdscdma cit = ci.tdscdma.get(0);
mCellIdentityTdscdma = new CellIdentityTdscdma(cit.cellIdentityTdscdma);
mCellSignalStrengthTdscdma = new CellSignalStrengthTdscdma(cit.signalStrengthTdscdma);
}
@Override public CellIdentityTdscdma getCellIdentity() {
return mCellIdentityTdscdma;
}
/** @hide */

View File

@@ -47,6 +47,22 @@ public final class CellInfoWcdma extends CellInfo implements Parcelable {
this.mCellSignalStrengthWcdma = ci.mCellSignalStrengthWcdma.copy();
}
/** @hide */
public CellInfoWcdma(android.hardware.radio.V1_0.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_0.CellInfoWcdma ciw = ci.wcdma.get(0);
mCellIdentityWcdma = new CellIdentityWcdma(ciw.cellIdentityWcdma);
mCellSignalStrengthWcdma = new CellSignalStrengthWcdma(ciw.signalStrengthWcdma);
}
/** @hide */
public CellInfoWcdma(android.hardware.radio.V1_2.CellInfo ci) {
super(ci);
final android.hardware.radio.V1_2.CellInfoWcdma ciw = ci.wcdma.get(0);
mCellIdentityWcdma = new CellIdentityWcdma(ciw.cellIdentityWcdma);
mCellSignalStrengthWcdma = new CellSignalStrengthWcdma(ciw.signalStrengthWcdma);
}
@Override
public CellIdentityWcdma getCellIdentity() {
return mCellIdentityWcdma;