Simplification

pull/162/head
M66B 5 years ago
parent 53d281c55f
commit f142e0b647

@ -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;

Loading…
Cancel
Save