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
This commit is contained in:
tmfang
2018-08-17 15:16:12 +08:00
parent b53cdf09dd
commit 5f7c991162

View File

@@ -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