Prevent errors when updating operator pref summary

The response for manual network selection request may come after the
fragment that displays the search results is already destroyed, say
when the user moves out of the results screen. In this case, attempting
to update the summary for the chosen operator preference leads to an
exception.

Check whether the preference to be updated is still valid before
attempting to update its summary.

Bug: 161422555
Test: Manually tested - verified that no exception was thrown when the
response of manual network selection request was received after the
fragment was destroyed.
Change-Id: I087c0e101fa75f229bc4353defbb14e8bf30153f
This commit is contained in:
Sneh Bansal
2020-07-16 18:18:56 +05:30
committed by Bonian Chen
parent 99a7c3ef00
commit da432283cf

View File

@@ -227,9 +227,13 @@ public class NetworkSelectSettings extends DashboardFragment {
setProgressBarVisible(false);
getPreferenceScreen().setEnabled(true);
mSelectedPreference.setSummary(isSucceed
? R.string.network_connected
: R.string.network_could_not_connect);
if (mSelectedPreference != null) {
mSelectedPreference.setSummary(isSucceed
? R.string.network_connected
: R.string.network_could_not_connect);
} else {
Log.e(TAG, "No preference to update!");
}
break;
case EVENT_NETWORK_SCAN_RESULTS:
List<CellInfo> results = aggregateCellInfoList((List<CellInfo>) msg.obj);