Search in sources :

Example 26 with CellIdentityGsm

use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.

the class ServiceStateTrackerTest method testGsmCellLocation.

@Test
@MediumTest
public // TODO(nharold): we probably should remove support for this procedure (GET_LOC)
void testGsmCellLocation() {
    CellIdentityGsm cellIdentityGsm = new CellIdentityGsm(2, 3, 900, 5, "001", "01", "test", "tst", Collections.emptyList());
    NetworkRegistrationInfo result = new NetworkRegistrationInfo.Builder().setDomain(NetworkRegistrationInfo.DOMAIN_CS).setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN).setRegistrationState(NetworkRegistrationInfo.REGISTRATION_STATE_HOME).setCellIdentity(cellIdentityGsm).setRegisteredPlmn("00101").build();
    sst.sendMessage(sst.obtainMessage(ServiceStateTracker.EVENT_GET_LOC_DONE, new AsyncResult(null, result, null)));
    waitForLastHandlerAction(mSSTTestHandler.getThreadHandler());
    WorkSource workSource = new WorkSource(Process.myUid(), mContext.getPackageName());
    GsmCellLocation cl = (GsmCellLocation) sst.getCellIdentity().asCellLocation();
    assertEquals(2, cl.getLac());
    assertEquals(3, cl.getCid());
}
Also used : NetworkRegistrationInfo(android.telephony.NetworkRegistrationInfo) CellIdentityGsm(android.telephony.CellIdentityGsm) WorkSource(android.os.WorkSource) GsmCellLocation(android.telephony.gsm.GsmCellLocation) AsyncResult(android.os.AsyncResult) FlakyTest(androidx.test.filters.FlakyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 27 with CellIdentityGsm

use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.

the class ServiceStateTrackerTest method testRatRatchet.

// Edge and GPRS are grouped under the same family and Edge has higher rate than GPRS.
// Expect no rat update when move from E to G.
@Test
public void testRatRatchet() throws Exception {
    CellIdentityGsm cellIdentity = new CellIdentityGsm(0, 1, 900, 5, "001", "01", "test", "tst", Collections.emptyList());
    // start on GPRS
    changeRegState(1, cellIdentity, 16, 1);
    assertEquals(ServiceState.STATE_IN_SERVICE, sst.getCurrentDataConnectionState());
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_GPRS, sst.mSS.getRilDataRadioTechnology());
    // upgrade to EDGE
    changeRegState(1, cellIdentity, 16, 2);
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology());
    // drop back to GPRS and expect a ratchet
    changeRegState(1, cellIdentity, 16, 1);
    assertEquals(ServiceState.RIL_RADIO_TECHNOLOGY_EDGE, sst.mSS.getRilDataRadioTechnology());
}
Also used : CellIdentityGsm(android.telephony.CellIdentityGsm) FlakyTest(androidx.test.filters.FlakyTest) MediumTest(android.test.suitebuilder.annotation.MediumTest) SmallTest(android.test.suitebuilder.annotation.SmallTest) Test(org.junit.Test)

Example 28 with CellIdentityGsm

use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.

the class NetworkScanResultTest method testParcel.

@Test
@SmallTest
public void testParcel() {
    ArrayList<CellInfo> infos = new ArrayList<CellInfo>();
    CellIdentityGsm cig = new CellIdentityGsm(1, 2, 40, 5, "001", "01", "test", "tst", Collections.emptyList());
    CellSignalStrengthGsm cssg = new CellSignalStrengthGsm(5, 6, 7);
    CellInfoGsm gsm = new CellInfoGsm();
    gsm.setRegistered(true);
    gsm.setTimeStamp(9);
    gsm.setCellIdentity(cig);
    gsm.setCellSignalStrength(cssg);
    infos.add(gsm);
    CellIdentityLte cil = new CellIdentityLte(10, 5, 200, 2000, new int[] { 1, 2 }, 10000, "001", "01", "test", "tst", Collections.emptyList(), null);
    CellSignalStrengthLte cssl = new CellSignalStrengthLte(15, 16, 17, 18, 19, 20);
    CellInfoLte lte = new CellInfoLte();
    lte.setRegistered(false);
    lte.setTimeStamp(22);
    lte.setCellIdentity(cil);
    lte.setCellSignalStrength(cssl);
    infos.add(lte);
    NetworkScanResult nsr = new NetworkScanResult(0, 0, infos);
    Parcel p = Parcel.obtain();
    nsr.writeToParcel(p, 0);
    p.setDataPosition(0);
    NetworkScanResult newNsr = NetworkScanResult.CREATOR.createFromParcel(p);
    assertEquals(nsr, newNsr);
}
Also used : CellSignalStrengthLte(android.telephony.CellSignalStrengthLte) CellInfoLte(android.telephony.CellInfoLte) CellInfo(android.telephony.CellInfo) CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) CellIdentityLte(android.telephony.CellIdentityLte) Parcel(android.os.Parcel) ArrayList(java.util.ArrayList) CellIdentityGsm(android.telephony.CellIdentityGsm) CellInfoGsm(android.telephony.CellInfoGsm) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) SmallTest(androidx.test.filters.SmallTest)

Example 29 with CellIdentityGsm

use of android.telephony.CellIdentityGsm in project android_frameworks_opt_telephony by LineageOS.

the class RILTest method testConvertHalCellInfoListForGSM.

@Test
public void testConvertHalCellInfoListForGSM() {
    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 = RSSI_ASU;
    cellinfo.signalStrengthGsm.bitErrorRate = BIT_ERROR_RATE;
    cellinfo.signalStrengthGsm.timingAdvance = TIMING_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);
    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_UNKNOWN);
    // override the timestamp
    cellInfoGsm.setTimeStamp(TIMESTAMP);
    assertEquals(expected, cellInfoGsm);
}
Also used : ArrayList(java.util.ArrayList) CellIdentityGsm(android.telephony.CellIdentityGsm) CellInfoGsm(android.telephony.CellInfoGsm) CellInfo(android.telephony.CellInfo) CellSignalStrengthGsm(android.telephony.CellSignalStrengthGsm) FlakyTest(androidx.test.filters.FlakyTest) Test(org.junit.Test)

Example 30 with CellIdentityGsm

use of android.telephony.CellIdentityGsm in project android_frameworks_base by AOSPA.

the class NetworkMonitor method sendNetworkConditionsBroadcast.

/**
     * @param responseReceived - whether or not we received a valid HTTP response to our request.
     * If false, isCaptivePortal and responseTimestampMs are ignored
     * TODO: This should be moved to the transports.  The latency could be passed to the transports
     * along with the captive portal result.  Currently the TYPE_MOBILE broadcasts appear unused so
     * perhaps this could just be added to the WiFi transport only.
     */
private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal, long requestTimestampMs, long responseTimestampMs) {
    if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 0) {
        return;
    }
    if (systemReady == false)
        return;
    Intent latencyBroadcast = new Intent(ACTION_NETWORK_CONDITIONS_MEASURED);
    switch(mNetworkAgentInfo.networkInfo.getType()) {
        case ConnectivityManager.TYPE_WIFI:
            WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo();
            if (currentWifiInfo != null) {
                // NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not
                // surrounded by double quotation marks (thus violating the Javadoc), but this
                // was changed to match the Javadoc in API 17. Since clients may have started
                // sanitizing the output of this method since API 17 was released, we should
                // not change it here as it would become impossible to tell whether the SSID is
                // simply being surrounded by quotes due to the API, or whether those quotes
                // are actually part of the SSID.
                latencyBroadcast.putExtra(EXTRA_SSID, currentWifiInfo.getSSID());
                latencyBroadcast.putExtra(EXTRA_BSSID, currentWifiInfo.getBSSID());
            } else {
                if (VDBG)
                    logw("network info is TYPE_WIFI but no ConnectionInfo found");
                return;
            }
            break;
        case ConnectivityManager.TYPE_MOBILE:
            latencyBroadcast.putExtra(EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType());
            List<CellInfo> info = mTelephonyManager.getAllCellInfo();
            if (info == null)
                return;
            int numRegisteredCellInfo = 0;
            for (CellInfo cellInfo : info) {
                if (cellInfo.isRegistered()) {
                    numRegisteredCellInfo++;
                    if (numRegisteredCellInfo > 1) {
                        if (VDBG)
                            logw("more than one registered CellInfo." + " Can't tell which is active.  Bailing.");
                        return;
                    }
                    if (cellInfo instanceof CellInfoCdma) {
                        CellIdentityCdma cellId = ((CellInfoCdma) cellInfo).getCellIdentity();
                        latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
                    } else if (cellInfo instanceof CellInfoGsm) {
                        CellIdentityGsm cellId = ((CellInfoGsm) cellInfo).getCellIdentity();
                        latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
                    } else if (cellInfo instanceof CellInfoLte) {
                        CellIdentityLte cellId = ((CellInfoLte) cellInfo).getCellIdentity();
                        latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
                    } else if (cellInfo instanceof CellInfoWcdma) {
                        CellIdentityWcdma cellId = ((CellInfoWcdma) cellInfo).getCellIdentity();
                        latencyBroadcast.putExtra(EXTRA_CELL_ID, cellId);
                    } else {
                        if (VDBG)
                            logw("Registered cellinfo is unrecognized");
                        return;
                    }
                }
            }
            break;
        default:
            return;
    }
    latencyBroadcast.putExtra(EXTRA_CONNECTIVITY_TYPE, mNetworkAgentInfo.networkInfo.getType());
    latencyBroadcast.putExtra(EXTRA_RESPONSE_RECEIVED, responseReceived);
    latencyBroadcast.putExtra(EXTRA_REQUEST_TIMESTAMP_MS, requestTimestampMs);
    if (responseReceived) {
        latencyBroadcast.putExtra(EXTRA_IS_CAPTIVE_PORTAL, isCaptivePortal);
        latencyBroadcast.putExtra(EXTRA_RESPONSE_TIMESTAMP_MS, responseTimestampMs);
    }
    mContext.sendBroadcastAsUser(latencyBroadcast, UserHandle.CURRENT, PERMISSION_ACCESS_NETWORK_CONDITIONS);
}
Also used : CellInfoCdma(android.telephony.CellInfoCdma) CellInfoWcdma(android.telephony.CellInfoWcdma) CellIdentityGsm(android.telephony.CellIdentityGsm) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) WifiInfo(android.net.wifi.WifiInfo) CellInfoGsm(android.telephony.CellInfoGsm) CellInfoLte(android.telephony.CellInfoLte) CellIdentityCdma(android.telephony.CellIdentityCdma) CellInfo(android.telephony.CellInfo) CellIdentityLte(android.telephony.CellIdentityLte) CellIdentityWcdma(android.telephony.CellIdentityWcdma)

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