|
|
|
@ -151,15 +151,17 @@ public class ConnectionHelper {
|
|
|
|
|
|
|
|
|
|
private static Boolean isMetered(Context context) {
|
|
|
|
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
if (cm == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
|
|
|
NetworkInfo ani = (cm == null ? null : cm.getActiveNetworkInfo());
|
|
|
|
|
NetworkInfo ani = cm.getActiveNetworkInfo();
|
|
|
|
|
if (ani == null || !ani.isConnected())
|
|
|
|
|
return null;
|
|
|
|
|
return cm.isActiveNetworkMetered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Network active = (cm == null ? null : cm.getActiveNetwork());
|
|
|
|
|
Network active = cm.getActiveNetwork();
|
|
|
|
|
if (active == null) {
|
|
|
|
|
Log.i("isMetered: no active network");
|
|
|
|
|
return null;
|
|
|
|
|