From 36b314c6e05381c2540afc961f338d75fcb26515 Mon Sep 17 00:00:00 2001 From: "sj.cha" Date: Wed, 27 Mar 2019 09:19:28 +0900 Subject: [PATCH] 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 Change-Id: I4c680b383f94c86a1c806d986e56f9f00d2be10e --- src/com/android/settings/vpn2/ConfigDialogFragment.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/settings/vpn2/ConfigDialogFragment.java b/src/com/android/settings/vpn2/ConfigDialogFragment.java index c6475164d7e..0212a2050f0 100644 --- a/src/com/android/settings/vpn2/ConfigDialogFragment.java +++ b/src/com/android/settings/vpn2/ConfigDialogFragment.java @@ -143,6 +143,10 @@ public class ConfigDialogFragment extends InstrumentedDialogFragment implements @Override public void onClick(DialogInterface dialogInterface, int button) { ConfigDialog dialog = (ConfigDialog) getDialog(); + if (dialog == null) { + Log.e(TAG, "ConfigDialog object is null"); + return; + } VpnProfile profile = dialog.getProfile(); if (button == DialogInterface.BUTTON_POSITIVE) {