Simplification

This commit is contained in:
M66B 2019-09-30 18:13:40 +02:00
parent 53d281c55f
commit f142e0b647
1 changed files with 4 additions and 2 deletions

View File

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