Don't crash quick settings if Wi-Fi is not supported.

Bug: 209906859
Test: flash wifi-less device, tap around quick settings
Change-Id: Iee8b3bf33c2abfb507b89db4a6781fb832571139
This commit is contained in:
Tomasz Wasilczyk
2021-12-10 09:05:12 -08:00
parent e3abce68e5
commit 959e7cd704
3 changed files with 10 additions and 3 deletions

View File

@@ -320,7 +320,7 @@ public class InternetDialog extends SystemUIDialog implements
showProgressBar();
final boolean isDeviceLocked = mInternetDialogController.isDeviceLocked();
final boolean isWifiEnabled = mWifiManager.isWifiEnabled();
final boolean isWifiEnabled = mWifiManager != null && mWifiManager.isWifiEnabled();
final boolean isWifiScanEnabled = mInternetDialogController.isWifiScanEnabled();
updateWifiToggle(isWifiEnabled, isDeviceLocked);
updateConnectedWifi(isWifiEnabled, isDeviceLocked);
@@ -350,6 +350,7 @@ public class InternetDialog extends SystemUIDialog implements
mSeeAllLayout.setOnClickListener(v -> onClickSeeMoreButton());
mWiFiToggle.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
if (mWifiManager == null) return;
buttonView.setChecked(isChecked);
mWifiManager.setWifiEnabled(isChecked);
});
@@ -375,8 +376,9 @@ public class InternetDialog extends SystemUIDialog implements
Log.d(TAG, "setMobileDataLayout, isCarrierNetworkActive = " + isCarrierNetworkActive);
}
boolean isWifiEnabled = mWifiManager != null && mWifiManager.isWifiEnabled();
if (!mInternetDialogController.hasActiveSubId()
&& (!mWifiManager.isWifiEnabled() || !isCarrierNetworkActive)) {
&& (!isWifiEnabled || !isCarrierNetworkActive)) {
mMobileNetworkLayout.setVisibility(View.GONE);
} else {
mMobileNetworkLayout.setVisibility(View.VISIBLE);

View File

@@ -826,7 +826,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi
if (!mLocationController.isLocationEnabled()) {
return false;
}
return mWifiManager.isScanAlwaysAvailable();
return mWifiManager != null && mWifiManager.isScanAlwaysAvailable();
}
static class WifiEntryConnectCallback implements WifiEntry.ConnectCallback {

View File

@@ -117,6 +117,7 @@ public class AccessPointControllerImpl implements AccessPointController,
}
public boolean canConfigWifi() {
if (!mWifiPickerTrackerFactory.isSupported()) return false;
return !mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI,
new UserHandle(mCurrentUser));
}
@@ -312,6 +313,10 @@ public class AccessPointControllerImpl implements AccessPointController,
mWorkerHandler = workerHandler;
}
private boolean isSupported() {
return mWifiManager != null;
}
/**
* Create a {@link WifiPickerTracker}
*