Java Code Examples for android.telephony.TelephonyManager#NETWORK_TYPE_HSDPA
The following examples show how to use
android.telephony.TelephonyManager#NETWORK_TYPE_HSDPA .
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 |
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 |
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: Util.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static @C.NetworkType int getMobileNetworkType(NetworkInfo networkInfo) { switch (networkInfo.getSubtype()) { case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: return C.NETWORK_TYPE_2G; case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return C.NETWORK_TYPE_3G; case TelephonyManager.NETWORK_TYPE_LTE: return C.NETWORK_TYPE_4G; case TelephonyManager.NETWORK_TYPE_IWLAN: return C.NETWORK_TYPE_WIFI; case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: // Future mobile network types. return C.NETWORK_TYPE_CELLULAR_UNKNOWN; } }
Example 4
Source File: NetworkUtil.java From RxZhihuDaily with MIT License | 5 votes |
/** * 获取在Mobile网络下的网络类型. 2G,3G,4G * * @param context * @return */ public static int getNetworkClass(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager != null) { NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null) { if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { switch (networkInfo.getSubtype()) { 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 NETWORK_CLASS_2_G; 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 12: // TelephonyManager.NETWORK_TYPE_EVDO_B: case 14: // TelephonyManager.NETWORK_TYPE_EHRPD: case 15: // TelephonyManager.NETWORK_TYPE_HSPAP: return NETWORK_CLASS_3_G; case 13: // TelephonyManager.NETWORK_TYPE_LTE: return NETWORK_CLASS_4_G; default: return NETWORK_CLASS_UNKNOWN; } } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { return NETWORK_CLASS_WIFI; } } } return NETWORK_CLASS_UNKNOWN; }
Example 5
Source File: NetworkUtils.java From SprintNBA with Apache License 2.0 | 5 votes |
/** * 获取网络连接类型 * <p/> * 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 6
Source File: DeviceInfo.java From clevertap-android-sdk with MIT License | 5 votes |
private String getNetworkType() { TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (mTelephonyManager == null) { return null; } int networkType = mTelephonyManager.getNetworkType(); 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: 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: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: return "3G"; case TelephonyManager.NETWORK_TYPE_LTE: return "4G"; default: return null; } }
Example 7
Source File: NetworkChangeNotifierAutoDetect.java From cronet with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns the connection type for the given ConnectivityManager type and subtype. */ @ConnectionType private static int convertToConnectionType(int type, int subtype) { switch (type) { case ConnectivityManager.TYPE_ETHERNET: return ConnectionType.CONNECTION_ETHERNET; case ConnectivityManager.TYPE_WIFI: return ConnectionType.CONNECTION_WIFI; case ConnectivityManager.TYPE_WIMAX: return ConnectionType.CONNECTION_4G; case ConnectivityManager.TYPE_BLUETOOTH: return ConnectionType.CONNECTION_BLUETOOTH; case ConnectivityManager.TYPE_MOBILE: // Use information from TelephonyManager to classify the connection. switch (subtype) { 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 ConnectionType.CONNECTION_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: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: return ConnectionType.CONNECTION_3G; case TelephonyManager.NETWORK_TYPE_LTE: return ConnectionType.CONNECTION_4G; default: return ConnectionType.CONNECTION_UNKNOWN; } default: return ConnectionType.CONNECTION_UNKNOWN; } }
Example 8
Source File: NetworkManagerFinal.java From zone-sdk with MIT License | 5 votes |
/** * 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 9
Source File: ConnectionBuddy.java From android_connectionbuddy with Apache License 2.0 | 4 votes |
/** * Get mobile network signal strength. */ private ConnectivityStrength getMobileConnectionStrength(NetworkInfo info) { if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE) { switch (info.getSubtype()) { case TelephonyManager.NETWORK_TYPE_1xRTT: return new ConnectivityStrength(ConnectivityStrength.POOR); case TelephonyManager.NETWORK_TYPE_CDMA: return new ConnectivityStrength(ConnectivityStrength.POOR); case TelephonyManager.NETWORK_TYPE_EDGE: return new ConnectivityStrength(ConnectivityStrength.POOR); case TelephonyManager.NETWORK_TYPE_EVDO_0: return new ConnectivityStrength(ConnectivityStrength.GOOD); case TelephonyManager.NETWORK_TYPE_EVDO_A: return new ConnectivityStrength(ConnectivityStrength.GOOD); case TelephonyManager.NETWORK_TYPE_GPRS: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_HSDPA: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_HSPA: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_HSUPA: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_UMTS: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_EHRPD: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_EVDO_B: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_HSPAP: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_IDEN: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); case TelephonyManager.NETWORK_TYPE_LTE: return new ConnectivityStrength(ConnectivityStrength.EXCELLENT); default: return new ConnectivityStrength(ConnectivityStrength.UNDEFINED); } } else { return new ConnectivityStrength(ConnectivityStrength.UNDEFINED); } }
Example 10
Source File: NetworkChangeNotifierAutoDetect.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
public int getCurrentConnectionType() { // Track exactly what type of connection we have. if (!mConnectivityManagerDelegate.activeNetworkExists() || !mConnectivityManagerDelegate.isConnected()) { return NetworkChangeNotifier.CONNECTION_NONE; } switch (mConnectivityManagerDelegate.getNetworkType()) { case ConnectivityManager.TYPE_ETHERNET: return NetworkChangeNotifier.CONNECTION_ETHERNET; case ConnectivityManager.TYPE_WIFI: return NetworkChangeNotifier.CONNECTION_WIFI; case ConnectivityManager.TYPE_WIMAX: return NetworkChangeNotifier.CONNECTION_4G; case ConnectivityManager.TYPE_MOBILE: // Use information from TelephonyManager to classify the connection. switch (mConnectivityManagerDelegate.getNetworkSubtype()) { 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 NetworkChangeNotifier.CONNECTION_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: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: return NetworkChangeNotifier.CONNECTION_3G; case TelephonyManager.NETWORK_TYPE_LTE: return NetworkChangeNotifier.CONNECTION_4G; default: return NetworkChangeNotifier.CONNECTION_UNKNOWN; } default: return NetworkChangeNotifier.CONNECTION_UNKNOWN; } }
Example 11
Source File: DeviceInfo.java From proofmode with GNU General Public License v3.0 | 4 votes |
public static String getDataType(Context activity) { String type = "Mobile Data"; TelephonyManager tm = (TelephonyManager) activity.getSystemService(Context.TELEPHONY_SERVICE); switch (tm.getNetworkType()) { case TelephonyManager.NETWORK_TYPE_CDMA: type = "Mobile Data LTE"; Log.d("Type", "LTE"); // for 3g HSDPA networktype will be return as // per testing(real) in device with 3g enable // data // and speed will also matters to decide 3g network type break; case TelephonyManager.NETWORK_TYPE_LTE: type = "Mobile Data LTE"; Log.d("Type", "LTE"); // for 3g HSDPA networktype will be return as // per testing(real) in device with 3g enable // data // and speed will also matters to decide 3g network type break; case TelephonyManager.NETWORK_TYPE_HSDPA: type = "Mobile Data 3G"; Log.d("Type", "3g"); // for 3g HSDPA networktype will be return as // per testing(real) in device with 3g enable // data // and speed will also matters to decide 3g network type break; case TelephonyManager.NETWORK_TYPE_HSPAP: type = "Mobile Data 4G"; Log.d("Type", "4g"); // No specification for the 4g but from wiki // i found(HSPAP used in 4g) break; case TelephonyManager.NETWORK_TYPE_GPRS: type = "Mobile Data GPRS"; Log.d("Type", "GPRS"); break; case TelephonyManager.NETWORK_TYPE_EDGE: type = "Mobile Data EDGE 2G"; Log.d("Type", "EDGE 2g"); break; } return type; }
Example 12
Source File: MainActivity.java From spidey with GNU General Public License v3.0 | 4 votes |
private boolean isProperNetworkState () { ConnectivityManager mgr = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE); //boolean is3G = mgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting(); NetworkInfo[] networkInfos = mgr.getAllNetworkInfo(); for (NetworkInfo netInfo : networkInfos) { if(netInfo.getType()==ConnectivityManager.TYPE_MOBILE) { int subType = netInfo.getSubtype(); 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 true; // ~ 50-100 kbps case TelephonyManager.NETWORK_TYPE_EVDO_0: return false; // ~ 400-1000 kbps case TelephonyManager.NETWORK_TYPE_EVDO_A: return false; // ~ 600-1400 kbps case TelephonyManager.NETWORK_TYPE_GPRS: return true; // ~ 100 kbps case TelephonyManager.NETWORK_TYPE_HSDPA: return false; // ~ 2-14 Mbps case TelephonyManager.NETWORK_TYPE_HSPA: return false; // ~ 700-1700 kbps case TelephonyManager.NETWORK_TYPE_HSUPA: return false; // ~ 1-23 Mbps case TelephonyManager.NETWORK_TYPE_UMTS: return false; // ~ 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 false; // ~ 1-2 Mbps case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9 return false; // ~ 5 Mbps case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13 return false; // ~ 10-20 Mbps case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8 return false; // ~25 kbps case TelephonyManager.NETWORK_TYPE_LTE: // API level 11 return false; // ~ 10+ Mbps // Unknown case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: return true; } } } return true; }
Example 13
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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 14
Source File: AppNetWorkUtil.java From Ency with Apache License 2.0 | 4 votes |
/** * 获取当前网络具体类型 * <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 15
Source File: DownloaderService.java From QtAndroidTools with MIT License | 4 votes |
/** * Updates the network type based upon the type and subtype returned from * the connectivity manager. Subtype is only used for cellular signals. * * @param type * @param subType */ private void updateNetworkType(int type, int subType) { switch (type) { case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_ETHERNET: case ConnectivityManager.TYPE_BLUETOOTH: mIsCellularConnection = false; mIsAtLeast3G = false; mIsAtLeast4G = false; break; case ConnectivityManager.TYPE_WIMAX: mIsCellularConnection = true; mIsAtLeast3G = true; mIsAtLeast4G = true; break; case ConnectivityManager.TYPE_MOBILE: mIsCellularConnection = true; switch (subType) { case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_IDEN: mIsAtLeast3G = false; mIsAtLeast4G = false; break; 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_UMTS: mIsAtLeast3G = true; mIsAtLeast4G = false; break; case TelephonyManager.NETWORK_TYPE_LTE: // 4G case TelephonyManager.NETWORK_TYPE_EHRPD: // 3G ++ interop // with 4G case TelephonyManager.NETWORK_TYPE_HSPAP: // 3G ++ but // marketed as // 4G mIsAtLeast3G = true; mIsAtLeast4G = true; break; default: mIsCellularConnection = false; mIsAtLeast3G = false; mIsAtLeast4G = false; } } }
Example 16
Source File: NetworkUtils.java From AndroidModulePattern with Apache License 2.0 | 4 votes |
/** * 获取当前网络类型 * <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 17
Source File: VoIPBaseService.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
protected int getNetworkType() { final NetworkInfo info = lastNetInfo = getActiveNetworkInfo(); int type = TgVoip.NET_TYPE_UNKNOWN; if (info != null) { switch (info.getType()) { case ConnectivityManager.TYPE_MOBILE: switch (info.getSubtype()) { case TelephonyManager.NETWORK_TYPE_GPRS: type = TgVoip.NET_TYPE_GPRS; break; case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_1xRTT: type = TgVoip.NET_TYPE_EDGE; break; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: type = TgVoip.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 = TgVoip.NET_TYPE_HSPA; break; case TelephonyManager.NETWORK_TYPE_LTE: type = TgVoip.NET_TYPE_LTE; break; default: type = TgVoip.NET_TYPE_OTHER_MOBILE; break; } break; case ConnectivityManager.TYPE_WIFI: type = TgVoip.NET_TYPE_WIFI; break; case ConnectivityManager.TYPE_ETHERNET: type = TgVoip.NET_TYPE_ETHERNET; break; } } return type; }
Example 18
Source File: ConnectivityUtil.java From RxAndroidBootstrap with Apache License 2.0 | 4 votes |
/** * 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 19
Source File: NetworkMonitorAutoDetect.java From webrtc_android with MIT License | 4 votes |
private static ConnectionType getConnectionType( boolean isConnected, int networkType, int networkSubtype) { if (!isConnected) { return ConnectionType.CONNECTION_NONE; } switch (networkType) { case ConnectivityManager.TYPE_ETHERNET: return ConnectionType.CONNECTION_ETHERNET; case ConnectivityManager.TYPE_WIFI: return ConnectionType.CONNECTION_WIFI; case ConnectivityManager.TYPE_WIMAX: return ConnectionType.CONNECTION_4G; case ConnectivityManager.TYPE_BLUETOOTH: return ConnectionType.CONNECTION_BLUETOOTH; case ConnectivityManager.TYPE_MOBILE: // Use information from TelephonyManager to classify the connection. switch (networkSubtype) { 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 ConnectionType.CONNECTION_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: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: return ConnectionType.CONNECTION_3G; case TelephonyManager.NETWORK_TYPE_LTE: return ConnectionType.CONNECTION_4G; default: return ConnectionType.CONNECTION_UNKNOWN_CELLULAR; } case ConnectivityManager.TYPE_VPN: return ConnectionType.CONNECTION_VPN; default: return ConnectionType.CONNECTION_UNKNOWN; } }
Example 20
Source File: PlayerUtils.java From DKVideoPlayer with Apache License 2.0 | 4 votes |
/** * 判断当前网络类型 */ public static int getNetworkType(Context context) { //改为context.getApplicationContext(),防止在Android 6.0上发生内存泄漏 ConnectivityManager connectMgr = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectMgr == null) { return NO_NETWORK; } NetworkInfo networkInfo = connectMgr.getActiveNetworkInfo(); if (networkInfo == null) { // 没有任何网络 return NO_NETWORK; } if (!networkInfo.isConnected()) { // 网络断开或关闭 return NETWORK_CLOSED; } if (networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) { // 以太网网络 return NETWORK_ETHERNET; } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { // wifi网络,当激活时,默认情况下,所有的数据流量将使用此连接 return NETWORK_WIFI; } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { // 移动数据连接,不能与连接共存,如果wifi打开,则自动关闭 switch (networkInfo.getSubtype()) { // 2G 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: // 3G 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: // 4G case TelephonyManager.NETWORK_TYPE_LTE: // 5G case TelephonyManager.NETWORK_TYPE_NR: return NETWORK_MOBILE; } } // 未知网络 return NETWORK_UNKNOWN; }