summaryrefslogtreecommitdiff
path: root/core/java/android/bluetooth/BluetoothInputDevice.java
diff options
context:
space:
mode:
authorPriti Aghera <paghera@broadcom.com>2012-04-09 12:13:17 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-16 21:20:07 -0700
commit349e62f329bbb8edab89356973773a5648f26751 (patch)
tree6967888d3826319eba1410f9dc0705a5951388e0 /core/java/android/bluetooth/BluetoothInputDevice.java
parent4c9cacadcc7ab20e06763746bbb41d0acdc106b5 (diff)
HID-PTS: Included apis' for pts tests
Change-Id: I7dc0a893ee86a2560c351a565bd170517f6c6079
Diffstat (limited to 'core/java/android/bluetooth/BluetoothInputDevice.java')
-rwxr-xr-x[-rw-r--r--]core/java/android/bluetooth/BluetoothInputDevice.java240
1 files changed, 240 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothInputDevice.java b/core/java/android/bluetooth/BluetoothInputDevice.java
index 199cc7a019d1..478a9d3b6929 100644..100755
--- a/core/java/android/bluetooth/BluetoothInputDevice.java
+++ b/core/java/android/bluetooth/BluetoothInputDevice.java
@@ -24,6 +24,7 @@ import android.content.Intent;
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 @@ public final class BluetoothInputDevice implements BluetoothProfile {
"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 final class BluetoothInputDevice implements BluetoothProfile {
*/
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 @@ public final class BluetoothInputDevice implements BluetoothProfile {
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);
}