use of android.telephony.CellInfo 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.CellInfo 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.CellInfo in project android_frameworks_opt_telephony by LineageOS.
the class SimulatedCommands method getCellInfoList.
@Override
public void getCellInfoList(Message response, WorkSource WorkSource) {
if (mCellInfoList == null) {
Parcel p = Parcel.obtain();
p.writeInt(1);
p.writeInt(1);
p.writeInt(2);
p.writeLong(1453510289108L);
p.writeInt(310);
p.writeInt(260);
p.writeInt(123);
p.writeInt(456);
p.writeInt(99);
p.writeInt(3);
p.setDataPosition(0);
CellInfoGsm cellInfo = CellInfoGsm.CREATOR.createFromParcel(p);
ArrayList<CellInfo> mCellInfoList = new ArrayList();
mCellInfoList.add(cellInfo);
}
resultSuccess(response, mCellInfoList);
}
use of android.telephony.CellInfo in project android_frameworks_opt_telephony by LineageOS.
the class ServiceStateTrackerTest method testCellInfoList.
@Test
@MediumTest
public void testCellInfoList() {
Parcel p = Parcel.obtain();
p.writeInt(1);
p.writeInt(1);
p.writeInt(2);
p.writeLong(1453510289108L);
p.writeInt(310);
p.writeInt(260);
p.writeInt(123);
p.writeInt(456);
p.writeInt(99);
p.writeInt(3);
p.setDataPosition(0);
CellInfoGsm cellInfo = CellInfoGsm.CREATOR.createFromParcel(p);
ArrayList<CellInfo> list = new ArrayList();
list.add(cellInfo);
mSimulatedCommands.setCellInfoList(list);
WorkSource workSource = new WorkSource(Process.myUid(), mContext.getPackageName());
assertEquals(sst.getAllCellInfo(workSource), list);
}
use of android.telephony.CellInfo in project android_frameworks_opt_telephony by LineageOS.
the class NetworkScanRequestTracker method notifyMessenger.
/**
* Sends a message back to the application via its callback.
*/
private void notifyMessenger(NetworkScanRequestInfo nsri, int what, int err, List<CellInfo> result) {
Messenger messenger = nsri.mMessenger;
Message message = Message.obtain();
message.what = what;
message.arg1 = err;
message.arg2 = nsri.mScanId;
if (result != null) {
CellInfo[] ci = result.toArray(new CellInfo[result.size()]);
Bundle b = new Bundle();
b.putParcelableArray(TelephonyScanManager.SCAN_RESULT_KEY, ci);
message.setData(b);
} else {
message.obj = null;
}
try {
messenger.send(message);
} catch (RemoteException e) {
Log.e(TAG, "Exception in notifyMessenger: " + e);
}
}
Aggregations