use of android.telephony.CellIdentityGsm 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.CellIdentityGsm in project android_packages_apps_Settings by crdroidandroid.
the class RadioInfo method buildGsmInfoString.
private final String buildGsmInfoString(CellInfoGsm ci) {
CellIdentityGsm cidGsm = ci.getCellIdentity();
CellSignalStrengthGsm ssGsm = ci.getCellSignalStrength();
return String.format("%-3.3s %-3.3s %-3.3s %-5.5s %-5.5s %-6.6s %-4.4s %-4.4s\n", ci.isRegistered() ? "S " : " ", getCellInfoDisplayString(cidGsm.getMcc()), getCellInfoDisplayString(cidGsm.getMnc()), getCellInfoDisplayString(cidGsm.getLac()), getCellInfoDisplayString(cidGsm.getCid()), getCellInfoDisplayString(cidGsm.getArfcn()), getCellInfoDisplayString(cidGsm.getBsic()), getCellInfoDisplayString(ssGsm.getDbm()));
}
use of android.telephony.CellIdentityGsm 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.CellIdentityGsm 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());
}
});
}
}
}
use of android.telephony.CellIdentityGsm in project VirtualApp by asLody.
the class MethodProxies method createCellInfo.
private static CellInfo createCellInfo(VCell cell) {
if (cell.type == 2) {
// CDMA
CellInfoCdma cdma = mirror.android.telephony.CellInfoCdma.ctor.newInstance();
CellIdentityCdma identityCdma = mirror.android.telephony.CellInfoCdma.mCellIdentityCdma.get(cdma);
CellSignalStrengthCdma strengthCdma = mirror.android.telephony.CellInfoCdma.mCellSignalStrengthCdma.get(cdma);
mirror.android.telephony.CellIdentityCdma.mNetworkId.set(identityCdma, cell.networkId);
mirror.android.telephony.CellIdentityCdma.mSystemId.set(identityCdma, cell.systemId);
mirror.android.telephony.CellIdentityCdma.mBasestationId.set(identityCdma, cell.baseStationId);
mirror.android.telephony.CellSignalStrengthCdma.mCdmaDbm.set(strengthCdma, -74);
mirror.android.telephony.CellSignalStrengthCdma.mCdmaEcio.set(strengthCdma, -91);
mirror.android.telephony.CellSignalStrengthCdma.mEvdoDbm.set(strengthCdma, -64);
mirror.android.telephony.CellSignalStrengthCdma.mEvdoSnr.set(strengthCdma, 7);
return cdma;
} else {
// GSM
CellInfoGsm gsm = mirror.android.telephony.CellInfoGsm.ctor.newInstance();
CellIdentityGsm identityGsm = mirror.android.telephony.CellInfoGsm.mCellIdentityGsm.get(gsm);
CellSignalStrengthGsm strengthGsm = mirror.android.telephony.CellInfoGsm.mCellSignalStrengthGsm.get(gsm);
mirror.android.telephony.CellIdentityGsm.mMcc.set(identityGsm, cell.mcc);
mirror.android.telephony.CellIdentityGsm.mMnc.set(identityGsm, cell.mnc);
mirror.android.telephony.CellIdentityGsm.mLac.set(identityGsm, cell.lac);
mirror.android.telephony.CellIdentityGsm.mCid.set(identityGsm, cell.cid);
mirror.android.telephony.CellSignalStrengthGsm.mSignalStrength.set(strengthGsm, 20);
mirror.android.telephony.CellSignalStrengthGsm.mBitErrorRate.set(strengthGsm, 0);
return gsm;
}
}
Aggregations