mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-27 16:10:58 +01:00
Refactoring small improvement
This commit is contained in:
@@ -696,16 +696,18 @@ public class Helper {
|
||||
}
|
||||
|
||||
static boolean isConnected(Context context) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo ni = cm.getActiveNetworkInfo();
|
||||
return (ni != null && ni.isConnected());
|
||||
return (isMetered(context, false) != null);
|
||||
}
|
||||
|
||||
static Boolean isMetered(Context context, boolean log) {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M)
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
NetworkInfo ani = cm.getActiveNetworkInfo();
|
||||
if (ani == null || !ani.isConnected())
|
||||
return null;
|
||||
return cm.isActiveNetworkMetered();
|
||||
}
|
||||
|
||||
Network active = cm.getActiveNetwork();
|
||||
if (active == null) {
|
||||
|
||||
Reference in New Issue
Block a user