Fix code for NPE when click add and cancel repeatly VPN profile

Symptom: NPE is happened when click add and cancel repeatly VPN profile

Root Cause: Exception handling for ConfigDialog object

Steps to reproduce :
1. Go to VPN menu in Settings without Secure LockScreen
2. Click add VPN profile button
3. Keyguard dialog show
4. Click cancel button
5. Repeat 2 - 4 step

Test: refer a "Steps to reproduce"

Solution: Add exception handling for ConfigDialog object. This is a very rare case. But exception handling code should be needed.

Signed-off-by: SangJin Cha <sj.cha@lge.com>
Change-Id: I4c680b383f94c86a1c806d986e56f9f00d2be10e
This commit is contained in:
sj.cha
2019-03-27 09:19:28 +09:00
parent f467ee4a28
commit 36b314c6e0

View File

@@ -143,6 +143,10 @@ public class ConfigDialogFragment extends InstrumentedDialogFragment implements
@Override @Override
public void onClick(DialogInterface dialogInterface, int button) { public void onClick(DialogInterface dialogInterface, int button) {
ConfigDialog dialog = (ConfigDialog) getDialog(); ConfigDialog dialog = (ConfigDialog) getDialog();
if (dialog == null) {
Log.e(TAG, "ConfigDialog object is null");
return;
}
VpnProfile profile = dialog.getProfile(); VpnProfile profile = dialog.getProfile();
if (button == DialogInterface.BUTTON_POSITIVE) { if (button == DialogInterface.BUTTON_POSITIVE) {