Update WifiManagerFacade with API updates in WifiManager.
b/22802062

Change-Id: I56fe5598e71e4cdecdfaa3b4e31a41323ab8ac16
diff --git a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java
index 0e58146..2675ceb 100755
--- a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java
@@ -34,10 +34,13 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.net.ConnectivityManager;
+import android.net.DhcpInfo;
+import android.net.Network;
 import android.net.NetworkInfo;
 import android.net.NetworkInfo.DetailedState;
 import android.net.wifi.ScanResult;
 import android.net.wifi.WifiActivityEnergyInfo;
+import android.net.wifi.WifiChannel;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiConfiguration.AuthAlgorithm;
 import android.net.wifi.WifiConfiguration.KeyMgmt;
@@ -302,7 +305,7 @@
             config.priority = j.getInt("priority");
         }
         if (j.has("apBand")) {
-        	config.apBand = j.getInt("apBand");
+            config.apBand = j.getInt("apBand");
         }
         if (j.has("preSharedKey")) {
             config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
@@ -545,6 +548,11 @@
         return mWifi.enableNetwork(netId, disableOthers);
     }
 
+    @Rpc(description = "Enable WiFi verbose logging.")
+    public void wifiEnableVerboseLogging(@RpcParameter(name = "level") Integer level) {
+        mWifi.enableVerboseLogging(level);
+    }
+
     @Rpc(description = "Connect to a wifi network that uses Enterprise authentication methods.")
     public void wifiEnterpriseConnect(@RpcParameter(name = "config") JSONObject config)
             throws JSONException, GeneralSecurityException {
@@ -561,6 +569,11 @@
         }
     }
 
+    @Rpc(description = "Resets all WifiManager settings.")
+    public void wifiFactoryReset() {
+        mWifi.factoryReset();
+    }
+
     /**
      * Forget a wifi network with priority
      *
@@ -572,6 +585,21 @@
         mWifi.forget(newtorkId, listener);
     }
 
+    @Rpc(description = "Gets the Wi-Fi AP Configuration.")
+    public WifiConfiguration wifiGetApConfiguration() {
+        return mWifi.getWifiApConfiguration();
+    }
+
+    @Rpc(description = "Get a list of available channels for customized scan.")
+    public List<WifiChannel> wifiGetChannelList() {
+        return mWifi.getChannelList();
+    }
+
+    @Rpc(description = "Returns the file in which IP and proxy configuration data is stored.")
+    public String wifiGetConfigFile() {
+        return mWifi.getConfigFile();
+    }
+
     @Rpc(description = "Return a list of all the configured wifi networks.")
     public List<WifiConfiguration> wifiGetConfiguredNetworks() {
         return mWifi.getConfiguredNetworks();
@@ -587,14 +615,44 @@
         return mWifi.getControllerActivityEnergyInfo(0);
     }
 
+    @Rpc(description = "Get the country code used by WiFi.")
+    public String wifiGetCountryCode() {
+        return mWifi.getCountryCode();
+    }
+
+    @Rpc(description = "Get the current network.")
+    public Network wifiGetCurrentNetwork() {
+        return mWifi.getCurrentNetwork();
+    }
+
+    @Rpc(description = "Get the info from last successful DHCP request.")
+    public DhcpInfo wifiGetDhcpInfo() {
+        return mWifi.getDhcpInfo();
+    }
+
+    @Rpc(description = "Get privileged configured networks.")
+    public List<WifiConfiguration> wifiGetPrivilegedConfiguredNetworks() {
+        return mWifi.getPrivilegedConfiguredNetworks();
+    }
+
     @Rpc(description = "Returns the list of access points found during the most recent Wifi scan.")
     public List<ScanResult> wifiGetScanResults() {
         return mWifi.getScanResults();
     }
 
-    @Rpc(description = "Gets the Wi-Fi AP Configuration.")
-    public WifiConfiguration wifiGetApConfiguration() {
-        return mWifi.getWifiApConfiguration();
+    @Rpc(description = "Get the current level of WiFi verbose logging.")
+    public Integer wifiGetVerboseLoggingLevel() {
+        return mWifi.getVerboseLoggingLevel();
+    }
+
+    @Rpc(description = "true if this adapter supports 5 GHz band.")
+    public Boolean wifiIs5GHzBandSupported() {
+        return mWifi.is5GHzBandSupported();
+    }
+
+    @Rpc(description = "true if this adapter supports multiple simultaneous connections.")
+    public Boolean wifiIsAdditionalStaSupported() {
+        return mWifi.isAdditionalStaSupported();
     }
 
     @Rpc(description = "Return whether Wi-Fi AP is enabled or disabled.")
@@ -602,6 +660,11 @@
         return mWifi.isWifiApEnabled();
     }
 
+    @Rpc(description = "Check if the Batched Scan feature is supported..")
+    public Boolean wifiIsBatchedScanSupported() {
+        return mWifi.isBatchedScanSupported();
+    }
+
     @Rpc(description = "Check if Device-to-AP RTT is supported.")
     public Boolean wifiIsDeviceToApRttSupported() {
         return mWifi.isDeviceToApRttSupported();
@@ -612,16 +675,56 @@
         return mWifi.isDeviceToDeviceRttSupported();
     }
 
+    @Rpc(description = "Check if the chipset supports dual frequency band (2.4 GHz and 5 GHz).")
+    public Boolean wifiIsDualBandSupported() {
+        return mWifi.isDualBandSupported();
+    }
+
     @Rpc(description = "Check if this adapter supports advanced power/performance counters.")
     public Boolean wifiIsEnhancedPowerReportingSupported() {
         return mWifi.isEnhancedPowerReportingSupported();
     }
 
+    @Rpc(description = "Check if multicast is enabled.")
+    public Boolean wifiIsMulticastEnabled() {
+        return mWifi.isMulticastEnabled();
+    }
+
+    @Rpc(description = "true if this adapter supports Neighbour Awareness Network APIs.")
+    public Boolean wifiIsNanSupported() {
+        return mWifi.isNanSupported();
+    }
+
+    @Rpc(description = "true if this adapter supports Off Channel Tunnel Directed Link Setup.")
+    public Boolean wifiIsOffChannelTdlsSupported() {
+        return mWifi.isOffChannelTdlsSupported();
+    }
+
+    @Rpc(description = "true if this adapter supports WifiP2pManager (Wi-Fi Direct).")
+    public Boolean wifiIsP2pSupported() {
+        return mWifi.isP2pSupported();
+    }
+
+    @Rpc(description = "true if this adapter supports passpoint.")
+    public Boolean wifiIsPasspointSupported() {
+        return mWifi.isPasspointSupported();
+    }
+
+    @Rpc(description = "true if this adapter supports portable Wi-Fi hotspot.")
+    public Boolean wifiIsPortableHotspotSupported() {
+        return mWifi.isPortableHotspotSupported();
+    }
+
+    @Rpc(description = "true if this adapter supports offloaded connectivity scan.")
+    public Boolean wifiIsPreferredNetworkOffloadSupported() {
+        return mWifi.isPreferredNetworkOffloadSupported();
+    }
+
     @Rpc(description = "Check if wifi scanner is supported on this device.")
     public Boolean wifiIsScannerSupported() {
         return mWifi.isWifiScannerSupported();
     }
-
+    
     @Rpc(description = "Check if tdls is supported on this device.")
     public Boolean wifiIsTdlsSupported() {
         return mWifi.isTdlsSupported();
@@ -645,6 +748,11 @@
         }
     }
 
+    @Rpc(description = "Force a re-reading of batched scan results.")
+    public void wifiPollBatchedScan() {
+        mWifi.pollBatchedScan();
+    }
+
     /**
      * Connects to a wifi network with priority
      *
@@ -705,6 +813,13 @@
         }
     }
 
+    @Rpc(description = "Set the country code used by WiFi.")
+    public void wifiSetCountryCode(
+            @RpcParameter(name = "country") String country,
+            @RpcParameter(name = "persist") Boolean persist) {
+        mWifi.setCountryCode(country, persist);
+    }
+
     @Rpc(description = "Enable/disable tdls with a mac address.")
     public void wifiSetTdlsEnabledWithMacAddress(
             @RpcParameter(name = "remoteMacAddress") String remoteMacAddress,
@@ -720,6 +835,11 @@
         return mWifi.startScan();
     }
 
+    @Rpc(description = "Start the driver and connect to network. This function will over-ride WifiLock and device idle status.")
+    public Boolean wifiStart() {
+        return mWifi.startWifi();
+    }
+
     @Rpc(description = "Start Wi-fi Protected Setup.")
     public void wifiStartWps(
             @RpcParameter(name = "config",
@@ -747,6 +867,11 @@
         }
     }
 
+    @Rpc(description = "Disconnect from a network (if any) and stop the driver. This function will over-ride WifiLock and device idle status.")
+    public Boolean wifiStop() {
+        return mWifi.stopWifi();
+    }
+
     @Rpc(description = "Toggle Wifi on and off.", returns = "True if Wifi is enabled.")
     public Boolean wifiToggleState(@RpcParameter(name = "enabled") @RpcOptional Boolean enabled) {
         if (enabled == null) {
diff --git a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
index 9c7a2e0..60874c4 100644
--- a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
+++ b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
@@ -44,11 +44,14 @@
 import android.graphics.Point;
 import android.location.Address;
 import android.location.Location;
+import android.net.DhcpInfo;
+import android.net.Network;
 import android.net.NetworkInfo;
 import android.net.Uri;
 import android.net.wifi.RttManager.RttCapabilities;
 import android.net.wifi.ScanResult;
 import android.net.wifi.WifiActivityEnergyInfo;
+import android.net.wifi.WifiChannel;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiEnterpriseConfig;
 import android.net.wifi.WifiInfo;
@@ -194,6 +197,9 @@
         if (data instanceof NeighboringCellInfo) {
             return buildNeighboringCellInfo((NeighboringCellInfo) data);
         }
+        if (data instanceof Network) {
+            return buildNetwork((Network) data);
+        }
         if (data instanceof NetworkInfo) {
             return buildNetworkInfo((NetworkInfo) data);
         }
@@ -218,6 +224,9 @@
         if (data instanceof SubscriptionInfo) {
             return buildSubscriptionInfoRecord((SubscriptionInfo) data);
         }
+        if (data instanceof DhcpInfo) {
+            return buildDhcpInfo((DhcpInfo) data);
+        }
         if (data instanceof DisplayMetrics) {
             return buildDisplayMetrics((DisplayMetrics) data);
         }
@@ -227,6 +236,9 @@
         if (data instanceof WifiActivityEnergyInfo) {
             return buildWifiActivityEnergyInfo((WifiActivityEnergyInfo) data);
         }
+        if (data instanceof WifiChannel) {
+            return buildWifiChannel((WifiChannel) data);
+        }
         if (data instanceof WifiConfiguration) {
             return buildWifiConfiguration((WifiConfiguration) data);
         }
@@ -467,6 +479,17 @@
         return result;
     }
 
+    private static JSONObject buildDhcpInfo(DhcpInfo data) throws JSONException {
+        JSONObject result = new JSONObject();
+        result.put("ipAddress", data.ipAddress);
+        result.put("dns1", data.dns1);
+        result.put("dns2", data.dns2);
+        result.put("gateway", data.gateway);
+        result.put("serverAddress", data.serverAddress);
+        result.put("leaseDuration", data.leaseDuration);
+        return result;
+    }
+
     private static JSONObject buildJsonEvent(Event event) throws JSONException {
         JSONObject result = new JSONObject();
         result.put("name", event.getName());
@@ -577,19 +600,6 @@
         return result;
     }
 
-    private static JSONObject buildWifiActivityEnergyInfo(
-            WifiActivityEnergyInfo data) throws JSONException {
-        JSONObject result = new JSONObject();
-        result.put("ControllerEnergyUsed", data.getControllerEnergyUsed());
-        result.put("ControllerIdleTimeMillis",
-                data.getControllerIdleTimeMillis());
-        result.put("ControllerRxTimeMillis", data.getControllerRxTimeMillis());
-        result.put("ControllerTxTimeMillis", data.getControllerTxTimeMillis());
-        result.put("StackState", data.getStackState());
-        result.put("TimeStamp", data.getTimeStamp());
-        return result;
-    }
-
     private static JSONObject buildJsonWifiInfo(WifiInfo data)
             throws JSONException {
         JSONObject result = new JSONObject();
@@ -744,6 +754,12 @@
         return result;
     }
 
+    private static Object buildNetwork(Network data) throws JSONException {
+        JSONObject nw = new JSONObject();
+        nw.put("netId", data.netId);
+        return nw;
+    }
+
     private static Object buildNetworkInfo(NetworkInfo data)
             throws JSONException {
         JSONObject info = new JSONObject();
@@ -820,6 +836,28 @@
         return msg;
     }
 
+    private static JSONObject buildWifiActivityEnergyInfo(
+            WifiActivityEnergyInfo data) throws JSONException {
+        JSONObject result = new JSONObject();
+        result.put("ControllerEnergyUsed", data.getControllerEnergyUsed());
+        result.put("ControllerIdleTimeMillis",
+                data.getControllerIdleTimeMillis());
+        result.put("ControllerRxTimeMillis", data.getControllerRxTimeMillis());
+        result.put("ControllerTxTimeMillis", data.getControllerTxTimeMillis());
+        result.put("StackState", data.getStackState());
+        result.put("TimeStamp", data.getTimeStamp());
+        return result;
+    }
+
+    private static Object buildWifiChannel(WifiChannel data) throws JSONException {
+        JSONObject channel = new JSONObject();
+        channel.put("channelNum", data.channelNum);
+        channel.put("freqMHz", data.freqMHz);
+        channel.put("isDFS", data.isDFS);
+        channel.put("isValid", data.isValid());
+        return channel;
+    }
+
     private static Object buildWifiConfiguration(WifiConfiguration data)
             throws JSONException {
         JSONObject config = new JSONObject();