Merge "Add setWifiApConfiguration interface" into gingerbread
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java
index 46a68ac..509c789 100644
--- a/services/java/com/android/server/WifiService.java
+++ b/services/java/com/android/server/WifiService.java
@@ -631,6 +631,7 @@
     }
 
     public WifiConfiguration getWifiApConfiguration() {
+        enforceAccessPermission();
         final ContentResolver cr = mContext.getContentResolver();
         WifiConfiguration wifiConfig = new WifiConfiguration();
         int authType;
@@ -648,7 +649,8 @@
         }
     }
 
-    private void persistApConfiguration(WifiConfiguration wifiConfig) {
+    public void setWifiApConfiguration(WifiConfiguration wifiConfig) {
+        enforceChangePermission();
         final ContentResolver cr = mContext.getContentResolver();
         boolean isWpa;
         if (wifiConfig == null)
@@ -681,7 +683,7 @@
                 try {
                     nwService.setAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName(),
                                              SOFTAP_IFACE);
-                    persistApConfiguration(wifiConfig);
+                    setWifiApConfiguration(wifiConfig);
                     return true;
                 } catch(Exception e) {
                     Slog.e(TAG, "Exception in nwService during AP restart");
@@ -733,7 +735,7 @@
                 return false;
             }
 
-            persistApConfiguration(wifiConfig);
+            setWifiApConfiguration(wifiConfig);
 
         } else {
 
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 5fd44b1..6e0bc9d 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -83,5 +83,7 @@
     int getWifiApEnabledState();
 
     WifiConfiguration getWifiApConfiguration();
+
+    void setWifiApConfiguration(in WifiConfiguration wifiConfig);
 }
 
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 970d5fc..4a22b68 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -824,6 +824,21 @@
     }
 
     /**
+     * Sets the Wi-Fi AP Configuration.
+     * @return {@code true} if the operation succeeded, {@code false} otherwise
+     *
+     * @hide Dont open yet
+     */
+    public boolean setWifiApConfiguration(WifiConfiguration wifiConfig) {
+        try {
+            mService.setWifiApConfiguration(wifiConfig);
+            return true;
+        } catch (RemoteException e) {
+            return false;
+        }
+    }
+
+    /**
      * Allows an application to keep the Wi-Fi radio awake.
      * Normally the Wi-Fi radio may turn off when the user has not used the device in a while.
      * Acquiring a WifiLock will keep the radio on until the lock is released.  Multiple