Fix the NPE issue in the Internet Settings

- Missing to remove the mRemoveLoadingRunnable in the onStop() function, which will cause the callback to run after the fragment is destroyed and encounter this NPE issue.

Bug: 193405782
Test: manual test
make RunSettingsRoboTests ROBOTEST_FILTER=NetworkProviderSettingsTest

Change-Id: I48b85173db1e6689dd056ba71f2fac776ffabbc9
This commit is contained in:
Weng Su
2021-07-14 14:41:57 +08:00
parent e796b8bf6e
commit 5a916eaaf9
2 changed files with 34 additions and 3 deletions

View File

@@ -167,7 +167,8 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
}
private boolean mIsViewLoading;
private final Runnable mRemoveLoadingRunnable = () -> {
@VisibleForTesting
final Runnable mRemoveLoadingRunnable = () -> {
if (mIsViewLoading) {
setLoading(false, false);
mIsViewLoading = false;
@@ -175,11 +176,13 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
};
private boolean mIsWifiEntryListStale = true;
private final Runnable mUpdateWifiEntryPreferencesRunnable = () -> {
@VisibleForTesting
final Runnable mUpdateWifiEntryPreferencesRunnable = () -> {
updateWifiEntryPreferences();
getView().postDelayed(mRemoveLoadingRunnable, 10);
};
private final Runnable mHideProgressBarRunnable = () -> {
@VisibleForTesting
final Runnable mHideProgressBarRunnable = () -> {
setProgressBarVisible(false);
};
@@ -445,6 +448,7 @@ public class NetworkProviderSettings extends RestrictedSettingsFragment
@Override
public void onStop() {
mIsWifiEntryListStale = true;
getView().removeCallbacks(mRemoveLoadingRunnable);
getView().removeCallbacks(mUpdateWifiEntryPreferencesRunnable);
getView().removeCallbacks(mHideProgressBarRunnable);
mAirplaneModeEnabler.stop();