Get WIFI_SERVICE using application context to avoid leaks.
Linting complains about this issue.
This commit is contained in:
parent
8fbf67c03c
commit
3139415172
@ -62,7 +62,7 @@ public class WifiStateChangeService extends IntentService {
|
|||||||
}
|
}
|
||||||
Utils.debugLog(TAG, "WiFi change service started, clearing info about wifi state until we have figured it out again.");
|
Utils.debugLog(TAG, "WiFi change service started, clearing info about wifi state until we have figured it out again.");
|
||||||
NetworkInfo ni = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
NetworkInfo ni = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||||
wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
|
wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
|
||||||
int wifiState = wifiManager.getWifiState();
|
int wifiState = wifiManager.getWifiState();
|
||||||
if (ni == null || ni.isConnected()) {
|
if (ni == null || ni.isConnected()) {
|
||||||
Utils.debugLog(TAG, "ni == " + ni + " wifiState == " + printWifiState(wifiState));
|
Utils.debugLog(TAG, "ni == " + ni + " wifiState == " + printWifiState(wifiState));
|
||||||
|
@ -672,7 +672,7 @@ public class ManageReposActivity extends AppCompatActivity implements LoaderMana
|
|||||||
private void checkIfNewRepoOnSameWifi(NewRepoConfig newRepo) {
|
private void checkIfNewRepoOnSameWifi(NewRepoConfig newRepo) {
|
||||||
// if this is a local repo, check we're on the same wifi
|
// if this is a local repo, check we're on the same wifi
|
||||||
if (!TextUtils.isEmpty(newRepo.getBssid())) {
|
if (!TextUtils.isEmpty(newRepo.getBssid())) {
|
||||||
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||||
String bssid = wifiInfo.getBSSID();
|
String bssid = wifiInfo.getBSSID();
|
||||||
if (TextUtils.isEmpty(bssid)) { /* not all devices have wifi */
|
if (TextUtils.isEmpty(bssid)) { /* not all devices have wifi */
|
||||||
|
@ -254,7 +254,7 @@ public class SwapWorkflowActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void promptToSetupWifiAP() {
|
private void promptToSetupWifiAP() {
|
||||||
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
|
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
||||||
WifiApControl ap = WifiApControl.getInstance(this);
|
WifiApControl ap = WifiApControl.getInstance(this);
|
||||||
wifiManager.setWifiEnabled(false);
|
wifiManager.setWifiEnabled(false);
|
||||||
if (!ap.enable()) {
|
if (!ap.enable()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user