Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1caaf744 authored by Weng Su's avatar Weng Su
Browse files

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
parent 59e82689
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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);