diff options
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothManager.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothManager.java | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/framework/java/android/bluetooth/BluetoothManager.java b/framework/java/android/bluetooth/BluetoothManager.java index bacce80062..7e3bb05fe0 100644 --- a/framework/java/android/bluetooth/BluetoothManager.java +++ b/framework/java/android/bluetooth/BluetoothManager.java @@ -86,17 +86,16 @@ public final class BluetoothManager { * * @param device Remote bluetooth device. * @param profile GATT or GATT_SERVER - * @return State of the profile connection. One of - * {@link BluetoothProfile#STATE_CONNECTED}, {@link BluetoothProfile#STATE_CONNECTING}, - * {@link BluetoothProfile#STATE_DISCONNECTED}, - * {@link BluetoothProfile#STATE_DISCONNECTING} + * @return State of the profile connection. One of {@link BluetoothProfile#STATE_CONNECTED}, + * {@link BluetoothProfile#STATE_CONNECTING}, {@link BluetoothProfile#STATE_DISCONNECTED}, + * {@link BluetoothProfile#STATE_DISCONNECTING} */ @RequiresPermission(Manifest.permission.BLUETOOTH) public int getConnectionState(BluetoothDevice device, int profile) { - if (DBG) Log.d(TAG,"getConnectionState()"); + if (DBG) Log.d(TAG, "getConnectionState()"); List<BluetoothDevice> connectedDevices = getConnectedDevices(profile); - for(BluetoothDevice connectedDevice : connectedDevices) { + for (BluetoothDevice connectedDevice : connectedDevices) { if (device.equals(connectedDevice)) { return BluetoothProfile.STATE_CONNECTED; } @@ -120,7 +119,7 @@ public final class BluetoothManager { */ @RequiresPermission(Manifest.permission.BLUETOOTH) public List<BluetoothDevice> getConnectedDevices(int profile) { - if (DBG) Log.d(TAG,"getConnectedDevices"); + if (DBG) Log.d(TAG, "getConnectedDevices"); if (profile != BluetoothProfile.GATT && profile != BluetoothProfile.GATT_SERVER) { throw new IllegalArgumentException("Profile not supported: " + profile); } @@ -133,16 +132,15 @@ public final class BluetoothManager { if (iGatt == null) return connectedDevices; connectedDevices = iGatt.getDevicesMatchingConnectionStates( - new int[] { BluetoothProfile.STATE_CONNECTED }); + new int[]{BluetoothProfile.STATE_CONNECTED}); } catch (RemoteException e) { - Log.e(TAG,"",e); + Log.e(TAG, "", e); } return connectedDevices; } /** - * * Get a list of devices that match any of the given connection * states. * @@ -155,15 +153,14 @@ public final class BluetoothManager { * to know the state of the local adapter. * * @param profile GATT or GATT_SERVER - * @param states Array of states. States can be one of - * {@link BluetoothProfile#STATE_CONNECTED}, {@link BluetoothProfile#STATE_CONNECTING}, - * {@link BluetoothProfile#STATE_DISCONNECTED}, - * {@link BluetoothProfile#STATE_DISCONNECTING}, + * @param states Array of states. States can be one of {@link BluetoothProfile#STATE_CONNECTED}, + * {@link BluetoothProfile#STATE_CONNECTING}, {@link BluetoothProfile#STATE_DISCONNECTED}, + * {@link BluetoothProfile#STATE_DISCONNECTING}, * @return List of devices. The list will be empty on error. */ @RequiresPermission(Manifest.permission.BLUETOOTH) public List<BluetoothDevice> getDevicesMatchingConnectionStates(int profile, int[] states) { - if (DBG) Log.d(TAG,"getDevicesMatchingConnectionStates"); + if (DBG) Log.d(TAG, "getDevicesMatchingConnectionStates"); if (profile != BluetoothProfile.GATT && profile != BluetoothProfile.GATT_SERVER) { throw new IllegalArgumentException("Profile not supported: " + profile); @@ -177,7 +174,7 @@ public final class BluetoothManager { if (iGatt == null) return devices; devices = iGatt.getDevicesMatchingConnectionStates(states); } catch (RemoteException e) { - Log.e(TAG,"",e); + Log.e(TAG, "", e); } return devices; @@ -189,14 +186,15 @@ public final class BluetoothManager { * as the results of any other GATT server operations. * The method returns a BluetoothGattServer instance. You can use BluetoothGattServer * to conduct GATT server operations. + * * @param context App context * @param callback GATT server callback handler that will receive asynchronous callbacks. * @return BluetoothGattServer instance */ public BluetoothGattServer openGattServer(Context context, - BluetoothGattServerCallback callback) { + BluetoothGattServerCallback callback) { - return (openGattServer (context, callback, BluetoothDevice.TRANSPORT_AUTO)); + return (openGattServer(context, callback, BluetoothDevice.TRANSPORT_AUTO)); } /** @@ -205,16 +203,17 @@ public final class BluetoothManager { * as the results of any other GATT server operations. * The method returns a BluetoothGattServer instance. You can use BluetoothGattServer * to conduct GATT server operations. + * * @param context App context * @param callback GATT server callback handler that will receive asynchronous callbacks. - * @param transport preferred transport for GATT connections to remote dual-mode devices - * {@link BluetoothDevice#TRANSPORT_AUTO} or - * {@link BluetoothDevice#TRANSPORT_BREDR} or {@link BluetoothDevice#TRANSPORT_LE} + * @param transport preferred transport for GATT connections to remote dual-mode devices {@link + * BluetoothDevice#TRANSPORT_AUTO} or {@link BluetoothDevice#TRANSPORT_BREDR} or {@link + * BluetoothDevice#TRANSPORT_LE} * @return BluetoothGattServer instance * @hide */ public BluetoothGattServer openGattServer(Context context, - BluetoothGattServerCallback callback,int transport) { + BluetoothGattServerCallback callback, int transport) { if (context == null || callback == null) { throw new IllegalArgumentException("null parameter: " + context + " " + callback); } @@ -229,11 +228,11 @@ public final class BluetoothManager { Log.e(TAG, "Fail to get GATT Server connection"); return null; } - BluetoothGattServer mGattServer = new BluetoothGattServer(iGatt,transport); + BluetoothGattServer mGattServer = new BluetoothGattServer(iGatt, transport); Boolean regStatus = mGattServer.registerCallback(callback); - return regStatus? mGattServer : null; + return regStatus ? mGattServer : null; } catch (RemoteException e) { - Log.e(TAG,"",e); + Log.e(TAG, "", e); return null; } } |