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());
}
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());
}
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);
}
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);
}
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);
}
Aggregations