Loading src/java/com/android/internal/telephony/RIL.java +23 −7 Original line number Diff line number Diff line Loading @@ -189,6 +189,9 @@ public class RIL extends BaseCommands implements CommandsInterface { static final int IRADIO_GET_SERVICE_DELAY_MILLIS = 4 * 1000; static final String EMPTY_ALPHA_LONG = ""; static final String EMPTY_ALPHA_SHORT = ""; public static List<TelephonyHistogram> getTelephonyRILTimingHistograms() { List<TelephonyHistogram> list; synchronized (mRilTimeHistograms) { Loading Loading @@ -4813,7 +4816,12 @@ public class RIL extends BaseCommands implements CommandsInterface { return capacityResponse; } static ArrayList<CellInfo> convertHalCellInfoList( /** * Convert CellInfo defined in 1.0/types.hal to CellInfo type. * @param records List of CellInfo defined in 1.0/types.hal * @return List of converted CellInfo object */ public static ArrayList<CellInfo> convertHalCellInfoList( ArrayList<android.hardware.radio.V1_0.CellInfo> records) { ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size()); Loading @@ -4827,12 +4835,14 @@ public class RIL extends BaseCommands implements CommandsInterface { switch (record.cellInfoType) { case CellInfoType.GSM: { CellInfoGsm cellInfoGsm = record.gsm.get(0); p.writeInt(Integer.parseInt(cellInfoGsm.cellIdentityGsm.mcc)); p.writeInt(Integer.parseInt(cellInfoGsm.cellIdentityGsm.mnc)); p.writeInt(cellInfoGsm.cellIdentityGsm.lac); p.writeInt(cellInfoGsm.cellIdentityGsm.cid); p.writeInt(cellInfoGsm.cellIdentityGsm.arfcn); p.writeInt(Byte.toUnsignedInt(cellInfoGsm.cellIdentityGsm.bsic)); p.writeString(cellInfoGsm.cellIdentityGsm.mcc); p.writeString(cellInfoGsm.cellIdentityGsm.mnc); p.writeString(EMPTY_ALPHA_LONG); p.writeString(EMPTY_ALPHA_SHORT); p.writeInt(cellInfoGsm.signalStrengthGsm.signalStrength); p.writeInt(cellInfoGsm.signalStrengthGsm.bitErrorRate); p.writeInt(cellInfoGsm.signalStrengthGsm.timingAdvance); Loading @@ -4846,6 +4856,8 @@ public class RIL extends BaseCommands implements CommandsInterface { p.writeInt(cellInfoCdma.cellIdentityCdma.baseStationId); p.writeInt(cellInfoCdma.cellIdentityCdma.longitude); p.writeInt(cellInfoCdma.cellIdentityCdma.latitude); p.writeString(EMPTY_ALPHA_LONG); p.writeString(EMPTY_ALPHA_SHORT); p.writeInt(cellInfoCdma.signalStrengthCdma.dbm); p.writeInt(cellInfoCdma.signalStrengthCdma.ecio); p.writeInt(cellInfoCdma.signalStrengthEvdo.dbm); Loading @@ -4856,12 +4868,14 @@ public class RIL extends BaseCommands implements CommandsInterface { case CellInfoType.LTE: { CellInfoLte cellInfoLte = record.lte.get(0); p.writeInt(Integer.parseInt(cellInfoLte.cellIdentityLte.mcc)); p.writeInt(Integer.parseInt(cellInfoLte.cellIdentityLte.mnc)); p.writeInt(cellInfoLte.cellIdentityLte.ci); p.writeInt(cellInfoLte.cellIdentityLte.pci); p.writeInt(cellInfoLte.cellIdentityLte.tac); p.writeInt(cellInfoLte.cellIdentityLte.earfcn); p.writeString(cellInfoLte.cellIdentityLte.mcc); p.writeString(cellInfoLte.cellIdentityLte.mnc); p.writeString(EMPTY_ALPHA_LONG); p.writeString(EMPTY_ALPHA_SHORT); p.writeInt(cellInfoLte.signalStrengthLte.signalStrength); p.writeInt(cellInfoLte.signalStrengthLte.rsrp); p.writeInt(cellInfoLte.signalStrengthLte.rsrq); Loading @@ -4873,12 +4887,14 @@ public class RIL extends BaseCommands implements CommandsInterface { case CellInfoType.WCDMA: { CellInfoWcdma cellInfoWcdma = record.wcdma.get(0); p.writeInt(Integer.parseInt(cellInfoWcdma.cellIdentityWcdma.mcc)); p.writeInt(Integer.parseInt(cellInfoWcdma.cellIdentityWcdma.mnc)); p.writeInt(cellInfoWcdma.cellIdentityWcdma.lac); p.writeInt(cellInfoWcdma.cellIdentityWcdma.cid); p.writeInt(cellInfoWcdma.cellIdentityWcdma.psc); p.writeInt(cellInfoWcdma.cellIdentityWcdma.uarfcn); p.writeString(cellInfoWcdma.cellIdentityWcdma.mcc); p.writeString(cellInfoWcdma.cellIdentityWcdma.mnc); p.writeString(EMPTY_ALPHA_LONG); p.writeString(EMPTY_ALPHA_SHORT); p.writeInt(cellInfoWcdma.signalStrengthWcdma.signalStrength); p.writeInt(cellInfoWcdma.signalStrengthWcdma.bitErrorRate); break; Loading tests/telephonytests/src/com/android/internal/telephony/CellIdentityGsmTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -172,4 +172,21 @@ public class CellIdentityGsmTest extends AndroidTestCase { CellIdentityGsm newCi = CellIdentityGsm.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, null, null); Parcel p = Parcel.obtain(); p.writeInt(LAC); p.writeInt(CID); p.writeInt(ARFCN); p.writeInt(BSIC); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.setDataPosition(0); CellIdentityGsm newCi = CellIdentityGsm.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } } tests/telephonytests/src/com/android/internal/telephony/CellIdentityLteTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -168,4 +168,21 @@ public class CellIdentityLteTest extends AndroidTestCase { CellIdentityLte newCi = CellIdentityLte.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, null, null, null, null); Parcel p = Parcel.obtain(); p.writeInt(CI); p.writeInt(PCI); p.writeInt(TAC); p.writeInt(EARFCN); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.setDataPosition(0); CellIdentityLte newCi = CellIdentityLte.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } } tests/telephonytests/src/com/android/internal/telephony/CellIdentityWcdmaTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -167,4 +167,21 @@ public class CellIdentityWcdmaTest extends AndroidTestCase { CellIdentityWcdma newCi = CellIdentityWcdma.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityWcdma ci = new CellIdentityWcdma(LAC, CID, PSC, UARFCN, null, null, null, null); Parcel p = Parcel.obtain(); p.writeInt(LAC); p.writeInt(CID); p.writeInt(PSC); p.writeInt(UARFCN); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.setDataPosition(0); CellIdentityWcdma newCi = CellIdentityWcdma.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } } tests/telephonytests/src/com/android/internal/telephony/RILTest.java +216 −1 Original line number Diff line number Diff line Loading @@ -106,6 +106,19 @@ import android.os.IPowerManager; import android.os.Message; import android.os.PowerManager; import android.os.WorkSource; import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoWcdma; import android.telephony.CellSignalStrengthCdma; import android.telephony.CellSignalStrengthGsm; import android.telephony.CellSignalStrengthLte; import android.telephony.CellSignalStrengthWcdma; import android.telephony.SmsManager; import android.telephony.TelephonyManager; Loading @@ -123,7 +136,6 @@ import org.mockito.MockitoAnnotations; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; public class RILTest extends TelephonyTest { Loading @@ -144,6 +156,47 @@ public class RILTest extends TelephonyTest { private RILTestHandler mTestHandler; ArgumentCaptor<Integer> mSerialNumberCaptor = ArgumentCaptor.forClass(Integer.class); // Constants private static final String ALPHA_LONG = "long"; private static final String ALPHA_SHORT = "short"; private static final int ARFCN = 690; private static final int BASESTATION_ID = 65531; private static final int BIT_ERROR_RATE = 99; private static final int BSIC = 8; private static final int CI = 268435456; private static final int CID = 65535; private static final int CQI = 2147483647; private static final int DBM = 74; private static final int EARFCN = 262140; private static final int ECIO = 124; private static final String EMPTY_ALPHA_LONG = ""; private static final String EMPTY_ALPHA_SHORT = ""; private static final int LAC = 65535; private static final int LATITUDE = 1292000; private static final int LONGITUDE = 1295000; private static final int MCC = 120; private static final String MCC_STR = "120"; private static final int MNC = 260; private static final String MNC_STR = "260"; private static final int NETWORK_ID = 65534; private static final int PCI = 503; private static final int PSC = 500; private static final int RIL_TIMESTAMP_TYPE_OEM_RIL = 3; private static final int RSSNR = 2147483647; private static final int RSRP = 96; private static final int RSRQ = 10; private static final int SIGNAL_NOICE_RATIO = 6; private static final int SIGNAL_STRENGTH = 24; private static final int SYSTEM_ID = 65533; private static final int TAC = 65535; private static final int TIME_ADVANCE = 4; private static final long TIMESTAMP = 215924934; private static final int UARFCN = 690; private static final int TYPE_CDMA = 2; private static final int TYPE_GSM = 1; private static final int TYPE_LTE = 3; private static final int TYPE_WCDMA = 4; private class RILTestHandler extends HandlerThread { RILTestHandler(String name) { Loading Loading @@ -852,4 +905,166 @@ public class RILTest extends TelephonyTest { respInfo.type = type; return respInfo; } @Test public void testConvertHalCellInfoListForLTE() throws Exception { android.hardware.radio.V1_0.CellInfoLte lte = new android.hardware.radio.V1_0.CellInfoLte(); lte.cellIdentityLte.ci = CI; lte.cellIdentityLte.pci = PCI; lte.cellIdentityLte.tac = TAC; lte.cellIdentityLte.earfcn = EARFCN; lte.cellIdentityLte.mcc = MCC_STR; lte.cellIdentityLte.mnc = MNC_STR; lte.signalStrengthLte.signalStrength = SIGNAL_STRENGTH; lte.signalStrengthLte.rsrp = RSRP; lte.signalStrengthLte.rsrq = RSRQ; lte.signalStrengthLte.rssnr = RSSNR; lte.signalStrengthLte.cqi = CQI; lte.signalStrengthLte.timingAdvance = TIME_ADVANCE; android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo(); record.cellInfoType = TYPE_LTE; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.lte.add(lte); ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records); assertEquals(1, ret.size()); CellInfoLte cellInfoLte = (CellInfoLte) ret.get(0); CellInfoLte expected = new CellInfoLte(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityLte cil = new CellIdentityLte( CI, PCI, TAC, EARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthLte css = new CellSignalStrengthLte( SIGNAL_STRENGTH, -RSRP, -RSRQ, RSSNR, CQI, TIME_ADVANCE); expected.setCellIdentity(cil); expected.setCellSignalStrength(css); assertEquals(expected, cellInfoLte); } @Test public void testConvertHalCellInfoListForGSM() throws Exception { android.hardware.radio.V1_0.CellInfoGsm cellinfo = new android.hardware.radio.V1_0.CellInfoGsm(); cellinfo.cellIdentityGsm.lac = LAC; cellinfo.cellIdentityGsm.cid = CID; cellinfo.cellIdentityGsm.bsic = BSIC; cellinfo.cellIdentityGsm.arfcn = ARFCN; cellinfo.cellIdentityGsm.mcc = MCC_STR; cellinfo.cellIdentityGsm.mnc = MNC_STR; cellinfo.signalStrengthGsm.signalStrength = SIGNAL_STRENGTH; cellinfo.signalStrengthGsm.bitErrorRate = BIT_ERROR_RATE; cellinfo.signalStrengthGsm.timingAdvance = TIME_ADVANCE; android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo(); record.cellInfoType = TYPE_GSM; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.gsm.add(cellinfo); ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records); assertEquals(1, ret.size()); CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0); CellInfoGsm expected = new CellInfoGsm(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityGsm ci = new CellIdentityGsm( LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthGsm cs = new CellSignalStrengthGsm(); cs.initialize(SIGNAL_STRENGTH, BIT_ERROR_RATE, TIME_ADVANCE); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); assertEquals(expected, cellInfoGsm); } @Test public void testConvertHalCellInfoListForWcdma() throws Exception { android.hardware.radio.V1_0.CellInfoWcdma cellinfo = new android.hardware.radio.V1_0.CellInfoWcdma(); cellinfo.cellIdentityWcdma.lac = LAC; cellinfo.cellIdentityWcdma.cid = CID; cellinfo.cellIdentityWcdma.psc = PSC; cellinfo.cellIdentityWcdma.uarfcn = UARFCN; cellinfo.cellIdentityWcdma.mcc = MCC_STR; cellinfo.cellIdentityWcdma.mnc = MNC_STR; cellinfo.signalStrengthWcdma.signalStrength = SIGNAL_STRENGTH; cellinfo.signalStrengthWcdma.bitErrorRate = BIT_ERROR_RATE; android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo(); record.cellInfoType = TYPE_WCDMA; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.wcdma.add(cellinfo); ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records); assertEquals(1, ret.size()); CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ret.get(0); CellInfoWcdma expected = new CellInfoWcdma(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); 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); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); assertEquals(expected, cellInfoWcdma); } @Test public void testConvertHalCellInfoListForCdma() throws Exception { android.hardware.radio.V1_0.CellInfoCdma cellinfo = new android.hardware.radio.V1_0.CellInfoCdma(); cellinfo.cellIdentityCdma.networkId = NETWORK_ID; cellinfo.cellIdentityCdma.systemId = SYSTEM_ID; cellinfo.cellIdentityCdma.baseStationId = BASESTATION_ID; cellinfo.cellIdentityCdma.longitude = LONGITUDE; cellinfo.cellIdentityCdma.latitude = LATITUDE; cellinfo.signalStrengthCdma.dbm = DBM; cellinfo.signalStrengthCdma.ecio = ECIO; cellinfo.signalStrengthEvdo.dbm = DBM; cellinfo.signalStrengthEvdo.ecio = ECIO; cellinfo.signalStrengthEvdo.signalNoiseRatio = SIGNAL_NOICE_RATIO; android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo(); record.cellInfoType = TYPE_CDMA; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.cdma.add(cellinfo); ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records); assertEquals(1, ret.size()); CellInfoCdma cellInfoCdma = (CellInfoCdma) ret.get(0); CellInfoCdma expected = new CellInfoCdma(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityCdma ci = new CellIdentityCdma( NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthCdma cs = new CellSignalStrengthCdma( -DBM, -ECIO, -DBM, -ECIO, SIGNAL_NOICE_RATIO); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); assertEquals(expected, cellInfoCdma); } } Loading
src/java/com/android/internal/telephony/RIL.java +23 −7 Original line number Diff line number Diff line Loading @@ -189,6 +189,9 @@ public class RIL extends BaseCommands implements CommandsInterface { static final int IRADIO_GET_SERVICE_DELAY_MILLIS = 4 * 1000; static final String EMPTY_ALPHA_LONG = ""; static final String EMPTY_ALPHA_SHORT = ""; public static List<TelephonyHistogram> getTelephonyRILTimingHistograms() { List<TelephonyHistogram> list; synchronized (mRilTimeHistograms) { Loading Loading @@ -4813,7 +4816,12 @@ public class RIL extends BaseCommands implements CommandsInterface { return capacityResponse; } static ArrayList<CellInfo> convertHalCellInfoList( /** * Convert CellInfo defined in 1.0/types.hal to CellInfo type. * @param records List of CellInfo defined in 1.0/types.hal * @return List of converted CellInfo object */ public static ArrayList<CellInfo> convertHalCellInfoList( ArrayList<android.hardware.radio.V1_0.CellInfo> records) { ArrayList<CellInfo> response = new ArrayList<CellInfo>(records.size()); Loading @@ -4827,12 +4835,14 @@ public class RIL extends BaseCommands implements CommandsInterface { switch (record.cellInfoType) { case CellInfoType.GSM: { CellInfoGsm cellInfoGsm = record.gsm.get(0); p.writeInt(Integer.parseInt(cellInfoGsm.cellIdentityGsm.mcc)); p.writeInt(Integer.parseInt(cellInfoGsm.cellIdentityGsm.mnc)); p.writeInt(cellInfoGsm.cellIdentityGsm.lac); p.writeInt(cellInfoGsm.cellIdentityGsm.cid); p.writeInt(cellInfoGsm.cellIdentityGsm.arfcn); p.writeInt(Byte.toUnsignedInt(cellInfoGsm.cellIdentityGsm.bsic)); p.writeString(cellInfoGsm.cellIdentityGsm.mcc); p.writeString(cellInfoGsm.cellIdentityGsm.mnc); p.writeString(EMPTY_ALPHA_LONG); p.writeString(EMPTY_ALPHA_SHORT); p.writeInt(cellInfoGsm.signalStrengthGsm.signalStrength); p.writeInt(cellInfoGsm.signalStrengthGsm.bitErrorRate); p.writeInt(cellInfoGsm.signalStrengthGsm.timingAdvance); Loading @@ -4846,6 +4856,8 @@ public class RIL extends BaseCommands implements CommandsInterface { p.writeInt(cellInfoCdma.cellIdentityCdma.baseStationId); p.writeInt(cellInfoCdma.cellIdentityCdma.longitude); p.writeInt(cellInfoCdma.cellIdentityCdma.latitude); p.writeString(EMPTY_ALPHA_LONG); p.writeString(EMPTY_ALPHA_SHORT); p.writeInt(cellInfoCdma.signalStrengthCdma.dbm); p.writeInt(cellInfoCdma.signalStrengthCdma.ecio); p.writeInt(cellInfoCdma.signalStrengthEvdo.dbm); Loading @@ -4856,12 +4868,14 @@ public class RIL extends BaseCommands implements CommandsInterface { case CellInfoType.LTE: { CellInfoLte cellInfoLte = record.lte.get(0); p.writeInt(Integer.parseInt(cellInfoLte.cellIdentityLte.mcc)); p.writeInt(Integer.parseInt(cellInfoLte.cellIdentityLte.mnc)); p.writeInt(cellInfoLte.cellIdentityLte.ci); p.writeInt(cellInfoLte.cellIdentityLte.pci); p.writeInt(cellInfoLte.cellIdentityLte.tac); p.writeInt(cellInfoLte.cellIdentityLte.earfcn); p.writeString(cellInfoLte.cellIdentityLte.mcc); p.writeString(cellInfoLte.cellIdentityLte.mnc); p.writeString(EMPTY_ALPHA_LONG); p.writeString(EMPTY_ALPHA_SHORT); p.writeInt(cellInfoLte.signalStrengthLte.signalStrength); p.writeInt(cellInfoLte.signalStrengthLte.rsrp); p.writeInt(cellInfoLte.signalStrengthLte.rsrq); Loading @@ -4873,12 +4887,14 @@ public class RIL extends BaseCommands implements CommandsInterface { case CellInfoType.WCDMA: { CellInfoWcdma cellInfoWcdma = record.wcdma.get(0); p.writeInt(Integer.parseInt(cellInfoWcdma.cellIdentityWcdma.mcc)); p.writeInt(Integer.parseInt(cellInfoWcdma.cellIdentityWcdma.mnc)); p.writeInt(cellInfoWcdma.cellIdentityWcdma.lac); p.writeInt(cellInfoWcdma.cellIdentityWcdma.cid); p.writeInt(cellInfoWcdma.cellIdentityWcdma.psc); p.writeInt(cellInfoWcdma.cellIdentityWcdma.uarfcn); p.writeString(cellInfoWcdma.cellIdentityWcdma.mcc); p.writeString(cellInfoWcdma.cellIdentityWcdma.mnc); p.writeString(EMPTY_ALPHA_LONG); p.writeString(EMPTY_ALPHA_SHORT); p.writeInt(cellInfoWcdma.signalStrengthWcdma.signalStrength); p.writeInt(cellInfoWcdma.signalStrengthWcdma.bitErrorRate); break; Loading
tests/telephonytests/src/com/android/internal/telephony/CellIdentityGsmTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -172,4 +172,21 @@ public class CellIdentityGsmTest extends AndroidTestCase { CellIdentityGsm newCi = CellIdentityGsm.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, null, null); Parcel p = Parcel.obtain(); p.writeInt(LAC); p.writeInt(CID); p.writeInt(ARFCN); p.writeInt(BSIC); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.setDataPosition(0); CellIdentityGsm newCi = CellIdentityGsm.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } }
tests/telephonytests/src/com/android/internal/telephony/CellIdentityLteTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -168,4 +168,21 @@ public class CellIdentityLteTest extends AndroidTestCase { CellIdentityLte newCi = CellIdentityLte.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityLte ci = new CellIdentityLte(CI, PCI, TAC, EARFCN, null, null, null, null); Parcel p = Parcel.obtain(); p.writeInt(CI); p.writeInt(PCI); p.writeInt(TAC); p.writeInt(EARFCN); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.setDataPosition(0); CellIdentityLte newCi = CellIdentityLte.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } }
tests/telephonytests/src/com/android/internal/telephony/CellIdentityWcdmaTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -167,4 +167,21 @@ public class CellIdentityWcdmaTest extends AndroidTestCase { CellIdentityWcdma newCi = CellIdentityWcdma.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } @SmallTest public void testParcelWithUnknowMccMnc() { CellIdentityWcdma ci = new CellIdentityWcdma(LAC, CID, PSC, UARFCN, null, null, null, null); Parcel p = Parcel.obtain(); p.writeInt(LAC); p.writeInt(CID); p.writeInt(PSC); p.writeInt(UARFCN); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.writeString(String.valueOf(Integer.MAX_VALUE)); p.setDataPosition(0); CellIdentityWcdma newCi = CellIdentityWcdma.CREATOR.createFromParcel(p); assertEquals(ci, newCi); } }
tests/telephonytests/src/com/android/internal/telephony/RILTest.java +216 −1 Original line number Diff line number Diff line Loading @@ -106,6 +106,19 @@ import android.os.IPowerManager; import android.os.Message; import android.os.PowerManager; import android.os.WorkSource; import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoWcdma; import android.telephony.CellSignalStrengthCdma; import android.telephony.CellSignalStrengthGsm; import android.telephony.CellSignalStrengthLte; import android.telephony.CellSignalStrengthWcdma; import android.telephony.SmsManager; import android.telephony.TelephonyManager; Loading @@ -123,7 +136,6 @@ import org.mockito.MockitoAnnotations; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; public class RILTest extends TelephonyTest { Loading @@ -144,6 +156,47 @@ public class RILTest extends TelephonyTest { private RILTestHandler mTestHandler; ArgumentCaptor<Integer> mSerialNumberCaptor = ArgumentCaptor.forClass(Integer.class); // Constants private static final String ALPHA_LONG = "long"; private static final String ALPHA_SHORT = "short"; private static final int ARFCN = 690; private static final int BASESTATION_ID = 65531; private static final int BIT_ERROR_RATE = 99; private static final int BSIC = 8; private static final int CI = 268435456; private static final int CID = 65535; private static final int CQI = 2147483647; private static final int DBM = 74; private static final int EARFCN = 262140; private static final int ECIO = 124; private static final String EMPTY_ALPHA_LONG = ""; private static final String EMPTY_ALPHA_SHORT = ""; private static final int LAC = 65535; private static final int LATITUDE = 1292000; private static final int LONGITUDE = 1295000; private static final int MCC = 120; private static final String MCC_STR = "120"; private static final int MNC = 260; private static final String MNC_STR = "260"; private static final int NETWORK_ID = 65534; private static final int PCI = 503; private static final int PSC = 500; private static final int RIL_TIMESTAMP_TYPE_OEM_RIL = 3; private static final int RSSNR = 2147483647; private static final int RSRP = 96; private static final int RSRQ = 10; private static final int SIGNAL_NOICE_RATIO = 6; private static final int SIGNAL_STRENGTH = 24; private static final int SYSTEM_ID = 65533; private static final int TAC = 65535; private static final int TIME_ADVANCE = 4; private static final long TIMESTAMP = 215924934; private static final int UARFCN = 690; private static final int TYPE_CDMA = 2; private static final int TYPE_GSM = 1; private static final int TYPE_LTE = 3; private static final int TYPE_WCDMA = 4; private class RILTestHandler extends HandlerThread { RILTestHandler(String name) { Loading Loading @@ -852,4 +905,166 @@ public class RILTest extends TelephonyTest { respInfo.type = type; return respInfo; } @Test public void testConvertHalCellInfoListForLTE() throws Exception { android.hardware.radio.V1_0.CellInfoLte lte = new android.hardware.radio.V1_0.CellInfoLte(); lte.cellIdentityLte.ci = CI; lte.cellIdentityLte.pci = PCI; lte.cellIdentityLte.tac = TAC; lte.cellIdentityLte.earfcn = EARFCN; lte.cellIdentityLte.mcc = MCC_STR; lte.cellIdentityLte.mnc = MNC_STR; lte.signalStrengthLte.signalStrength = SIGNAL_STRENGTH; lte.signalStrengthLte.rsrp = RSRP; lte.signalStrengthLte.rsrq = RSRQ; lte.signalStrengthLte.rssnr = RSSNR; lte.signalStrengthLte.cqi = CQI; lte.signalStrengthLte.timingAdvance = TIME_ADVANCE; android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo(); record.cellInfoType = TYPE_LTE; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.lte.add(lte); ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records); assertEquals(1, ret.size()); CellInfoLte cellInfoLte = (CellInfoLte) ret.get(0); CellInfoLte expected = new CellInfoLte(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityLte cil = new CellIdentityLte( CI, PCI, TAC, EARFCN, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthLte css = new CellSignalStrengthLte( SIGNAL_STRENGTH, -RSRP, -RSRQ, RSSNR, CQI, TIME_ADVANCE); expected.setCellIdentity(cil); expected.setCellSignalStrength(css); assertEquals(expected, cellInfoLte); } @Test public void testConvertHalCellInfoListForGSM() throws Exception { android.hardware.radio.V1_0.CellInfoGsm cellinfo = new android.hardware.radio.V1_0.CellInfoGsm(); cellinfo.cellIdentityGsm.lac = LAC; cellinfo.cellIdentityGsm.cid = CID; cellinfo.cellIdentityGsm.bsic = BSIC; cellinfo.cellIdentityGsm.arfcn = ARFCN; cellinfo.cellIdentityGsm.mcc = MCC_STR; cellinfo.cellIdentityGsm.mnc = MNC_STR; cellinfo.signalStrengthGsm.signalStrength = SIGNAL_STRENGTH; cellinfo.signalStrengthGsm.bitErrorRate = BIT_ERROR_RATE; cellinfo.signalStrengthGsm.timingAdvance = TIME_ADVANCE; android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo(); record.cellInfoType = TYPE_GSM; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.gsm.add(cellinfo); ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records); assertEquals(1, ret.size()); CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0); CellInfoGsm expected = new CellInfoGsm(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityGsm ci = new CellIdentityGsm( LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthGsm cs = new CellSignalStrengthGsm(); cs.initialize(SIGNAL_STRENGTH, BIT_ERROR_RATE, TIME_ADVANCE); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); assertEquals(expected, cellInfoGsm); } @Test public void testConvertHalCellInfoListForWcdma() throws Exception { android.hardware.radio.V1_0.CellInfoWcdma cellinfo = new android.hardware.radio.V1_0.CellInfoWcdma(); cellinfo.cellIdentityWcdma.lac = LAC; cellinfo.cellIdentityWcdma.cid = CID; cellinfo.cellIdentityWcdma.psc = PSC; cellinfo.cellIdentityWcdma.uarfcn = UARFCN; cellinfo.cellIdentityWcdma.mcc = MCC_STR; cellinfo.cellIdentityWcdma.mnc = MNC_STR; cellinfo.signalStrengthWcdma.signalStrength = SIGNAL_STRENGTH; cellinfo.signalStrengthWcdma.bitErrorRate = BIT_ERROR_RATE; android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo(); record.cellInfoType = TYPE_WCDMA; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.wcdma.add(cellinfo); ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records); assertEquals(1, ret.size()); CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ret.get(0); CellInfoWcdma expected = new CellInfoWcdma(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); 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); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); assertEquals(expected, cellInfoWcdma); } @Test public void testConvertHalCellInfoListForCdma() throws Exception { android.hardware.radio.V1_0.CellInfoCdma cellinfo = new android.hardware.radio.V1_0.CellInfoCdma(); cellinfo.cellIdentityCdma.networkId = NETWORK_ID; cellinfo.cellIdentityCdma.systemId = SYSTEM_ID; cellinfo.cellIdentityCdma.baseStationId = BASESTATION_ID; cellinfo.cellIdentityCdma.longitude = LONGITUDE; cellinfo.cellIdentityCdma.latitude = LATITUDE; cellinfo.signalStrengthCdma.dbm = DBM; cellinfo.signalStrengthCdma.ecio = ECIO; cellinfo.signalStrengthEvdo.dbm = DBM; cellinfo.signalStrengthEvdo.ecio = ECIO; cellinfo.signalStrengthEvdo.signalNoiseRatio = SIGNAL_NOICE_RATIO; android.hardware.radio.V1_0.CellInfo record = new android.hardware.radio.V1_0.CellInfo(); record.cellInfoType = TYPE_CDMA; record.registered = false; record.timeStampType = RIL_TIMESTAMP_TYPE_OEM_RIL; record.timeStamp = TIMESTAMP; record.cdma.add(cellinfo); ArrayList<android.hardware.radio.V1_0.CellInfo> records = new ArrayList<android.hardware.radio.V1_0.CellInfo>(); records.add(record); ArrayList<CellInfo> ret = RIL.convertHalCellInfoList(records); assertEquals(1, ret.size()); CellInfoCdma cellInfoCdma = (CellInfoCdma) ret.get(0); CellInfoCdma expected = new CellInfoCdma(); expected.setRegistered(false); expected.setTimeStamp(TIMESTAMP); expected.setTimeStampType(RIL_TIMESTAMP_TYPE_OEM_RIL); CellIdentityCdma ci = new CellIdentityCdma( NETWORK_ID, SYSTEM_ID, BASESTATION_ID, LONGITUDE, LATITUDE, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT); CellSignalStrengthCdma cs = new CellSignalStrengthCdma( -DBM, -ECIO, -DBM, -ECIO, SIGNAL_NOICE_RATIO); expected.setCellIdentity(ci); expected.setCellSignalStrength(cs); assertEquals(expected, cellInfoCdma); } }