mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-03 13:44:40 +00:00
Bugsnag: honor metered setting
This commit is contained in:
parent
b247745b4d
commit
835e11c0a0
1 changed files with 15 additions and 0 deletions
|
@ -8,13 +8,16 @@ import android.app.Application;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Environment;
|
||||
import android.os.storage.StorageManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function2;
|
||||
|
@ -121,6 +124,18 @@ public class Client implements MetadataAware, CallbackAware, UserAware {
|
|||
connectivity = new ConnectivityCompat(appContext, new Function2<Boolean, String, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(Boolean hasConnection, String networkState) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext);
|
||||
boolean metered = prefs.getBoolean("metered", true);
|
||||
if (!metered)
|
||||
try {
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager) appContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (cm != null && cm.isActiveNetworkMetered())
|
||||
hasConnection = false;
|
||||
} catch (Throwable ex) {
|
||||
android.util.Log.e("fairemail", ex + "\n" + android.util.Log.getStackTraceString(ex));
|
||||
}
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("hasConnection", hasConnection);
|
||||
data.put("networkState", networkState);
|
||||
|
|
Loading…
Reference in a new issue