Revert "Add Sms/Mms sent failure reasons parsing in sl4a. am: aa6562e1cc am: 427a48e566" am: 24a9ffaf6b
am: e75962b48d

Change-Id: Ia905ca7a85521177c2a351ff9468afa95c8564ea
diff --git a/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java b/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
index 6f152ba..3ef49f9 100644
--- a/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/SettingsFacade.java
@@ -36,6 +36,7 @@
 import com.googlecode.android_scripting.future.FutureActivityTask;
 import com.googlecode.android_scripting.jsonrpc.RpcReceiver;
 import com.googlecode.android_scripting.rpc.Rpc;
+import com.googlecode.android_scripting.rpc.RpcDefault;
 import com.googlecode.android_scripting.rpc.RpcOptional;
 import com.googlecode.android_scripting.rpc.RpcParameter;
 
@@ -55,7 +56,7 @@
     /**
      * Creates a new SettingsFacade.
      *
-     * @param service is the {@link Context} the APIs will run under
+     * @param manager is the {@link Context} the APIs will run under
      */
     public SettingsFacade(FacadeManager manager) {
         super(manager);
@@ -244,22 +245,28 @@
     }
 
     @Rpc(description = "Set a string password to the device.")
-    public void setDevicePassword(@RpcParameter(name = "password") String password) {
+    public void setDevicePassword(@RpcParameter(name = "password") String password,
+                                  @RpcParameter(name = "previousPassword")
+                                  @RpcDefault("")
+                                  @RpcOptional
+                                  String previousPassword) {
         // mLockPatternUtils.setLockPatternEnabled(true, UserHandle.myUserId());
         mLockPatternUtils.setLockScreenDisabled(false, UserHandle.myUserId());
         mLockPatternUtils.setCredentialRequiredToDecrypt(true);
-        mLockPatternUtils.saveLockPassword(password, null,
+        mLockPatternUtils.saveLockPassword(password, previousPassword,
                 DevicePolicyManager.PASSWORD_QUALITY_NUMERIC, UserHandle.myUserId());
     }
 
-    @Rpc(description = "Disable screen lock password on the device.")
-    public void disableDevicePassword() {
-        mLockPatternUtils.clearEncryptionPassword();
-        // mLockPatternUtils.setLockPatternEnabled(false, UserHandle.myUserId());
-        mLockPatternUtils.setLockScreenDisabled(true, UserHandle.myUserId());
-        mLockPatternUtils.setCredentialRequiredToDecrypt(false);
-        mLockPatternUtils.clearEncryptionPassword();
-        mLockPatternUtils.clearLock(null, UserHandle.myUserId());
+    @Rpc(description = "Disable screen lock password on the device. Note that disabling the " +
+            "screen lock while the screen is locked will still require the screen to be " +
+            "unlocked via pressing the back button and swiping up. To get around this, make sure " +
+            "the screen is on/unlocked when calling this method.")
+    public void disableDevicePassword(
+            @RpcParameter(name = "currentPassword",
+                          description = "The current password used to lock the device")
+            @RpcDefault("1111")
+            @RpcOptional String currentPassword) {
+        mLockPatternUtils.clearLock(currentPassword, UserHandle.myUserId());
         mLockPatternUtils.setLockScreenDisabled(true, UserHandle.myUserId());
     }
 
diff --git a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
index 214169c..8c539d8 100644
--- a/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/telephony/TelephonyManagerFacade.java
@@ -734,6 +734,30 @@
         return mTelephonyManager.getSimSerialNumber(subId);
     }
 
+    /**
+     * Set SIM card power state.
+     *
+     * @param state  State of SIM (0: power down, 1: power up, 2: pass through)
+     **/
+    @Rpc(description = "Set the SIM power state of the SIM card for default slot ID.")
+    public void telephonySetSimPowerState(
+                  @RpcParameter(name = "state") Integer state) {
+        mTelephonyManager.setSimPowerState(state);
+    }
+
+    /**
+     * Set SIM card power state.
+     *
+     * @param slotId SIM slot id
+     * @param state  State of SIM (0: power down, 1: power up, 2: pass through)
+     **/
+    @Rpc(description = "Set the SIM power state for SIM slot slotId.")
+    public void telephonySetSimStateForSlotId(
+                  @RpcParameter(name = "slotId") Integer slotId,
+                  @RpcParameter(name = "state") Integer state) {
+        mTelephonyManager.setSimPowerStateForSlot(slotId, state);
+    }
+
     @Rpc(description = "Returns the state of the SIM card for default slot ID.")
     public String telephonyGetSimState() {
         return telephonyGetSimStateForSlotId(
@@ -1255,6 +1279,30 @@
         return null;
     }
 
+    /**
+    * Read the value of a NV item.
+    * @param itemId Integer the NV item id to be read.
+    * @return the NV item value String.
+    */
+    @Rpc(description = "Returns the NV item as a String")
+    public String telephonyNvReadItem(
+                   @RpcParameter(name = "itemId") Integer itemId) {
+        return mTelephonyManager.nvReadItem(itemId);
+    }
+
+    /**
+    * Write a value to a NV item.
+    * @param itemId Integer the NV item id to be written.
+    * @param itemValue String the NV item value to be written.
+    * @return true or false for successfully or unsuccessfully writing.
+    */
+    @Rpc(description = "Write the NV item by itemId and String value")
+    public Boolean telephonyNvWriteItem(
+                   @RpcParameter(name = "itemId") Integer itemId,
+                   @RpcParameter(name = "itemValue") String itemValue) {
+        return mTelephonyManager.nvWriteItem(itemId, itemValue);
+    }
+
     private StateChangeListener getStateChangeListenerForSubscription(
             int subId,
             boolean createIfNeeded) {
diff --git a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiAwareManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiAwareManagerFacade.java
index d447f95..17053ec 100644
--- a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiAwareManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiAwareManagerFacade.java
@@ -21,6 +21,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.PackageManager;
 import android.net.NetworkSpecifier;
 import android.net.wifi.RttManager;
 import android.net.wifi.RttManager.RttResult;
@@ -327,6 +328,11 @@
         mService.unregisterReceiver(mStateChangedReceiver);
     }
 
+    @Rpc(description = "Does the device support the Wi-Fi Aware feature?")
+    public Boolean doesDeviceSupportWifiAwareFeature() {
+        return mService.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_AWARE);
+    }
+
     @Rpc(description = "Is Aware Usage Enabled?")
     public Boolean wifiIsAwareAvailable() throws RemoteException {
         synchronized (mLock) {
diff --git a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiP2pManagerFacade.java b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiP2pManagerFacade.java
index db2b321..b6a2e05 100644
--- a/Common/src/com/googlecode/android_scripting/facade/wifi/WifiP2pManagerFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/wifi/WifiP2pManagerFacade.java
@@ -458,7 +458,9 @@
 
     @Rpc(description = "Close the current wifi p2p connection created with initialize.")
     public void wifiP2pClose() {
-        mP2p.close(mChannel);
+        if (mChannel != null) {
+            mChannel.close();
+        }
     }
 
     @Rpc(description = "Returns true if wifi p2p is enabled, false otherwise.")
diff --git a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
index 8966859..29dc554 100644
--- a/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
+++ b/Common/src/com/googlecode/android_scripting/jsonrpc/JsonBuilder.java
@@ -736,6 +736,8 @@
         result.put("mnc", cellidentity.getMnc());
         result.put("cid", cellidentity.getCid());
         result.put("lac", cellidentity.getLac());
+        result.put("bsic", cellidentity.getBsic());
+        result.put("arfcn", cellidentity.getArfcn());
         result.put("signal_strength", signalstrength.getDbm());
         result.put("asulevel", signalstrength.getAsuLevel());
         return result;
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..5943cc6
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,9 @@
+bettyzhou@google.com
+bmahadev@google.com
+etancohen@google.com
+jpawlowski@google.com
+krisr@google.com
+tturney@google.com
+markdr@google.com
+sutherlandsean@google.com
+bpeake@google.com