Add Enterprise Wifi connection support in sl4a.
b/19590352

Also add sl4a support to enable/disable lockscreen with password,
which is essential because keystore is locked without a lockscreen password.

Also fix:
b/19590414
b/19585194

Change-Id: I2498817240eda7b022c484bb7b01477474b2150a
diff --git a/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java b/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
index 7510fc1..4e138e3 100644
--- a/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
@@ -21,7 +21,6 @@
 import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.media.AudioManager;
-import android.net.ConnectivityManager;
 import android.os.PowerManager;
 import android.os.SystemClock;
 import android.provider.Settings.SettingNotFoundException;
@@ -233,19 +232,20 @@
 
     @Rpc(description = "Set a string password to the device.")
     public void setDevicePassword(@RpcParameter(name = "password") String password) {
-        mLockPatternUtils.setLockPatternEnabled(true);
+        // mLockPatternUtils.setLockPatternEnabled(true);
+        mLockPatternUtils.setLockScreenDisabled(false);
         mLockPatternUtils.setCredentialRequiredToDecrypt(true);
-        mLockPatternUtils.saveLockPassword(password,
-                DevicePolicyManager.PASSWORD_QUALITY_NUMERIC,
-                false);
+        mLockPatternUtils.saveLockPassword(password, DevicePolicyManager.PASSWORD_QUALITY_NUMERIC);
     }
 
     @Rpc(description = "Disable screen lock password on the device.")
     public void disableDevicePassword() {
         mLockPatternUtils.clearEncryptionPassword();
-        mLockPatternUtils.setLockPatternEnabled(false);
+        // mLockPatternUtils.setLockPatternEnabled(false);
+        mLockPatternUtils.setLockScreenDisabled(true);
         mLockPatternUtils.setCredentialRequiredToDecrypt(false);
-        mLockPatternUtils.clearLock(false);
+        mLockPatternUtils.clearEncryptionPassword();
+        mLockPatternUtils.clearLock();
         mLockPatternUtils.setLockScreenDisabled(true);
     }
 
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 8800f9a..88b169e 100755
--- a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiManagerFacade.java
@@ -275,7 +275,7 @@
     }
 
     private WifiConfiguration genEnterpriseConfig(String configStr) throws JSONException,
-    GeneralSecurityException {
+            GeneralSecurityException {
         if (configStr == null) {
             return null;
         }
@@ -400,7 +400,7 @@
     }
 
     private PrivateKey strToPrivateKey(String key) throws NoSuchAlgorithmException,
-    InvalidKeySpecException {
+            InvalidKeySpecException {
         byte[] keyBytes = base64StrToBytes(key);
         PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
         KeyFactory fact = KeyFactory.getInstance("RSA");
@@ -409,7 +409,7 @@
     }
 
     private PublicKey strToPublicKey(String key) throws NoSuchAlgorithmException,
-    InvalidKeySpecException {
+            InvalidKeySpecException {
         byte[] keyBytes = base64StrToBytes(key);
         X509EncodedKeySpec keySpec = new X509EncodedKeySpec(keyBytes);
         KeyFactory fact = KeyFactory.getInstance("RSA");
@@ -472,7 +472,7 @@
     public Boolean wifiConnect(
             @RpcParameter(name = "SSID") String SSID,
             @RpcParameter(name = "Password") @RpcOptional @RpcDefault(value = "") String Password)
-                    throws ConnectException {
+            throws ConnectException {
         WifiConfiguration wifiConfig = genWifiConfig(SSID, Password);
         mWifi.addNetwork(wifiConfig);
         Boolean status = false;
@@ -643,8 +643,8 @@
     @Rpc(description = "Start Wi-fi Protected Setup.")
     public void wifiStartWps(
             @RpcParameter(name = "config",
-            description = "A json string with fields \"setup\", \"BSSID\", and \"pin\"") String config)
-                    throws JSONException {
+                    description = "A json string with fields \"setup\", \"BSSID\", and \"pin\"") String config)
+            throws JSONException {
         WpsInfo info = parseWpsInfo(config);
         WifiWpsCallback listener = new WifiWpsCallback();
         Log.d("Starting wps with: " + info);
diff --git a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiScannerFacade.java b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiScannerFacade.java
index bc54c99..26c5a98 100644
--- a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiScannerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiScannerFacade.java
@@ -180,11 +180,6 @@
         }
 
         @Override
-        public void onResults(ScanResult[] results) {
-            /* deprecated : Will not be called */
-        }
-        
-        @Override
         public void onResults(ScanData[] results) {
             Log.d("onResult WifiScanListener " + mIndex);
             wifiScannerDataList.put(mIndex, results);