Do a null check on setting an AP as configured

This was introduced when trying to fix bug 2296038. A null check is required on AP.

Bug: 2296038
diff --git a/src/com/android/settings/wifi/AccessPointDialog.java b/src/com/android/settings/wifi/AccessPointDialog.java
index 69fad0f..bf9a471 100644
--- a/src/com/android/settings/wifi/AccessPointDialog.java
+++ b/src/com/android/settings/wifi/AccessPointDialog.java
@@ -632,8 +632,14 @@
             updateEnterpriseFields();
         }
 
-        /* AP state on the current scan list needs update to enable "Forget" capability */
-        mWifiLayer.getWifiLayerApInstance(mState).setConfigured(true);
+        /**
+         * AP state on the current scan list needs update to enable "Forget" capability.
+         * This is not required for newly added APs.
+         */
+        AccessPointState ap = mWifiLayer.getWifiLayerApInstance(mState);
+        if(ap != null) {
+            ap.setConfigured(true);
+        }
 
         if (!mWifiLayer.saveNetwork(mState)) {
             return;