Search in sources :

Example 1 with LocationServices

use of com.secupwn.aimsicd.utils.LocationServices in project Android-IMSI-Catcher-Detector by CellularPrivacy.

the class MainActivity method downloadBtsDataIfApiKeyAvailable.

private void downloadBtsDataIfApiKeyAvailable() {
    if (CellTracker.OCID_API_KEY != null && !CellTracker.OCID_API_KEY.equals("NA")) {
        Cell cell = new Cell();
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        String networkOperator = tm.getNetworkOperator();
        if (networkOperator != null && !networkOperator.isEmpty()) {
            int mcc = Integer.parseInt(networkOperator.substring(0, 3));
            cell.setMobileCountryCode(mcc);
            int mnc = Integer.parseInt(networkOperator.substring(3));
            cell.setMobileNetworkCode(mnc);
            log.debug("CELL:: mobileCountryCode=" + mcc + " mobileNetworkCode=" + mnc);
        }
        GeoLocation loc = mAimsicdService.lastKnownLocation();
        if (loc != null) {
            Helpers.msgLong(this, getString(R.string.contacting_opencellid_for_data));
            cell.setLon(loc.getLongitudeInDegrees());
            cell.setLat(loc.getLatitudeInDegrees());
            Helpers.getOpenCellData(this, cell, RequestTask.DBE_DOWNLOAD_REQUEST, mAimsicdService);
        } else {
            Helpers.msgShort(this, getString(R.string.waiting_for_location));
            // This uses the LocationServices to get CID/LAC/MNC/MCC to be used
            // for grabbing the BTS data from OCID, via their API.
            // CID Location Async Output Delegate Interface Implementation
            LocationServices.LocationAsync locationAsync = new LocationServices.LocationAsync();
            locationAsync.delegate = this;
            locationAsync.execute(mAimsicdService.getCell().getCellId(), mAimsicdService.getCell().getLocationAreaCode(), mAimsicdService.getCell().getMobileNetworkCode(), mAimsicdService.getCell().getMobileCountryCode());
        }
    } else {
        Helpers.sendMsg(this, getString(R.string.no_opencellid_key_detected));
    }
}
Also used : TelephonyManager(android.telephony.TelephonyManager) LocationServices(com.secupwn.aimsicd.utils.LocationServices) GeoLocation(com.secupwn.aimsicd.utils.GeoLocation) Cell(com.secupwn.aimsicd.utils.Cell)

Aggregations

TelephonyManager (android.telephony.TelephonyManager)1 Cell (com.secupwn.aimsicd.utils.Cell)1 GeoLocation (com.secupwn.aimsicd.utils.GeoLocation)1 LocationServices (com.secupwn.aimsicd.utils.LocationServices)1