[Android] Clear network state when listener in unregistered
Geoffrey Métais
git at videolan.org
Wed Jul 18 10:26:36 CEST 2018
vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jul 18 10:25:54 2018 +0200| [9a8c1067be072c60e89afd49534d037c959e928d] | committer: Geoffrey Métais
Clear network state when listener in unregistered
> https://code.videolan.org/videolan/vlc-android/commit/9a8c1067be072c60e89afd49534d037c959e928d
---
vlc-android/src/org/videolan/vlc/ExternalMonitor.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
index 4b265de14..a1a7aed1c 100644
--- a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
+++ b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
@@ -23,6 +23,7 @@
package org.videolan.vlc;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -33,6 +34,7 @@ import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.Uri;
+import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -91,6 +93,9 @@ public class ExternalMonitor extends BroadcastReceiver {
static void unregister(Context ctx) {
ctx.unregisterReceiver(instance);
+ connected = false;
+ mobile = false;
+ vpn = false;
}
public static ExternalMonitor getInstance() {
@@ -160,8 +165,7 @@ public class ExternalMonitor extends BroadcastReceiver {
};
private synchronized void notifyConnectionChanges() {
- for (NetworkObserver obs : networkObservers)
- obs.onNetworkConnectionChanged(connected);
+ for (NetworkObserver obs : networkObservers) obs.onNetworkConnectionChanged(connected);
}
private static synchronized void notifyStorageChanges(String path) {
@@ -209,6 +213,7 @@ public class ExternalMonitor extends BroadcastReceiver {
}
}
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
private boolean updateVPNStatus() {
if (AndroidUtil.isLolliPopOrLater) {
for (Network network : cm.getAllNetworks()) {
More information about the Android
mailing list