Loading src/java/com/android/internal/telephony/CellularNetworkService.java +3 −1 Original line number Diff line number Diff line Loading @@ -330,7 +330,8 @@ public class CellularNetworkService extends NetworkService { cellIdentity.cellIdentityTdscdma.get(0); result = new CellIdentityTdscdma(cellIdentityTdscdma.mcc, cellIdentityTdscdma.mnc, cellIdentityTdscdma.lac, cellIdentityTdscdma.cid, cellIdentityTdscdma.cpid); cellIdentityTdscdma.cid, cellIdentityTdscdma.cpid, Integer.MAX_VALUE, null, null); } break; } Loading Loading @@ -417,6 +418,7 @@ public class CellularNetworkService extends NetworkService { cellIdentityTdscdma.base.lac, cellIdentityTdscdma.base.cid, cellIdentityTdscdma.base.cpid, cellIdentityTdscdma.uarfcn, cellIdentityTdscdma.operatorNames.alphaLong, cellIdentityTdscdma.operatorNames.alphaShort); } Loading src/java/com/android/internal/telephony/RIL.java +75 −12 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.hardware.radio.V1_0.CdmaSmsWriteArgs; import android.hardware.radio.V1_0.CellInfoCdma; import android.hardware.radio.V1_0.CellInfoGsm; import android.hardware.radio.V1_0.CellInfoLte; import android.hardware.radio.V1_0.CellInfoTdscdma; import android.hardware.radio.V1_0.CellInfoType; import android.hardware.radio.V1_0.CellInfoWcdma; import android.hardware.radio.V1_0.DataProfileInfo; Loading Loading @@ -5279,7 +5280,7 @@ public class RIL extends BaseCommands implements CommandsInterface { private static void writeToParcelForWcdma( Parcel p, int lac, int cid, int psc, int uarfcn, String mcc, String mnc, String al, String as, int ss, int ber) { String al, String as, int ss, int ber, int rscp, int ecno) { p.writeInt(CellIdentity.TYPE_WCDMA); p.writeString(mcc); p.writeString(mnc); Loading @@ -5291,6 +5292,25 @@ public class RIL extends BaseCommands implements CommandsInterface { p.writeInt(uarfcn); p.writeInt(ss); p.writeInt(ber); p.writeInt(rscp); p.writeInt(ecno); } private static void writeToParcelForTdscdma( Parcel p, int lac, int cid, int cpid, int uarfcn, String mcc, String mnc, String al, String as, int ss, int ber, int rscp) { p.writeInt(CellIdentity.TYPE_TDSCDMA); p.writeString(mcc); p.writeString(mnc); p.writeString(al); p.writeString(as); p.writeInt(lac); p.writeInt(cid); p.writeInt(cpid); p.writeInt(uarfcn); p.writeInt(ss); p.writeInt(ber); p.writeInt(rscp); } /** Loading Loading @@ -5384,10 +5404,29 @@ public class RIL extends BaseCommands implements CommandsInterface { EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT, cellInfoWcdma.signalStrengthWcdma.signalStrength, cellInfoWcdma.signalStrengthWcdma.bitErrorRate); cellInfoWcdma.signalStrengthWcdma.bitErrorRate, Integer.MAX_VALUE, Integer.MAX_VALUE); break; } case CellInfoType.TD_SCDMA: { CellInfoTdscdma cellInfoTdscdma = record.tdscdma.get(0); writeToParcelForTdscdma( p, cellInfoTdscdma.cellIdentityTdscdma.lac, cellInfoTdscdma.cellIdentityTdscdma.cid, cellInfoTdscdma.cellIdentityTdscdma.cpid, Integer.MAX_VALUE, cellInfoTdscdma.cellIdentityTdscdma.mcc, cellInfoTdscdma.cellIdentityTdscdma.mnc, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT, Integer.MAX_VALUE, Integer.MAX_VALUE, convertTdscdmaRscpTo1_2(cellInfoTdscdma.signalStrengthTdscdma.rscp)); break; } default: throw new RuntimeException("unexpected cellinfotype: " + record.cellInfoType); } Loading Loading @@ -5492,7 +5531,28 @@ public class RIL extends BaseCommands implements CommandsInterface { cellInfoWcdma.cellIdentityWcdma.operatorNames.alphaLong, cellInfoWcdma.cellIdentityWcdma.operatorNames.alphaShort, cellInfoWcdma.signalStrengthWcdma.base.signalStrength, cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate); cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate, cellInfoWcdma.signalStrengthWcdma.rscp, cellInfoWcdma.signalStrengthWcdma.ecno); break; } case CellInfoType.TD_SCDMA: { android.hardware.radio.V1_2.CellInfoTdscdma cellInfoTdscdma = record.tdscdma.get(0); writeToParcelForTdscdma( p, cellInfoTdscdma.cellIdentityTdscdma.base.lac, cellInfoTdscdma.cellIdentityTdscdma.base.cid, cellInfoTdscdma.cellIdentityTdscdma.base.cpid, cellInfoTdscdma.cellIdentityTdscdma.uarfcn, cellInfoTdscdma.cellIdentityTdscdma.base.mcc, cellInfoTdscdma.cellIdentityTdscdma.base.mnc, cellInfoTdscdma.cellIdentityTdscdma.operatorNames.alphaLong, cellInfoTdscdma.cellIdentityTdscdma.operatorNames.alphaShort, cellInfoTdscdma.signalStrengthTdscdma.signalStrength, cellInfoTdscdma.signalStrengthTdscdma.bitErrorRate, cellInfoTdscdma.signalStrengthTdscdma.rscp); break; } Loading @@ -5509,19 +5569,22 @@ public class RIL extends BaseCommands implements CommandsInterface { return response; } /** Convert HAL 1.0 Signal Strength to android SignalStrength */ @VisibleForTesting public static SignalStrength convertHalSignalStrength( android.hardware.radio.V1_0.SignalStrength signalStrength) { int tdscdmaRscp_1_2 = 255; // 255 is the value for unknown/unreported ASU. private static int convertTdscdmaRscpTo1_2(int rscp) { // The HAL 1.0 range is 25..120; the ASU/ HAL 1.2 range is 0..96; // yes, this means the range in 1.0 cannot express -24dBm = 96 if (signalStrength.tdScdma.rscp >= 25 && signalStrength.tdScdma.rscp <= 120) { if (rscp >= 25 && rscp <= 120) { // First we flip the sign to convert from the HALs -rscp to the actual RSCP value. int rscpDbm = -signalStrength.tdScdma.rscp; int rscpDbm = -rscp; // Then to convert from RSCP to ASU, we apply the offset which aligns 0 ASU to -120dBm. tdscdmaRscp_1_2 = rscpDbm + 120; return rscpDbm + 120; } return Integer.MAX_VALUE; } /** Convert HAL 1.0 Signal Strength to android SignalStrength */ @VisibleForTesting public static SignalStrength convertHalSignalStrength( android.hardware.radio.V1_0.SignalStrength signalStrength) { return new SignalStrength( signalStrength.gw.signalStrength, signalStrength.gw.bitErrorRate, Loading @@ -5535,7 +5598,7 @@ public class RIL extends BaseCommands implements CommandsInterface { signalStrength.lte.rsrq, signalStrength.lte.rssnr, signalStrength.lte.cqi, tdscdmaRscp_1_2); convertTdscdmaRscpTo1_2(signalStrength.tdScdma.rscp)); } /** Convert HAL 1.2 Signal Strength to android SignalStrength */ Loading tests/telephonytests/src/com/android/internal/telephony/CellIdentityTdscdmaTest.java +19 −9 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { // Tracking area code ranges from 0 to 65535. private static final int TAC = 65535; // Absolute RF Channel Number ranges from 0 to 262140. private static final int EARFCN = 262140; private static final int UARFCN = 262140; private static final int MCC = 120; private static final int MNC = 260; private static final String MCC_STR = "120"; Loading @@ -52,33 +52,38 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testDefaultConstructor() { CellIdentityTdscdma ci = new CellIdentityTdscdma(MCC_STR, MNC_STR, LAC, CID, CPID); new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); assertEquals(MCC_STR, ci.getMccString()); assertEquals(MNC_STR, ci.getMncString()); assertEquals(LAC, ci.getLac()); assertEquals(CID, ci.getCid()); assertEquals(CPID, ci.getCpid()); assertEquals(UARFCN, ci.getChannelNumber()); assertEquals(ALPHA_LONG, ci.getOperatorAlphaLong()); assertEquals(ALPHA_SHORT, ci.getOperatorAlphaShort()); } @SmallTest public void testConstructorWithEmptyMccMnc() { CellIdentityTdscdma ci = new CellIdentityTdscdma(null, null, LAC, CID, CPID); CellIdentityTdscdma ci = new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, "", ""); assertNull(ci.getMccString()); assertNull(ci.getMncString()); ci = new CellIdentityTdscdma(MCC_STR, null, LAC, CID, CPID); ci = new CellIdentityTdscdma(MCC_STR, null, LAC, CID, CPID, UARFCN, "", ""); assertEquals(MCC_STR, ci.getMccString()); assertNull(ci.getMncString()); ci = new CellIdentityTdscdma(null, MNC_STR, LAC, CID, CPID); ci = new CellIdentityTdscdma(null, MNC_STR, LAC, CID, CPID, UARFCN, "", ""); assertEquals(MNC_STR, ci.getMncString()); assertNull(ci.getMccString()); ci = new CellIdentityTdscdma("", "", LAC, CID, CPID); ci = new CellIdentityTdscdma("", "", LAC, CID, CPID, UARFCN, "", ""); assertNull(ci.getMccString()); assertNull(ci.getMncString()); Loading @@ -86,7 +91,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testParcel() { CellIdentityTdscdma ci = new CellIdentityTdscdma(MCC_STR, MNC_STR, LAC, CID, CPID); CellIdentityTdscdma ci = new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, UARFCN, CPID, ALPHA_LONG, ALPHA_SHORT); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -99,7 +105,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityTdscdma ci = new CellIdentityTdscdma(null, null, LAC, CID, CPID, ALPHA_LONG, ALPHA_SHORT); new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); Parcel p = Parcel.obtain(); p.writeInt(CellIdentity.TYPE_TDSCDMA); Loading @@ -110,6 +117,7 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { p.writeInt(LAC); p.writeInt(CID); p.writeInt(CPID); p.writeInt(UARFCN); p.setDataPosition(0); CellIdentityTdscdma newCi = CellIdentityTdscdma.CREATOR.createFromParcel(p); Loading @@ -121,7 +129,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { final String invalidMcc = "randomStuff"; final String invalidMnc = "randomStuff"; CellIdentityTdscdma ci = new CellIdentityTdscdma(null, null, LAC, CID, CPID, ALPHA_LONG, ALPHA_SHORT); new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); Parcel p = Parcel.obtain(); p.writeInt(CellIdentity.TYPE_TDSCDMA); Loading @@ -132,6 +141,7 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { p.writeInt(LAC); p.writeInt(CID); p.writeInt(CPID); p.writeInt(UARFCN); p.setDataPosition(0); CellIdentityTdscdma newCi = CellIdentityTdscdma.CREATOR.createFromParcel(p); Loading tests/telephonytests/src/com/android/internal/telephony/RILTest.java +57 −6 Original line number Diff line number Diff line Loading @@ -115,15 +115,18 @@ import android.telephony.AccessNetworkConstants; import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; import android.telephony.CellIdentityTdscdma; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoTdscdma; import android.telephony.CellInfoWcdma; import android.telephony.CellSignalStrengthCdma; import android.telephony.CellSignalStrengthGsm; import android.telephony.CellSignalStrengthLte; import android.telephony.CellSignalStrengthTdscdma; import android.telephony.CellSignalStrengthWcdma; import android.telephony.SmsManager; import android.telephony.TelephonyManager; Loading Loading @@ -194,6 +197,8 @@ public class RILTest extends TelephonyTest { private static final int RSSNR = 2147483647; private static final int RSRP = 96; private static final int RSRQ = 10; private static final int RSCP = 94; private static final int ECNO = 5; private static final int SIGNAL_NOISE_RATIO = 6; private static final int SIGNAL_STRENGTH = 24; private static final int SYSTEM_ID = 65533; Loading @@ -205,6 +210,7 @@ public class RILTest extends TelephonyTest { private static final int TYPE_GSM = 1; private static final int TYPE_LTE = 3; private static final int TYPE_WCDMA = 4; private static final int TYPE_TD_SCDMA = 5; private static final int PROFILE_ID = 0; private static final String APN = "apn"; Loading Loading @@ -1184,13 +1190,55 @@ public class RILTest extends TelephonyTest { expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityWcdma ci = new CellIdentityWcdma( LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma( SIGNAL_STRENGTH, BIT_ERROR_RATE, Integer.MAX_VALUE, Integer.MAX_VALUE); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); expected.setCellConnectionStatus(CellInfo.CONNECTION_UNKNOWN); assertEquals(expected, cellInfoWcdma); } @Test public void testConvertHalCellInfoListForTdscdma() throws Exception { android.hardware.radio.V1_2.CellInfoTdscdma cellinfo = new android.hardware.radio.V1_2.CellInfoTdscdma(); cellinfo.cellIdentityTdscdma.base.lac = LAC; cellinfo.cellIdentityTdscdma.base.cid = CID; cellinfo.cellIdentityTdscdma.base.cpid = PSC; cellinfo.cellIdentityTdscdma.uarfcn = UARFCN; cellinfo.cellIdentityTdscdma.base.mcc = MCC_STR; cellinfo.cellIdentityTdscdma.base.mnc = MNC_STR; cellinfo.signalStrengthTdscdma.signalStrength = SIGNAL_STRENGTH; cellinfo.signalStrengthTdscdma.bitErrorRate = BIT_ERROR_RATE; cellinfo.signalStrengthTdscdma.rscp = RSCP; android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo(); record.cellInfoType = TYPE_TD_SCDMA; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.tdscdma.add(cellinfo); ArrayList<android.hardware.radio.V1_2.CellInfo> records = new ArrayList<android.hardware.radio.V1_2.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList_1_2(records); assertEquals(1, ret.size()); CellInfoTdscdma cellInfoTdscdma = (CellInfoTdscdma) ret.get(0); CellInfoTdscdma expected = new CellInfoTdscdma(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE); CellIdentityTdscdma ci = new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, PSC, UARFCN, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthTdscdma cs = new CellSignalStrengthTdscdma( SIGNAL_STRENGTH, BIT_ERROR_RATE, RSCP); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); assertEquals(expected, cellInfoTdscdma); } @Test public void testConvertHalCellInfoListForCdma() throws Exception { android.hardware.radio.V1_0.CellInfoCdma cellinfo = Loading Loading @@ -1375,7 +1423,8 @@ public class RILTest extends TelephonyTest { expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityWcdma ci = new CellIdentityWcdma( LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE, RSCP, ECNO); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE); Loading @@ -1395,7 +1444,8 @@ public class RILTest extends TelephonyTest { expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityWcdma ci = new CellIdentityWcdma( LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma( SIGNAL_STRENGTH, BIT_ERROR_RATE, RSCP, ECNO); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE); Loading @@ -1417,7 +1467,8 @@ public class RILTest extends TelephonyTest { expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityWcdma ci = new CellIdentityWcdma( LAC, CID, PSC, UARFCN, null, null, ALPHA_LONG, ALPHA_SHORT); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma( SIGNAL_STRENGTH, BIT_ERROR_RATE, RSCP, ECNO); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE); Loading Loading @@ -1540,8 +1591,8 @@ public class RILTest extends TelephonyTest { cellinfo.cellIdentityWcdma.operatorNames.alphaShort = alphaShort; cellinfo.signalStrengthWcdma.base.signalStrength = SIGNAL_STRENGTH; cellinfo.signalStrengthWcdma.base.bitErrorRate = BIT_ERROR_RATE; cellinfo.signalStrengthWcdma.rscp = 10; cellinfo.signalStrengthWcdma.ecno = 5; cellinfo.signalStrengthWcdma.rscp = RSCP; cellinfo.signalStrengthWcdma.ecno = ECNO; android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo(); record.cellInfoType = TYPE_WCDMA; record.registered = false; Loading Loading
src/java/com/android/internal/telephony/CellularNetworkService.java +3 −1 Original line number Diff line number Diff line Loading @@ -330,7 +330,8 @@ public class CellularNetworkService extends NetworkService { cellIdentity.cellIdentityTdscdma.get(0); result = new CellIdentityTdscdma(cellIdentityTdscdma.mcc, cellIdentityTdscdma.mnc, cellIdentityTdscdma.lac, cellIdentityTdscdma.cid, cellIdentityTdscdma.cpid); cellIdentityTdscdma.cid, cellIdentityTdscdma.cpid, Integer.MAX_VALUE, null, null); } break; } Loading Loading @@ -417,6 +418,7 @@ public class CellularNetworkService extends NetworkService { cellIdentityTdscdma.base.lac, cellIdentityTdscdma.base.cid, cellIdentityTdscdma.base.cpid, cellIdentityTdscdma.uarfcn, cellIdentityTdscdma.operatorNames.alphaLong, cellIdentityTdscdma.operatorNames.alphaShort); } Loading
src/java/com/android/internal/telephony/RIL.java +75 −12 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.hardware.radio.V1_0.CdmaSmsWriteArgs; import android.hardware.radio.V1_0.CellInfoCdma; import android.hardware.radio.V1_0.CellInfoGsm; import android.hardware.radio.V1_0.CellInfoLte; import android.hardware.radio.V1_0.CellInfoTdscdma; import android.hardware.radio.V1_0.CellInfoType; import android.hardware.radio.V1_0.CellInfoWcdma; import android.hardware.radio.V1_0.DataProfileInfo; Loading Loading @@ -5279,7 +5280,7 @@ public class RIL extends BaseCommands implements CommandsInterface { private static void writeToParcelForWcdma( Parcel p, int lac, int cid, int psc, int uarfcn, String mcc, String mnc, String al, String as, int ss, int ber) { String al, String as, int ss, int ber, int rscp, int ecno) { p.writeInt(CellIdentity.TYPE_WCDMA); p.writeString(mcc); p.writeString(mnc); Loading @@ -5291,6 +5292,25 @@ public class RIL extends BaseCommands implements CommandsInterface { p.writeInt(uarfcn); p.writeInt(ss); p.writeInt(ber); p.writeInt(rscp); p.writeInt(ecno); } private static void writeToParcelForTdscdma( Parcel p, int lac, int cid, int cpid, int uarfcn, String mcc, String mnc, String al, String as, int ss, int ber, int rscp) { p.writeInt(CellIdentity.TYPE_TDSCDMA); p.writeString(mcc); p.writeString(mnc); p.writeString(al); p.writeString(as); p.writeInt(lac); p.writeInt(cid); p.writeInt(cpid); p.writeInt(uarfcn); p.writeInt(ss); p.writeInt(ber); p.writeInt(rscp); } /** Loading Loading @@ -5384,10 +5404,29 @@ public class RIL extends BaseCommands implements CommandsInterface { EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT, cellInfoWcdma.signalStrengthWcdma.signalStrength, cellInfoWcdma.signalStrengthWcdma.bitErrorRate); cellInfoWcdma.signalStrengthWcdma.bitErrorRate, Integer.MAX_VALUE, Integer.MAX_VALUE); break; } case CellInfoType.TD_SCDMA: { CellInfoTdscdma cellInfoTdscdma = record.tdscdma.get(0); writeToParcelForTdscdma( p, cellInfoTdscdma.cellIdentityTdscdma.lac, cellInfoTdscdma.cellIdentityTdscdma.cid, cellInfoTdscdma.cellIdentityTdscdma.cpid, Integer.MAX_VALUE, cellInfoTdscdma.cellIdentityTdscdma.mcc, cellInfoTdscdma.cellIdentityTdscdma.mnc, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT, Integer.MAX_VALUE, Integer.MAX_VALUE, convertTdscdmaRscpTo1_2(cellInfoTdscdma.signalStrengthTdscdma.rscp)); break; } default: throw new RuntimeException("unexpected cellinfotype: " + record.cellInfoType); } Loading Loading @@ -5492,7 +5531,28 @@ public class RIL extends BaseCommands implements CommandsInterface { cellInfoWcdma.cellIdentityWcdma.operatorNames.alphaLong, cellInfoWcdma.cellIdentityWcdma.operatorNames.alphaShort, cellInfoWcdma.signalStrengthWcdma.base.signalStrength, cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate); cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate, cellInfoWcdma.signalStrengthWcdma.rscp, cellInfoWcdma.signalStrengthWcdma.ecno); break; } case CellInfoType.TD_SCDMA: { android.hardware.radio.V1_2.CellInfoTdscdma cellInfoTdscdma = record.tdscdma.get(0); writeToParcelForTdscdma( p, cellInfoTdscdma.cellIdentityTdscdma.base.lac, cellInfoTdscdma.cellIdentityTdscdma.base.cid, cellInfoTdscdma.cellIdentityTdscdma.base.cpid, cellInfoTdscdma.cellIdentityTdscdma.uarfcn, cellInfoTdscdma.cellIdentityTdscdma.base.mcc, cellInfoTdscdma.cellIdentityTdscdma.base.mnc, cellInfoTdscdma.cellIdentityTdscdma.operatorNames.alphaLong, cellInfoTdscdma.cellIdentityTdscdma.operatorNames.alphaShort, cellInfoTdscdma.signalStrengthTdscdma.signalStrength, cellInfoTdscdma.signalStrengthTdscdma.bitErrorRate, cellInfoTdscdma.signalStrengthTdscdma.rscp); break; } Loading @@ -5509,19 +5569,22 @@ public class RIL extends BaseCommands implements CommandsInterface { return response; } /** Convert HAL 1.0 Signal Strength to android SignalStrength */ @VisibleForTesting public static SignalStrength convertHalSignalStrength( android.hardware.radio.V1_0.SignalStrength signalStrength) { int tdscdmaRscp_1_2 = 255; // 255 is the value for unknown/unreported ASU. private static int convertTdscdmaRscpTo1_2(int rscp) { // The HAL 1.0 range is 25..120; the ASU/ HAL 1.2 range is 0..96; // yes, this means the range in 1.0 cannot express -24dBm = 96 if (signalStrength.tdScdma.rscp >= 25 && signalStrength.tdScdma.rscp <= 120) { if (rscp >= 25 && rscp <= 120) { // First we flip the sign to convert from the HALs -rscp to the actual RSCP value. int rscpDbm = -signalStrength.tdScdma.rscp; int rscpDbm = -rscp; // Then to convert from RSCP to ASU, we apply the offset which aligns 0 ASU to -120dBm. tdscdmaRscp_1_2 = rscpDbm + 120; return rscpDbm + 120; } return Integer.MAX_VALUE; } /** Convert HAL 1.0 Signal Strength to android SignalStrength */ @VisibleForTesting public static SignalStrength convertHalSignalStrength( android.hardware.radio.V1_0.SignalStrength signalStrength) { return new SignalStrength( signalStrength.gw.signalStrength, signalStrength.gw.bitErrorRate, Loading @@ -5535,7 +5598,7 @@ public class RIL extends BaseCommands implements CommandsInterface { signalStrength.lte.rsrq, signalStrength.lte.rssnr, signalStrength.lte.cqi, tdscdmaRscp_1_2); convertTdscdmaRscpTo1_2(signalStrength.tdScdma.rscp)); } /** Convert HAL 1.2 Signal Strength to android SignalStrength */ Loading
tests/telephonytests/src/com/android/internal/telephony/CellIdentityTdscdmaTest.java +19 −9 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { // Tracking area code ranges from 0 to 65535. private static final int TAC = 65535; // Absolute RF Channel Number ranges from 0 to 262140. private static final int EARFCN = 262140; private static final int UARFCN = 262140; private static final int MCC = 120; private static final int MNC = 260; private static final String MCC_STR = "120"; Loading @@ -52,33 +52,38 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testDefaultConstructor() { CellIdentityTdscdma ci = new CellIdentityTdscdma(MCC_STR, MNC_STR, LAC, CID, CPID); new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); assertEquals(MCC_STR, ci.getMccString()); assertEquals(MNC_STR, ci.getMncString()); assertEquals(LAC, ci.getLac()); assertEquals(CID, ci.getCid()); assertEquals(CPID, ci.getCpid()); assertEquals(UARFCN, ci.getChannelNumber()); assertEquals(ALPHA_LONG, ci.getOperatorAlphaLong()); assertEquals(ALPHA_SHORT, ci.getOperatorAlphaShort()); } @SmallTest public void testConstructorWithEmptyMccMnc() { CellIdentityTdscdma ci = new CellIdentityTdscdma(null, null, LAC, CID, CPID); CellIdentityTdscdma ci = new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, "", ""); assertNull(ci.getMccString()); assertNull(ci.getMncString()); ci = new CellIdentityTdscdma(MCC_STR, null, LAC, CID, CPID); ci = new CellIdentityTdscdma(MCC_STR, null, LAC, CID, CPID, UARFCN, "", ""); assertEquals(MCC_STR, ci.getMccString()); assertNull(ci.getMncString()); ci = new CellIdentityTdscdma(null, MNC_STR, LAC, CID, CPID); ci = new CellIdentityTdscdma(null, MNC_STR, LAC, CID, CPID, UARFCN, "", ""); assertEquals(MNC_STR, ci.getMncString()); assertNull(ci.getMccString()); ci = new CellIdentityTdscdma("", "", LAC, CID, CPID); ci = new CellIdentityTdscdma("", "", LAC, CID, CPID, UARFCN, "", ""); assertNull(ci.getMccString()); assertNull(ci.getMncString()); Loading @@ -86,7 +91,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testParcel() { CellIdentityTdscdma ci = new CellIdentityTdscdma(MCC_STR, MNC_STR, LAC, CID, CPID); CellIdentityTdscdma ci = new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, UARFCN, CPID, ALPHA_LONG, ALPHA_SHORT); Parcel p = Parcel.obtain(); ci.writeToParcel(p, 0); Loading @@ -99,7 +105,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityTdscdma ci = new CellIdentityTdscdma(null, null, LAC, CID, CPID, ALPHA_LONG, ALPHA_SHORT); new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); Parcel p = Parcel.obtain(); p.writeInt(CellIdentity.TYPE_TDSCDMA); Loading @@ -110,6 +117,7 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { p.writeInt(LAC); p.writeInt(CID); p.writeInt(CPID); p.writeInt(UARFCN); p.setDataPosition(0); CellIdentityTdscdma newCi = CellIdentityTdscdma.CREATOR.createFromParcel(p); Loading @@ -121,7 +129,8 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { final String invalidMcc = "randomStuff"; final String invalidMnc = "randomStuff"; CellIdentityTdscdma ci = new CellIdentityTdscdma(null, null, LAC, CID, CPID, ALPHA_LONG, ALPHA_SHORT); new CellIdentityTdscdma( null, null, LAC, CID, CPID, UARFCN, ALPHA_LONG, ALPHA_SHORT); Parcel p = Parcel.obtain(); p.writeInt(CellIdentity.TYPE_TDSCDMA); Loading @@ -132,6 +141,7 @@ public class CellIdentityTdscdmaTest extends AndroidTestCase { p.writeInt(LAC); p.writeInt(CID); p.writeInt(CPID); p.writeInt(UARFCN); p.setDataPosition(0); CellIdentityTdscdma newCi = CellIdentityTdscdma.CREATOR.createFromParcel(p); Loading
tests/telephonytests/src/com/android/internal/telephony/RILTest.java +57 −6 Original line number Diff line number Diff line Loading @@ -115,15 +115,18 @@ import android.telephony.AccessNetworkConstants; import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; import android.telephony.CellIdentityTdscdma; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoTdscdma; import android.telephony.CellInfoWcdma; import android.telephony.CellSignalStrengthCdma; import android.telephony.CellSignalStrengthGsm; import android.telephony.CellSignalStrengthLte; import android.telephony.CellSignalStrengthTdscdma; import android.telephony.CellSignalStrengthWcdma; import android.telephony.SmsManager; import android.telephony.TelephonyManager; Loading Loading @@ -194,6 +197,8 @@ public class RILTest extends TelephonyTest { private static final int RSSNR = 2147483647; private static final int RSRP = 96; private static final int RSRQ = 10; private static final int RSCP = 94; private static final int ECNO = 5; private static final int SIGNAL_NOISE_RATIO = 6; private static final int SIGNAL_STRENGTH = 24; private static final int SYSTEM_ID = 65533; Loading @@ -205,6 +210,7 @@ public class RILTest extends TelephonyTest { private static final int TYPE_GSM = 1; private static final int TYPE_LTE = 3; private static final int TYPE_WCDMA = 4; private static final int TYPE_TD_SCDMA = 5; private static final int PROFILE_ID = 0; private static final String APN = "apn"; Loading Loading @@ -1184,13 +1190,55 @@ public class RILTest extends TelephonyTest { expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityWcdma ci = new CellIdentityWcdma( LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma( SIGNAL_STRENGTH, BIT_ERROR_RATE, Integer.MAX_VALUE, Integer.MAX_VALUE); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); expected.setCellConnectionStatus(CellInfo.CONNECTION_UNKNOWN); assertEquals(expected, cellInfoWcdma); } @Test public void testConvertHalCellInfoListForTdscdma() throws Exception { android.hardware.radio.V1_2.CellInfoTdscdma cellinfo = new android.hardware.radio.V1_2.CellInfoTdscdma(); cellinfo.cellIdentityTdscdma.base.lac = LAC; cellinfo.cellIdentityTdscdma.base.cid = CID; cellinfo.cellIdentityTdscdma.base.cpid = PSC; cellinfo.cellIdentityTdscdma.uarfcn = UARFCN; cellinfo.cellIdentityTdscdma.base.mcc = MCC_STR; cellinfo.cellIdentityTdscdma.base.mnc = MNC_STR; cellinfo.signalStrengthTdscdma.signalStrength = SIGNAL_STRENGTH; cellinfo.signalStrengthTdscdma.bitErrorRate = BIT_ERROR_RATE; cellinfo.signalStrengthTdscdma.rscp = RSCP; android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo(); record.cellInfoType = TYPE_TD_SCDMA; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.tdscdma.add(cellinfo); ArrayList<android.hardware.radio.V1_2.CellInfo> records = new ArrayList<android.hardware.radio.V1_2.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList_1_2(records); assertEquals(1, ret.size()); CellInfoTdscdma cellInfoTdscdma = (CellInfoTdscdma) ret.get(0); CellInfoTdscdma expected = new CellInfoTdscdma(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE); CellIdentityTdscdma ci = new CellIdentityTdscdma( MCC_STR, MNC_STR, LAC, CID, PSC, UARFCN, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthTdscdma cs = new CellSignalStrengthTdscdma( SIGNAL_STRENGTH, BIT_ERROR_RATE, RSCP); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); assertEquals(expected, cellInfoTdscdma); } @Test public void testConvertHalCellInfoListForCdma() throws Exception { android.hardware.radio.V1_0.CellInfoCdma cellinfo = Loading Loading @@ -1375,7 +1423,8 @@ public class RILTest extends TelephonyTest { expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityWcdma ci = new CellIdentityWcdma( LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, ALPHA_LONG, ALPHA_SHORT); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE, RSCP, ECNO); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE); Loading @@ -1395,7 +1444,8 @@ public class RILTest extends TelephonyTest { expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityWcdma ci = new CellIdentityWcdma( LAC, CID, PSC, UARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma( SIGNAL_STRENGTH, BIT_ERROR_RATE, RSCP, ECNO); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE); Loading @@ -1417,7 +1467,8 @@ public class RILTest extends TelephonyTest { expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityWcdma ci = new CellIdentityWcdma( LAC, CID, PSC, UARFCN, null, null, ALPHA_LONG, ALPHA_SHORT); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma(SIGNAL_STRENGTH, BIT_ERROR_RATE); CellSignalStrengthWcdma cs = new CellSignalStrengthWcdma( SIGNAL_STRENGTH, BIT_ERROR_RATE, RSCP, ECNO); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE); Loading Loading @@ -1540,8 +1591,8 @@ public class RILTest extends TelephonyTest { cellinfo.cellIdentityWcdma.operatorNames.alphaShort = alphaShort; cellinfo.signalStrengthWcdma.base.signalStrength = SIGNAL_STRENGTH; cellinfo.signalStrengthWcdma.base.bitErrorRate = BIT_ERROR_RATE; cellinfo.signalStrengthWcdma.rscp = 10; cellinfo.signalStrengthWcdma.ecno = 5; cellinfo.signalStrengthWcdma.rscp = RSCP; cellinfo.signalStrengthWcdma.ecno = ECNO; android.hardware.radio.V1_2.CellInfo record = new android.hardware.radio.V1_2.CellInfo(); record.cellInfoType = TYPE_WCDMA; record.registered = false; Loading