Merge "Add new interfaces to BluetoothHidDeviceFacade to be able to send/reply report in bytes array"
diff --git a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidDeviceFacade.java b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidDeviceFacade.java
index 4e9b238..bc73e6a 100644
--- a/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidDeviceFacade.java
+++ b/Common/src/com/googlecode/android_scripting/facade/bluetooth/BluetoothHidDeviceFacade.java
@@ -430,6 +430,34 @@
     }
 
     /**
+     * Send a bytes array data report to a connected HID host using interrupt channel.
+     * @param deviceID name or MAC address or the HID input host
+     * @param id report Id, as defined in descriptor. Can be 0 in case Report Id are not defined in
+     * descriptor.
+     * @param report byte array to be sent into HID device
+     * @return true if successfully sent the report; otherwise false
+     * @throws Exception error from Bluetooth HidDevService
+     */
+    @Rpc(description = "Send bytes array report to a connected HID host using interrupt channel.")
+    public Boolean bluetoothHidDeviceSendBytesArrayReport(
+            @RpcParameter(name = "deviceID",
+                    description = "Name or MAC address of a bluetooth device.")
+                    String deviceID,
+            @RpcParameter(name = "descriptor",
+                    description = "Descriptor of the report")
+                    Integer id,
+            @RpcParameter(name = "report")
+                    byte[] report) throws Exception {
+        if (sHidDeviceProfile == null) {
+            return false;
+        }
+
+        BluetoothDevice device = BluetoothFacade.getDevice(sHidDeviceProfile.getConnectedDevices(),
+                deviceID);
+        return sHidDeviceProfile.sendReport(device, id, report);
+    }
+
+    /**
      * Send a report to the connected HID host as reply for GET_REPORT request from the HID host.
      * @param deviceID name or MAC address or the HID input host
      * @param type type of the report, as in request
@@ -463,6 +491,39 @@
     }
 
     /**
+     * Send a bytes array report to the connected HID host as reply for GET_REPORT request
+     * from the HID host.
+     * @param deviceID name or MAC address or the HID input host
+     * @param type type of the report, as in request
+     * @param id id of the report, as in request
+     * @param report byte array to be sent into HID device
+     * @return true if successfully sent the reply report; otherwise false
+     * @throws Exception error from Bluetooth HidDevService
+     */
+    @Rpc(description = "Send reply bytes array report to a connected HID..")
+    public Boolean bluetoothHidDeviceReplyBytesArrayReport(
+            @RpcParameter(name = "deviceID",
+                    description = "Name or MAC address of a bluetooth device.")
+                    String deviceID,
+            @RpcParameter(name = "type",
+                    description = "Type as in the report.")
+                    Integer type,
+            @RpcParameter(name = "id",
+                    description = "id as in the report.")
+                    Integer id,
+            @RpcParameter(name = "report")
+                    byte[] report) throws Exception {
+        if (sHidDeviceProfile == null) {
+            return false;
+        }
+
+        BluetoothDevice device = BluetoothFacade.getDevice(sHidDeviceProfile.getConnectedDevices(),
+                deviceID);
+        return sHidDeviceProfile.replyReport(
+                device, (byte) (int) type, (byte) (int) id, report);
+    }
+
+    /**
      * Send error handshake message as reply for invalid SET_REPORT request from the HID host.
      * @param deviceID name or MAC address or the HID input host
      * @param error error byte