1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-25 01:06:04 +00:00

Logout on previous network

This commit is contained in:
M66B 2020-10-27 21:41:22 +01:00
parent 80a00b157d
commit 94340307c4

View file

@ -2004,8 +2004,18 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} }
if (!Objects.equals(lastActive, active)) { if (!Objects.equals(lastActive, active)) {
if (lastActive != null) if (lastActive != null) {
lastLost = new Date().getTime(); boolean connected = false;
try {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = (cm == null ? null : cm.getNetworkInfo(lastActive));
connected = (ni != null && ni.isConnected());
} catch (Throwable ex) {
Log.e(ex);
}
if (!connected)
lastLost = new Date().getTime();
}
lastActive = active; lastActive = active;
EntityLog.log(ServiceSynchronize.this, "New active network=" + active); EntityLog.log(ServiceSynchronize.this, "New active network=" + active);