From 1e976cbe99bf7635a9112f6f90091457dc88ec37 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Wed, 27 Nov 2013 18:37:44 -0500 Subject: [PATCH] bug 944043 - security exception on start up for GeckoView app r=mfinkle --- mobile/android/base/GeckoAppShell.java | 14 +++++++++++--- mobile/android/base/GeckoNetworkManager.java | 6 +++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 13a55e85cfb0..e6abbd55d225 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -1515,9 +1515,13 @@ public class GeckoAppShell public static boolean isNetworkLinkUp() { ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo info = cm.getActiveNetworkInfo(); - if (info == null || !info.isConnected()) + try { + NetworkInfo info = cm.getActiveNetworkInfo(); + if (info == null || !info.isConnected()) + return false; + } catch (SecurityException se) { return false; + } return true; } @@ -1525,8 +1529,12 @@ public class GeckoAppShell public static boolean isNetworkLinkKnown() { ConnectivityManager cm = (ConnectivityManager) getContext().getSystemService(Context.CONNECTIVITY_SERVICE); - if (cm.getActiveNetworkInfo() == null) + try { + if (cm.getActiveNetworkInfo() == null) + return false; + } catch (SecurityException se) { return false; + } return true; } diff --git a/mobile/android/base/GeckoNetworkManager.java b/mobile/android/base/GeckoNetworkManager.java index 45f560757c35..b38fd2442c19 100644 --- a/mobile/android/base/GeckoNetworkManager.java +++ b/mobile/android/base/GeckoNetworkManager.java @@ -220,7 +220,11 @@ public class GeckoNetworkManager extends BroadcastReceiver { return NetworkType.NETWORK_NONE; } - NetworkInfo ni = cm.getActiveNetworkInfo(); + NetworkInfo ni = null; + try { + ni = cm.getActiveNetworkInfo(); + } catch (SecurityException se) {} // if we don't have the permission, fall through to null check + if (ni == null) { return NetworkType.NETWORK_NONE; }