private static List filterCellsWithNullIds()

in packages/@fbcmobile-signalscan/android/src/main/java/com/fbc/signalscan/utils/CellInfoUtil.java [50:101]


  private static List<CellInfo> filterCellsWithNullIds(List<CellInfo> cellScanList) {
    if (cellScanList == null) {
      Log.d(TAG, "cellScanList was null");
      return null;
    }
    List<CellInfo> validCellScanList = new ArrayList<>(cellScanList.size());
    for (CellInfo cell : cellScanList) {
      boolean isValid = false;
      if (cell instanceof CellInfoCdma) {
        CellInfoCdma cdmaCell = (CellInfoCdma) cell;
        CellIdentityCdma cellId = cdmaCell.getCellIdentity();
        isValid =
            cellId != null
                && cellId.getBasestationId() != Integer.MAX_VALUE
                && cellId.getSystemId() != Integer.MAX_VALUE
                && cellId.getNetworkId() != Integer.MAX_VALUE;
      } else if (cell instanceof CellInfoGsm) {
        CellInfoGsm gsmCell = (CellInfoGsm) cell;
        CellIdentityGsm id = gsmCell.getCellIdentity();
        isValid =
            id != null
                && id.getCid() != Integer.MAX_VALUE
                && id.getLac() != Integer.MAX_VALUE
                && id.getMcc() != Integer.MAX_VALUE
                && id.getMnc() != Integer.MAX_VALUE
                && !(id.getMcc() == 0 && id.getMnc() == 0);
      } else if (cell instanceof CellInfoLte) {
        CellInfoLte lteCell = (CellInfoLte) cell;
        CellIdentityLte id = lteCell.getCellIdentity();
        isValid =
            id != null
                && id.getCi() != Integer.MAX_VALUE
                && id.getMcc() != Integer.MAX_VALUE
                && id.getMnc() != Integer.MAX_VALUE
                && !(id.getMcc() == 0 && id.getMnc() == 0);
      } else if (cell instanceof CellInfoWcdma) {
        CellInfoWcdma wcdmaCell = (CellInfoWcdma) cell;
        CellIdentityWcdma id = wcdmaCell.getCellIdentity();
        isValid =
            id != null
                && id.getCid() != Integer.MAX_VALUE
                && id.getLac() != Integer.MAX_VALUE
                && id.getMcc() != Integer.MAX_VALUE
                && id.getMnc() != Integer.MAX_VALUE
                && !(id.getMcc() == 0 && id.getMnc() == 0);
      }
      if (isValid) {
        validCellScanList.add(cell);
      }
    }
    return validCellScanList;
  }