use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.
the class RILTest method testConvertHalCellInfoList_1_2ForGSMWithEmptyMccMnc.
@Test
public void testConvertHalCellInfoList_1_2ForGSMWithEmptyMccMnc() {
// MCC/MNC will be set as INT_MAX if unknown
ArrayList<CellInfo> ret = getCellInfoListForGSM(String.valueOf(Integer.MAX_VALUE), String.valueOf(Integer.MAX_VALUE), ALPHA_LONG, ALPHA_SHORT);
assertEquals(1, ret.size());
CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0);
CellInfoGsm expected = new CellInfoGsm();
expected.setRegistered(false);
expected.setTimeStamp(TIMESTAMP);
CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, null, null, ALPHA_LONG, ALPHA_SHORT, Collections.emptyList());
CellSignalStrengthGsm cs = new CellSignalStrengthGsm(RSSI, BIT_ERROR_RATE, TIMING_ADVANCE);
expected.setCellIdentity(ci);
expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
expected.setCellSignalStrength(cs);
// override the timestamp
cellInfoGsm.setTimeStamp(TIMESTAMP);
assertEquals(expected, cellInfoGsm);
}
use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.
the class RILTest method testConvertHalCellInfoList_1_2ForGSMWithEmptyOperatorInfo.
@Test
public void testConvertHalCellInfoList_1_2ForGSMWithEmptyOperatorInfo() {
ArrayList<CellInfo> ret = getCellInfoListForGSM(MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT);
assertEquals(1, ret.size());
CellInfoGsm cellInfoGsm = (CellInfoGsm) ret.get(0);
CellInfoGsm expected = new CellInfoGsm();
expected.setRegistered(false);
expected.setTimeStamp(TIMESTAMP);
CellIdentityGsm ci = new CellIdentityGsm(LAC, CID, ARFCN, BSIC, MCC_STR, MNC_STR, EMPTY_ALPHA_LONG, EMPTY_ALPHA_SHORT, Collections.emptyList());
CellSignalStrengthGsm cs = new CellSignalStrengthGsm(RSSI, BIT_ERROR_RATE, TIMING_ADVANCE);
expected.setCellIdentity(ci);
expected.setCellSignalStrength(cs);
expected.setCellConnectionStatus(CellInfo.CONNECTION_NONE);
// override the timestamp
cellInfoGsm.setTimeStamp(TIMESTAMP);
assertEquals(expected, cellInfoGsm);
}
use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.
the class DefaultPhoneNotifierTest method testNotifyCellLocation.
@Test
@SmallTest
public void testNotifyCellLocation() throws Exception {
// mock gsm cell location
CellIdentityGsm mGsmCellLocation = new CellIdentityGsm(2, 3, 0, 0, null, null, null, null, Collections.emptyList());
doReturn(mGsmCellLocation).when(mPhone).getCellIdentity();
ArgumentCaptor<CellIdentityGsm> cellLocationCapture = ArgumentCaptor.forClass(CellIdentityGsm.class);
mDefaultPhoneNotifierUT.notifyCellLocation(mPhone, mGsmCellLocation);
verify(mTelephonyRegistryManager).notifyCellLocation(eq(0), cellLocationCapture.capture());
assertEquals(2, cellLocationCapture.getValue().asCellLocation().getLac());
assertEquals(3, cellLocationCapture.getValue().asCellLocation().getCid());
assertEquals(-1, cellLocationCapture.getValue().asCellLocation().getPsc());
doReturn(1).when(mPhone).getSubId();
mDefaultPhoneNotifierUT.notifyCellLocation(mPhone, mGsmCellLocation);
verify(mTelephonyRegistryManager).notifyCellLocation(eq(1), cellLocationCapture.capture());
assertEquals(2, cellLocationCapture.getValue().asCellLocation().getLac());
assertEquals(3, cellLocationCapture.getValue().asCellLocation().getCid());
assertEquals(-1, cellLocationCapture.getValue().asCellLocation().getPsc());
}
use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.
the class LocaleTrackerTest method setUp.
@Before
public void setUp() throws Exception {
logd("LocaleTrackerTest +Setup!");
super.setUp(getClass().getSimpleName());
mLocaleTracker = new LocaleTracker(mPhone, mNitzStateMachine, Looper.myLooper());
// This is a workaround to bypass setting system properties, which causes access violation.
doReturn(-1).when(mPhone).getPhoneId();
mCellInfo = new CellInfoGsm();
mCellInfo.setCellIdentity(new CellIdentityGsm(CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, CellInfo.UNAVAILABLE, US_MCC, FAKE_MNC, null, null, Collections.emptyList()));
doAnswer(invocation -> {
Message m = invocation.getArgument(1);
AsyncResult.forMessage(m, Arrays.asList(mCellInfo), null);
m.sendToTarget();
return null;
}).when(mPhone).requestCellInfoUpdate(any(), any());
processAllMessages();
logd("LocaleTrackerTest -Setup!");
}
use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.
the class GsmCdmaPhoneTest method testGetCellLocation.
@Test
@SmallTest
public void testGetCellLocation() {
// GSM
CellIdentity cellLocation = new CellIdentityGsm();
WorkSource workSource = new WorkSource(Process.myUid(), mContext.getPackageName());
doReturn(cellLocation).when(mSST).getCellIdentity();
assertEquals(cellLocation, mPhoneUT.getCellIdentity());
// Switch to CDMA
switchToCdma();
CellIdentityCdma cdmaCellLocation = new CellIdentityCdma();
doReturn(cdmaCellLocation).when(mSST).getCellIdentity();
CellIdentityCdma actualCellLocation = (CellIdentityCdma) mPhoneUT.getCellIdentity();
assertEquals(actualCellLocation, cdmaCellLocation);
}
Aggregations