HID-PTS: Included apis' for pts tests
Change-Id: I7dc0a893ee86a2560c351a565bd170517f6c6079
diff --git a/core/java/android/bluetooth/BluetoothInputDevice.java b/core/java/android/bluetooth/BluetoothInputDevice.java
old mode 100644
new mode 100755
index 199cc7a..478a9d3
--- a/core/java/android/bluetooth/BluetoothInputDevice.java
+++ b/core/java/android/bluetooth/BluetoothInputDevice.java
@@ -24,6 +24,7 @@
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
+import android.os.ServiceManager;
import android.util.Log;
import java.util.ArrayList;
@@ -68,6 +69,22 @@
"android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED";
/**
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_PROTOCOL_MODE_CHANGED =
+ "android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED";
+
+
+ /**
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_VIRTUAL_UNPLUG_STATUS =
+ "android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS";
+
+
+ /**
* Return codes for the connect and disconnect Bluez / Dbus calls.
* @hide
*/
@@ -93,6 +110,77 @@
*/
public static final int INPUT_OPERATION_SUCCESS = 5004;
+ /**
+ * @hide
+ */
+ public static final int PROTOCOL_REPORT_MODE = 0;
+
+ /**
+ * @hide
+ */
+ public static final int PROTOCOL_BOOT_MODE = 1;
+
+ /**
+ * @hide
+ */
+ public static final int PROTOCOL_UNSUPPORTED_MODE = 255;
+
+ /* int reportType, int reportType, int bufferSize */
+ /**
+ * @hide
+ */
+ public static final byte REPORT_TYPE_INPUT = 0;
+
+ /**
+ * @hide
+ */
+ public static final byte REPORT_TYPE_OUTPUT = 1;
+
+ /**
+ * @hide
+ */
+ public static final byte REPORT_TYPE_FEATURE = 2;
+
+ /**
+ * @hide
+ */
+ public static final int VIRTUAL_UNPLUG_STATUS_SUCCESS = 0;
+
+ /**
+ * @hide
+ */
+ public static final int VIRTUAL_UNPLUG_STATUS_FAIL = 1;
+
+ /**
+ * @hide
+ */
+ public static final String EXTRA_PROTOCOL_MODE = "android.bluetooth.BluetoothInputDevice.extra.PROTOCOL_MODE";
+
+ /**
+ * @hide
+ */
+ public static final String EXTRA_REPORT_TYPE = "android.bluetooth.BluetoothInputDevice.extra.REPORT_TYPE";
+
+ /**
+ * @hide
+ */
+ public static final String EXTRA_REPORT_ID = "android.bluetooth.BluetoothInputDevice.extra.REPORT_ID";
+
+ /**
+ * @hide
+ */
+ public static final String EXTRA_REPORT_BUFFER_SIZE = "android.bluetooth.BluetoothInputDevice.extra.REPORT_BUFFER_SIZE";
+
+ /**
+ * @hide
+ */
+ public static final String EXTRA_REPORT = "android.bluetooth.BluetoothInputDevice.extra.REPORT";
+
+ /**
+ * @hide
+ */
+ public static final String EXTRA_VIRTUAL_UNPLUG_STATUS = "android.bluetooth.BluetoothInputDevice.extra.VIRTUAL_UNPLUG_STATUS";
+
private Context mContext;
private ServiceListener mServiceListener;
private BluetoothAdapter mAdapter;
@@ -337,6 +425,158 @@
return false;
}
+
+ /**
+ * Initiate virtual unplug for a HID input device.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ *
+ * @param device Remote Bluetooth Device
+ * @return false on immediate error,
+ * true otherwise
+ * @hide
+ */
+ public boolean virtualUnplug(BluetoothDevice device) {
+ if (DBG) log("virtualUnplug(" + device + ")");
+ if (mService != null && isEnabled() && isValidDevice(device)) {
+ try {
+ return mService.virtualUnplug(device);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
+ return false;
+ }
+ }
+
+ if (mService == null) Log.w(TAG, "Proxy not attached to service");
+ return false;
+
+ }
+
+ /**
+ * Send Get_Protocol_Mode command to the connected HID input device.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ *
+ * @param device Remote Bluetooth Device
+ * @return false on immediate error,
+ *true otherwise
+ * @hide
+ */
+ public boolean getProtocolMode(BluetoothDevice device) {
+ if (DBG) log("getProtocolMode(" + device + ")");
+ if (mService != null && isEnabled() && isValidDevice(device)) {
+ try {
+ return mService.getProtocolMode(device);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
+ return false;
+ }
+ }
+ if (mService == null) Log.w(TAG, "Proxy not attached to service");
+ return false;
+ }
+
+ /**
+ * Send Set_Protocol_Mode command to the connected HID input device.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ *
+ * @param device Remote Bluetooth Device
+ * @return false on immediate error,
+ * true otherwise
+ * @hide
+ */
+ public boolean setProtocolMode(BluetoothDevice device, int protocolMode) {
+ if (DBG) log("setProtocolMode(" + device + ")");
+ if (mService != null && isEnabled() && isValidDevice(device)) {
+ try {
+ return mService.setProtocolMode(device, protocolMode);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
+ return false;
+ }
+ }
+ if (mService == null) Log.w(TAG, "Proxy not attached to service");
+ return false;
+ }
+
+ /**
+ * Send Get_Report command to the connected HID input device.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ *
+ * @param device Remote Bluetooth Device
+ * @param reportType Report type
+ * @param reportId Report ID
+ * @param bufferSize Report receiving buffer size
+ * @return false on immediate error,
+ * true otherwise
+ * @hide
+ */
+ public boolean getReport(BluetoothDevice device, byte reportType, byte reportId, int bufferSize) {
+ if (DBG) log("getReport(" + device + "), reportType=" + reportType + " reportId=" + reportId + "bufferSize=" + bufferSize);
+ if (mService != null && isEnabled() && isValidDevice(device)) {
+ try {
+ return mService.getReport(device, reportType, reportId, bufferSize);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
+ return false;
+ }
+ }
+ if (mService == null) Log.w(TAG, "Proxy not attached to service");
+ return false;
+ }
+
+ /**
+ * Send Set_Report command to the connected HID input device.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ *
+ * @param device Remote Bluetooth Device
+ * @param reportType Report type
+ * @param report Report receiving buffer size
+ * @return false on immediate error,
+ * true otherwise
+ * @hide
+ */
+ public boolean setReport(BluetoothDevice device, byte reportType, String report) {
+ if (DBG) log("setReport(" + device + "), reportType=" + reportType + " report=" + report);
+ if (mService != null && isEnabled() && isValidDevice(device)) {
+ try {
+ return mService.setReport(device, reportType, report);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
+ return false;
+ }
+ }
+ if (mService == null) Log.w(TAG, "Proxy not attached to service");
+ return false;
+ }
+
+ /**
+ * Send Send_Data command to the connected HID input device.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN} permission.
+ *
+ * @param device Remote Bluetooth Device
+ * @param data Data to send
+ * @return false on immediate error,
+ * true otherwise
+ * @hide
+ */
+ public boolean sendData(BluetoothDevice device, String report) {
+ if (DBG) log("sendData(" + device + "), report=" + report);
+ if (mService != null && isEnabled() && isValidDevice(device)) {
+ try {
+ return mService.sendData(device, report);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
+ return false;
+ }
+ }
+ if (mService == null) Log.w(TAG, "Proxy not attached to service");
+ return false;
+ }
private static void log(String msg) {
Log.d(TAG, msg);
}