Java Code Examples for android.telephony.TelephonyManager#NETWORK_TYPE_UNKNOWN
The following examples show how to use
android.telephony.TelephonyManager#NETWORK_TYPE_UNKNOWN .
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: TelephonyRegistry.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public void notifyPreciseDataConnectionFailed(String reason, String apnType, String apn, String failCause) { if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) { return; } synchronized (mRecords) { mPreciseDataConnectionState = new PreciseDataConnectionState( TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause); for (Record r : mRecords) { if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { try { r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); } catch (RemoteException ex) { mRemoveList.add(r.binder); } } } handleRemoveListLocked(); } broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause); }
Example 2
Source File: NetInfoModule.java From react-native-GPay with MIT License | 6 votes |
private String getEffectiveConnectionType(NetworkInfo networkInfo) { switch (networkInfo.getSubtype()) { 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: return EFFECTIVE_CONNECTION_TYPE_2G; case TelephonyManager.NETWORK_TYPE_EHRPD: 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_UMTS: return EFFECTIVE_CONNECTION_TYPE_3G; case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_LTE: return EFFECTIVE_CONNECTION_TYPE_4G; case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: return EFFECTIVE_CONNECTION_TYPE_UNKNOWN; } }
Example 3
Source File: NetworkUtils.java From seny-devpkg with Apache License 2.0 | 5 votes |
/** * Whether is fast mobile network * * @param context * @return */ private static boolean isFastMobileNetwork(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (telephonyManager == null) { return false; } switch (telephonyManager.getNetworkType()) { case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_LTE: return true; 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: case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: return false; } }
Example 4
Source File: Util.java From tracker-control-android with GNU General Public License v3.0 | 5 votes |
public static String getGeneralInfo(Context context) { StringBuilder sb = new StringBuilder(); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); sb.append(String.format("Interactive %B\r\n", isInteractive(context))); sb.append(String.format("Connected %B\r\n", isConnected(context))); sb.append(String.format("WiFi %B\r\n", isWifiActive(context))); sb.append(String.format("Metered %B\r\n", isMeteredNetwork(context))); sb.append(String.format("Roaming %B\r\n", isRoaming(context))); if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) sb.append(String.format("SIM %s/%s/%s\r\n", tm.getSimCountryIso(), tm.getSimOperatorName(), tm.getSimOperator())); if (tm.getNetworkType() != TelephonyManager.NETWORK_TYPE_UNKNOWN) sb.append(String.format("Network %s/%s/%s\r\n", tm.getNetworkCountryIso(), tm.getNetworkOperatorName(), tm.getNetworkOperator())); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) sb.append(String.format("Power saving %B\r\n", pm.isPowerSaveMode())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) sb.append(String.format("Battery optimizing %B\r\n", batteryOptimizing(context))); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) sb.append(String.format("Data saving %B\r\n", dataSaving(context))); if (sb.length() > 2) sb.setLength(sb.length() - 2); return sb.toString(); }
Example 5
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 6
Source File: Util.java From kcanotify with GNU General Public License v3.0 | 5 votes |
public static String getGeneralInfo(Context context) { StringBuilder sb = new StringBuilder(); TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); sb.append(KcaUtils.format("Interactive %B\r\n", isInteractive(context))); sb.append(KcaUtils.format("Connected %B\r\n", isConnected(context))); sb.append(KcaUtils.format("WiFi %B\r\n", isWifiActive(context))); sb.append(KcaUtils.format("Metered %B\r\n", isMeteredNetwork(context))); sb.append(KcaUtils.format("Roaming %B\r\n", isRoaming(context))); if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) sb.append(KcaUtils.format("SIM %s/%s/%s\r\n", tm.getSimCountryIso(), tm.getSimOperatorName(), tm.getSimOperator())); if (tm.getNetworkType() != TelephonyManager.NETWORK_TYPE_UNKNOWN) sb.append(KcaUtils.format("Network %s/%s/%s\r\n", tm.getNetworkCountryIso(), tm.getNetworkOperatorName(), tm.getNetworkOperator())); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) sb.append(KcaUtils.format("Power saving %B\r\n", pm.isPowerSaveMode())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) sb.append(KcaUtils.format("Battery optimizing %B\r\n", batteryOptimizing(context))); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) sb.append(KcaUtils.format("Data saving %B\r\n", dataSaving(context))); if (sb.length() > 2) sb.setLength(sb.length() - 2); return sb.toString(); }
Example 7
Source File: Util.java From Telegram 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 8
Source File: NetworkUtils.java From android-utils with Apache License 2.0 | 4 votes |
/** * 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 9
Source File: NetWorkUtils.java From Simpler with Apache License 2.0 | 4 votes |
/** * Whether is fast mobile network * * @param context context * @return FastMobileNetwork */ private static boolean isFastMobileNetwork(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE); if (telephonyManager == null) { return false; } switch (telephonyManager.getNetworkType()) { case TelephonyManager.NETWORK_TYPE_1xRTT: return false; case TelephonyManager.NETWORK_TYPE_CDMA: return false; case TelephonyManager.NETWORK_TYPE_EDGE: return false; case TelephonyManager.NETWORK_TYPE_EVDO_0: return true; case TelephonyManager.NETWORK_TYPE_EVDO_A: return true; case TelephonyManager.NETWORK_TYPE_GPRS: return false; case TelephonyManager.NETWORK_TYPE_HSDPA: return true; case TelephonyManager.NETWORK_TYPE_HSPA: return true; case TelephonyManager.NETWORK_TYPE_HSUPA: return true; case TelephonyManager.NETWORK_TYPE_UMTS: return true; case TelephonyManager.NETWORK_TYPE_EHRPD: return true; case TelephonyManager.NETWORK_TYPE_EVDO_B: return true; case TelephonyManager.NETWORK_TYPE_HSPAP: return true; case TelephonyManager.NETWORK_TYPE_IDEN: return false; case TelephonyManager.NETWORK_TYPE_LTE: return true; case TelephonyManager.NETWORK_TYPE_UNKNOWN: return false; default: return false; } }
Example 10
Source File: NetworkUtil.java From RxZhihuDaily with MIT License | 4 votes |
/** * 仅判断Mobile网络的慢速.蓝牙等其他网络不做判断. * * @param context * @return */ public static NetworkSpeedMode getNetworkSpeedModeInMobile(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_IDEN: // ~25 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_CDMA: // ~ 14-64 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_1xRTT: // ~ 50-100 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_EDGE: // ~ 50-100 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_GPRS: // ~ 100 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_EVDO_0: // ~ 400-1000 // kbps return NetworkSpeedMode.NORMAL; case TelephonyManager.NETWORK_TYPE_EVDO_A: // ~ 600-1400 // kbps return NetworkSpeedMode.NORMAL; case TelephonyManager.NETWORK_TYPE_HSPA: // ~ 700-1700 kbps return NetworkSpeedMode.NORMAL; case TelephonyManager.NETWORK_TYPE_UMTS: // ~ 400-7000 kbps return NetworkSpeedMode.NORMAL; case 14: // TelephonyManager.NETWORK_TYPE_EHRPD: // ~ 1-2 // Mbps return NetworkSpeedMode.NORMAL; case 12: // TelephonyManager.NETWORK_TYPE_EVDO_B: // ~ 5 // Mbps return NetworkSpeedMode.NORMAL; case TelephonyManager.NETWORK_TYPE_HSDPA: // ~ 2-14 Mbps return NetworkSpeedMode.HIGH; case TelephonyManager.NETWORK_TYPE_HSUPA: // ~ 1-23 Mbps return NetworkSpeedMode.HIGH; case 15: // TelephonyManager.NETWORK_TYPE_HSPAP: // ~ 10-20 // Mbps return NetworkSpeedMode.HIGH; case 13: // TelephonyManager.NETWORK_TYPE_LTE: // ~ 10+ Mbps return NetworkSpeedMode.HIGH; case TelephonyManager.NETWORK_TYPE_UNKNOWN: return NetworkSpeedMode.NORMAL; default: break; } } } } return NetworkSpeedMode.UNKNOWN; }
Example 11
Source File: NetWorkUtils.java From GankGirl with GNU Lesser General Public License v2.1 | 4 votes |
/** * Whether is fast mobile network * * @param context context * @return FastMobileNetwork */ private static boolean isFastMobileNetwork(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE); if (telephonyManager == null) { return false; } switch (telephonyManager.getNetworkType()) { case TelephonyManager.NETWORK_TYPE_1xRTT: return false; case TelephonyManager.NETWORK_TYPE_CDMA: return false; case TelephonyManager.NETWORK_TYPE_EDGE: return false; case TelephonyManager.NETWORK_TYPE_EVDO_0: return true; case TelephonyManager.NETWORK_TYPE_EVDO_A: return true; case TelephonyManager.NETWORK_TYPE_GPRS: return false; case TelephonyManager.NETWORK_TYPE_HSDPA: return true; case TelephonyManager.NETWORK_TYPE_HSPA: return true; case TelephonyManager.NETWORK_TYPE_HSUPA: return true; case TelephonyManager.NETWORK_TYPE_UMTS: return true; case TelephonyManager.NETWORK_TYPE_EHRPD: return true; case TelephonyManager.NETWORK_TYPE_EVDO_B: return true; case TelephonyManager.NETWORK_TYPE_HSPAP: return true; case TelephonyManager.NETWORK_TYPE_IDEN: return false; case TelephonyManager.NETWORK_TYPE_LTE: return true; case TelephonyManager.NETWORK_TYPE_UNKNOWN: return false; default: return false; } }
Example 12
Source File: RMBTTask.java From open-rmbt with Apache License 2.0 | 4 votes |
public void runNDT() { final NDTRunner ndtRunner = new NDTRunner(); ndtRunnerHolder.set(ndtRunner); Log.d(LOG_TAG, "ndt status RUNNING"); final String ndtNetworkType; final int networkType = getNetworkType(); switch (networkType) { case InformationCollector.NETWORK_WIFI: ndtNetworkType = NdtTests.NETWORK_WIFI; break; case TelephonyManager.NETWORK_TYPE_UNKNOWN: ndtNetworkType = NdtTests.NETWORK_UNKNOWN; break; default: ndtNetworkType = NdtTests.NETWORK_MOBILE; break; } ndtRunner.runNDT(ndtNetworkType, ndtRunner.new UiServices() { @Override public void sendResults() { client.getControlConnection().sendNDTResult(this, null); } public boolean wantToStop() { if (super.wantToStop()) return true; if (cancelled.get()) { cancel(); return true; } return false; } }); }
Example 13
Source File: TraceDeviceInfo.java From sdl_java_suite with BSD 3-Clause "New" or "Revised" License | 4 votes |
static String getTelephonyHeader() { // Telephony manager can tell us a few things... String info = ""; if (m_telephonyManager != null) { try { // getDeviceId() requires android.permission.READ_PHONE_STATE info = "<deviceid>" + m_telephonyManager.getDeviceId() + "</deviceid>"; } catch (Exception e1) { DebugTool.logError("Failure getting telephony device ID: " + e1.toString(), e1); } info = "<pt>"; switch (m_telephonyManager.getPhoneType()) { case TelephonyManager.PHONE_TYPE_NONE: info += "NONE"; break; case TelephonyManager.PHONE_TYPE_GSM: info += "GSM"; break; case TelephonyManager.PHONE_TYPE_CDMA: info += "CDMA"; break; default: info += "UNKNOWN"; } // end-switch info += "</pt>" + "<nt>"; switch (m_telephonyManager.getNetworkType()) { case TelephonyManager.NETWORK_TYPE_UNKNOWN: info += "UKNOWN"; break; case TelephonyManager.NETWORK_TYPE_GPRS: info += "GPRS"; break; case TelephonyManager.NETWORK_TYPE_EDGE: info += "EDGE"; break; case TelephonyManager.NETWORK_TYPE_UMTS: info += "UMTS"; break; case TelephonyManager.NETWORK_TYPE_HSDPA: info += "HSDPA"; break; case TelephonyManager.NETWORK_TYPE_HSUPA: info += "HSUPA"; break; case TelephonyManager.NETWORK_TYPE_HSPA: info += "HSPA"; break; case TelephonyManager.NETWORK_TYPE_CDMA: info += "CDMA"; break; case TelephonyManager.NETWORK_TYPE_EVDO_0: info += "EVDO_O"; break; case TelephonyManager.NETWORK_TYPE_EVDO_A: info += "EVDO_A"; break; case TelephonyManager.NETWORK_TYPE_1xRTT: info += "1xRTT"; break; default: info += "UNKNOWN"; break; } // end-switch info += "</nt>"; } // end-if return info; }
Example 14
Source File: InformationCollector.java From open-rmbt with Apache License 2.0 | 4 votes |
/** Returns the network that the phone is on (e.g. Wifi, Edge, GPRS, etc). */ public int getNetwork() { int result = TelephonyManager.NETWORK_TYPE_UNKNOWN; if (connManager != null) { final NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo(); if (activeNetworkInfo != null) { final int type = activeNetworkInfo.getType(); switch (type) { case ConnectivityManager.TYPE_WIFI: result = NETWORK_WIFI; break; case ConnectivityManager.TYPE_BLUETOOTH: result = NETWORK_BLUETOOTH; break; case ConnectivityManager.TYPE_ETHERNET: result = NETWORK_ETHERNET; break; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: result = telManager.getNetworkType(); break; } } } /* detect change from wifi to mobile or reverse */ final int lastNetworkType = this.lastNetworkType.get(); if (result != TelephonyManager.NETWORK_TYPE_UNKNOWN && lastNetworkType != TelephonyManager.NETWORK_TYPE_UNKNOWN) { if ( (result == NETWORK_WIFI && lastNetworkType != NETWORK_WIFI) || (result != NETWORK_WIFI && lastNetworkType == NETWORK_WIFI) ) illegalNetworkTypeChangeDetcted.set(true); } if (result != lastNetworkType) { this.lastNetworkType.set(result); if (telListener != null) telListener.onSignalStrengthsChanged(null); } return result; }
Example 15
Source File: Util.java From NMSAlphabetAndroidApp with MIT License | 4 votes |
private 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 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: default: return false; } } else { return false; } }
Example 16
Source File: Network.java From Saiy-PS with GNU Affero General Public License v3.0 | 4 votes |
/** * Check if the connection is fast * * @param type of connection * @param subType of connection * @return true if the connection is 3g or above */ public static boolean isConnectionFast(final int type, final int subType) { switch (type) { case ConnectivityManager.TYPE_WIFI: return true; case ConnectivityManager.TYPE_WIMAX: return true; case 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 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; } default: return false; } }
Example 17
Source File: NetworkUtil.java From NIM_Android_UIKit with MIT License | 4 votes |
/** * 仅判断Mobile网络的慢速.蓝牙等其他网络不做判断. * * @param context * @return */ public static NetworkSpeedMode getNetworkSpeedModeInMobile(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_IDEN: // ~25 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_CDMA: // ~ 14-64 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_1xRTT: // ~ 50-100 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_EDGE: // ~ 50-100 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_GPRS: // ~ 100 kbps return NetworkSpeedMode.LOW; case TelephonyManager.NETWORK_TYPE_EVDO_0: // ~ 400-1000 // kbps return NetworkSpeedMode.NORMAL; case TelephonyManager.NETWORK_TYPE_EVDO_A: // ~ 600-1400 // kbps return NetworkSpeedMode.NORMAL; case TelephonyManager.NETWORK_TYPE_HSPA: // ~ 700-1700 kbps return NetworkSpeedMode.NORMAL; case TelephonyManager.NETWORK_TYPE_UMTS: // ~ 400-7000 kbps return NetworkSpeedMode.NORMAL; case 14: // TelephonyManager.NETWORK_TYPE_EHRPD: // ~ 1-2 // Mbps return NetworkSpeedMode.NORMAL; case 12: // TelephonyManager.NETWORK_TYPE_EVDO_B: // ~ 5 // Mbps return NetworkSpeedMode.NORMAL; case TelephonyManager.NETWORK_TYPE_HSDPA: // ~ 2-14 Mbps return NetworkSpeedMode.HIGH; case TelephonyManager.NETWORK_TYPE_HSUPA: // ~ 1-23 Mbps return NetworkSpeedMode.HIGH; case 15: // TelephonyManager.NETWORK_TYPE_HSPAP: // ~ 10-20 // Mbps return NetworkSpeedMode.HIGH; case 13: // TelephonyManager.NETWORK_TYPE_LTE: // ~ 10+ Mbps return NetworkSpeedMode.HIGH; case TelephonyManager.NETWORK_TYPE_UNKNOWN: return NetworkSpeedMode.NORMAL; default: break; } } } } return NetworkSpeedMode.UNKNOWN; }
Example 18
Source File: AppNetworkMgr.java From AndroidWallet with GNU General Public License v3.0 | 4 votes |
/** * Whether is fast mobile network * * @param context context * @return FastMobileNetwork */ private static boolean isFastMobileNetwork(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService( Context.TELEPHONY_SERVICE); if (telephonyManager == null) { return false; } switch (telephonyManager.getNetworkType()) { case TelephonyManager.NETWORK_TYPE_1xRTT: return false; case TelephonyManager.NETWORK_TYPE_CDMA: return false; case TelephonyManager.NETWORK_TYPE_EDGE: return false; case TelephonyManager.NETWORK_TYPE_EVDO_0: return true; case TelephonyManager.NETWORK_TYPE_EVDO_A: return true; case TelephonyManager.NETWORK_TYPE_GPRS: return false; case TelephonyManager.NETWORK_TYPE_HSDPA: return true; case TelephonyManager.NETWORK_TYPE_HSPA: return true; case TelephonyManager.NETWORK_TYPE_HSUPA: return true; case TelephonyManager.NETWORK_TYPE_UMTS: return true; case TelephonyManager.NETWORK_TYPE_EHRPD: return true; case TelephonyManager.NETWORK_TYPE_EVDO_B: return true; case TelephonyManager.NETWORK_TYPE_HSPAP: return true; case TelephonyManager.NETWORK_TYPE_IDEN: return false; case TelephonyManager.NETWORK_TYPE_LTE: return true; case TelephonyManager.NETWORK_TYPE_UNKNOWN: return false; default: return false; } }
Example 19
Source File: Util.java From NetGuard with GNU General Public License v3.0 | 4 votes |
public static int getNetworkType(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = (cm == null ? null : cm.getActiveNetworkInfo()); return (ni == null ? TelephonyManager.NETWORK_TYPE_UNKNOWN : ni.getSubtype()); }
Example 20
Source File: AppNetworkMgr.java From AndroidWallet with GNU General Public License v3.0 | 2 votes |
/** * 判断当前网络的具体类型是否是UNKNOWN * * @param context 上下文 * @return false:当前网络的具体类型是否是UNKNOWN。false:当前没有网络连接或者具体类型不是UNKNOWN */ public static boolean isUNKNOWNBySubtype(Context context) { return getCurrentNetworkSubtype(context) == TelephonyManager.NETWORK_TYPE_UNKNOWN; }