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:Main.java

public static String convertPhoneType(int type) {
    switch (type) {
    case TelephonyManager.PHONE_TYPE_NONE:
        return "NONE";
    case TelephonyManager.PHONE_TYPE_GSM:
        return "GSM";
    case TelephonyManager.PHONE_TYPE_CDMA:
        return "CDMA";
    case TelephonyManager.PHONE_TYPE_SIP:
        return "SIP";
    default:/*from w  w w.  j  a  v  a2 s  .  c  o  m*/
        return UNKNOWN;
    }
}

From source file:Main.java

public static boolean canMakeCall(Context ctx) {
    TelephonyManager manager = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    return manager.getSimState() == TelephonyManager.SIM_STATE_READY
            && (manager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM
                    || manager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA);
}

From source file:Main.java

/**
 * @param phone_type "getPhoneType()"/*from w  ww.  j  a v  a 2  s . c o  m*/
 * @param id_length Length of device id string.
 * @return The date Google release the given Android version.
 */
public static String getDeviceIdType(int phone_type, int id_length) {
    switch (phone_type) {
    case TelephonyManager.PHONE_TYPE_GSM://1
        return "IMEI";
    case TelephonyManager.PHONE_TYPE_CDMA://2
        if (id_length == 8) {
            return "ESN";
        }
        return "MEID";
    default:
        return UNKNOWN;
    }
}

From source file:Main.java

/**
 * Returns a constant indicating the device phone type.
 * This indicates the type of radio used to transmit voice calls.
 * @param phone_type "getPhoneType()"//  w  ww  . j a v  a  2 s.com
 */
public static String getPhoneTypeStr(int phone_type) {
    switch (phone_type) {
    case TelephonyManager.PHONE_TYPE_NONE://0
        return "PHONE_TYPE_NONE";
    case TelephonyManager.PHONE_TYPE_GSM://1
        return "PHONE_TYPE_GSM";
    case TelephonyManager.PHONE_TYPE_CDMA://2
        return "PHONE_TYPE_CDMA";
    case TelephonyManager.PHONE_TYPE_SIP://3
        return "PHONE_TYPE_SIP";//API 11
    default:
        return UNKNOWN;
    }
}

From source file:Main.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//w  ww.j a v a  2s.  c om
 */
public static String getDeviceCountry(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.toLowerCase(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.toLowerCase(Locale.US);
            }
        }
    } catch (Exception e) {
    }
    return null;
}

From source file:Main.java

/**
 * /*w  w  w .  jav a  2s . c  om*/
 * @param type
 * @return
 */
public static String getTelephonyPhoneType(int type) {
    switch (type) {
    case TelephonyManager.PHONE_TYPE_CDMA:
        return "CDMA";
    case TelephonyManager.PHONE_TYPE_GSM:
        return "GSM";
    case TelephonyManager.PHONE_TYPE_NONE:
        return "None";
    default:
        return "Unknown[" + type + "]";
    }
}

From source file:uk.ac.ucl.excites.sapelli.shared.util.android.DeviceControl.java

public static boolean isCDMA(Context context) {
    return getPhoneType(context) == TelephonyManager.PHONE_TYPE_CDMA;
}

From source file:com.tingtingapps.securesms.mms.LegacyMmsConnection.java

protected boolean isCdmaDevice() {
    return ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
            .getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA;
}

From source file:org.mozilla.mozstumbler.service.stumblerthread.datahandling.StumblerBundle.java

public JSONObject toMLSJSON() throws JSONException {
    JSONObject item = new JSONObject();

    item.put(DataStorageContract.ReportsColumns.TIME, mGpsPosition.getTime());
    item.put(DataStorageContract.ReportsColumns.LAT, Math.floor(mGpsPosition.getLatitude() * 1.0E6) / 1.0E6);
    item.put(DataStorageContract.ReportsColumns.LON, Math.floor(mGpsPosition.getLongitude() * 1.0E6) / 1.0E6);

    if (mGpsPosition.hasAccuracy()) {
        item.put(DataStorageContract.ReportsColumns.ACCURACY, (int) Math.ceil(mGpsPosition.getAccuracy()));
    }/*w ww. j a va2 s  . c o m*/

    if (mGpsPosition.hasAltitude()) {
        item.put(DataStorageContract.ReportsColumns.ALTITUDE, Math.round(mGpsPosition.getAltitude()));
    }

    if (mPhoneType == TelephonyManager.PHONE_TYPE_GSM) {
        item.put(DataStorageContract.ReportsColumns.RADIO, "gsm");
    } else if (mPhoneType == TelephonyManager.PHONE_TYPE_CDMA) {
        item.put(DataStorageContract.ReportsColumns.RADIO, "cdma");
    } else {
        // issue #598. investigate this case further in future
        item.put(DataStorageContract.ReportsColumns.RADIO, "");
    }

    JSONArray cellJSON = new JSONArray();
    for (CellInfo c : mCellData.values()) {
        JSONObject obj = c.toJSONObject();
        cellJSON.put(obj);
    }

    item.put(DataStorageContract.ReportsColumns.CELL, cellJSON);
    item.put(DataStorageContract.ReportsColumns.CELL_COUNT, cellJSON.length());

    JSONArray wifis = new JSONArray();
    for (ScanResult s : mWifiData.values()) {
        JSONObject wifiEntry = new JSONObject();
        wifiEntry.put("key", s.BSSID);
        wifiEntry.put("frequency", s.frequency);
        wifiEntry.put("signal", s.level);
        wifis.put(wifiEntry);
    }
    item.put(DataStorageContract.ReportsColumns.WIFI, wifis);
    item.put(DataStorageContract.ReportsColumns.WIFI_COUNT, wifis.length());

    return item;
}

From source file:org.smssecure.smssecure.mms.LegacyMmsConnection.java

protected boolean isDirectConnect() {
    // We think Sprint supports direct connection over wifi/data, but not Verizon
    Set<String> sprintMccMncs = new HashSet<String>() {
        {/*w ww  .j  a  v  a 2s  .c o m*/
            add("312530");
            add("311880");
            add("311870");
            add("311490");
            add("310120");
            add("316010");
            add("312190");
        }
    };

    return ServiceUtil.getTelephonyManager(context).getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA
            && sprintMccMncs.contains(TelephonyUtil.getMccMnc(context));
}