From a6c74136b5839e0c0f8fa86b718cfac628887a9c Mon Sep 17 00:00:00 2001 From: volzhs Date: Fri, 12 May 2017 14:24:14 +0900 Subject: [PATCH] Fix possible memory leak for Android /godot_dev/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java:575: Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing to .getApplicationContext() [WifiManagerLeak] mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Explanation for issues of type "WifiManagerLeak": 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. Change context.getSystemService(...) to context.getApplicationContext().getSystemService(...). 1 errors, 0 warnings --- .../vending/expansion/downloader/impl/DownloaderService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java index 627bf3eedd7..e83faa2756e 100644 --- a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java +++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloaderService.java @@ -569,10 +569,10 @@ public abstract class DownloaderService extends CustomIntentService implements I */ void pollNetworkState() { if (null == mConnectivityManager) { - mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); + mConnectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); } if (null == mWifiManager) { - mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); + mWifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); } if (mConnectivityManager == null) { Log.w(Constants.TAG,