From 56cc9043dee456207bc3c231ad60db0771632f03 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 10 Feb 2019 08:05:17 +0000 Subject: [PATCH] Check if active network is connected --- app/src/main/java/eu/faircode/email/Helper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 89c90e1547..67ed6a4f6f 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -706,8 +706,15 @@ public class Helper { return null; } + NetworkInfo ani = cm.getNetworkInfo(active); if (log) - EntityLog.log(context, "isMetered: active info=" + cm.getNetworkInfo(active)); + EntityLog.log(context, "isMetered: active info=" + ani); + + if (ani == null || !ani.isConnected()) { + if (log) + EntityLog.log(context, "isMetered: active network not connected"); + return null; + } NetworkCapabilities caps = cm.getNetworkCapabilities(active); if (caps == null) {