|
|
|
@ -116,11 +116,11 @@ public class ConnectionHelper {
|
|
|
|
|
if (state.connected && !roaming) {
|
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
|
|
|
|
NetworkInfo ani = cm.getActiveNetworkInfo();
|
|
|
|
|
NetworkInfo ani = (cm == null ? null : cm.getActiveNetworkInfo());
|
|
|
|
|
if (ani != null)
|
|
|
|
|
state.roaming = ani.isRoaming();
|
|
|
|
|
} else {
|
|
|
|
|
Network active = cm.getActiveNetwork();
|
|
|
|
|
Network active = (cm == null ? null : cm.getActiveNetwork());
|
|
|
|
|
if (active != null) {
|
|
|
|
|
NetworkCapabilities caps = cm.getNetworkCapabilities(active);
|
|
|
|
|
if (caps != null)
|
|
|
|
@ -152,13 +152,13 @@ public class ConnectionHelper {
|
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
|
|
|
NetworkInfo ani = cm.getActiveNetworkInfo();
|
|
|
|
|
NetworkInfo ani = (cm == null ? null : cm.getActiveNetworkInfo());
|
|
|
|
|
if (ani == null || !ani.isConnected())
|
|
|
|
|
return null;
|
|
|
|
|
return cm.isActiveNetworkMetered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Network active = cm.getActiveNetwork();
|
|
|
|
|
Network active = (cm == null ? null : cm.getActiveNetwork());
|
|
|
|
|
if (active == null) {
|
|
|
|
|
Log.i("isMetered: no active network");
|
|
|
|
|
return null;
|
|
|
|
@ -199,7 +199,6 @@ public class ConnectionHelper {
|
|
|
|
|
|
|
|
|
|
boolean underlying = false;
|
|
|
|
|
Network[] networks = cm.getAllNetworks();
|
|
|
|
|
if (networks != null)
|
|
|
|
|
for (Network network : networks) {
|
|
|
|
|
caps = cm.getNetworkCapabilities(network);
|
|
|
|
|
if (caps == null) {
|
|
|
|
|