use of android.telephony.CellInfoWcdma in project platform_frameworks_base by android.
the class EmergencyAffordanceService method handleUpdateCellInfo.
private boolean handleUpdateCellInfo() {
List<CellInfo> cellInfos = mTelephonyManager.getAllCellInfo();
if (cellInfos == null) {
return false;
}
boolean stopScanningAfterScan = false;
for (CellInfo cellInfo : cellInfos) {
int mcc = 0;
if (cellInfo instanceof CellInfoGsm) {
mcc = ((CellInfoGsm) cellInfo).getCellIdentity().getMcc();
} else if (cellInfo instanceof CellInfoLte) {
mcc = ((CellInfoLte) cellInfo).getCellIdentity().getMcc();
} else if (cellInfo instanceof CellInfoWcdma) {
mcc = ((CellInfoWcdma) cellInfo).getCellIdentity().getMcc();
}
if (mccRequiresEmergencyAffordance(mcc)) {
setNetworkNeedsEmergencyAffordance(true);
return true;
} else if (mcc != 0 && mcc != Integer.MAX_VALUE) {
// we found an mcc that isn't in the list, abort
stopScanningAfterScan = true;
}
}
if (stopScanningAfterScan) {
stopScanning();
} else {
onCellScanFinishedUnsuccessful();
}
setNetworkNeedsEmergencyAffordance(false);
return false;
}
use of android.telephony.CellInfoWcdma in project PhoneProfilesPlus by henrichg.
the class PhoneStateScanner method getAllCellInfo.
/*
void resetListening(boolean oldPowerSaveMode, boolean forceReset) {
if ((forceReset) || (PPApplication.isPowerSaveMode != oldPowerSaveMode)) {
disconnect();
connect();
}
}
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void getAllCellInfo(List<CellInfo> cellInfo) {
if (cellInfo != null) {
if (Permissions.checkLocation(context.getApplicationContext())) {
for (CellInfo _cellInfo : cellInfo) {
if (_cellInfo instanceof CellInfoGsm) {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm info="+_cellInfo);
CellIdentityGsm identityGsm = ((CellInfoGsm) _cellInfo).getCellIdentity();
if (identityGsm.getCid() != Integer.MAX_VALUE) {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "gsm mCid="+identityGsm.getCid());
if (_cellInfo.isRegistered()) {
registeredCell = identityGsm.getCid();
lastConnectedTime = Calendar.getInstance().getTimeInMillis();
}
}
} else if (_cellInfo instanceof CellInfoLte) {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte info="+_cellInfo);
CellIdentityLte identityLte = ((CellInfoLte) _cellInfo).getCellIdentity();
if (identityLte.getCi() != Integer.MAX_VALUE) {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "lte mCi="+identityLte.getCi());
if (_cellInfo.isRegistered()) {
registeredCell = identityLte.getCi();
lastConnectedTime = Calendar.getInstance().getTimeInMillis();
}
}
} else if (_cellInfo instanceof CellInfoWcdma) {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma info="+_cellInfo);
// if (android.os.Build.VERSION.SDK_INT >= 18) {
CellIdentityWcdma identityWcdma = ((CellInfoWcdma) _cellInfo).getCellIdentity();
if (identityWcdma.getCid() != Integer.MAX_VALUE) {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid=" + identityWcdma.getCid());
if (_cellInfo.isRegistered()) {
registeredCell = identityWcdma.getCid();
lastConnectedTime = Calendar.getInstance().getTimeInMillis();
}
}
// }
// else {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid=not supported for API level < 18");
// }
} else if (_cellInfo instanceof CellInfoCdma) {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cdma info="+_cellInfo);
CellIdentityCdma identityCdma = ((CellInfoCdma) _cellInfo).getCellIdentity();
if (identityCdma.getBasestationId() != Integer.MAX_VALUE) {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "wcdma mCid="+identityCdma.getBasestationId());
if (_cellInfo.isRegistered()) {
registeredCell = identityCdma.getBasestationId();
lastConnectedTime = Calendar.getInstance().getTimeInMillis();
}
}
}
// else {
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "unknown info="+_cellInfo);
// }
}
// PPApplication.logE("PhoneStateScanner.getAllCellInfo", "---- end ----------------------------");
PPApplication.logE("PhoneStateScanner.getAllCellInfo", "registeredCell=" + registeredCell);
}
} else
PPApplication.logE("PhoneStateScanner.getAllCellInfo", "cell info is null");
}
use of android.telephony.CellInfoWcdma in project android_packages_apps_Settings by omnirom.
the class RadioInfo method buildCellInfoString.
private final String buildCellInfoString(List<CellInfo> arrayCi) {
String value = new String();
StringBuilder cdmaCells = new StringBuilder(), gsmCells = new StringBuilder(), lteCells = new StringBuilder(), wcdmaCells = new StringBuilder();
if (arrayCi != null) {
for (CellInfo ci : arrayCi) {
if (ci instanceof CellInfoLte) {
lteCells.append(buildLteInfoString((CellInfoLte) ci));
} else if (ci instanceof CellInfoWcdma) {
wcdmaCells.append(buildWcdmaInfoString((CellInfoWcdma) ci));
} else if (ci instanceof CellInfoGsm) {
gsmCells.append(buildGsmInfoString((CellInfoGsm) ci));
} else if (ci instanceof CellInfoCdma) {
cdmaCells.append(buildCdmaInfoString((CellInfoCdma) ci));
}
}
if (lteCells.length() != 0) {
value += String.format("LTE\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-3.3s %-6.6s %-4.4s %-4.4s %-2.2s\n", "SRV", "MCC", "MNC", "TAC", "CID", "PCI", "EARFCN", "RSRP", "RSRQ", "TA");
value += lteCells.toString();
}
if (wcdmaCells.length() != 0) {
value += String.format("WCDMA\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-3.3s %-4.4s\n", "SRV", "MCC", "MNC", "LAC", "CID", "UARFCN", "PSC", "RSCP");
value += wcdmaCells.toString();
}
if (gsmCells.length() != 0) {
value += String.format("GSM\n%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", "SRV", "MCC", "MNC", "LAC", "CID", "ARFCN", "BSIC", "RSSI");
value += gsmCells.toString();
}
if (cdmaCells.length() != 0) {
value += String.format("CDMA/EVDO\n%-3.3s %-5.5s %-5.5s %-5.5s %-6.6s %-6.6s %-6.6s %-6.6s %-5.5s\n", "SRV", "SID", "NID", "BSID", "C-RSSI", "C-ECIO", "E-RSSI", "E-ECIO", "E-SNR");
value += cdmaCells.toString();
}
} else {
value = "unknown";
}
return value.toString();
}
use of android.telephony.CellInfoWcdma in project android_frameworks_opt_telephony by LineageOS.
the class ServiceStateTracker method getCellLocation.
/**
* @param workSource calling WorkSource
* @return the current cell location information. Prefer Gsm location
* information if available otherwise return LTE location information
*/
public CellLocation getCellLocation(WorkSource workSource) {
if (((GsmCellLocation) mCellLoc).getLac() >= 0 && ((GsmCellLocation) mCellLoc).getCid() >= 0) {
if (VDBG)
log("getCellLocation(): X good mCellLoc=" + mCellLoc);
return mCellLoc;
} else {
List<CellInfo> result = getAllCellInfo(workSource);
if (result != null) {
// A hack to allow tunneling of LTE information via GsmCellLocation
// so that older Network Location Providers can return some information
// on LTE only networks, see bug 9228974.
//
// We'll search the return CellInfo array preferring GSM/WCDMA
// data, but if there is none we'll tunnel the first LTE information
// in the list.
//
// The tunnel'd LTE information is returned as follows:
// LAC = TAC field
// CID = CI field
// PSC = 0.
GsmCellLocation cellLocOther = new GsmCellLocation();
for (CellInfo ci : result) {
if (ci instanceof CellInfoGsm) {
CellInfoGsm cellInfoGsm = (CellInfoGsm) ci;
CellIdentityGsm cellIdentityGsm = cellInfoGsm.getCellIdentity();
cellLocOther.setLacAndCid(cellIdentityGsm.getLac(), cellIdentityGsm.getCid());
cellLocOther.setPsc(cellIdentityGsm.getPsc());
if (VDBG)
log("getCellLocation(): X ret GSM info=" + cellLocOther);
return cellLocOther;
} else if (ci instanceof CellInfoWcdma) {
CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) ci;
CellIdentityWcdma cellIdentityWcdma = cellInfoWcdma.getCellIdentity();
cellLocOther.setLacAndCid(cellIdentityWcdma.getLac(), cellIdentityWcdma.getCid());
cellLocOther.setPsc(cellIdentityWcdma.getPsc());
if (VDBG)
log("getCellLocation(): X ret WCDMA info=" + cellLocOther);
return cellLocOther;
} else if ((ci instanceof CellInfoLte) && ((cellLocOther.getLac() < 0) || (cellLocOther.getCid() < 0))) {
// We'll return the first good LTE info we get if there is no better answer
CellInfoLte cellInfoLte = (CellInfoLte) ci;
CellIdentityLte cellIdentityLte = cellInfoLte.getCellIdentity();
if ((cellIdentityLte.getTac() != Integer.MAX_VALUE) && (cellIdentityLte.getCi() != Integer.MAX_VALUE)) {
cellLocOther.setLacAndCid(cellIdentityLte.getTac(), cellIdentityLte.getCi());
cellLocOther.setPsc(0);
if (VDBG) {
log("getCellLocation(): possible LTE cellLocOther=" + cellLocOther);
}
}
}
}
if (VDBG) {
log("getCellLocation(): X ret best answer cellLocOther=" + cellLocOther);
}
return cellLocOther;
} else {
if (VDBG) {
log("getCellLocation(): X empty mCellLoc and CellInfo mCellLoc=" + mCellLoc);
}
return mCellLoc;
}
}
}
use of android.telephony.CellInfoWcdma in project network-monitor by caarmen.
the class CellLocationDataSource method fillCellLocationV17.
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void fillCellLocationV17(ContentValues values) {
if (PermissionUtil.hasLocationPermission(mContext)) {
@SuppressLint("MissingPermission") List<CellInfo> cellInfos = mTelephonyManager.getAllCellInfo();
if (cellInfos == null || cellInfos.isEmpty()) {
fillCellLocation(values);
} else {
StreamSupport.stream(cellInfos).filter(CellInfo::isRegistered).forEach(cellInfo -> {
if (cellInfo instanceof CellInfoGsm) {
CellInfoGsm gsmCellInfo = (CellInfoGsm) cellInfo;
CellIdentityGsm cellIdentityGsm = gsmCellInfo.getCellIdentity();
setGsmCellInfo(values, cellIdentityGsm.getCid(), cellIdentityGsm.getLac());
} else if (cellInfo instanceof CellInfoCdma) {
CellInfoCdma cellInfoCdma = (CellInfoCdma) cellInfo;
CellIdentityCdma cellIdentityCdma = cellInfoCdma.getCellIdentity();
setCdmaCellInfo(values, cellIdentityCdma.getBasestationId(), cellIdentityCdma.getLatitude(), cellIdentityCdma.getLongitude(), cellIdentityCdma.getNetworkId(), cellIdentityCdma.getSystemId());
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && cellInfo instanceof CellInfoWcdma) {
CellInfoWcdma cellInfoWcdma = (CellInfoWcdma) cellInfo;
CellIdentityWcdma cellIdentityWcdma = cellInfoWcdma.getCellIdentity();
setGsmCellInfo(values, cellIdentityWcdma.getCid(), cellIdentityWcdma.getLac());
values.put(NetMonColumns.GSM_CELL_PSC, cellIdentityWcdma.getPsc());
} else if (cellInfo instanceof CellInfoLte) {
CellInfoLte cellInfoLte = (CellInfoLte) cellInfo;
CellIdentityLte cellIdentityLte = cellInfoLte.getCellIdentity();
values.put(NetMonColumns.LTE_CELL_CI, cellIdentityLte.getCi());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
values.put(NetMonColumns.LTE_CELL_EARFCN, cellIdentityLte.getEarfcn());
}
values.put(NetMonColumns.LTE_CELL_TAC, cellIdentityLte.getTac());
values.put(NetMonColumns.LTE_CELL_PCI, cellIdentityLte.getPci());
}
});
}
}
}
Aggregations