From da432283cf6f7512cd18b45710c0573b1ab7f120 Mon Sep 17 00:00:00 2001 From: Sneh Bansal Date: Thu, 16 Jul 2020 18:18:56 +0530 Subject: [PATCH] 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 --- .../network/telephony/NetworkSelectSettings.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java index b36248f1479..d74714fbb63 100644 --- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java +++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java @@ -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 results = aggregateCellInfoList((List) msg.obj);