in packages/@fbcmobile-signalscan/android/src/main/java/com/fbc/signalscan/CellScanResultsModule.java [264:340]
private WritableMap processCellScanResults(
TelephonyManager teleManager, @Nullable List<CellInfo> cellList) {
Context context = reactContext.getApplicationContext();
WritableMap map = Arguments.createMap();
if (cellList == null || cellList.isEmpty()) {
Log.d(TAG, "cell scan found 0 cells, falling back to getCellLocation()");
CellLocation cellLocation = null;
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
cellLocation = teleManager.getCellLocation();
}
if (cellLocation == null) {
map.putString(ERROR_KEY, ERROR_CODE_NO_DATA);
Log.d(TAG, ERROR_NO_DATA);
return map;
}
WritableMap fields = Arguments.createMap();
fields.putInt(CELL_FIELD_DBM, MIN_SIGNAL_STRENGTH);
if (cellLocation instanceof GsmCellLocation) {
Log.d(TAG, "cell is instance of GsmCellLocation");
fields.putString(CELL_FIELD_TYPE, GSM);
fields.putString(
CELL_FIELD_ID, Integer.toString(((GsmCellLocation) cellLocation).getCid()));
fields.putString(
CELL_FIELD_LAC, Integer.toString(((GsmCellLocation) cellLocation).getLac()));
} else if (cellLocation instanceof CdmaCellLocation) {
Log.d(TAG, "cell is instance of CdmaCellLocation");
fields.putString(CELL_FIELD_TYPE, CDMA);
fields.putString(
CELL_FIELD_ID, Integer.toString(((CdmaCellLocation) cellLocation).getBaseStationId()));
fields.putString(
CELL_FIELD_BASE_STATION_ID,
Integer.toString(((CdmaCellLocation) cellLocation).getBaseStationId()));
fields.putString(
CELL_FIELD_NETWORK_ID,
Integer.toString(((CdmaCellLocation) cellLocation).getNetworkId()));
fields.putString(
CELL_FIELD_SYSTEM_ID,
Integer.toString(((CdmaCellLocation) cellLocation).getSystemId()));
} else {
fields.putString(CELL_FIELD_TYPE, "UNKNOWN");
fields.merge(getDefaultValues());
Log.d(TAG, "Unknown cell type");
}
map.putMap(Integer.toString(0), fields);
return map;
}
Log.d(TAG, String.format("cell scan found %s cells", cellList.size()));
int i = 0;
for (CellInfo cell : cellList) {
WritableMap fields;
if (cell instanceof CellInfoCdma) {
Log.d(TAG, "cell is instance of CellInfoCdma");
fields = setCDMAInfo((CellInfoCdma) cell);
} else if (cell instanceof CellInfoGsm) {
Log.d(TAG, "cell is instance of CellInfoGsm");
fields = setGSMInfo((CellInfoGsm) cell);
} else if (cell instanceof CellInfoLte) {
Log.d(TAG, "cell is instance of CellInfoLte");
fields = setLTEInfo((CellInfoLte) cell);
} else if (cell instanceof CellInfoWcdma) {
Log.d(TAG, "cell is instance of CellInfoWcdma");
fields = setWCDMAInfo((CellInfoWcdma) cell);
} else {
fields = Arguments.createMap();
fields.putString(CELL_FIELD_TYPE, "UNKNOWN");
fields.merge(getDefaultValues());
Log.d(TAG, String.format("Unknown cell type: %s", cell.toString()));
}
map.putMap(Integer.toString(i), fields);
i++;
}
return map;
}