From 5f7c991162190b9a038b2126d5bf4148595494dc Mon Sep 17 00:00:00 2001 From: tmfang Date: Fri, 17 Aug 2018 15:16:12 +0800 Subject: [PATCH] Fix crash on "Set up Wi-Fi NFC tag" dialog When user launches "Set up Wi-Fi NFC tag" dialog and then tries to rotate screen, device will crash. Because isShowing() of dialog won't return true anymore when fragment calls onSaveIntance(), we can't save status of dialog successfully. And then, when fragment called onCreateDialog() again, it can't get any dialog object. So, we only check dialog whether is null or not. If dialog is null, it means that there is no dialog was shown before user rotates the screen. Fixes: 112741721 Test: NFC tag wifi test, robo test Change-Id: Idb448ea32c4215d8380c69bfd896cc91d8c1f8d1 --- src/com/android/settings/wifi/WifiSettings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index 877c70e909b..9e2fac32646 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -443,7 +443,7 @@ public class WifiSettings extends RestrictedSettingsFragment } } - if (mWifiToNfcDialog != null && mWifiToNfcDialog.isShowing()) { + if (mWifiToNfcDialog != null) { Bundle savedState = new Bundle(); mWifiToNfcDialog.saveState(savedState); outState.putBundle(SAVED_WIFI_NFC_DIALOG_STATE, savedState); @@ -617,7 +617,6 @@ public class WifiSettings extends RestrictedSettingsFragment mWifiToNfcDialog = new WriteWifiConfigToNfcDialog(getActivity(), mWifiNfcDialogSavedState); } - return mWifiToNfcDialog; } return super.onCreateDialog(dialogId); @@ -633,6 +632,7 @@ public class WifiSettings extends RestrictedSettingsFragment public void onDismiss(DialogInterface dialog) { // We don't keep any dialog object when dialog was dismissed. mDialog = null; + mWifiToNfcDialog = null; } @Override