From 125510489de7aa202ca57c857f8e9e96d9f3ea4f Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Thu, 12 Oct 2023 16:34:27 -0400 Subject: [PATCH] Fix lint warning releated to potential leak (#29715) NsdManagerServiceBrowser.java:51: Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing context to context.getApplicationContext() [WifiManagerPotentialLeak] Apply the recommendation from this check. --- .../android/java/chip/platform/NsdManagerServiceBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/android/java/chip/platform/NsdManagerServiceBrowser.java b/src/platform/android/java/chip/platform/NsdManagerServiceBrowser.java index 4e6bfc70d05f6d..3532182f65d483 100644 --- a/src/platform/android/java/chip/platform/NsdManagerServiceBrowser.java +++ b/src/platform/android/java/chip/platform/NsdManagerServiceBrowser.java @@ -42,7 +42,7 @@ public NsdManagerServiceBrowser(Context context) { this.mainThreadHandler = new Handler(Looper.getMainLooper()); this.multicastLock = - ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)) + ((WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE)) .createMulticastLock("chipBrowseMulticastLock"); this.multicastLock.setReferenceCounted(true); callbackMap = new HashMap<>();