mirror of
https://gitee.com/shuto/cordova-plugin-network-information.git
synced 2025-01-19 05:52:49 +08:00
removed autolayout
This commit is contained in:
parent
08698002ce
commit
acc02f2981
@ -200,10 +200,10 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
String connectionType = determineCurrentConnectionType();
|
String connectionType = determineCurrentConnectionType();
|
||||||
|
|
||||||
LOG.d(LOG_TAG, "Intent " + intent.getAction());
|
LOG.d(LOG_TAG, "Intent " + intent.getAction());
|
||||||
if (TYPE_NONE.equals(connectionType)) {
|
if(TYPE_NONE.equals(connectionType)) {
|
||||||
boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
|
boolean noConnectivity = intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
|
||||||
LOG.d(LOG_TAG, "Intent no connectivity: " + noConnectivity);
|
LOG.d(LOG_TAG, "Intent no connectivity: " + noConnectivity);
|
||||||
if (noConnectivity) {
|
if(noConnectivity) {
|
||||||
LOG.d(LOG_TAG, "Really no connectivity");
|
LOG.d(LOG_TAG, "Really no connectivity");
|
||||||
} else {
|
} else {
|
||||||
LOG.d(LOG_TAG, "!!! Switching to unknown, Intent states there is a connectivity.");
|
LOG.d(LOG_TAG, "!!! Switching to unknown, Intent states there is a connectivity.");
|
||||||
@ -219,7 +219,7 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
|
|
||||||
private String determineCurrentConnectionType() {
|
private String determineCurrentConnectionType() {
|
||||||
String connectionType;
|
String connectionType;
|
||||||
if (NetworkManager.this.lastInfo == null) {
|
if(NetworkManager.this.lastInfo == null) {
|
||||||
connectionType = TYPE_NONE;
|
connectionType = TYPE_NONE;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -243,7 +243,7 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
receiver = null;
|
receiver = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (this.lollipopAndAboveNetworkCallback != null) {
|
} else if(this.lollipopAndAboveNetworkCallback != null) {
|
||||||
try {
|
try {
|
||||||
sockMan.unregisterNetworkCallback(this.lollipopAndAboveNetworkCallback);
|
sockMan.unregisterNetworkCallback(this.lollipopAndAboveNetworkCallback);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -268,7 +268,8 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
// send update to javascript "navigator.network.connection"
|
// send update to javascript "navigator.network.connection"
|
||||||
// Jellybean sends its own info
|
// Jellybean sends its own info
|
||||||
JSONObject thisInfo = this.getConnectionInfo(info);
|
JSONObject thisInfo = this.getConnectionInfo(info);
|
||||||
if (!thisInfo.equals(lastInfo)) {
|
if(!thisInfo.equals(lastInfo))
|
||||||
|
{
|
||||||
String connectionType = "";
|
String connectionType = "";
|
||||||
try {
|
try {
|
||||||
connectionType = thisInfo.get("type").toString();
|
connectionType = thisInfo.get("type").toString();
|
||||||
@ -294,7 +295,8 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
// If we are not connected to any network set type to none
|
// If we are not connected to any network set type to none
|
||||||
if (!info.isConnected()) {
|
if (!info.isConnected()) {
|
||||||
type = TYPE_NONE;
|
type = TYPE_NONE;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
type = getType(info);
|
type = getType(info);
|
||||||
}
|
}
|
||||||
extraInfo = info.getExtraInfo();
|
extraInfo = info.getExtraInfo();
|
||||||
@ -343,16 +345,19 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
LOG.d(LOG_TAG, "wifi : " + WIFI);
|
LOG.d(LOG_TAG, "wifi : " + WIFI);
|
||||||
if (type.equals(WIFI)) {
|
if (type.equals(WIFI)) {
|
||||||
return TYPE_WIFI;
|
return TYPE_WIFI;
|
||||||
} else if (type.toLowerCase().equals(TYPE_ETHERNET) || type.toLowerCase().startsWith(TYPE_ETHERNET_SHORT)) {
|
}
|
||||||
|
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)) {
|
||||||
type = info.getSubtypeName().toLowerCase(Locale.US);
|
type = info.getSubtypeName().toLowerCase(Locale.US);
|
||||||
if (type.equals(GSM) ||
|
if (type.equals(GSM) ||
|
||||||
type.equals(GPRS) ||
|
type.equals(GPRS) ||
|
||||||
type.equals(EDGE) ||
|
type.equals(EDGE) ||
|
||||||
type.equals(TWO_G)) {
|
type.equals(TWO_G)) {
|
||||||
return TYPE_2G;
|
return TYPE_2G;
|
||||||
} else if (type.startsWith(CDMA) ||
|
}
|
||||||
|
else if (type.startsWith(CDMA) ||
|
||||||
type.equals(UMTS) ||
|
type.equals(UMTS) ||
|
||||||
type.equals(ONEXRTT) ||
|
type.equals(ONEXRTT) ||
|
||||||
type.equals(EHRPD) ||
|
type.equals(EHRPD) ||
|
||||||
@ -361,14 +366,16 @@ public class NetworkManager extends CordovaPlugin {
|
|||||||
type.equals(HSPA) ||
|
type.equals(HSPA) ||
|
||||||
type.equals(THREE_G)) {
|
type.equals(THREE_G)) {
|
||||||
return TYPE_3G;
|
return TYPE_3G;
|
||||||
} else if (type.equals(LTE) ||
|
}
|
||||||
|
else if (type.equals(LTE) ||
|
||||||
type.equals(UMB) ||
|
type.equals(UMB) ||
|
||||||
type.equals(HSPA_PLUS) ||
|
type.equals(HSPA_PLUS) ||
|
||||||
type.equals(FOUR_G)) {
|
type.equals(FOUR_G)) {
|
||||||
return TYPE_4G;
|
return TYPE_4G;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return TYPE_NONE;
|
return TYPE_NONE;
|
||||||
}
|
}
|
||||||
return TYPE_UNKNOWN;
|
return TYPE_UNKNOWN;
|
||||||
|
Loading…
Reference in New Issue
Block a user