Fix Settings crash issue
- Add conditional checks to avoid UI updates when the fragment is finishing or destoryed. - Add conditional checks to avoid UI updates if the fragment resource is not ready. Bug: 185756174 Test: manual test make RunSettingsRoboTests ROBOTEST_FILTER=NetworkProviderSettingsTest Change-Id: I506ee81985158b8992529440a31d2d5cfe81f441
This commit is contained in:
@@ -710,6 +710,11 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
Log.i(TAG, "onWifiStateChanged called with wifi state: " + wifiState);
|
||||
}
|
||||
|
||||
if (isFinishingOrDestroyed()) {
|
||||
Log.w(TAG, "onWifiStateChanged shouldn't run when fragment is finishing or destroyed");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (wifiState) {
|
||||
case WifiManager.WIFI_STATE_ENABLED:
|
||||
updateWifiEntryPreferences();
|
||||
@@ -979,6 +984,11 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
||||
|
||||
private String getSavedNetworkSettingsSummaryText(
|
||||
int numSavedNetworks, int numSavedSubscriptions) {
|
||||
if (getResources() == null) {
|
||||
Log.w(TAG, "getSavedNetworkSettingsSummaryText shouldn't run if resource is not ready");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (numSavedSubscriptions == 0) {
|
||||
return getResources().getQuantityString(R.plurals.wifi_saved_access_points_summary,
|
||||
numSavedNetworks, numSavedNetworks);
|
||||
|
Reference in New Issue
Block a user