Search in sources :

Example 46 with CellIdentityGsm

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);
}
Also used : CellInfo(android.telephony.CellInfo) CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityGsm(android.telephony.CellIdentityGsm) CellInfoGsm(android.telephony.CellInfoGsm) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 47 with CellIdentityGsm

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);
}
Also used : CellInfo(android.telephony.CellInfo) CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityGsm(android.telephony.CellIdentityGsm) CellInfoGsm(android.telephony.CellInfoGsm) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 48 with CellIdentityGsm

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());
}
Also used : CellIdentityGsm(android.telephony.CellIdentityGsm) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 49 with CellIdentityGsm

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!");
}
Also used : Message(android.os.Message) CellIdentityGsm(android.telephony.CellIdentityGsm) CellInfoGsm(android.telephony.CellInfoGsm) Before(org.junit.Before)

Example 50 with CellIdentityGsm

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);
}
Also used : CellIdentityCdma(android.telephony.CellIdentityCdma) CellIdentity(android.telephony.CellIdentity) CellIdentityGsm(android.telephony.CellIdentityGsm) WorkSource(android.os.WorkSource) FlakyTest(androidx.test.filters.FlakyTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

CellIdentityGsm (android.telephony.CellIdentityGsm)53 CellInfoGsm (android.telephony.CellInfoGsm)25 CellSignalStrengthGsm (android.telephony.CellSignalStrengthGsm)20 SmallTest (android.test.suitebuilder.annotation.SmallTest)19 CellIdentityCdma (android.telephony.CellIdentityCdma)16 CellIdentityLte (android.telephony.CellIdentityLte)16 CellInfo (android.telephony.CellInfo)16 CellIdentityWcdma (android.telephony.CellIdentityWcdma)14 CellInfoCdma (android.telephony.CellInfoCdma)14 CellInfoLte (android.telephony.CellInfoLte)13 Test (org.junit.Test)13 CellInfoWcdma (android.telephony.CellInfoWcdma)12 FlakyTest (androidx.test.filters.FlakyTest)11 CellSignalStrengthCdma (android.telephony.CellSignalStrengthCdma)6 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 PendingIntent (android.app.PendingIntent)5 Intent (android.content.Intent)5 WifiInfo (android.net.wifi.WifiInfo)5 Parcel (android.os.Parcel)4 CellIdentity (android.telephony.CellIdentity)4