[Android] Prevent NPE in ExtMonitor

Geoffrey Métais git at videolan.org
Mon Oct 2 10:25:31 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Oct  2 10:23:44 2017 +0200| [094935a4391a6c0673da8bce49a656635ce7cf6f] | committer: Geoffrey Métais

Prevent NPE in ExtMonitor

> https://code.videolan.org/videolan/vlc-android/commit/094935a4391a6c0673da8bce49a656635ce7cf6f
---

 vlc-android/src/org/videolan/vlc/ExternalMonitor.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
index 86fa793de..7c85353fc 100644
--- a/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
+++ b/vlc-android/src/org/videolan/vlc/ExternalMonitor.java
@@ -194,7 +194,8 @@ public class ExternalMonitor extends BroadcastReceiver {
     private boolean updateVPNStatus() {
         if (AndroidUtil.isLolliPopOrLater) {
             for (Network network : cm.getAllNetworks()) {
-                if (cm.getNetworkCapabilities(network).hasTransport(NetworkCapabilities.TRANSPORT_VPN))
+                final NetworkCapabilities nc = cm.getNetworkCapabilities(network);
+                if (nc != null && nc.hasTransport(NetworkCapabilities.TRANSPORT_VPN))
                     return true;
             }
             return false;



More information about the Android mailing list