Search in sources :

Example 1 with Cell

use of com.secupwn.aimsicd.utils.Cell 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)

Example 2 with Cell

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

the class MainActivity method processFinish.

@Override
public void processFinish(List<Cell> cells) {
    if (cells != null) {
        if (!cells.isEmpty()) {
            for (Cell cell : cells) {
                log.info("processFinish - Cell =" + cell.toString());
                if (cell.isValid()) {
                    mAimsicdService.setCell(cell);
                    Intent intent = new Intent(AimsicdService.UPDATE_DISPLAY);
                    intent.putExtra("update", true);
                    sendBroadcast(intent);
                }
            }
        }
    }
}
Also used : Intent(android.content.Intent) Cell(com.secupwn.aimsicd.utils.Cell)

Example 3 with Cell

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

the class MapViewerOsmDroid method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch(item.getItemId()) {
        case R.id.map_preferences:
            Intent intent = new Intent(this, MapPrefActivity.class);
            startActivity(intent);
            return true;
        case R.id.get_opencellid:
            {
                if (mBound) {
                    GeoLocation lastKnown = mAimsicdService.lastKnownLocation();
                    if (lastKnown != null) {
                        Helpers.msgLong(this, getString(R.string.contacting_opencellid_for_data));
                        Cell cell;
                        cell = mAimsicdService.getCell();
                        cell.setLon(lastKnown.getLongitudeInDegrees());
                        cell.setLat(lastKnown.getLatitudeInDegrees());
                        setRefreshActionButtonState(true);
                        TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false);
                        Helpers.getOpenCellData(this, cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP, mAimsicdService);
                        return true;
                    }
                }
                if (loc != null) {
                    Helpers.msgLong(this, getString(R.string.contacting_opencellid_for_data));
                    Cell cell = new Cell();
                    cell.setLat(loc.getLatitude());
                    cell.setLon(loc.getLongitude());
                    setRefreshActionButtonState(true);
                    TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false);
                    Helpers.getOpenCellData(this, cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP, mAimsicdService);
                } else {
                    Helpers.msgLong(this, getString(R.string.unable_to_determine_last_location));
                }
                return true;
            }
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : Intent(android.content.Intent) GeoLocation(com.secupwn.aimsicd.utils.GeoLocation) Cell(com.secupwn.aimsicd.utils.Cell)

Example 4 with Cell

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

the class DeviceFragment method getOpenCellIdResponseCallback.

@NonNull
private Callback getOpenCellIdResponseCallback() {
    return new Callback() {

        @Override
        public void onFailure(Request request, IOException e) {
            Handler refresh = new Handler(Looper.getMainLooper());
            refresh.post(new Runnable() {

                public void run() {
                    refreshFailed();
                }
            });
        }

        @Override
        public void onResponse(final Response response) throws IOException {
            Handler refresh = new Handler(Looper.getMainLooper());
            refresh.post(new Runnable() {

                public void run() {
                    Cell cell = responseToCell(response);
                    processFinish(cell);
                }
            });
        }
    };
}
Also used : Response(com.squareup.okhttp.Response) Callback(com.squareup.okhttp.Callback) Request(com.squareup.okhttp.Request) Handler(android.os.Handler) IOException(java.io.IOException) Cell(com.secupwn.aimsicd.utils.Cell) NonNull(android.support.annotation.NonNull)

Example 5 with Cell

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

the class MapFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch(item.getItemId()) {
        case R.id.map_preferences:
            Intent intent = new Intent(getActivity(), MapPrefActivity.class);
            startActivity(intent);
            return true;
        case R.id.get_opencellid:
            {
                if (mBound) {
                    GeoLocation lastKnown = mAimsicdService.lastKnownLocation();
                    if (lastKnown != null) {
                        Helpers.msgLong(getActivity(), getString(R.string.contacting_opencellid_for_data));
                        Cell cell;
                        cell = mAimsicdService.getCell();
                        cell.setLon(lastKnown.getLongitudeInDegrees());
                        cell.setLat(lastKnown.getLatitudeInDegrees());
                        setRefreshActionButtonState(true);
                        TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false);
                        Helpers.getOpenCellData((InjectionAppCompatActivity) getActivity(), cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP, mAimsicdService);
                        return true;
                    }
                }
                if (loc != null) {
                    Helpers.msgLong(getActivity(), getString(R.string.contacting_opencellid_for_data));
                    Cell cell = new Cell();
                    cell.setLat(loc.getLatitude());
                    cell.setLon(loc.getLongitude());
                    setRefreshActionButtonState(true);
                    TinyDB.getInstance().putBoolean(TinyDbKeys.FINISHED_LOAD_IN_MAP, false);
                    Helpers.getOpenCellData((InjectionAppCompatActivity) getActivity(), cell, RequestTask.DBE_DOWNLOAD_REQUEST_FROM_MAP, mAimsicdService);
                } else {
                    Helpers.msgLong(getActivity(), getString(R.string.unable_to_determine_last_location));
                }
                return true;
            }
        default:
            return super.onOptionsItemSelected(item);
    }
}
Also used : Intent(android.content.Intent) InjectionAppCompatActivity(io.freefair.android.injection.app.InjectionAppCompatActivity) GeoLocation(com.secupwn.aimsicd.utils.GeoLocation) Cell(com.secupwn.aimsicd.utils.Cell)

Aggregations

Cell (com.secupwn.aimsicd.utils.Cell)10 GeoLocation (com.secupwn.aimsicd.utils.GeoLocation)5 Intent (android.content.Intent)3 TelephonyManager (android.telephony.TelephonyManager)2 IOException (java.io.IOException)2 Location (android.location.Location)1 Handler (android.os.Handler)1 NonNull (android.support.annotation.NonNull)1 NeighboringCellInfo (android.telephony.NeighboringCellInfo)1 BaseInflaterAdapter (com.secupwn.aimsicd.adapters.BaseInflaterAdapter)1 CardItemData (com.secupwn.aimsicd.adapters.CardItemData)1 CellCardInflater (com.secupwn.aimsicd.adapters.CellCardInflater)1 GpsLocation (com.secupwn.aimsicd.data.model.GpsLocation)1 LocationServices (com.secupwn.aimsicd.utils.LocationServices)1 TruncatedLocation (com.secupwn.aimsicd.utils.TruncatedLocation)1 Callback (com.squareup.okhttp.Callback)1 Request (com.squareup.okhttp.Request)1 Response (com.squareup.okhttp.Response)1 InjectionAppCompatActivity (io.freefair.android.injection.app.InjectionAppCompatActivity)1 Realm (io.realm.Realm)1