summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothInputHost.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothInputHost.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothInputHost.java118
1 files changed, 62 insertions, 56 deletions
diff --git a/framework/java/android/bluetooth/BluetoothInputHost.java b/framework/java/android/bluetooth/BluetoothInputHost.java
index 68d105f115..15303dc794 100644
--- a/framework/java/android/bluetooth/BluetoothInputHost.java
+++ b/framework/java/android/bluetooth/BluetoothInputHost.java
@@ -26,8 +26,8 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
-import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
/**
@@ -43,9 +43,9 @@ public final class BluetoothInputHost implements BluetoothProfile {
*
* <p>This intent will have 3 extras:
* <ul>
- * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
- * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile.</li>
- * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
+ * <li> {@link #EXTRA_STATE} - The current state of the profile. </li>
+ * <li> {@link #EXTRA_PREVIOUS_STATE}- The previous state of the profile.</li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device. </li>
* </ul>
*
* <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
@@ -57,13 +57,12 @@ public final class BluetoothInputHost implements BluetoothProfile {
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_CONNECTION_STATE_CHANGED =
- "android.bluetooth.inputhost.profile.action.CONNECTION_STATE_CHANGED";
+ "android.bluetooth.inputhost.profile.action.CONNECTION_STATE_CHANGED";
/**
* Constants representing device subclass.
*
- * @see #registerApp(String, String, String, byte, byte[],
- * BluetoothHidDeviceCallback)
+ * @see #registerApp(String, String, String, byte, byte[], BluetoothHidDeviceCallback)
*/
public static final byte SUBCLASS1_NONE = (byte) 0x00;
public static final byte SUBCLASS1_KEYBOARD = (byte) 0x40;
@@ -118,7 +117,8 @@ public final class BluetoothInputHost implements BluetoothProfile {
private BluetoothAdapter mAdapter;
- private static class BluetoothHidDeviceCallbackWrapper extends IBluetoothHidDeviceCallback.Stub {
+ private static class BluetoothHidDeviceCallbackWrapper extends
+ IBluetoothHidDeviceCallback.Stub {
private BluetoothHidDeviceCallback mCallback;
@@ -163,37 +163,44 @@ public final class BluetoothInputHost implements BluetoothProfile {
}
}
- final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
- new IBluetoothStateChangeCallback.Stub() {
-
- public void onBluetoothStateChange(boolean up) {
- Log.d(TAG, "onBluetoothStateChange: up=" + up);
- synchronized (mConnection) {
- if (!up) {
- Log.d(TAG,"Unbinding service...");
- if (mService != null) {
- mService = null;
- try {
- mContext.unbindService(mConnection);
- } catch (IllegalArgumentException e) {
- Log.e(TAG,"onBluetoothStateChange: could not unbind service:", e);
+ private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
+ new IBluetoothStateChangeCallback.Stub() {
+
+ public void onBluetoothStateChange(boolean up) {
+ Log.d(TAG, "onBluetoothStateChange: up=" + up);
+ synchronized (mConnection) {
+ if (!up) {
+ Log.d(TAG, "Unbinding service...");
+ if (mService != null) {
+ mService = null;
+ try {
+ mContext.unbindService(mConnection);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "onBluetoothStateChange: could not unbind service:",
+ e);
+ }
+ }
+ } else {
+ try {
+ if (mService == null) {
+ Log.d(TAG, "Binding HID Device service...");
+ doBind();
+ }
+ } catch (IllegalStateException e) {
+ Log.e(TAG,
+ "onBluetoothStateChange: could not bind to HID Dev "
+ + "service: ",
+ e);
+ } catch (SecurityException e) {
+ Log.e(TAG,
+ "onBluetoothStateChange: could not bind to HID Dev "
+ + "service: ",
+ e);
+ }
}
}
- } else {
- try {
- if (mService == null) {
- Log.d(TAG,"Binding HID Device service...");
- doBind();
- }
- } catch (IllegalStateException e) {
- Log.e(TAG,"onBluetoothStateChange: could not bind to HID Dev service: ", e);
- } catch (SecurityException e) {
- Log.e(TAG,"onBluetoothStateChange: could not bind to HID Dev service: ", e);
- }
}
- }
- }
- };
+ };
private ServiceConnection mConnection = new ServiceConnection() {
@@ -204,7 +211,7 @@ public final class BluetoothInputHost implements BluetoothProfile {
if (mServiceListener != null) {
mServiceListener.onServiceConnected(BluetoothProfile.INPUT_HOST,
- BluetoothInputHost.this);
+ BluetoothInputHost.this);
}
}
@@ -269,9 +276,9 @@ public final class BluetoothInputHost implements BluetoothProfile {
try {
mContext.unbindService(mConnection);
} catch (IllegalArgumentException e) {
- Log.e(TAG,"close: could not unbind HID Dev service: ", e);
+ Log.e(TAG, "close: could not unbind HID Dev service: ", e);
}
- }
+ }
}
mServiceListener = null;
@@ -280,6 +287,7 @@ public final class BluetoothInputHost implements BluetoothProfile {
/**
* {@inheritDoc}
*/
+ @Override
public List<BluetoothDevice> getConnectedDevices() {
Log.v(TAG, "getConnectedDevices()");
@@ -299,6 +307,7 @@ public final class BluetoothInputHost implements BluetoothProfile {
/**
* {@inheritDoc}
*/
+ @Override
public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
Log.v(TAG, "getDevicesMatchingConnectionStates(): states=" + Arrays.toString(states));
@@ -318,6 +327,7 @@ public final class BluetoothInputHost implements BluetoothProfile {
/**
* {@inheritDoc}
*/
+ @Override
public int getConnectionState(BluetoothDevice device) {
Log.v(TAG, "getConnectionState(): device=" + device);
@@ -341,14 +351,11 @@ public final class BluetoothInputHost implements BluetoothProfile {
* should be unregistered using
* {@link #unregisterApp(BluetoothHidDeviceAppConfiguration)}.
*
- * @param sdp {@link BluetoothHidDeviceAppSdpSettings} object of
- * HID Device SDP record.
- * @param inQos {@link BluetoothHidDeviceAppQosSettings} object of
- * Incoming QoS Settings.
- * @param outQos {@link BluetoothHidDeviceAppQosSettings} object of
- * Outgoing QoS Settings.
- * @param callback {@link BluetoothHidDeviceCallback} object to which
- * callback messages will be sent.
+ * @param sdp {@link BluetoothHidDeviceAppSdpSettings} object of HID Device SDP record.
+ * @param inQos {@link BluetoothHidDeviceAppQosSettings} object of Incoming QoS Settings.
+ * @param outQos {@link BluetoothHidDeviceAppQosSettings} object of Outgoing QoS Settings.
+ * @param callback {@link BluetoothHidDeviceCallback} object to which callback messages will be
+ * sent.
* @return
*/
public boolean registerApp(BluetoothHidDeviceAppSdpSettings sdp,
@@ -366,9 +373,9 @@ public final class BluetoothInputHost implements BluetoothProfile {
if (mService != null) {
try {
BluetoothHidDeviceAppConfiguration config =
- new BluetoothHidDeviceAppConfiguration();
+ new BluetoothHidDeviceAppConfiguration();
BluetoothHidDeviceCallbackWrapper cbw =
- new BluetoothHidDeviceCallbackWrapper(callback);
+ new BluetoothHidDeviceCallbackWrapper(callback);
result = mService.registerApp(config, sdp, inQos, outQos, cbw);
} catch (RemoteException e) {
Log.e(TAG, e.toString());
@@ -385,11 +392,10 @@ public final class BluetoothInputHost implements BluetoothProfile {
* new connections will be allowed until registered again using
* {@link #registerApp(String, String, String, byte, byte[], BluetoothHidDeviceCallback)}
*
- * @param config {@link BluetoothHidDeviceAppConfiguration} object as
- * obtained from
- * {@link BluetoothHidDeviceCallback#onAppStatusChanged(BluetoothDevice,
- * BluetoothHidDeviceAppConfiguration, boolean)}
- *
+ * @param config {@link BluetoothHidDeviceAppConfiguration} object as obtained from {@link
+ * BluetoothHidDeviceCallback#onAppStatusChanged(BluetoothDevice,
+ * BluetoothHidDeviceAppConfiguration,
+ * boolean)}
* @return
*/
public boolean unregisterApp(BluetoothHidDeviceAppConfiguration config) {
@@ -413,8 +419,8 @@ public final class BluetoothInputHost implements BluetoothProfile {
/**
* Sends report to remote host using interrupt channel.
*
- * @param id Report Id, as defined in descriptor. Can be 0 in case Report Id
- * are not defined in descriptor.
+ * @param id Report Id, as defined in descriptor. Can be 0 in case Report Id are not defined in
+ * descriptor.
* @param data Report data, not including Report Id.
* @return
*/