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
Merged-In: I506ee81985158b8992529440a31d2d5cfe81f441
(cherry picked from commit 1caaf7447d
)
This commit is contained in:
@@ -710,6 +710,11 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
|||||||
Log.i(TAG, "onWifiStateChanged called with wifi state: " + wifiState);
|
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) {
|
switch (wifiState) {
|
||||||
case WifiManager.WIFI_STATE_ENABLED:
|
case WifiManager.WIFI_STATE_ENABLED:
|
||||||
updateWifiEntryPreferences();
|
updateWifiEntryPreferences();
|
||||||
@@ -981,6 +986,11 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
|
|||||||
|
|
||||||
private String getSavedNetworkSettingsSummaryText(
|
private String getSavedNetworkSettingsSummaryText(
|
||||||
int numSavedNetworks, int numSavedSubscriptions) {
|
int numSavedNetworks, int numSavedSubscriptions) {
|
||||||
|
if (getResources() == null) {
|
||||||
|
Log.w(TAG, "getSavedNetworkSettingsSummaryText shouldn't run if resource is not ready");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (numSavedSubscriptions == 0) {
|
if (numSavedSubscriptions == 0) {
|
||||||
return getResources().getQuantityString(R.plurals.wifi_saved_access_points_summary,
|
return getResources().getQuantityString(R.plurals.wifi_saved_access_points_summary,
|
||||||
numSavedNetworks, numSavedNetworks);
|
numSavedNetworks, numSavedNetworks);
|
||||||
|
Reference in New Issue
Block a user