fix lint "WifiManager Potential Leak"

This commit is contained in:
Hans-Christoph Steiner 2018-08-10 10:48:29 +02:00
parent e75a1a7005
commit 0e6e839ed7

View File

@ -2,22 +2,19 @@ package org.fdroid.fdroid.localrepo.peers;
import android.content.Context; import android.content.Context;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import org.fdroid.fdroid.FDroidApp; import org.fdroid.fdroid.FDroidApp;
import org.fdroid.fdroid.Utils; import org.fdroid.fdroid.Utils;
import rx.Observable;
import java.io.IOException; import rx.Subscriber;
import java.net.InetAddress; import rx.functions.Action0;
import rx.subscriptions.Subscriptions;
import javax.jmdns.JmDNS; import javax.jmdns.JmDNS;
import javax.jmdns.ServiceEvent; import javax.jmdns.ServiceEvent;
import javax.jmdns.ServiceInfo; import javax.jmdns.ServiceInfo;
import javax.jmdns.ServiceListener; import javax.jmdns.ServiceListener;
import java.io.IOException;
import rx.Observable; import java.net.InetAddress;
import rx.Subscriber;
import rx.functions.Action0;
import rx.subscriptions.Subscriptions;
@SuppressWarnings("LineLength") @SuppressWarnings("LineLength")
final class BonjourFinder extends PeerFinder implements ServiceListener { final class BonjourFinder extends PeerFinder implements ServiceListener {
@ -58,7 +55,7 @@ final class BonjourFinder extends PeerFinder implements ServiceListener {
Utils.debugLog(TAG, "Requested Bonjour (mDNS) scan for peers."); Utils.debugLog(TAG, "Requested Bonjour (mDNS) scan for peers.");
if (wifiManager == null) { if (wifiManager == null) {
wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
multicastLock = wifiManager.createMulticastLock(context.getPackageName()); multicastLock = wifiManager.createMulticastLock(context.getPackageName());
multicastLock.setReferenceCounted(false); multicastLock.setReferenceCounted(false);
} }