mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-03-15 12:51:00 +08:00
Detection of Ethernet Network Type on Android
On an Android device with Ethernet interface we have to support NetworkInfo's typeName equals 'eth', therefore NetworkManager cannot determine Network Type (and returns 'UNKNOWN').
This commit is contained in:
parent
83e870bf4e
commit
7a8971c2f9
@ -69,6 +69,7 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
// return type
|
// return type
|
||||||
public static final String TYPE_UNKNOWN = "unknown";
|
public static final String TYPE_UNKNOWN = "unknown";
|
||||||
public static final String TYPE_ETHERNET = "ethernet";
|
public static final String TYPE_ETHERNET = "ethernet";
|
||||||
|
public static final String TYPE_ETHERNET_SHORT = "eth";
|
||||||
public static final String TYPE_WIFI = "wifi";
|
public static final String TYPE_WIFI = "wifi";
|
||||||
public static final String TYPE_2G = "2g";
|
public static final String TYPE_2G = "2g";
|
||||||
public static final String TYPE_3G = "3g";
|
public static final String TYPE_3G = "3g";
|
||||||
@ -240,7 +241,7 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
if (type.equals(WIFI)) {
|
if (type.equals(WIFI)) {
|
||||||
return TYPE_WIFI;
|
return TYPE_WIFI;
|
||||||
}
|
}
|
||||||
else if (type.toLowerCase().equals(TYPE_ETHERNET)) {
|
else if (type.toLowerCase().equals(TYPE_ETHERNET) || type.toLowerCase().startsWith(TYPE_ETHERNET_SHORT) {
|
||||||
return TYPE_ETHERNET;
|
return TYPE_ETHERNET;
|
||||||
}
|
}
|
||||||
else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
|
else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user