Skip to content
Snippets Groups Projects
Commit b7303728 authored by Sebastiano Barezzi's avatar Sebastiano Barezzi Committed by Dhina17
Browse files

SettingsLib: Handle WifiService being null

During development the Wi-Fi service might not work, let's handle this
case so the Setting app doesn't crash when opening the about phone
page

Logic borrowed from the Bluetooth controller

Change-Id: Id8f6ba5d7cbac5780363612b50848ecfea10bc04
parent 4e057772
No related branches found
No related tags found
No related merge requests found
......@@ -59,7 +59,7 @@ public abstract class AbstractWifiMacAddressPreferenceController
@Override
public boolean isAvailable() {
return true;
return mWifiManager != null;
}
@Override
......@@ -70,10 +70,8 @@ public abstract class AbstractWifiMacAddressPreferenceController
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
if (isAvailable()) {
mWifiMacAddress = screen.findPreference(KEY_WIFI_MAC_ADDRESS);
updateConnectivity();
}
mWifiMacAddress = screen.findPreference(KEY_WIFI_MAC_ADDRESS);
updateConnectivity();
}
@Override
......@@ -84,16 +82,16 @@ public abstract class AbstractWifiMacAddressPreferenceController
@SuppressLint("HardwareIds")
@Override
protected void updateConnectivity() {
if (mWifiManager == null || mWifiMacAddress == null) {
return;
}
final String[] macAddresses = mWifiManager.getFactoryMacAddresses();
String macAddress = null;
if (macAddresses != null && macAddresses.length > 0) {
macAddress = macAddresses[0];
}
if (mWifiMacAddress == null) {
return;
}
if (TextUtils.isEmpty(macAddress) || macAddress.equals(WifiInfo.DEFAULT_MAC_ADDRESS)) {
mWifiMacAddress.setSummary(R.string.status_unavailable);
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment