Search in sources :

Example 1 with NeighboringCellInfo

use of android.telephony.NeighboringCellInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RadioInfo method updateNeighboringCids.

private final void updateNeighboringCids(List<NeighboringCellInfo> cids) {
    StringBuilder sb = new StringBuilder();
    if (cids != null) {
        if (cids.isEmpty()) {
            sb.append("no neighboring cells");
        } else {
            for (NeighboringCellInfo cell : cids) {
                sb.append(cell.toString()).append(" ");
            }
        }
    } else {
        sb.append("unknown");
    }
    mNeighboringCids.setText(sb.toString());
}
Also used : NeighboringCellInfo(android.telephony.NeighboringCellInfo)

Example 2 with NeighboringCellInfo

use of android.telephony.NeighboringCellInfo in project Android-IMSI-Catcher-Detector by CellularPrivacy.

the class CellTracker method updateNeighboringCells.

/**
     *  Description:    Updates Neighboring Cell details
     *
     *                  TODO: add more details...
     *
     *
     */
public List<Cell> updateNeighboringCells() {
    List<Cell> neighboringCells = new ArrayList<>();
    List<NeighboringCellInfo> neighboringCellInfo = tm.getNeighboringCellInfo();
    if (neighboringCellInfo == null) {
        neighboringCellInfo = new ArrayList<>();
    }
    // NC list present? (default is false)
    Boolean nclp = tinydb.getBoolean("nc_list_present");
    //if nclp = true then check for neighboringCellInfo
    if (neighboringCellInfo != null && neighboringCellInfo.size() == 0 && nclp) {
        log.info("NeighboringCellInfo is empty: start polling...");
        // Try to poll the neighboring cells for a few seconds
        // TODO What is this ??
        neighboringCellBlockingQueue = new LinkedBlockingQueue<>(100);
        // TODO: See issue #555 (DeviceApi17.java is using API 18 CellInfoWcdma calls.
        if (Build.VERSION.SDK_INT > 17) {
            DeviceApi18.startListening(tm, phoneStatelistener);
        } else {
            tm.listen(phoneStatelistener, PhoneStateListener.LISTEN_CELL_LOCATION | // API 17
            PhoneStateListener.LISTEN_CELL_INFO | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
        }
        // TODO: Consider removing ??
        for (int i = 0; i < 10 && neighboringCellInfo.size() == 0; i++) {
            try {
                log.debug("NeighboringCellInfo empty: trying " + i);
                NeighboringCellInfo info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS);
                if (info == null) {
                    neighboringCellInfo = tm.getNeighboringCellInfo();
                    if (neighboringCellInfo != null) {
                        if (neighboringCellInfo.size() > 0) {
                            // Can we think of a better log message here?
                            log.debug("NeighboringCellInfo found on " + i + " try. (time based)");
                            break;
                        } else {
                            continue;
                        }
                    }
                }
                List<NeighboringCellInfo> cellInfoList = new ArrayList<>(neighboringCellBlockingQueue.size() + 1);
                while (info != null) {
                    cellInfoList.add(info);
                    info = neighboringCellBlockingQueue.poll(1, TimeUnit.SECONDS);
                }
                neighboringCellInfo = cellInfoList;
            } catch (InterruptedException e) {
                // TODO: Add a more valuable message here!
                log.error("", e);
            }
        }
    }
    // Add NC list to DBi_measure:nc_list
    for (NeighboringCellInfo neighborCell : neighboringCellInfo) {
        log.info("NeighboringCellInfo -" + " LAC:" + neighborCell.getLac() + " CID:" + neighborCell.getCid() + " PSC:" + neighborCell.getPsc() + " RSSI:" + neighborCell.getRssi());
        final Cell cell = new Cell(neighborCell.getCid(), neighborCell.getLac(), neighborCell.getRssi(), neighborCell.getPsc(), neighborCell.getNetworkType(), false);
        neighboringCells.add(cell);
    }
    return neighboringCells;
}
Also used : NeighboringCellInfo(android.telephony.NeighboringCellInfo) ArrayList(java.util.ArrayList) Cell(com.secupwn.aimsicd.utils.Cell)

Example 3 with NeighboringCellInfo

use of android.telephony.NeighboringCellInfo in project AisenWeiBo by wangdan.

the class SinaSDK method locationMobileGetLocation.

/**
	 * 根据移动基站WIFI等数据获取当前位置信息
	 * 
	 * @return
	 * @throws TaskException
	 */
public SinaLocationMap locationMobileGetLocation() throws TaskException {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    // 请求版本信息
    requestMap.put("version", "2.0");
    // 请求地址信息
    requestMap.put("host", "api.weibo.com");
    // 请求类型
    requestMap.put("radio_type", "gsm");
    // 是否需要返回详细地址,可选,默认:false
    requestMap.put("request_address", "true");
    // 返回坐标是否偏移处理,偏移后坐标适合在新浪地图上使用(http://map.sina.com.cn),
    // 不适用于百度地图(各地图偏移量不同,请谨慎处理);可选,默认:false
    requestMap.put("decode_pos", "true");
    TelephonyManager mTelNet = (TelephonyManager) GlobalContext.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
    GsmCellLocation location = null;
    if (mTelNet != null)
        location = (GsmCellLocation) mTelNet.getCellLocation();
    if (location != null) {
        String operator = mTelNet.getNetworkOperator();
        int mcc = Integer.parseInt(operator.substring(0, 3));
        int mnc = Integer.parseInt(operator.substring(3));
        List<NeighboringCellInfo> cellInfoList = mTelNet.getNeighboringCellInfo();
        ArrayList<Map<String, Object>> cellMapList = new ArrayList<Map<String, Object>>();
        for (NeighboringCellInfo cellInfo : cellInfoList) {
            // 基站信息
            Map<String, Object> cellMap = new HashMap<String, Object>();
            // 基站号
            cellMap.put("cell_id", location.getCid());
            // 小区号
            cellMap.put("location_area_code", cellInfo.getLac());
            // 地区代码
            cellMap.put("mobile_country_code", mcc);
            // 运营商号
            cellMap.put("mobile_network_code", mnc);
            // 信号强度
            cellMap.put("signal_strength", cellInfo.getRssi());
            cellMapList.add(cellMap);
        }
        if (cellMapList.size() > 0)
            requestMap.put("cell_towers", cellMapList);
    }
    WifiManager wm = (WifiManager) GlobalContext.getInstance().getSystemService(Context.WIFI_SERVICE);
    List<ScanResult> scanResultList = wm.getScanResults();
    if (scanResultList != null && scanResultList.size() > 0) {
        ArrayList<Map<String, Object>> wifiMapList = new ArrayList<Map<String, Object>>();
        for (ScanResult scanResult : scanResultList) {
            // WIFI信息
            Map<String, Object> wifiMap = new HashMap<String, Object>();
            wifiMapList.add(wifiMap);
            wifiMap.put("mac_address", scanResult.BSSID);
            wifiMap.put("mac_name", scanResult.SSID);
            // 信号强度
            wifiMap.put("signal_strength", scanResult.level);
        }
        if (wifiMapList.size() > 0)
            requestMap.put("wifi_towers", wifiMapList);
    }
    HttpConfig config = getHttpConfig();
    Params params = new Params();
    params.addParameter("json", JSON.toJSONString(requestMap));
    return doPost(config, getSetting("locationMobileGetLocation"), null, params, null, SinaLocationMap.class);
}
Also used : WifiManager(android.net.wifi.WifiManager) ScanResult(android.net.wifi.ScanResult) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Params(org.aisen.android.network.http.Params) NeighboringCellInfo(android.telephony.NeighboringCellInfo) TelephonyManager(android.telephony.TelephonyManager) JSONObject(com.alibaba.fastjson.JSONObject) HttpConfig(org.aisen.android.network.http.HttpConfig) GsmCellLocation(android.telephony.gsm.GsmCellLocation) Map(java.util.Map) SinaLocationMap(org.aisen.weibo.sina.sinasdk.bean.SinaLocationMap) HashMap(java.util.HashMap)

Example 4 with NeighboringCellInfo

use of android.telephony.NeighboringCellInfo in project XobotOS by xamarin.

the class RIL method responseCellList.

private Object responseCellList(Parcel p) {
    int num, rssi;
    String location;
    ArrayList<NeighboringCellInfo> response;
    NeighboringCellInfo cell;
    num = p.readInt();
    response = new ArrayList<NeighboringCellInfo>();
    // Determine the radio access type
    String radioString = SystemProperties.get(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, "unknown");
    int radioType;
    if (radioString.equals("GPRS")) {
        radioType = NETWORK_TYPE_GPRS;
    } else if (radioString.equals("EDGE")) {
        radioType = NETWORK_TYPE_EDGE;
    } else if (radioString.equals("UMTS")) {
        radioType = NETWORK_TYPE_UMTS;
    } else if (radioString.equals("HSDPA")) {
        radioType = NETWORK_TYPE_HSDPA;
    } else if (radioString.equals("HSUPA")) {
        radioType = NETWORK_TYPE_HSUPA;
    } else if (radioString.equals("HSPA")) {
        radioType = NETWORK_TYPE_HSPA;
    } else {
        radioType = NETWORK_TYPE_UNKNOWN;
    }
    // Interpret the location based on radio access type
    if (radioType != NETWORK_TYPE_UNKNOWN) {
        for (int i = 0; i < num; i++) {
            rssi = p.readInt();
            location = p.readString();
            cell = new NeighboringCellInfo(rssi, location, radioType);
            response.add(cell);
        }
    }
    return response;
}
Also used : NeighboringCellInfo(android.telephony.NeighboringCellInfo)

Aggregations

NeighboringCellInfo (android.telephony.NeighboringCellInfo)4 ArrayList (java.util.ArrayList)2 ScanResult (android.net.wifi.ScanResult)1 WifiManager (android.net.wifi.WifiManager)1 TelephonyManager (android.telephony.TelephonyManager)1 GsmCellLocation (android.telephony.gsm.GsmCellLocation)1 JSONObject (com.alibaba.fastjson.JSONObject)1 Cell (com.secupwn.aimsicd.utils.Cell)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 HttpConfig (org.aisen.android.network.http.HttpConfig)1 Params (org.aisen.android.network.http.Params)1 SinaLocationMap (org.aisen.weibo.sina.sinasdk.bean.SinaLocationMap)1