Prevent possible WifiManager leak
This commit is contained in:
parent
17401fd7e1
commit
416846499a
|
@ -81,7 +81,7 @@ public abstract class ServerProxy implements Runnable {
|
|||
return getAddress("127.0.0.1", request);
|
||||
}
|
||||
public String getPublicAddress(String request) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
int ipAddress = wifiManager.getConnectionInfo().getIpAddress();
|
||||
|
||||
if (ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN)) {
|
||||
|
|
|
@ -998,7 +998,7 @@ public final class Util {
|
|||
}
|
||||
public static String getSSID(Context context) {
|
||||
if (isWifiConnected(context)) {
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
if (wifiManager.getConnectionInfo() != null && wifiManager.getConnectionInfo().getSSID() != null) {
|
||||
return wifiManager.getConnectionInfo().getSSID().replace("\"", "");
|
||||
}
|
||||
|
@ -1371,7 +1371,7 @@ public final class Util {
|
|||
}
|
||||
|
||||
public static WifiManager.WifiLock createWifiLock(Context context, String tag) {
|
||||
WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiManager wm = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||
int lockType = WifiManager.WIFI_MODE_FULL;
|
||||
if (Build.VERSION.SDK_INT >= 12) {
|
||||
lockType = 3;
|
||||
|
|
Loading…
Reference in New Issue