Java 类android.telephony.NeighboringCellInfo 实例源码

项目:AIMSICDL    文件:CellTracker.java   
/**
 *  Description:  TODO: add more info
 *
 *  Issues:
 *
 *      [ ]     Getting and comparing signal strengths between different RATs can be very
 *              tricky, since they all return different ranges of values. AOS doesn't
 *              specify very clearly what exactly is returned, even though people have
 *              a good idea, by trial and error.
 *
 *              See note in : SignalStrengthTracker.java
 *
 *  Notes:
 *
 *
 *
 */
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    // Update Signal Strength
    if (signalStrength.isGsm()) {
        int dbm;
        if (signalStrength.getGsmSignalStrength() <= 2 ||
                signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
            // Unknown signal strength, get it another way
            String[] bits = signalStrength.toString().split(" ");
            dbm = Integer.parseInt(bits[9]);
        } else {
            dbm = signalStrength.getGsmSignalStrength();
        }
        mDevice.setSignalDbm(dbm);
    } else {
        int evdoDbm = signalStrength.getEvdoDbm();
        int cdmaDbm = signalStrength.getCdmaDbm();

        // Use lowest signal to be conservative
        mDevice.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
    }
    // Send it to signal tracker
    signalStrengthTracker.registerSignalStrength(mDevice.mCell.getCID(), mDevice.getSignalDBm());
    //signalStrengthTracker.isMysterious(mDevice.mCell.getCID(), mDevice.getSignalDBm());
}
项目:letv    文件:b.java   
public final int[] d() {
    if (this.c == 0) {
        return new int[0];
    }
    List<NeighboringCellInfo> neighboringCellInfo = this.q.getNeighboringCellInfo();
    if (neighboringCellInfo == null || neighboringCellInfo.size() == 0) {
        return new int[]{this.c};
    }
    Object obj = new int[((neighboringCellInfo.size() * 2) + 2)];
    obj[0] = this.c;
    obj[1] = this.a;
    int i = 2;
    for (NeighboringCellInfo neighboringCellInfo2 : neighboringCellInfo) {
        int cid = neighboringCellInfo2.getCid();
        if (cid > 0 && cid != SupportMenu.USER_MASK) {
            int i2 = i + 1;
            obj[i] = cid;
            i = i2 + 1;
            obj[i2] = neighboringCellInfo2.getRssi();
        }
    }
    Object obj2 = new int[i];
    System.arraycopy(obj, 0, obj2, 0, i);
    return obj2;
}
项目:TPlayer    文件:MethodProxies.java   
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    if (isFakeLocationEnable()) {
        List<VCell> cells = VirtualLocationManager.get().getNeighboringCell(getAppUserId(), getAppPkg());
        if (cells != null) {
            List<NeighboringCellInfo> infos = new ArrayList<>();
            for (VCell cell : cells) {
                NeighboringCellInfo info = new NeighboringCellInfo();
                mirror.android.telephony.NeighboringCellInfo.mLac.set(info, cell.lac);
                mirror.android.telephony.NeighboringCellInfo.mCid.set(info, cell.cid);
                mirror.android.telephony.NeighboringCellInfo.mRssi.set(info, 6);
                infos.add(info);
            }
            return infos;
        }
    }
    return super.call(who, method, args);
}
项目:TowerCollector    文件:LegacyMeasurementParser.java   
private void removeDuplicatedNeighbors(List<NeighboringCellInfo> neighboringCells, Measurement measurement) {
    List<NeighboringCellInfo> cellsToRemove = new ArrayList<NeighboringCellInfo>();
    Set<String> uniqueCellKeys = new HashSet<String>();

    uniqueCellKeys.add(createCellKey(measurement));
    for (NeighboringCellInfo cell : neighboringCells) {
        String key = createCellKey(cell, measurement);
        if (uniqueCellKeys.contains(key)) {
            Log.d("removeDuplicatedNeighbors(): Remove duplicated cell: %s", key);
            cellsToRemove.add(cell);
        } else {
            uniqueCellKeys.add(key);
        }
    }

    neighboringCells.removeAll(cellsToRemove);
}
项目:TowerCollector    文件:MeasurementUpdater.java   
public synchronized void setLastCellLocation(CellLocation cellLocation, NetworkGroup networkType,
                                             String operatorCode, String operatorName, List<NeighboringCellInfo> neighboringCells) {
    Log.d("setLastCellLocation(): Cell location updated: %s, network type: %s, operator code: %s, operator name: %s", cellLocation, networkType, operatorCode, operatorName);
    // check if any changes
    boolean cellChanged = (!isCellLocationEqual(lastCellLocation, cellLocation)
            || lastNetworkType != networkType
            || !lastOperatorCode.equals(operatorCode)
            || !lastOperatorName.equals(operatorName));
    // update last cell
    this.lastCellLocation = cellLocation;
    this.lastNetworkType = networkType;
    this.lastOperatorCode = operatorCode;
    this.lastOperatorName = operatorName;
    this.neighboringCells = neighboringCells;
    if (this.neighboringCells == null) {
        this.neighboringCells = EMPTY_NEIGHBORING_CELL_LIST;
    }
    if (cellChanged) {
        notifyIfReadyToProcess();
    }
}
项目:TowerCollector    文件:CellLocationConverter.java   
public void update(Measurement m, CellLocation cellLocation, int mcc, int mnc, NetworkGroup networkType) {
    if (cellLocation instanceof GsmCellLocation) {
        GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;
        if (gsmCellLocation.getCid() <= 65535 && gsmCellLocation.getPsc() == NeighboringCellInfo.UNKNOWN_CID) {
            m.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), NetworkGroup.Gsm);
        } else {
            // fix invalid network types (unfortunately not possible to distinguish between UMTS and LTE)
            if (networkType == NetworkGroup.Gsm || networkType == NetworkGroup.Cdma)
                networkType = NetworkGroup.Unknown;
            int psc = gsmCellLocation.getPsc();
            if (psc == NeighboringCellInfo.UNKNOWN_CID || psc == Measurement.UNKNOWN_CID) {
                psc = Measurement.UNKNOWN_CID;
            } else if (psc >= 504) {
                // only UMTS networks support larger PSC
                networkType = NetworkGroup.Wcdma;
            }
            m.setGsmCellLocation(mcc, mnc, gsmCellLocation.getLac(), gsmCellLocation.getCid(), psc, networkType);
        }
    } else if (cellLocation instanceof CdmaCellLocation) {
        CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;
        m.setCdmaCellLocation(cdmaCellLocation.getSystemId(), cdmaCellLocation.getNetworkId(), cdmaCellLocation.getBaseStationId());
    } else {
        throw new UnsupportedOperationException("Cell location type not supported `" + cellLocation.getClass().getName() + "`");
    }
}
项目:Android-IMSI-Catcher-Detector    文件:CellTracker.java   
/**
 *  Description:  TODO: add more info
 *
 *  Issues:
 *
 *      [ ]     Getting and comparing signal strengths between different RATs can be very
 *              tricky, since they all return different ranges of values. AOS doesn't
 *              specify very clearly what exactly is returned, even though people have
 *              a good idea, by trial and error.
 *
 *              See note in : SignalStrengthTracker.java
 */
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
    // Update Signal Strength
    if (signalStrength.isGsm()) {
        int dbm;
        if (signalStrength.getGsmSignalStrength() <= 2 ||
                signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
            // Unknown signal strength, get it another way
            String[] bits = signalStrength.toString().split(" ");
            dbm = Integer.parseInt(bits[9]);
        } else {
            dbm = signalStrength.getGsmSignalStrength();
        }
        device.setSignalDbm(dbm);
    } else {
        int evdoDbm = signalStrength.getEvdoDbm();
        int cdmaDbm = signalStrength.getCdmaDbm();

        // Use lowest signal to be conservative
        device.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
    }
    // Send it to signal tracker
    signalStrengthTracker.registerSignalStrength(device.cell.getCellId(), device.getSignalDBm());
    //signalStrengthTracker.isMysterious(device.cell.getCid(), device.getSignalDBm());
}
项目:mobility-logger    文件:LoggingService.java   
private void updateNeighboringCells(){
    /** Neighboring cells */
    List<NeighboringCellInfo> neighboringCellInfo;
    neighboringCellInfo = srvcTelephonyManager.getNeighboringCellInfo();

    /** Fill the hash tables depending on the network type*/
    for (NeighboringCellInfo i : neighboringCellInfo) {
        int networktype=i.getNetworkType();
        if ((networktype == TelephonyManager.NETWORK_TYPE_UMTS) || 
                (networktype == TelephonyManager.NETWORK_TYPE_HSDPA) ||
                (networktype == TelephonyManager.NETWORK_TYPE_HSUPA) ||
                (networktype == TelephonyManager.NETWORK_TYPE_HSPA))
            //neighborsmapUMTS.put(i.getPsc(), i.getRssi()-115);
            // Nexus 5 phone gives the actual rsrp instead of index level of CPICH
            neighborsmapUMTS.put(i.getPsc(), i.getRssi());
        else 
            neighborsmapGSM.put(i.getLac()+"-"+i.getCid(), (-113+2*(i.getRssi())));
    }
}
项目:tabulae    文件:CellIdPre17API.java   
public CellIdPre17API(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCellInfoList) {
    if (DEBUG) Log.d(TAG, "CellIdPre17API:");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        fallback_pre17api = true;
    }
    this.cellLocation = cellLocation;
    this.neighboringCellInfoList = neighboringCellInfoList;
    if (cellLocation != null) {
        this.i = -1;
    } else {
        this.i = 0;
    }
    String mccmnc = telephonyManager.getNetworkOperator();
    if (mccmnc != null && mccmnc.length() >= 5 && mccmnc.length() <= 6) {
        mcc = Integer.parseInt(mccmnc.substring(0, 3));
        mnc = Integer.parseInt(mccmnc.substring(3));
    } else {
        Log.e(TAG, "CellIdPre17API: wrong legnth (5-6) for mccmnc=" + mccmnc);
    }
    type = telephonyManager.getNetworkType();
    if (DEBUG)
        Log.d(TAG, "CellIdPre17API: mcc=" + mcc + ", mnc=" + mnc + ", type=" + type + " cellLocation=" + cellLocation + ", neighboringCellInfoList=" + neighboringCellInfoList);
}
项目:tabulae    文件:CellIdPre17API.java   
public void fill(TheDictionary map, NeighboringCellInfo value) throws Exception {
    if (value != null) {
        map.put("mcc", mcc);
        map.put("mnc", mnc);
        int i;
        i = value.getPsc();
        if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("psc", i);
        i = value.getRssi();
        if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("rssi", i);
        i = value.getLac();
        if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("lac", i);
        i = value.getCid();
        if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("cid", i);
        map.put("registered", false);
        determine_type(map);
    }
}
项目:Simplicissimus    文件:CellIdPre17API.java   
public CellIdPre17API(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCellInfoList) {
    if (DEBUG) Log.d(TAG, "CellIdPre17API:");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        this.fallback_pre17api = true;
    }
    this.cellLocation = cellLocation;
    this.neighboringCellInfoList = neighboringCellInfoList;
    if (cellLocation != null) {
        this.i = -1;
    }
    else {
        this.i = 0;
    }
    String mccmnc = telephonyManager.getNetworkOperator();
    if (mccmnc != null && mccmnc.length() >= 5 && mccmnc.length() <= 6) {
        mcc = Integer.parseInt(mccmnc.substring(0, 3));
        mnc = Integer.parseInt(mccmnc.substring(3));
    }
    else {
        Log.e(TAG, "CellIdPre17API: wrong legnth (5-6) for mccmnc=" + mccmnc);
    }
    type = telephonyManager.getNetworkType();
    if (DEBUG) Log.d(TAG, "CellIdPre17API: mcc=" + mcc + ", mnc=" + mnc + ", type=" + type + " cellLocation=" + cellLocation + ", neighboringCellInfoList=" + neighboringCellInfoList);
}
项目:LocalGSMLocationProvider    文件:CellbasedLocationProvider.java   
/**
 * Add neighbouring cells as generated by the getNeighboringCells API.
 * @param neighbours The list of neighbouring cells.
 */
public void addNeighbours(List<NeighboringCellInfo> neighbours) {
    if (neighbours == null || neighbours.isEmpty()) return;
    for (NeighboringCellInfo neighbour : neighbours) {
        List<CellInfo> cellInfos = db.query(neighbour.getCid(), neighbour.getLac());
        if (cellInfos != null && !cellInfos.isEmpty()) {
            for (CellInfo cellInfo : cellInfos) {
                pushRecentCells(cellInfo);
            }
        } else {
            CellInfo ci = new CellInfo();
            ci.lng = 0d;
            ci.lat = 0d;
            ci.CID = neighbour.getCid();
            ci.LAC = neighbour.getLac();
            ci.MCC = -1;
            ci.MNC = -1;
            pushUnusedCells(ci);
        }
    }
}
项目:LocalGSMLocationProvider    文件:CellbasedLocationProvider.java   
/**
 * Handle a modem event by trying to pull all information. The parameter inc defines if the
 * measurement counter should be increased on success.
 * @param inc True if the measurement counter should be increased.
 */
private void handle(boolean inc) {
    if (telephonyManager == null) return;
    final List<android.telephony.CellInfo> cellInfos = telephonyManager.getAllCellInfo();
    final List<NeighboringCellInfo> neighbours = telephonyManager.getNeighboringCellInfo();
    final CellLocation cellLocation = telephonyManager.getCellLocation();
    if (cellInfos == null || cellInfos.isEmpty()) {
        if (neighbours == null || neighbours.isEmpty()) {
            if (cellLocation == null || !(cellLocation instanceof GsmCellLocation)) return;
        }
    }
    if (inc) measurement.getAndIncrement();
    add(cellLocation);
    addNeighbours(neighbours);
    addCells(cellInfos);
    synchronized (recentCells) {
        cleanup();
    }
}
项目:Mobilog    文件:LoggingService.java   
private void updateNeighboringCells(){
    /** Neighboring cells */
    List<NeighboringCellInfo> neighboringCellInfo;
    neighboringCellInfo = srvcTelephonyManager.getNeighboringCellInfo();

    /** Fill the hash tables depending on the network type*/
    for (NeighboringCellInfo i : neighboringCellInfo) {
        int networktype=i.getNetworkType();
        if ((networktype == TelephonyManager.NETWORK_TYPE_UMTS) || 
                (networktype == TelephonyManager.NETWORK_TYPE_HSDPA) ||
                (networktype == TelephonyManager.NETWORK_TYPE_HSUPA) ||
                (networktype == TelephonyManager.NETWORK_TYPE_HSPA))
            neighborsmapUMTS.put(i.getPsc(), i.getRssi()-115);
        else 
            neighborsmapGSM.put(i.getLac()+"-"+i.getCid(), (-113+2*(i.getRssi())));
    }
}
项目:Mobilyzer    文件:PhoneUtils.java   
/**
 * Returns the information about cell towers in range. Returns null if the information is 
 * not available 
 * 
 * TODO(wenjiezeng): As folklore has it and Wenjie has confirmed, we cannot get cell info from
 * Samsung phones.
 */
public String getCellInfo(boolean cidOnly) {
  initNetwork();
  List<NeighboringCellInfo> infos = telephonyManager.getNeighboringCellInfo();
  StringBuffer buf = new StringBuffer();
  String tempResult = "";
  if (infos.size() > 0) {
    for (NeighboringCellInfo info : infos) {
      tempResult = cidOnly ? info.getCid() + ";" : info.getLac() + "," 
                             + info.getCid() + "," + info.getRssi() + ";";
      buf.append(tempResult);
    }
    // Removes the trailing semicolon
    buf.deleteCharAt(buf.length() - 1);
    return buf.toString();
  } else {
    return null;
  }
}
项目:pyneo-wirelesslocation    文件:CellIdPre17API.java   
public CellIdPre17API(TelephonyManager telephonyManager, CellLocation cellLocation, List<NeighboringCellInfo> neighboringCellInfoList) {
    if (DEBUG) Log.d(TAG, "CellIdPre17API:");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        this.fallback_pre17api = true;
    }
    this.cellLocation = cellLocation;
    this.neighboringCellInfoList = neighboringCellInfoList;
    if (cellLocation != null) {
        this.i = -1;
    }
    else {
        this.i = 0;
    }
    String mccmnc = telephonyManager.getNetworkOperator();
    if (mccmnc != null && mccmnc.length() >= 5 && mccmnc.length() <= 6) {
        mcc = Integer.parseInt(mccmnc.substring(0, 3));
        mnc = Integer.parseInt(mccmnc.substring(3));
    }
    else {
        Log.e(TAG, "CellIdPre17API: wrong legnth (5-6) for mccmnc=" + mccmnc);
    }
    type = telephonyManager.getNetworkType();
    if (DEBUG) Log.d(TAG, "CellIdPre17API: mcc=" + mcc + ", mnc=" + mnc + ", type=" + type + " cellLocation=" + cellLocation + ", neighboringCellInfoList=" + neighboringCellInfoList);
}
项目:Mobiperf-Library    文件:PhoneUtils.java   
/**
 * Returns the information about cell towers in range. Returns null if the information is 
 * not available 
 * 
 * TODO(wenjiezeng): As folklore has it and Wenjie has confirmed, we cannot get cell info from
 * Samsung phones.
 */
public String getCellInfo(boolean cidOnly) {
  initNetwork();
  List<NeighboringCellInfo> infos = telephonyManager.getNeighboringCellInfo();
  StringBuffer buf = new StringBuffer();
  String tempResult = "";
  if (infos.size() > 0) {
    for (NeighboringCellInfo info : infos) {
      tempResult = cidOnly ? info.getCid() + ";" : info.getLac() + "," 
                             + info.getCid() + "," + info.getRssi() + ";";
      buf.append(tempResult);
    }
    // Removes the trailing semicolon
    buf.deleteCharAt(buf.length() - 1);
    return buf.toString();
  } else {
    return null;
  }
}
项目:satstat    文件:RadioSectionFragment.java   
/**
 * Requeries neighboring cells
 */
protected void updateNeighboringCellInfo() {
    try {
        /*
         * NeighboringCellInfo is not supported on some devices and will return no data. It lists
         * only GSM and successors' cells, but not CDMA cells.
         */
        List<NeighboringCellInfo> neighboringCells = mainActivity.telephonyManager.getNeighboringCellInfo();
        String networkOperator = mainActivity.telephonyManager.getNetworkOperator();
        mCellsGsm.updateAll(networkOperator, neighboringCells);
        mCellsLte.updateAll(networkOperator, neighboringCells);
    } catch (SecurityException e) {
        // Permission not granted, can't retrieve cell data
        Log.w(TAG, "Permission not granted, cannot get neighboring cell info");
    }
}
项目:AIMSICDL    文件:CellTracker.java   
private void handlePhoneStateChange() {
    List<NeighboringCellInfo> neighboringCellInfo = tm.getNeighboringCellInfo();
    if (neighboringCellInfo == null || neighboringCellInfo.size() == 0) {
        return;
    }

    Log.i(TAG, mTAG + "NeighbouringCellInfo empty - event based polling succeeded!");
    tm.listen(phoneStatelistener, PhoneStateListener.LISTEN_NONE);
    if (neighboringCellInfo == null) {
        neighboringCellInfo = new ArrayList<>();
    }
    neighboringCellBlockingQueue.addAll(neighboringCellInfo);
}
项目:truth-android    文件:NeighboringCellInfoSubject.java   
public static SubjectFactory<NeighboringCellInfoSubject, NeighboringCellInfo> type() {
  return new SubjectFactory<NeighboringCellInfoSubject, NeighboringCellInfo>() {
    @Override
    public NeighboringCellInfoSubject getSubject(FailureStrategy fs, NeighboringCellInfo that) {
      return new NeighboringCellInfoSubject(fs, that);
    }
  };
}
项目:LBS    文件:GSMCellLocationLbs.java   
public static void getCurrentLocation(Context context) {
    TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    // 返回值MCC + MNC
    String operator = mTelephonyManager.getNetworkOperator();
    int mcc = Integer.parseInt(operator.substring(0, 3));
    int mnc = Integer.parseInt(operator.substring(3));
    Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t");
    // 中国移动和中国联通获取LAC、CID的方式
    GsmCellLocation location = (GsmCellLocation) mTelephonyManager.getCellLocation();
    int lac = location.getLac();
    int cellId = location.getCid();



    // 中国电信获取LAC、CID的方式
    CdmaCellLocation location1 = (CdmaCellLocation) mTelephonyManager.getCellLocation();
    lac = location1.getNetworkId();
    cellId = location1.getBaseStationId();
    cellId /= 16;

    Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t LAC = " + lac + "\t CID = " + cellId);
    // 获取邻区基站信息
    List<NeighboringCellInfo> infos = mTelephonyManager.getNeighboringCellInfo();
    StringBuffer sb = new StringBuffer("总数 : " + infos.size() + "\n");
    for (NeighboringCellInfo info1 : infos) { // 根据邻区总数进行循环
        sb.append(" LAC : " + info1.getLac()); // 取出当前邻区的LAC
        sb.append(" CID : " + info1.getCid()); // 取出当前邻区的CID
        sb.append(" BSSS : " + (-113 + 2 * info1.getRssi()) + "\n"); // 获取邻区基站信号强度
    }

    Log.i(TAG, " 获取邻区基站信息:" + sb.toString());
}
项目:TowerCollector    文件:CollectorService.java   
private void processCellLocation(CellLocation cellLocation, List<NeighboringCellInfo> neighboringCells) {
    // get network type
    int networkTypeInt = telephonyManager.getNetworkType();
    NetworkGroup networkType = NetworkTypeUtils.getNetworkGroup(networkTypeInt);
    // get network operator (may be unreliable for CDMA)
    String networkOperatorCode = telephonyManager.getNetworkOperator();
    String networkOperatorName = telephonyManager.getNetworkOperatorName();
    Log.d("processCellLocation(): Operator code = '%s', name = '%s'", networkOperatorCode, networkOperatorName);
    Log.d("processCellLocation(): Reported %s neighboring cells", (neighboringCells != null ? neighboringCells.size() : null));
    measurementUpdater.setLastCellLocation(cellLocation, networkType, networkOperatorCode, networkOperatorName, neighboringCells);
}
项目:TowerCollector    文件:CellLocationValidator.java   
public boolean isValid(NeighboringCellInfo neighboringCell, Measurement measurement) {
    NetworkGroup netType = NetworkTypeUtils.getNetworkGroup(neighboringCell.getNetworkType());
    if (netType == NetworkGroup.Gsm) {
        return getGsmValidator().isValid(neighboringCell.getCid(), neighboringCell.getLac(), measurement.getMnc(), measurement.getMcc(), NeighboringCellInfo.UNKNOWN_CID);
    } else if (netType == NetworkGroup.Wcdma) {
        // NOTE: Maybe some phones return full set for WCDMA and then it should be valid
        return getGsmValidator().isValid(neighboringCell.getCid(), neighboringCell.getLac(), measurement.getMnc(), measurement.getMcc(), neighboringCell.getPsc());
    }
    return false;
}
项目:TowerCollector    文件:CellLocationConverter.java   
public void update(Measurement m, NeighboringCellInfo cell, int mcc, int mnc) {
    // no type checking because only GSM and UMTS cells can have neighboring cells
    NetworkGroup networkType = NetworkTypeUtils.getNetworkGroup(cell.getNetworkType());
    if (networkType == NetworkGroup.Gsm) {
        m.setGsmCellLocation(mcc, mnc, cell.getLac(), cell.getCid(), NetworkGroup.Gsm);
    } else {
        int psc = cell.getPsc();
        if (psc == NeighboringCellInfo.UNKNOWN_CID) {
            psc = Measurement.UNKNOWN_CID;
        }
        m.setGsmCellLocation(mcc, mnc, m.getLac(), m.getCid(), psc, NetworkGroup.Wcdma);
    }
}
项目:TowerCollector    文件:UnitConverter.java   
public static int convertGsmDbmToAsu(int dbm) {
    if (dbm == Measurement.UNKNOWN_SIGNAL || dbm == NeighboringCellInfo.UNKNOWN_RSSI)
        return Measurement.UNKNOWN_SIGNAL;
    if (dbm <= -113)
        return 0;
    int asu = (dbm + 113) / 2;
    if (asu > 31)
        return 31;
    return asu;
}
项目:TowerCollector    文件:UnitConverter.java   
public static int convertLteAsuToDbm(int asu) {
    if (asu == Measurement.UNKNOWN_SIGNAL || asu == NeighboringCellInfo.UNKNOWN_RSSI)
        return Measurement.UNKNOWN_SIGNAL;
    if (asu <= 0)
        return -140;
    if (asu >= 97)
        return -43;
    return asu - 140;
}
项目:TowerCollector    文件:UnitConverter.java   
public static int convertLteDbmToAsu(int dbm) {
    if (dbm == Measurement.UNKNOWN_SIGNAL || dbm == NeighboringCellInfo.UNKNOWN_RSSI)
        return Measurement.UNKNOWN_SIGNAL;
    if (dbm <= -140)
        return 0;
    if (dbm >= -43)
        return 97;
    return dbm + 140;
}
项目:TowerCollector    文件:UnitConverter.java   
public static int convertCdmaAsuToDbm(int asu) {
    if (asu == Measurement.UNKNOWN_SIGNAL || asu == NeighboringCellInfo.UNKNOWN_RSSI)
        return Measurement.UNKNOWN_SIGNAL;
    if (asu == 16)
        return -75;
    else if (asu == 8)
        return -82;
    else if (asu == 4)
        return -90;
    else if (asu == 2)
        return -95;
    else if (asu == 1)
        return -100;
    return Measurement.UNKNOWN_SIGNAL;
}
项目:TowerCollector    文件:LegacyMeasurementProcessingEvent.java   
public LegacyMeasurementProcessingEvent(Location lastLocation, long lastLocationObtainedTime,
                                        CellLocation lastCellLocation, SignalStrength lastSignalStrength, NetworkGroup lastNetworkType,
                                        String lastOperatorCode, String lastOperatorName, List<NeighboringCellInfo> neighboringCells,
                                        int minDistance) {
    this.lastLocation = lastLocation;
    this.lastLocationObtainedTime = lastLocationObtainedTime;
    this.lastCellLocation = lastCellLocation;
    this.lastSignalStrength = lastSignalStrength;
    this.lastNetworkType = lastNetworkType;
    this.neighboringCells = neighboringCells;
    this.lastOperatorCode = lastOperatorCode;
    this.lastOperatorName = lastOperatorName;
    this.minDistance = minDistance;
}
项目:Android-IMSI-Catcher-Detector    文件:CellTracker.java   
private void handlePhoneStateChange() {
    List<NeighboringCellInfo> neighboringCellInfo = tm.getNeighboringCellInfo();
    if (neighboringCellInfo == null || neighboringCellInfo.size() == 0) {
        return;
    }

    log.info("NeighboringCellInfo empty - event based polling succeeded!");
    tm.listen(phoneStatelistener, PhoneStateListener.LISTEN_NONE);
    if (neighboringCellInfo == null) {
        neighboringCellInfo = new ArrayList<>();
    }
    neighboringCellBlockingQueue.addAll(neighboringCellInfo);
}
项目:openbmap    文件:WirelessLoggerService.java   
/**
 * @param ci
 * @return
 */
private boolean isValidNeigbor(final NeighboringCellInfo ci) {
    if (ci == null) {
        return false;
    }
    return (ci.getCid() !=  NeighboringCellInfo.UNKNOWN_CID || ci.getLac() != NeighboringCellInfo.UNKNOWN_CID || ci.getPsc() !=  NeighboringCellInfo.UNKNOWN_CID);
}
项目:android_external_UnifiedNlpApi    文件:CellBackendHelper.java   
private Cell parseCellInfo(NeighboringCellInfo info) {
    try {
        if (getCellType(info.getNetworkType()) != Cell.CellType.GSM) return null;
        return new Cell(Cell.CellType.GSM, getMcc(), getMnc(), info.getLac(), info.getCid(),
                info.getPsc(), info.getRssi());
    } catch (Exception ignored) {
    }
    return null;
}
项目:MiBandDecompiled    文件:ai.java   
protected final List m()
{
    ArrayList arraylist = new ArrayList();
    if (b == null)
    {
        return arraylist;
    }
    if (!c())
    {
        return arraylist;
    }
    Iterator iterator = b.getNeighboringCellInfo().iterator();
    int i1 = 0;
    do
    {
        if (!iterator.hasNext())
        {
            break;
        }
        NeighboringCellInfo neighboringcellinfo = (NeighboringCellInfo)iterator.next();
        if (i1 > 15)
        {
            break;
        }
        if (neighboringcellinfo.getLac() != 0 && neighboringcellinfo.getLac() != 65535 && neighboringcellinfo.getCid() != 65535 && neighboringcellinfo.getCid() != 0xfffffff)
        {
            arraylist.add(neighboringcellinfo);
            i1++;
        }
    } while (true);
    return arraylist;
}
项目:SignalAnalysis    文件:PhoneStateHelper.java   
/**
 * Get current neighboring cell info
 * 
 * @return neighboring cell information format as {@link String}
 */
public String getNeighboringCellInfo() {
    if (DBG)
        Log.d(Config.TAG, TAG + "getNeighboringCellInfo called");
    String ret = null;
    List<NeighboringCellInfo> listNeighboringCellInfo = mTelMgr
            .getNeighboringCellInfo();
    if (listNeighboringCellInfo != null)
        for (NeighboringCellInfo a_Info : listNeighboringCellInfo)
            ret = ret + "\nCell neighboring info : " + a_Info.getRssi()
                    + " - " + a_Info.getCid();
    return ret;
}
项目:Office-365-SDK-for-Android    文件:NetworkUtils.java   
/**
 * Retrieves network info data. *
 *
 * @return Current network info data.
 */
public static NetworkState getNetworkState(Context context) {
    NetworkState callInfoData = null;
    try {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        GsmCellLocation location = (GsmCellLocation) telephonyManager.getCellLocation();
        String mcc = "0";
        String mnc = "0";
        String networkOperator = telephonyManager.getNetworkOperator();
        if (networkOperator != null && networkOperator.length() > 0) {
            mcc = telephonyManager.getNetworkOperator().substring(0, 3);
            mnc = telephonyManager.getNetworkOperator().substring(3);
        }

        int[] neighborCellId;
        int[] neighborCellRssi;

        List<NeighboringCellInfo> neighboringList = telephonyManager.getNeighboringCellInfo();
        if (neighboringList != null && !neighboringList.isEmpty()) {
            neighborCellId = new int[neighboringList.size()];
            neighborCellRssi = new int[neighboringList.size()];
            for (int i = 0; i < neighboringList.size(); i++) {
                neighborCellRssi[i] = neighboringList.get(i).getRssi();
                neighborCellId[i] = neighboringList.get(i).getCid();
            }
        } else {
            neighborCellId = new int[] { -1 };
            neighborCellRssi = new int[] { -1 };
        }

        callInfoData = new NetworkState(System.currentTimeMillis(), (location != null) ? location.getCid() : 0, /* rssi, dbm, asu, */0, 0, 0,
                mcc, mnc, (location != null) ? location.getLac() : 0, NetworkUtils.isInRoaming(context),
                NetworkUtils.getDataConnectionState(context), NetworkUtils.getSimState(context), NetworkUtils.getNetworkType(context),
                NetworkUtils.isWiFiEnabled(context), neighborCellId, neighborCellRssi);
    } catch (final Exception e) {
        Logger.logApplicationException(e, NetworkUtils.class.getSimpleName() + ".getNetworkInfoData(): Failed.");
        e.printStackTrace();
    }
    return callInfoData;
}
项目:Simplicissimus    文件:CellIdPre17API.java   
public void fill(TheDictionary map, NeighboringCellInfo value) throws Exception {
    if (value != null) {
        map.put("mcc", mcc);
        map.put("mnc", mnc);
        int i;
        i = value.getPsc(); if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("psc", i);
        i = value.getRssi(); if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("rssi", i);
        i = value.getLac(); if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("lac", i);
        i = value.getCid(); if (i != NeighboringCellInfo.UNKNOWN_CID) map.put("cid", i);
        map.put("registered", false);
        determine_type(map);
    }
}
项目:LocalGSMLocationProvider    文件:CellTowerDatabase.java   
/**
 * Perform a (cached) DB query for a given cell tower. Note that MCC and MNC can be null.
 * @param mcc
 * @param mnc
 * @param cid
 * @param lac
 * @return
 */
public List<CellInfo> query(final Integer mcc, final Integer mnc, final int cid, final int lac) {
    if (this.reader == null) return null;

    if (cid == NeighboringCellInfo.UNKNOWN_CID || cid == Integer.MAX_VALUE) return null;

    if (mcc != null && mcc == Integer.MAX_VALUE) return query(null, mnc, cid, lac);
    if (mnc != null && mnc == Integer.MAX_VALUE) return query(mcc, null, cid, lac);

    QueryArgs args = new QueryArgs(mcc, mnc, cid, lac);
    Boolean negative = queryResultNegativeCache.get(args);
    if (negative != null && negative.booleanValue()) return null;

    List<CellInfo> cached = queryResultCache.get(args);
    if (cached != null) return cached;

    List<CellInfo> result = _query(mcc, mnc, cid, lac);

    if (result == null) {
        queryResultNegativeCache.put(args, true);
        return null;
    }

    result = Collections.unmodifiableList(result);

    queryResultCache.put(args, result);
    return result;
}
项目:LocalGSMLocationProvider    文件:CellTowerDatabase.java   
/**
 * Internal db query to retrieve all cell tower candidates for a given cid/lac.
 * @param mcc
 * @param mnc
 * @param cid
 * @param lac
 * @return
 */
private List<CellInfo> _query(Integer mcc, Integer mnc, int cid, int lac) {
    if (this.reader == null) return null;

    // we need at least CID/LAC
    if (cid == NeighboringCellInfo.UNKNOWN_CID) return null;

    android.util.Log.d("LNLP/Query", "(" + mcc + "," + mnc + "," + cid + "," + lac + ")");

    List<CellInfo> cil = _queryDirect(mcc, mnc, cid, lac);
    if (cil == null || cil.size() == 0) {
        if (cid > 0xffff) {
            _queryDirect(mcc, mnc, cid & 0xffff, lac);
        }
    }
    if (cil != null && cil.size() > 0) {
        return cil;
    }

    if (mcc != null && mnc != null) {
        return query(mcc, null, cid, lac);
    }

    if (mcc != null || mnc != null) {
        return query(null,null,cid,lac);
    }

    return null;
}
项目:skandroid-core    文件:CellTowersDataCollector.java   
synchronized static void sOnCellInfoChanged(List<CellInfo> cellInfo){
    List<NeighboringCellInfo> n = mTelManager.getNeighboringCellInfo();
    if( n != null && n.size() > 0){
        neighbours.setTime(System.currentTimeMillis());
        neighbours.setNeighbors(n);
    }
}
项目:skandroid-core    文件:CellTowersData.java   
public void setNeighbors(List<NeighboringCellInfo> inNeighbors) {

    // We NEVER allow the neighbors member to be set null.
    // Otherwise, tests might be mis-reported as failing.
    // If we're supplied a null value, set to use an empty list.
    if (inNeighbors == null) {
        // ... we should trap this where possible in the debugger...
        SKPorting.sAssert(getClass(), false);
     neighbors = new ArrayList<>();
    } else {
        neighbors = inNeighbors;
    }
}