[Settings] To avoid from crash when callback

Callback from SubscriptionManager and PhoneStateListner may comes in
under the case of Preference not available.

Bug: 141833767
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gBasePreferenceControllerTest
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=VideoCallingPreferenceControllerTest
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiCallingPreferenceControllerTest
Change-Id: I50b83b4488d272f6482bde5f09b57d59e6fc27a3
This commit is contained in:
Bonian Chen
2020-04-19 22:46:05 +08:00
parent 90cce123e5
commit 0f47147543
3 changed files with 8 additions and 2 deletions

View File

@@ -91,7 +91,8 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
@Override
public void updateState(Preference preference) {
super.updateState(preference);
if (mCallState == null) {
if ((mCallState == null) || (preference == null)) {
Log.d(TAG, "Skip update under mCallState=" + mCallState);
return;
}
final SwitchPreference switchPreference = (SwitchPreference) preference;