Example usage for android.telephony TelephonyManager PHONE_TYPE_CDMA

List of usage examples for android.telephony TelephonyManager PHONE_TYPE_CDMA

Introduction

In this page you can find the example usage for android.telephony TelephonyManager PHONE_TYPE_CDMA.

Prototype

int PHONE_TYPE_CDMA

To view the source code for android.telephony TelephonyManager PHONE_TYPE_CDMA.

Click Source Link

Document

Phone radio is CDMA.

Usage

From source file:tw.com.ksmt.cloud.libs.Utils.java

/**
 * Get ISO 3166-1 alpha-2 country code for this device (or null if not available)
 *
 * @param context Context reference to get the TelephonyManager instance from
 * @return country code or null/*from w  w  w .j  a  v a  2s  .  c  o  m*/
 */
public static String getCountryBySIM(Context context) {
    try {
        final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        final String simCountry = tm.getSimCountryIso();
        if (simCountry != null && simCountry.length() == 2) { // SIM country code is available
            return simCountry.toUpperCase(Locale.US);
        } else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) { // device is not 3G (would be unreliable)
            String networkCountry = tm.getNetworkCountryIso();
            if (networkCountry != null && networkCountry.length() == 2) { // network country code is available
                return networkCountry.toUpperCase(Locale.US);
            }
        }
    } catch (Exception e) {
    }
    return null;
}

From source file:com.mobilyzer.util.PhoneUtils.java

/** Returns "GSM", "CDMA". */
private String getTelephonyPhoneType() {
    switch (telephonyManager.getPhoneType()) {
    case TelephonyManager.PHONE_TYPE_CDMA:
        return "CDMA";
    case TelephonyManager.PHONE_TYPE_GSM:
        return "GSM";
    case TelephonyManager.PHONE_TYPE_NONE:
        return "None";
    }//from   w  w w  .ja  v  a  2s .co m
    return "Unknown";
}

From source file:org.restcomm.app.utillib.DataObjects.PhoneState.java

public int getNetworkTypeNumber() {
    // Any UMTS based technologies, return 2
    switch (getNetworkType()) {
    case TelephonyManager.NETWORK_TYPE_HSDPA:
    case TelephonyManager.NETWORK_TYPE_HSPA:
    case TelephonyManager.NETWORK_TYPE_HSUPA:
    case TelephonyManager.NETWORK_TYPE_UMTS:
    case NETWORK_NEWTYPE_HSPAP:
        return 2;
    }//from w ww  .j  a va2 s .  co  m
    if (getPhoneType() == TelephonyManager.PHONE_TYPE_GSM)
        return 1;
    // TODO: Can we detect UMTS and return 2? Otherwise it returns 1 for GSM which is fine
    if (getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA)
        return 3;
    return 0;
}

From source file:com.SecUpwN.AIMSICD.AIMSICD.java

public DrawerMenuActivityConfiguration getNavDrawerConfiguration() {

    List<NavDrawerItem> menu = new ArrayList<>();

    //Section Main
    menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_MAIN, getString(R.string.main)));
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.CURRENT_TREAT_LEVEL, getString(R.string.cell_info_title),
            R.drawable.cell_tower, true)); // Cell Information (Neighboring cells etc)
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.PHONE_SIM_DETAILS, getString(R.string.device_info),
            R.drawable.ic_action_phone, true)); // Phone/SIM Details
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.ACD, getString(R.string.cell_lookup),
            R.drawable.stat_sys_download_anim0, false)); // Lookup "All Current Cell Details (ACD)"
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.DB_VIEWER, getString(R.string.db_viewer),
            R.drawable.ic_action_storage, true)); // Database Viewer
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.ANTENNA_MAP_VIEW, getString(R.string.map_view),
            R.drawable.ic_action_map, false)); // Antenna Map Viewer
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.MAIN.AT_COMMAND_INTERFACE,
            getString(R.string.at_command_title), R.drawable.ic_action_computer, true)); // AT Command Interface

    //Section Tracking
    menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_TRACKING, getString(R.string.tracking)));
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.TRACKING.TOGGLE_AIMSICD_MONITORING,
            getString(R.string.toggle_aimsicd_monitoring), R.drawable.untrack_cell, false)); // Toggle "AIMSICD Monitoring"
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.TRACKING.TOGGLE_2G_ONLY_NETWORK,
            getString(R.string.toggle_2g_only_network_lock), R.drawable.untrack_cell, false)); // Toggle "Track Cell Details"
    if (CellTracker.PHONE_TYPE == TelephonyManager.PHONE_TYPE_CDMA) {
        menu.add(DrawerMenuItem.create(DrawerMenu.ID.TRACKING.TRACK_FEMTOCELL,
                getString(R.string.toggle_femtocell), R.drawable.ic_action_network_cell, false, false)); // Track FemtoCell
    }/*  ww  w  .  ja  v a 2 s.  c  o  m*/

    //Section Settings
    menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_SETTINGS, getString(R.string.settings)));
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.SETTINGS.PREFERENCES, getString(R.string.preferences),
            R.drawable.ic_action_settings, false)); // Preferences
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.SETTINGS.BACKUP_DB, getString(R.string.backup_database),
            R.drawable.ic_action_import_export, false)); // Backup Database
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.SETTINGS.RESTORE_DB, getString(R.string.restore_database),
            R.drawable.ic_action_import_export, false)); // Restore Database

    //Section Application
    menu.add(DrawerMenuSection.create(DrawerMenu.ID.SECTION_APPLICATION, getString(R.string.application)));
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.DOWNLOAD_LOCAL_BST_DATA,
            getString(R.string.get_opencellid), R.drawable.stat_sys_download_anim0, false)); // "Download Local BTS data"
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.UPLOAD_LOCAL_BST_DATA,
            getString(R.string.upload_bts), R.drawable.stat_sys_upload_anim0, false)); // "Upload Local BTS data"
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.ABOUT, getString(R.string.about_aimsicd),
            R.drawable.ic_action_about, true)); // About
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.SEND_DEBUGGING_LOG, getString(R.string.send_logs),
            R.drawable.ic_action_computer, false)); // Debugging
    menu.add(DrawerMenuItem.create(DrawerMenu.ID.APPLICATION.QUIT, getString(R.string.quit),
            R.drawable.ic_action_remove, false)); // Quit

    DrawerMenuActivityConfiguration navDrawerActivityConfiguration = new DrawerMenuActivityConfiguration();
    navDrawerActivityConfiguration.setMainLayout(R.layout.main);
    navDrawerActivityConfiguration.setDrawerLayoutId(R.id.drawer_layout);
    navDrawerActivityConfiguration.setLeftDrawerId(R.id.left_drawer);
    navDrawerActivityConfiguration.setNavItems(menu);
    navDrawerActivityConfiguration.setDrawerOpenDesc(R.string.drawer_open);
    navDrawerActivityConfiguration.setDrawerCloseDesc(R.string.drawer_close);
    navDrawerActivityConfiguration.setBaseAdapter(new DrawerMenuAdapter(this, R.layout.drawer_item, menu));
    return navDrawerActivityConfiguration;
}

From source file:com.secupwn.aimsicd.service.CellTracker.java

/**
 *          I removed the timer that activated this code and now the code will be run when
 *          the cell changes so it will detect faster rather than using a timer that might
 *          miss an imsi catcher, also says cpu rather than refreshing every x seconds.
 *
 *          original comments below from xLaMbChOpSx
 *
 *
 *  Description:    (From xLaMbChOpSx commit comment)
 *
 *      Initial implementation for detection method 1 to compare the CID & LAC with the Cell
 *      Information Table contents as an initial implementation for detection of a changed LAC,
 *      once OCID issues (API key use etc) have been finalised this detection method can be
 *      extended to include checking of external data.
 *
 *      REMOVED: refresh timer info/*from ww  w  . j  a  v  a2  s  .c o m*/
 *
 *      As I have no real way of testing this I require testing by other project members who
 *      do have access to equipment or an environment where a changing LAC can be simulated
 *      thus confirming the accuracy of this implementation.
 *
 *      Presently this will only invoke the MEDIUM threat level through the notification and
 *      does not fully implement the capturing and score based method as per the issue details
 *      once further testing is complete the alert and tracking of information can be refined.
 *
 *      See:
 *        https://github.com/xLaMbChOpSx/Android-IMSI-Catcher-Detector/commit/43ae77e2a0cad10dfd50f92da5a998f9ece95b38
 *        https://github.com/SecUpwN/Android-IMSI-Catcher-Detector/issues/91#issuecomment-64391732
 *
 *  Short explanation:
 *
 *                  This is a polling mechanism for getting the LAC/CID and location
 *                  info for the currently connected cell.
 *
 *  Variables:
 *                  FIXED: now updates on cell change rather than a timer
 *                  There is a "timer" here (REFRESH_RATE), what exactly is it timing?
 *                  "Every REFRESH_RATE seconds, get connected cell details."
 *
 *  Issues:     [ ] We shouldn't do any detection here!
 *              [ ] We might wanna use a listener to do this?
 *                  Are there any reasons why not using a listener?
 *
 *  ChangeLog:
 *              2015-03-03  E:V:A           Changed getProp() to use TinyDB (SharedPreferences)
 *              2015-0x-xx  banjaxbanjo     Update: ??? (hey dude what did you do?)
 *
 */
public void compareLac(CellLocation location) {

    @Cleanup
    Realm realm = Realm.getDefaultInstance();

    switch (device.getPhoneId()) {

    case TelephonyManager.PHONE_TYPE_NONE:
    case TelephonyManager.PHONE_TYPE_SIP:
    case TelephonyManager.PHONE_TYPE_GSM:
        GsmCellLocation gsmCellLocation = (GsmCellLocation) location;
        if (gsmCellLocation != null) {
            monitorCell.setLocationAreaCode(gsmCellLocation.getLac());
            monitorCell.setCellId(gsmCellLocation.getCid());

            // Check if LAC is ok
            boolean lacOK = dbHelper.checkLAC(realm, monitorCell);
            if (!lacOK) {
                changedLAC = true;
                dbHelper.toEventLog(realm, 1, "Changing LAC");

                // Detection Logs are made in checkLAC()
                vibrate(100, Status.MEDIUM);
            } else {
                changedLAC = false;
            }

            if (tinydb.getBoolean("ocid_downloaded")) {
                if (!dbHelper.openCellExists(realm, monitorCell.getCellId())) {
                    dbHelper.toEventLog(realm, 2, "CID not in Import realm");

                    log.info("ALERT: Connected to unknown CID not in Import realm: " + monitorCell.getCellId());
                    vibrate(100, Status.MEDIUM);

                    cellIdNotInOpenDb = true;
                } else {
                    cellIdNotInOpenDb = false;
                }
            }
        }
        break;

    case TelephonyManager.PHONE_TYPE_CDMA:
        CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) location;
        if (cdmaCellLocation != null) {
            monitorCell.setLocationAreaCode(cdmaCellLocation.getNetworkId());
            monitorCell.setCellId(cdmaCellLocation.getBaseStationId());

            boolean lacOK = dbHelper.checkLAC(realm, monitorCell);
            if (!lacOK) {
                changedLAC = true;
                /*dbHelper.insertEventLog(
                        MiscUtils.getCurrentTimeStamp(),
                        monitorCell.getLAC(),
                        monitorCell.getCid(),
                        monitorCell.getPSC(),//This is giving weird values like 21478364... is this right?
                        String.valueOf(monitorCell.getLat()),
                        String.valueOf(monitorCell.getLon()),
                        (int)monitorCell.getAccuracy(),
                        1,
                        "Changing LAC"
                );*/
                dbHelper.toEventLog(realm, 1, "Changing LAC");
            } else {
                changedLAC = false;
            }
        }
    }
    setNotification();
}

From source file:ca.psiphon.PsiphonTunnel.java

private static String getDeviceRegion(Context context) {
    String region = "";
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    if (telephonyManager != null) {
        region = telephonyManager.getSimCountryIso();
        if (region == null) {
            region = "";
        }//from  w ww  .  ja v a  2s  .c o  m
        if (region.length() == 0 && telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
            region = telephonyManager.getNetworkCountryIso();
            if (region == null) {
                region = "";
            }
        }
    }
    if (region.length() == 0) {
        Locale defaultLocale = Locale.getDefault();
        if (defaultLocale != null) {
            region = defaultLocale.getCountry();
        }
    }
    return region.toUpperCase(Locale.US);
}

From source file:org.restcomm.app.utillib.Reporters.ReportManager.java

/**
 * @return {@link DeviceInfo} object used to get device properties
 * @throws RuntimeException if phone type is not GSM or CDMA
 *///from   w ww .jav  a 2  s.  c o  m
public DeviceInfo getDevice() {
    int phoneType = ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE)).getPhoneType();
    if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
        return new GSMDevice(mContext);
    } else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
        return new CDMADevice(mContext);
    } else {
        return new GSMDevice(mContext);
        //throw new RuntimeException("Unsupported phone type");
    }
}

From source file:com.android.bluetooth.map.BluetoothMapContent.java

private void setType(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) {
    if ((ap.getParameterMask() & MASK_TYPE) != 0) {
        TYPE type = null;// w  w  w  .j a va  2s  .c om
        if (fi.msgType == FilterInfo.TYPE_SMS) {
            if (fi.phoneType == TelephonyManager.PHONE_TYPE_GSM) {
                type = TYPE.SMS_GSM;
            } else if (fi.phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
                type = TYPE.SMS_CDMA;
            }
        } else if (fi.msgType == FilterInfo.TYPE_MMS) {
            type = TYPE.MMS;
        } else {
            type = TYPE.EMAIL;
        }
        if (D)
            Log.d(TAG, "setType: " + type);
        e.setType(type);
    }
}

From source file:com.secupwn.aimsicd.service.CellTracker.java

/**
 * Add entries to the {@link com.secupwn.aimsicd.data.model.Measure Measure} realm
 */// w w  w  . j a v  a 2  s  . co  m
public void onLocationChanged(Location loc) {
    // TODO: See issue #555 (DeviceApi17.java is using API 18 CellInfoWcdma calls.
    if (Build.VERSION.SDK_INT > 17) {
        DeviceApi18.loadCellInfo(tm, device);
    }

    if (!device.cell.isValid()) {
        CellLocation cellLocation = tm.getCellLocation();
        if (cellLocation != null) {
            switch (device.getPhoneId()) {

            case TelephonyManager.PHONE_TYPE_NONE:
            case TelephonyManager.PHONE_TYPE_SIP:
            case TelephonyManager.PHONE_TYPE_GSM:
                GsmCellLocation gsmCellLocation = (GsmCellLocation) cellLocation;
                device.cell.setCellId(gsmCellLocation.getCid()); // CID
                device.cell.setLocationAreaCode(gsmCellLocation.getLac()); // LAC
                device.cell.setPrimaryScramblingCode(gsmCellLocation.getPsc()); // PSC
                break;

            case TelephonyManager.PHONE_TYPE_CDMA:
                CdmaCellLocation cdmaCellLocation = (CdmaCellLocation) cellLocation;
                device.cell.setCellId(cdmaCellLocation.getBaseStationId()); // BSID ??
                device.cell.setLocationAreaCode(cdmaCellLocation.getNetworkId()); // NID
                device.cell.setSid(cdmaCellLocation.getSystemId()); // SID
                device.cell.setMobileNetworkCode(cdmaCellLocation.getSystemId()); // MNC <== BUG!??

                break;
            }
        }
    }

    if (loc != null && (Double.doubleToRawLongBits(loc.getLatitude()) != 0
            && Double.doubleToRawLongBits(loc.getLongitude()) != 0)) {

        device.cell.setLon(loc.getLongitude()); // gpsd_lon
        device.cell.setLat(loc.getLatitude()); // gpsd_lat
        device.cell.setSpeed(loc.getSpeed()); // speed        // TODO: Remove, we're not using it!
        device.cell.setAccuracy(loc.getAccuracy()); // gpsd_accu
        device.cell.setBearing(loc.getBearing()); // -- [deg]??   // TODO: Remove, we're not using it!
        device.setLastLocation(loc); //

        // Store last known location in preference
        SharedPreferences.Editor prefsEditor;
        prefsEditor = prefs.edit();
        prefsEditor.putString(context.getString(R.string.data_last_lat_lon),
                String.valueOf(loc.getLatitude()) + ":" + String.valueOf(loc.getLongitude()));
        prefsEditor.apply();

        // This only logs a BTS if we have GPS lock
        // TODO: Is correct behaviour? We should consider logging all cells, even without GPS.
        if (trackingCell) {
            // This also checks that the locationAreaCode are cid are not in DB before inserting
            @Cleanup
            Realm realm = Realm.getDefaultInstance();
            dbHelper.insertBTS(realm, device.cell);
        }
    }
}

From source file:com.android.bluetooth.map.BluetoothMapContent.java

private void setHandle(BluetoothMapMessageListingElement e, Cursor c, FilterInfo fi, BluetoothMapAppParams ap) {
    long handle = c.getLong(c.getColumnIndex(BaseColumns._ID));
    TYPE type = null;//from  www  .j ava  2 s  .c  o m
    if (fi.msgType == FilterInfo.TYPE_SMS) {
        if (fi.phoneType == TelephonyManager.PHONE_TYPE_GSM) {
            type = TYPE.SMS_GSM;
        } else if (fi.phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
            type = TYPE.SMS_CDMA;
        }
    } else if (fi.msgType == FilterInfo.TYPE_MMS) {
        type = TYPE.MMS;
    } else {
        type = TYPE.EMAIL;
    }
    if (D && type != null)
        Log.d(TAG, "setHandle: " + handle + " - Type: " + type.name());
    e.setHandle(handle, type);
}