Bug 1510663 - Address WifiManager Potential Leak warning. r=geckoview-reviewers,snorp
authorEmily Toop <etoop@mozilla.com>
Wed, 19 Dec 2018 15:50:05 +0000
changeset 509363 d02e6cc785a9b1c53f83b5c9370cc37885c9208b
parent 509362 589569dbbb63666dc7927757c5f99aaa8ee332d0
child 509364 db7ef78c063b2d0532056aa768f80493c8d0b739
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, snorp
bugs1510663
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1510663 - Address WifiManager Potential Leak warning. r=geckoview-reviewers,snorp On versions prior to Android N (24), initializing the WifiManager via Context#getSystemService can cause a memory leak if the context is not the application context. Differential Revision: https://phabricator.services.mozilla.com/D14721
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
@@ -385,17 +385,17 @@ public class GeckoNetworkManager extends
     }
 
     private static int wifiDhcpGatewayAddress(final Context context) {
         if (context == null) {
             return 0;
         }
 
         try {
-            WifiManager mgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+            WifiManager mgr = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
             if (mgr == null) {
                 return 0;
             }
 
             @SuppressLint("MissingPermission") DhcpInfo d = mgr.getDhcpInfo();
             if (d == null) {
                 return 0;
             }