Java Code Examples for android.telephony.TelephonyManager#NETWORK_TYPE_HSUPA

The following examples show how to use android.telephony.TelephonyManager#NETWORK_TYPE_HSUPA . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CellBackendHelper.java    From android_external_UnifiedNlpApi with Apache License 2.0 6 votes vote down vote up
private static Cell.CellType getCellType(int networkType) {
    switch (networkType) {
        case TelephonyManager.NETWORK_TYPE_GPRS:
        case TelephonyManager.NETWORK_TYPE_EDGE:
            return Cell.CellType.GSM;
        case TelephonyManager.NETWORK_TYPE_UMTS:
        case TelephonyManager.NETWORK_TYPE_HSDPA:
        case TelephonyManager.NETWORK_TYPE_HSUPA:
        case TelephonyManager.NETWORK_TYPE_HSPA:
        case TelephonyManager.NETWORK_TYPE_HSPAP:
            return Cell.CellType.UMTS;
        case TelephonyManager.NETWORK_TYPE_LTE:
            return Cell.CellType.LTE;
        case TelephonyManager.NETWORK_TYPE_EVDO_0:
        case TelephonyManager.NETWORK_TYPE_EVDO_A:
        case TelephonyManager.NETWORK_TYPE_EVDO_B:
        case TelephonyManager.NETWORK_TYPE_1xRTT:
        case TelephonyManager.NETWORK_TYPE_EHRPD:
        case TelephonyManager.NETWORK_TYPE_IDEN:
            return Cell.CellType.CDMA;
    }
    return null;
}
 
Example 2
Source File: NetUtils.java    From Aria with Apache License 2.0 5 votes vote down vote up
private static boolean isFastMobileNetwork(Context context) {
  TelephonyManager telephonyManager =
      (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
  switch (telephonyManager.getNetworkType()) {
    case TelephonyManager.NETWORK_TYPE_1xRTT:
      return false; // ~ 50-100 kbps
    case TelephonyManager.NETWORK_TYPE_CDMA:
      return false; // ~ 14-64 kbps
    case TelephonyManager.NETWORK_TYPE_EDGE:
      return false; // ~ 50-100 kbps
    case TelephonyManager.NETWORK_TYPE_EVDO_0:
      return true; // ~ 400-1000 kbps
    case TelephonyManager.NETWORK_TYPE_EVDO_A:
      return true; // ~ 600-1400 kbps
    case TelephonyManager.NETWORK_TYPE_GPRS:
      return false; // ~ 100 kbps
    case TelephonyManager.NETWORK_TYPE_HSDPA:
      return true; // ~ 2-14 Mbps
    case TelephonyManager.NETWORK_TYPE_HSPA:
      return true; // ~ 700-1700 kbps
    case TelephonyManager.NETWORK_TYPE_HSUPA:
      return true; // ~ 1-23 Mbps
    case TelephonyManager.NETWORK_TYPE_UMTS:
      return true; // ~ 400-7000 kbps
    case TelephonyManager.NETWORK_TYPE_EHRPD:
      return true; // ~ 1-2 Mbps
    case TelephonyManager.NETWORK_TYPE_EVDO_B:
      return true; // ~ 5 Mbps
    case TelephonyManager.NETWORK_TYPE_HSPAP:
      return true; // ~ 10-20 Mbps
    case TelephonyManager.NETWORK_TYPE_IDEN:
      return false; // ~25 kbps
    case TelephonyManager.NETWORK_TYPE_LTE:
      return true; // ~ 10+ Mbps
    case TelephonyManager.NETWORK_TYPE_UNKNOWN:
      return false;
    default:
      return false;
  }
}
 
Example 3
Source File: NetCheck.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
/**
 * GPRS    2G(2.5) General Packet Radia Service 114kbps
 * EDGE    2G(2.75G) Enhanced Data Rate for GSM Evolution 384kbps
 * UMTS    3G WCDMA 联通3G Universal Mobile Telecommunication System 完整的3G移动通信技术标准
 * CDMA    2G 电信 Code Division Multiple Access 码分多址
 * EVDO_0  3G (EVDO 全程 CDMA2000 1xEV-DO) Evolution - Data Only (Data Optimized) 153.6kps - 2.4mbps 属于3G
 * EVDO_A  3G 1.8mbps - 3.1mbps 属于3G过渡,3.5G
 * 1xRTT   2G CDMA2000 1xRTT (RTT - 无线电传输技术) 144kbps 2G的过渡,
 * HSDPA   3.5G 高速下行分组接入 3.5G WCDMA High Speed Downlink Packet Access 14.4mbps
 * HSUPA   3.5G High Speed Uplink Packet Access 高速上行链路分组接入 1.4 - 5.8 mbps
 * HSPA    3G (分HSDPA,HSUPA) High Speed Packet Access
 * IDEN    2G Integrated Dispatch Enhanced Networks 集成数字增强型网络 (属于2G,来自维基百科)
 * EVDO_B  3G EV-DO Rev.B 14.7Mbps 下行 3.5G
 * LTE     4G Long Term Evolution FDD-LTE 和 TDD-LTE , 3G过渡,升级版 LTE Advanced 才是4G
 * EHRPD   3G CDMA2000向LTE 4G的中间产物 Evolved High Rate Packet Data HRPD的升级
 * HSPAP   3G HSPAP 比 HSDPA 快些
 *
 * @return {@link  NetWorkType}
 */
public static NetWorkType getNetworkType(Context context) {
    int type = getConnectedTypeINT(context);
    switch (type) {
        case ConnectivityManager.TYPE_WIFI:
            return NetWorkType.Wifi;
        case ConnectivityManager.TYPE_MOBILE:
        case ConnectivityManager.TYPE_MOBILE_DUN:
        case ConnectivityManager.TYPE_MOBILE_HIPRI:
        case ConnectivityManager.TYPE_MOBILE_MMS:
        case ConnectivityManager.TYPE_MOBILE_SUPL:
            int teleType = getTelephonyManager(context).getNetworkType();
            switch (teleType) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    return NetWorkType.Net2G;
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    return NetWorkType.Net3G;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    return NetWorkType.Net4G;
                default:
                    return NetWorkType.UnKnown;
            }
        default:
            return NetWorkType.UnKnown;
    }
}
 
Example 4
Source File: NetworkUtil.java    From ViewDebugHelper with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**<br/>
 * http://www.binkery.com/post/368.html<br/>*/
private static boolean isSlowMobileNetwork(Context context){
	TelephonyManager telephonyManager = (TelephonyManager) context
			.getSystemService(Context.TELEPHONY_SERVICE);
	boolean result=true;
	if(telephonyManager!=null){
		switch(telephonyManager.getNetworkType()){
			case TelephonyManager.NETWORK_TYPE_GPRS:
			case TelephonyManager.NETWORK_TYPE_EDGE:
			case TelephonyManager.NETWORK_TYPE_CDMA:
			case TelephonyManager.NETWORK_TYPE_1xRTT:
			case TelephonyManager.NETWORK_TYPE_IDEN:
				result=true;//2g
				break;
			case TelephonyManager.NETWORK_TYPE_UMTS:
			case TelephonyManager.NETWORK_TYPE_EVDO_0:
			case TelephonyManager.NETWORK_TYPE_EVDO_A:
			case TelephonyManager.NETWORK_TYPE_HSDPA:
			case TelephonyManager.NETWORK_TYPE_HSUPA:
			case TelephonyManager.NETWORK_TYPE_HSPA:
			case TelephonyManager.NETWORK_TYPE_EVDO_B:
			case TelephonyManager.NETWORK_TYPE_EHRPD:
			case TelephonyManager.NETWORK_TYPE_HSPAP:
				result=false;//3g
				break;
			case TelephonyManager.NETWORK_TYPE_LTE:
				result=false;//4g
				break;
			case TelephonyManager.NETWORK_TYPE_UNKNOWN:
				result=true;
				break;
		}
	}else{
		result=true;
	}
	return result;
}
 
Example 5
Source File: NetworkUtil.java    From DoingDaily with Apache License 2.0 5 votes vote down vote up
/**
 * 是否正在使用3g或者4g网络
 *
 * @param context
 * @return
 */
public static boolean is3GOr4GNetwork(Context context) {
    if (context == null) {
        return false;
    }
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivityManager != null) {
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        if (activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting()) {
            if (activeNetworkInfo.getType() != ConnectivityManager.TYPE_WIFI) {
                switch (activeNetworkInfo.getSubtype()) {
                    case TelephonyManager.NETWORK_TYPE_LTE: //4G
                    case TelephonyManager.NETWORK_TYPE_UMTS:
                    case TelephonyManager.NETWORK_TYPE_HSDPA:
                    case TelephonyManager.NETWORK_TYPE_HSUPA:
                    case TelephonyManager.NETWORK_TYPE_HSPA:
                    case TelephonyManager.NETWORK_TYPE_EVDO_0:
                    case TelephonyManager.NETWORK_TYPE_EVDO_A:
                    case TelephonyManager.NETWORK_TYPE_EVDO_B:
                    case TelephonyManager.NETWORK_TYPE_EHRPD:
                    case TelephonyManager.NETWORK_TYPE_HSPAP:
                        return true;
                }
            }
        }
    }
    return false;
}
 
Example 6
Source File: Connectivity.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
public static String getNetworkClass(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();
    if (info == null || !info.isConnected())
        return "-"; //not connected
    if (info.getType() == ConnectivityManager.TYPE_WIFI)
        return "WIFI";
    if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
        int networkType = info.getSubtype();
        switch (networkType) {
            case TelephonyManager.NETWORK_TYPE_GPRS:
            case TelephonyManager.NETWORK_TYPE_EDGE:
            case TelephonyManager.NETWORK_TYPE_CDMA:
            case TelephonyManager.NETWORK_TYPE_1xRTT:
            case TelephonyManager.NETWORK_TYPE_IDEN: //api<8 : replace by 11
                return "2G";
            case TelephonyManager.NETWORK_TYPE_UMTS:
            case TelephonyManager.NETWORK_TYPE_EVDO_0:
            case TelephonyManager.NETWORK_TYPE_EVDO_A:
            case TelephonyManager.NETWORK_TYPE_HSDPA:
            case TelephonyManager.NETWORK_TYPE_HSUPA:
            case TelephonyManager.NETWORK_TYPE_HSPA:
            case TelephonyManager.NETWORK_TYPE_EVDO_B: //api<9 : replace by 14
            case TelephonyManager.NETWORK_TYPE_EHRPD:  //api<11 : replace by 12
            case TelephonyManager.NETWORK_TYPE_HSPAP:  //api<13 : replace by 15
                return "3G";
            case TelephonyManager.NETWORK_TYPE_LTE:    //api<11 : replace by 13
                return "4G";
            default:
                return "?";
        }
    }
    return "?";
}
 
Example 7
Source File: NetworkUtils.java    From android-utils with Apache License 2.0 4 votes vote down vote up
/**
 * Check if the connection is fast
 *
 * @param type    the type
 * @param subType the sub type
 * @return boolean boolean
 */
public static boolean isConnectionFast(int type, int subType) {
    if (type == ConnectivityManager.TYPE_WIFI) {
        return true;
    } else if (type == ConnectivityManager.TYPE_MOBILE) {
        switch (subType) {
            case TelephonyManager.NETWORK_TYPE_1xRTT:
                return false; // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_CDMA:
                return false; // ~ 14-64 kbps
            case TelephonyManager.NETWORK_TYPE_EDGE:
                return false; // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_0:
                return true; // ~ 400-1000 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_A:
                return true; // ~ 600-1400 kbps
            case TelephonyManager.NETWORK_TYPE_GPRS:
                return false; // ~ 100 kbps
            case TelephonyManager.NETWORK_TYPE_HSDPA:
                return true; // ~ 2-14 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPA:
                return true; // ~ 700-1700 kbps
            case TelephonyManager.NETWORK_TYPE_HSUPA:
                return true; // ~ 1-23 Mbps
            case TelephonyManager.NETWORK_TYPE_UMTS:
                return true; // ~ 400-7000 kbps
            /*
             * Above API level 7, make sure to set android:targetSdkVersion
             * to appropriate level to use these
             */
            case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11
                return true; // ~ 1-2 Mbps
            case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9
                return true; // ~ 5 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13
                return true; // ~ 10-20 Mbps
            case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8
                return false; // ~25 kbps
            case TelephonyManager.NETWORK_TYPE_LTE: // API level 11
                return true; // ~ 10+ Mbps
            // Unknown
            case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            default:
                return false;
        }
    } else {
        return false;
    }
}
 
Example 8
Source File: RequestFileDownload.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Check if the connection is fast
 */
public int getMaxLimitDownload() {
    if (maxLimitDownload > 0) {
        return maxLimitDownload;
    }

    int maxLimit;

    if (HelperCheckInternetConnection.connectivityType == -1) {
        HelperCheckInternetConnection.detectConnectionTypeForDownload();
    }

    if (HelperCheckInternetConnection.connectivityType == ConnectivityManager.TYPE_WIFI) {
        int linkSpeed = 10;

        WifiManager wifiManager = (WifiManager) G.context.getSystemService(Context.WIFI_SERVICE);
        if (wifiManager != null) {
            WifiInfo wifiInfo = wifiManager.getConnectionInfo();
            if (wifiInfo != null) {
                linkSpeed = wifiInfo.getLinkSpeed();  // Mbps
                linkSpeed = (linkSpeed * 1024);   // Kbps
                //linkSpeed = (linkSpeed * 1024) / 8; // KByte per second
            }
        }

        if (linkSpeed < 100) {
            maxLimit = KB_10;
        } else if (linkSpeed < 1000) {
            maxLimit = KB_30;
        } else if (linkSpeed < 1500) {
            maxLimit = KB_50;
        } else {
            maxLimit = KB_100;
        }

    } else if (HelperCheckInternetConnection.connectivityType == ConnectivityManager.TYPE_MOBILE) {
        switch (HelperCheckInternetConnection.connectivitySubType) {
            case TelephonyManager.NETWORK_TYPE_CDMA:  // ~ 14-64  kbps
            case TelephonyManager.NETWORK_TYPE_IDEN:  // ~ 25     kbps -> API level 8
            case TelephonyManager.NETWORK_TYPE_1xRTT: // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_EDGE:  // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_GPRS:  // ~ 100    kbps
                maxLimit = KB_10;
                break;


            case TelephonyManager.NETWORK_TYPE_EVDO_0: // ~ 400-1000 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_A: // ~ 600-1400 kbps
                maxLimit = KB_30;
                break;


            case TelephonyManager.NETWORK_TYPE_HSPA: // ~ 700-1700 kbps
            case TelephonyManager.NETWORK_TYPE_UMTS: // ~ 400-7000 kbps
                maxLimit = KB_50;
                break;


            case TelephonyManager.NETWORK_TYPE_EHRPD:  // ~ 1-2   Mbps -> API level 11
            case TelephonyManager.NETWORK_TYPE_HSUPA:  // ~ 1-23  Mbps
            case TelephonyManager.NETWORK_TYPE_HSDPA:  // ~ 2-14  Mbps
            case TelephonyManager.NETWORK_TYPE_EVDO_B: // ~ 5     Mbps -> API level 9
            case TelephonyManager.NETWORK_TYPE_HSPAP:  // ~ 10-20 Mbps -> API level 13
            case TelephonyManager.NETWORK_TYPE_LTE:    // ~ 10+   Mbps -> API level 11
                maxLimit = KB_100;
                break;


            case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            default:
                maxLimit = KB_10;
        }
    } else {
        maxLimit = KB_10;
    }

    maxLimitDownload = maxLimit;
    return maxLimit;
}
 
Example 9
Source File: NetWorkUtils.java    From Readhub with Apache License 2.0 4 votes vote down vote up
public static NetworkType getNetworkType() {
    NetworkType netType = NetworkType.NETWORK_NO;
    NetworkInfo info = getActiveNetworkInfo();
    if (info != null && info.isAvailable()) {

        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            netType = NetworkType.NETWORK_WIFI;
        } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            switch (info.getSubtype()) {

                case NETWORK_TYPE_GSM:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    netType = NetworkType.NETWORK_2G;
                    break;

                case NETWORK_TYPE_TD_SCDMA:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    netType = NetworkType.NETWORK_3G;
                    break;

                case NETWORK_TYPE_IWLAN:
                case TelephonyManager.NETWORK_TYPE_LTE:
                    netType = NetworkType.NETWORK_4G;
                    break;
                default:

                    String subtypeName = info.getSubtypeName();
                    if (subtypeName.equalsIgnoreCase("TD-SCDMA")
                            || subtypeName.equalsIgnoreCase("WCDMA")
                            || subtypeName.equalsIgnoreCase("CDMA2000")) {
                        netType = NetworkType.NETWORK_3G;
                    } else {
                        netType = NetworkType.NETWORK_UNKNOWN;
                    }
                    break;
            }
        } else {
            netType = NetworkType.NETWORK_UNKNOWN;
        }
    }
    return netType;
}
 
Example 10
Source File: NetworkUtils.java    From Trojan with Apache License 2.0 4 votes vote down vote up
public static int getNetworkType(Context context) {
    if (null == context) {
        return NETWORK_NONE;
    }
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (null == connectivityManager) {
        return NETWORK_NONE;
    }

    final NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
    if (null == activeNetInfo || !activeNetInfo.isAvailable()) {
        return NETWORK_NONE;
    } else if (activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
        return NETWORK_WIFI;
    } else if (activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
        final NetworkInfo.State state = activeNetInfo.getState();
        final String subTypeName = activeNetInfo.getSubtypeName();
        if (null != state) {
            switch (activeNetInfo.getSubtype()) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    return NETWORK_2G;
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    return NETWORK_3G;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    return NETWORK_4G;
                default:
                    if (subTypeName.equalsIgnoreCase("TD-SCDMA")
                            || subTypeName.equalsIgnoreCase("WCDMA")
                            || subTypeName.equalsIgnoreCase("CDMA2000")) {
                        return NETWORK_3G;
                    } else {
                        return NETWORK_UNKNOWN_MOBILE;
                    }
            }
        }
    }
    return NETWORK_NONE;
}
 
Example 11
Source File: DeviceHelper.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
/**
 * Get the current networking
 * 
 * @return WIFI or MOBILE
 */
private boolean isFastMobileNetwork() {
	TelephonyManager phone = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
	if (phone == null) {
		return false;
	}

	switch (phone.getNetworkType()) {
	case TelephonyManager.NETWORK_TYPE_1xRTT:
		return false; // ~ 50-100 kbps
	case TelephonyManager.NETWORK_TYPE_CDMA:
		return false; // ~ 14-64 kbps
	case TelephonyManager.NETWORK_TYPE_EDGE:
		return false; // ~ 50-100 kbps
	case TelephonyManager.NETWORK_TYPE_EVDO_0:
		return true; // ~ 400-1000 kbps
	case TelephonyManager.NETWORK_TYPE_EVDO_A:
		return true; // ~ 600-1400 kbps
	case TelephonyManager.NETWORK_TYPE_GPRS:
		return false; // ~ 100 kbps
	case TelephonyManager.NETWORK_TYPE_HSDPA:
		return true; // ~ 2-14 Mbps
	case TelephonyManager.NETWORK_TYPE_HSPA:
		return true; // ~ 700-1700 kbps
	case TelephonyManager.NETWORK_TYPE_HSUPA:
		return true; // ~ 1-23 Mbps
	case TelephonyManager.NETWORK_TYPE_UMTS:
		return true; // ~ 400-7000 kbps
	case 14: // TelephonyManager.NETWORK_TYPE_EHRPD:
		return true; // ~ 1-2 Mbps
	case 12: // TelephonyManager.NETWORK_TYPE_EVDO_B:
		return true; // ~ 5 Mbps
	case 15: // TelephonyManager.NETWORK_TYPE_HSPAP:
		return true; // ~ 10-20 Mbps
	case TelephonyManager.NETWORK_TYPE_IDEN:
		return false; // ~25 kbps
	case 13: // TelephonyManager.NETWORK_TYPE_LTE:
		return true; // ~ 10+ Mbps
	case TelephonyManager.NETWORK_TYPE_UNKNOWN:
		return false;
	}
	return false;
}
 
Example 12
Source File: NetworkChangeNotifierAutoDetect.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the connection subtype for the given NetworkState.
 */
public int getConnectionSubtype() {
    if (!isConnected()) {
        return ConnectionSubtype.SUBTYPE_NONE;
    }

    switch (getNetworkType()) {
        case ConnectivityManager.TYPE_ETHERNET:
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_WIMAX:
        case ConnectivityManager.TYPE_BLUETOOTH:
            return ConnectionSubtype.SUBTYPE_UNKNOWN;
        case ConnectivityManager.TYPE_MOBILE:
            // Use information from TelephonyManager to classify the connection.
            switch (getNetworkSubType()) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                    return ConnectionSubtype.SUBTYPE_GPRS;
                case TelephonyManager.NETWORK_TYPE_EDGE:
                    return ConnectionSubtype.SUBTYPE_EDGE;
                case TelephonyManager.NETWORK_TYPE_CDMA:
                    return ConnectionSubtype.SUBTYPE_CDMA;
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                    return ConnectionSubtype.SUBTYPE_1XRTT;
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    return ConnectionSubtype.SUBTYPE_IDEN;
                case TelephonyManager.NETWORK_TYPE_UMTS:
                    return ConnectionSubtype.SUBTYPE_UMTS;
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                    return ConnectionSubtype.SUBTYPE_EVDO_REV_0;
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                    return ConnectionSubtype.SUBTYPE_EVDO_REV_A;
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                    return ConnectionSubtype.SUBTYPE_HSDPA;
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                    return ConnectionSubtype.SUBTYPE_HSUPA;
                case TelephonyManager.NETWORK_TYPE_HSPA:
                    return ConnectionSubtype.SUBTYPE_HSPA;
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                    return ConnectionSubtype.SUBTYPE_EVDO_REV_B;
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                    return ConnectionSubtype.SUBTYPE_EHRPD;
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    return ConnectionSubtype.SUBTYPE_HSPAP;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    return ConnectionSubtype.SUBTYPE_LTE;
                default:
                    return ConnectionSubtype.SUBTYPE_UNKNOWN;
            }
        default:
            return ConnectionSubtype.SUBTYPE_UNKNOWN;
    }
}
 
Example 13
Source File: Network.java    From Saiy-PS with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Get the current connection type from the {@link ConnectivityManager}
 *
 * @param ctx the application Context
 * @return the integer constant of the connection type
 */
public static int getConnectionType(final Context ctx) {
    final NetworkInfo info = getActiveNetworkInfo(ctx);
    final int infoType = info.getType();

    switch (infoType) {

        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_ETHERNET:
        case ConnectivityManager.TYPE_BLUETOOTH:
            if (DEBUG) {
                MyLog.i(CLS_NAME, "getConnectionType: CONNECTION_TYPE_WIFI");
            }
            return CONNECTION_TYPE_WIFI;

        case ConnectivityManager.TYPE_WIMAX:
            if (DEBUG) {
                MyLog.i(CLS_NAME, "getConnectionType: CONNECTION_TYPE_4G");
            }
            return CONNECTION_TYPE_4G;

        case ConnectivityManager.TYPE_MOBILE:

            final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
            final int networkType = tm.getNetworkType();

            switch (networkType) {

                case TelephonyManager.NETWORK_TYPE_GPRS: // ~ 100 kbps
                case TelephonyManager.NETWORK_TYPE_EDGE: // ~ 50-100 kbps
                case TelephonyManager.NETWORK_TYPE_CDMA: // ~ 14-64 kbps
                case TelephonyManager.NETWORK_TYPE_1xRTT: // ~ 50-100 kbps
                case TelephonyManager.NETWORK_TYPE_IDEN: // ~25 kbps
                    if (DEBUG) {
                        MyLog.i(CLS_NAME, "getConnectionType: CONNECTION_TYPE_2G");
                    }
                    return CONNECTION_TYPE_2G;

                case TelephonyManager.NETWORK_TYPE_UMTS: // ~ 400-7000 kbps
                case TelephonyManager.NETWORK_TYPE_EVDO_0: // ~ 400-1000 kbps
                case TelephonyManager.NETWORK_TYPE_EVDO_A: // ~ 600-1400 kbps
                case TelephonyManager.NETWORK_TYPE_HSDPA: // ~ 2-14 Mbps
                case TelephonyManager.NETWORK_TYPE_HSUPA: // ~ 1-23 Mbps
                case TelephonyManager.NETWORK_TYPE_HSPA: // ~ 700-1700 kbps
                case TelephonyManager.NETWORK_TYPE_EVDO_B: // ~ 5 Mbps
                case TelephonyManager.NETWORK_TYPE_EHRPD: // ~ 1-2 Mbps
                    if (DEBUG) {
                        MyLog.i(CLS_NAME, "getConnectionType: CONNECTION_TYPE_3G");
                    }
                    return CONNECTION_TYPE_3G;

                case TelephonyManager.NETWORK_TYPE_LTE: // ~ 10+ Mbps
                    if (DEBUG) {
                        MyLog.i(CLS_NAME, "getConnectionType: CONNECTION_TYPE_4G");
                    }
                    return CONNECTION_TYPE_4G;
                case TelephonyManager.NETWORK_TYPE_HSPAP: // ~ 10-20 Mbps
                    if (DEBUG) {
                        MyLog.i(CLS_NAME, "getConnectionType: CONNECTION_TYPE_4G");
                    }
                    return CONNECTION_TYPE_4G;

                default:
                    if (DEBUG) {
                        MyLog.w(CLS_NAME, "getConnectionType: CONNECTION_TYPE_UNKNOWN");
                    }
                    return CONNECTION_TYPE_UNKNOWN;

            }

        default:
            if (DEBUG) {
                MyLog.w(CLS_NAME, "getConnectionType: CONNECTION_TYPE_UNKNOWN");
            }
            return CONNECTION_TYPE_UNKNOWN;
    }
}
 
Example 14
Source File: CellTowerListGsm.java    From satstat with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Adds or updates a cell tower.
 * <p>
 * If the cell tower is already in the list, its data is updated; if not, a
 * new entry is created. Cells whose network type is not a flavor of GSM or
 * UMTS will be rejected.
 * <p>
 * This method will set the cell's identity data, generation and its signal
 * strength. 
 * @return The new or updated entry, or {@code null} if the cell was rejected
 */
public CellTowerGsm update(String networkOperator, NeighboringCellInfo cell) {
	int mcc = CellTower.UNKNOWN;
	int mnc = CellTower.UNKNOWN;
	if (networkOperator.length() > 3) {
		mcc = Integer.parseInt(networkOperator.substring(0, 3));
		mnc = Integer.parseInt(networkOperator.substring(3));
	}
	CellTowerGsm result = null;
	CellTowerGsm cand = this.get(mcc, mnc, cell.getLac(), cell.getCid());
	if ((cand != null) && CellTower.matches(cell.getPsc(), cand.getPsc()))
		result = cand;

	if (result == null) {
		cand = this.get(cell.getPsc());
		if ((cand != null)
				&& CellTower.matches(mcc, cand.getMcc())
				&& CellTower.matches(mnc, cand.getMnc())
				&& CellTower.matches(cell.getLac(), cand.getLac())
				&& CellTower.matches(cell.getCid(), cand.getCid()))
			result = cand;
	}
	if (result == null)
		result = new CellTowerGsm(mcc, mnc, cell.getLac(), cell.getCid(), cell.getPsc());
	result.setNeighboringCellInfo(true);
	int networkType = cell.getNetworkType();
	switch (networkType) {
		case TelephonyManager.NETWORK_TYPE_UMTS:
		case TelephonyManager.NETWORK_TYPE_HSDPA:
		case TelephonyManager.NETWORK_TYPE_HSUPA:
		case TelephonyManager.NETWORK_TYPE_HSPA:
			/*
			 * for details see TS 25.133 section 9.1.1.3
			 * http://www.3gpp.org/DynaReport/25133.htm
			 */
			result.setCpichRscp(cell.getRssi());
			break;
		case TelephonyManager.NETWORK_TYPE_EDGE:
		case TelephonyManager.NETWORK_TYPE_GPRS:
			result.setAsu(cell.getRssi());
			break;
		default:
			// not a GSM or UMTS cell, return
			return null;
			// result.setDbm(CellTower.DBM_UNKNOWN);
			// not needed because this is the default value; setting it
			// here might overwrite valid data obtained from a different
			// source
	}
	result.setNetworkType(networkType);
	if (result.getMcc() == CellTower.UNKNOWN)
		result.setMcc(mcc);
	if (result.getMnc() == CellTower.UNKNOWN)
		result.setMnc(mnc);
	if (result.getLac() == CellTower.UNKNOWN)
		result.setLac(cell.getLac());
	if (result.getCid() == CellTower.UNKNOWN)
		result.setCid(cell.getCid());
	if (result.getPsc() == CellTower.UNKNOWN)
		result.setPsc(cell.getPsc());
	this.put(result.getText(), result);
	this.put(result.getAltText(), result);
	if ((result.getText() == null) && (result.getAltText() == null))
		Log.d(this.getClass().getSimpleName(), String.format("Added %d G cell with no data from NeighboringCellInfo", result.getGeneration()));
	return result;
}
 
Example 15
Source File: VoIPBaseService.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
protected void updateNetworkType() {
	ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
	NetworkInfo info = cm.getActiveNetworkInfo();
	lastNetInfo = info;
	int type = VoIPController.NET_TYPE_UNKNOWN;
	if (info != null) {
		switch (info.getType()) {
			case ConnectivityManager.TYPE_MOBILE:
				switch (info.getSubtype()) {
					case TelephonyManager.NETWORK_TYPE_GPRS:
						type = VoIPController.NET_TYPE_GPRS;
						break;
					case TelephonyManager.NETWORK_TYPE_EDGE:
					case TelephonyManager.NETWORK_TYPE_1xRTT:
						type = VoIPController.NET_TYPE_EDGE;
						break;
					case TelephonyManager.NETWORK_TYPE_UMTS:
					case TelephonyManager.NETWORK_TYPE_EVDO_0:
						type = VoIPController.NET_TYPE_3G;
						break;
					case TelephonyManager.NETWORK_TYPE_HSDPA:
					case TelephonyManager.NETWORK_TYPE_HSPA:
					case TelephonyManager.NETWORK_TYPE_HSPAP:
					case TelephonyManager.NETWORK_TYPE_HSUPA:
					case TelephonyManager.NETWORK_TYPE_EVDO_A:
					case TelephonyManager.NETWORK_TYPE_EVDO_B:
						type = VoIPController.NET_TYPE_HSPA;
						break;
					case TelephonyManager.NETWORK_TYPE_LTE:
						type = VoIPController.NET_TYPE_LTE;
						break;
					default:
						type = VoIPController.NET_TYPE_OTHER_MOBILE;
						break;
				}
				break;
			case ConnectivityManager.TYPE_WIFI:
				type = VoIPController.NET_TYPE_WIFI;
				break;
			case ConnectivityManager.TYPE_ETHERNET:
				type = VoIPController.NET_TYPE_ETHERNET;
				break;
		}
	}
	if (controller != null) {
		controller.setNetworkType(type);
	}
}
 
Example 16
Source File: AppNetWorkUtil.java    From Ency with Apache License 2.0 4 votes vote down vote up
/**
 * 获取当前网络具体类型
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
 *
 * @return 网络类型
 */
public static String getNetworkSubType(Context context) {
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = manager.getActiveNetworkInfo();
    String subtype = NETWORK_NO;

    if (info != null && info.isAvailable()) {
        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            subtype = NETWORK_WIFI;
        } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            switch (info.getSubtype()) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    subtype = getOperatorName(context).concat(NETWORK_2G);
                    break;
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    subtype = getOperatorName(context).concat(NETWORK_3G);
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    subtype = getOperatorName(context).concat(NETWORK_4G);
                    break;
                default:
                    String subtypeName = info.getSubtypeName();
                    if (subtypeName.equalsIgnoreCase("TD-SCDMA")
                            || subtypeName.equalsIgnoreCase("WCDMA")
                            || subtypeName.equalsIgnoreCase("CDMA2000")) {
                        subtype = getOperatorName(context).concat(NETWORK_3G);
                    } else {
                        subtype = NETWORK_UNKNOWN;
                    }
                    break;
            }
        } else {
            subtype = NETWORK_UNKNOWN;
        }
    }
    return subtype;
}
 
Example 17
Source File: NetworkUtils.java    From pandroid with Apache License 2.0 4 votes vote down vote up
/**
 * Check if the connection is fast
 *
 * @param type
 * @param subType
 * @return
 */
public static boolean isConnectionFast(int type, int subType) {
    if (type == ConnectivityManager.TYPE_WIFI) {
        return true;
    } else if (type == ConnectivityManager.TYPE_MOBILE) {
        switch (subType) {
            case TelephonyManager.NETWORK_TYPE_1xRTT:
                return false; // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_CDMA:
                return false; // ~ 14-64 kbps
            case TelephonyManager.NETWORK_TYPE_EDGE:
                return false; // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_0:
                return true; // ~ 400-1000 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_A:
                return true; // ~ 600-1400 kbps
            case TelephonyManager.NETWORK_TYPE_GPRS:
                return false; // ~ 100 kbps
            case TelephonyManager.NETWORK_TYPE_HSDPA:
                return true; // ~ 2-14 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPA:
                return true; // ~ 700-1700 kbps
            case TelephonyManager.NETWORK_TYPE_HSUPA:
                return true; // ~ 1-23 Mbps
            case TelephonyManager.NETWORK_TYPE_UMTS:
                return true; // ~ 400-7000 kbps
        /*
         * Above API level 7, make sure to set android:targetSdkVersion
* to appropriate level to use these
*/
            case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11
                return true; // ~ 1-2 Mbps
            case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9
                return true; // ~ 5 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13
                return true; // ~ 10-20 Mbps
            case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8
                return false; // ~25 kbps
            case TelephonyManager.NETWORK_TYPE_LTE: // API level 11
                return true; // ~ 10+ Mbps
            // Unknown
            case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            default:
                return false;
        }
    } else {
        return false;
    }
}
 
Example 18
Source File: NetworkUtil.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 获取当前网络类型
 * 需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}
 */
@RequiresPermission("android.permission.ACCESS_NETWORK_STATE")
public static NetworkType getNetworkType(Context context) {
    NetworkType netType = NetworkType.NETWORK_NO;
    NetworkInfo info = getActiveNetworkInfo(context);
    if (info != null && info.isAvailable()) {

        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            netType = NetworkType.NETWORK_WIFI;
        } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            switch (info.getSubtype()) {

                case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    netType = NetworkType.NETWORK_3G;
                    break;

                case TelephonyManager.NETWORK_TYPE_LTE:
                case TelephonyManager.NETWORK_TYPE_IWLAN:
                    netType = NetworkType.NETWORK_4G;
                    break;

                case TelephonyManager.NETWORK_TYPE_GSM:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    netType = NetworkType.NETWORK_2G;
                    break;
                default:
                    String subtypeName = info.getSubtypeName();
                    if (subtypeName.equalsIgnoreCase("TD-SCDMA")
                            || subtypeName.equalsIgnoreCase("WCDMA")
                            || subtypeName.equalsIgnoreCase("CDMA2000")) {
                        netType = NetworkType.NETWORK_3G;
                    } else {
                        netType = NetworkType.NETWORK_UNKNOWN;
                    }
                    break;
            }
        } else {
            netType = NetworkType.NETWORK_UNKNOWN;
        }
    }
    return netType;
}
 
Example 19
Source File: NetworkUtils.java    From AndroidModulePattern with Apache License 2.0 4 votes vote down vote up
/**
 * 获取当前网络类型
 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p>
 *
 * @return 网络类型
 * <ul>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_WIFI   } </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_4G     } </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_3G     } </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_2G     } </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_UNKNOWN} </li>
 * <li>{@link NetworkUtils.NetworkType#NETWORK_NO     } </li>
 * </ul>
 */
public static NetworkType getNetworkType() {
    NetworkType netType = NetworkType.NETWORK_NO;
    NetworkInfo info = getActiveNetworkInfo();
    if (info != null && info.isAvailable()) {

        if (info.getType() == ConnectivityManager.TYPE_WIFI) {
            netType = NetworkType.NETWORK_WIFI;
        } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
            switch (info.getSubtype()) {

                case NETWORK_TYPE_GSM:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    netType = NetworkType.NETWORK_2G;
                    break;

                case NETWORK_TYPE_TD_SCDMA:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    netType = NetworkType.NETWORK_3G;
                    break;

                case NETWORK_TYPE_IWLAN:
                case TelephonyManager.NETWORK_TYPE_LTE:
                    netType = NetworkType.NETWORK_4G;
                    break;
                default:

                    String subtypeName = info.getSubtypeName();
                    if (subtypeName.equalsIgnoreCase("TD-SCDMA")
                            || subtypeName.equalsIgnoreCase("WCDMA")
                            || subtypeName.equalsIgnoreCase("CDMA2000")) {
                        netType = NetworkType.NETWORK_3G;
                    } else {
                        netType = NetworkType.NETWORK_UNKNOWN;
                    }
                    break;
            }
        } else {
            netType = NetworkType.NETWORK_UNKNOWN;
        }
    }
    return netType;
}
 
Example 20
Source File: Connectivity.java    From iGap-Android with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Check if the connection is fast
 */
public static boolean isConnectionFast(int type, int subType) {
    if (type == ConnectivityManager.TYPE_WIFI) {
        return true;
    } else if (type == ConnectivityManager.TYPE_MOBILE) {
        switch (subType) {
            case TelephonyManager.NETWORK_TYPE_1xRTT:
                return false; // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_CDMA:
                return false; // ~ 14-64 kbps
            case TelephonyManager.NETWORK_TYPE_EDGE:
                return false; // ~ 50-100 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_0:
                return true; // ~ 400-1000 kbps
            case TelephonyManager.NETWORK_TYPE_EVDO_A:
                return true; // ~ 600-1400 kbps
            case TelephonyManager.NETWORK_TYPE_GPRS:
                return false; // ~ 100 kbps
            case TelephonyManager.NETWORK_TYPE_HSDPA:
                return true; // ~ 2-14 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPA:
                return true; // ~ 700-1700 kbps
            case TelephonyManager.NETWORK_TYPE_HSUPA:
                return true; // ~ 1-23 Mbps
            case TelephonyManager.NETWORK_TYPE_UMTS:
                return true; // ~ 400-7000 kbps
        /*
         * Above API level 7, make sure to set android:targetSdkVersion
         * to appropriate level to use these
         */
            case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11
                return true; // ~ 1-2 Mbps
            case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9
                return true; // ~ 5 Mbps
            case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13
                return true; // ~ 10-20 Mbps
            case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8
                return false; // ~25 kbps
            case TelephonyManager.NETWORK_TYPE_LTE: // API level 11
                return true; // ~ 10+ Mbps
            // Unknown
            case TelephonyManager.NETWORK_TYPE_UNKNOWN:
            default:
                return false;
        }
    } else {
        return false;
    }
}