Allow soft AP settings config before bring up

Bug: 2538623
Change-Id: I4b927deb0e4981c164744b85e5c85c3fc95a31eb
diff --git a/res/xml/tether_prefs.xml b/res/xml/tether_prefs.xml
index 6e3d062..77fc7c6 100644
--- a/res/xml/tether_prefs.xml
+++ b/res/xml/tether_prefs.xml
@@ -28,7 +28,6 @@
 
     <PreferenceScreen
         android:key="wifi_ap_settings"
-        android:dependency="enable_wifi_ap"
         android:title="@string/wifi_tether_settings_text"
         android:summary="@string/wifi_tether_settings_subtext" >
         <intent
diff --git a/res/xml/wifi_ap_settings.xml b/res/xml/wifi_ap_settings.xml
index ad21714..9e26154 100644
--- a/res/xml/wifi_ap_settings.xml
+++ b/res/xml/wifi_ap_settings.xml
@@ -24,7 +24,6 @@
 
     <Preference
         android:key="wifi_ap_ssid_and_security"
-        android:dependency="enable_wifi_ap"
         android:title="@string/wifi_tether_configure_ap_text"
         android:persistent="false" />
 
diff --git a/src/com/android/settings/wifi/WifiApSettings.java b/src/com/android/settings/wifi/WifiApSettings.java
index 0815238..ca1b856 100644
--- a/src/com/android/settings/wifi/WifiApSettings.java
+++ b/src/com/android/settings/wifi/WifiApSettings.java
@@ -120,18 +120,25 @@
 
         if (button == DialogInterface.BUTTON_POSITIVE) {
             mWifiConfig = mDialog.getConfig();
-            if(mWifiConfig != null) {
-                mWifiManager.setWifiApEnabled(mWifiConfig, true);
+            if (mWifiConfig != null) {
+                /**
+                 * if soft AP is running, bring up with new config
+                 * else update the configuration alone
+                 */
+                if (mWifiManager.getWifiApState() == WifiManager.WIFI_AP_STATE_ENABLED) {
+                    mWifiManager.setWifiApEnabled(mWifiConfig, true);
+                    /**
+                     * There is no tether notification on changing AP
+                     * configuration. Update status with new config.
+                     */
+                    mWifiApEnabler.updateConfigSummary(mWifiConfig);
+                } else {
+                    mWifiManager.setWifiApConfiguration(mWifiConfig);
+                }
                 mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),
                             mWifiConfig.SSID,
                             mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
                             mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
-                /**
-                 * There is no tether notification on changing AP
-                 * configuration. Update status with new config.
-                 */
-                mWifiApEnabler.updateConfigSummary(mWifiConfig);
-
             }
         }
     }