Merge eab9e2ba6cb5f1245f09496df2728bd0e8af9dbe on remote branch

Change-Id: I915855a40876ee56169b2347cec63f2011cb4210
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
index 60e9797..4bdd943 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothConnectionFacade.java
@@ -576,11 +576,15 @@
 
     @Rpc(description = "Bluetooth init Bond by Mac Address")
     public boolean bluetoothBond(@RpcParameter(name = "macAddress") String macAddress) {
+        mContext.registerReceiver(new BondBroadcastReceiver(),
+                new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
         return mBluetoothAdapter.getRemoteDevice(macAddress).createBond();
     }
 
     @Rpc(description = "Bluetooth init LE Bond by Mac Address")
     public boolean bluetoothLeBond(@RpcParameter(name = "macAddress") String macAddress) {
+        mContext.registerReceiver(new BondBroadcastReceiver(),
+                new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED));
         return mBluetoothAdapter.getRemoteDevice(macAddress).createBond(BluetoothDevice.TRANSPORT_LE);
     }
 
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidFacade.java
index 24f0b08..6829c90 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidFacade.java
@@ -38,6 +38,7 @@
 import com.googlecode.android_scripting.rpc.RpcDefault;
 import com.googlecode.android_scripting.rpc.RpcParameter;
 
+import java.util.Arrays;
 import java.util.List;
 
 /*
@@ -122,9 +123,9 @@
                 }
                 break;
                 case BluetoothHidHost.ACTION_REPORT: {
-                    char[] report = intent.getCharArrayExtra(
+                    byte[] report = intent.getByteArrayExtra(
                             BluetoothHidHost.EXTRA_REPORT);
-                    Log.d("Received report: " + String.valueOf(report));
+                    Log.d("Received report: " + Arrays.toString(report));
                 }
                 break;
                 case BluetoothHidHost.ACTION_VIRTUAL_UNPLUG_STATUS: {
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/GattClientFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/GattClientFacade.java
index e228672..176dd30 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/GattClientFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/GattClientFacade.java
@@ -270,6 +270,21 @@
     }
 
     /**
+     * Reconnect to a Bluetooth GATT server
+     *
+     * @param index the bluetooth gatt index
+     * @throws Exception
+     */
+    @Rpc(description = "Reconnect a bluetooth gatt")
+    public void gattClientReconnect(@RpcParameter(name = "index") Integer index) throws Exception {
+        if (mBluetoothGattList.get(index) != null) {
+            mBluetoothGattList.get(index).connect();
+        } else {
+            throw new Exception("Invalid index input: " + index);
+        }
+    }
+
+    /**
      * Disconnect a bluetooth gatt
      *
      * @param index the bluetooth gatt index