summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothHealth.java
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-08-24 21:25:49 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-08-24 21:25:49 +0000
commit94bbd4256d7261aa1d8ddf660e7856cde5afa49f (patch)
tree8299c300f3b4dbc2a5360c3319ac41bf1b389e55 /framework/java/android/bluetooth/BluetoothHealth.java
parent931010f176faa894f06051c57290f7723dfbcd49 (diff)
parent9e045d26d0128826b40520f523307d8d16473779 (diff)
Merge changes from topic "bt-fix-checkstyle-errors"
* changes: Fix checkstyle errors (2/2) Fix checkstyle errors (1/2)
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHealth.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothHealth.java134
1 files changed, 64 insertions, 70 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHealth.java b/framework/java/android/bluetooth/BluetoothHealth.java
index 8d77888193..dc5f38135a 100644
--- a/framework/java/android/bluetooth/BluetoothHealth.java
+++ b/framework/java/android/bluetooth/BluetoothHealth.java
@@ -36,24 +36,23 @@ import java.util.List;
* Service via IPC.
*
* <p> How to connect to a health device which is acting in the source role.
- * <li> Use {@link BluetoothAdapter#getProfileProxy} to get
- * the BluetoothHealth proxy object. </li>
- * <li> Create an {@link BluetoothHealth} callback and call
- * {@link #registerSinkAppConfiguration} to register an application
- * configuration </li>
- * <li> Pair with the remote device. This currently needs to be done manually
- * from Bluetooth Settings </li>
- * <li> Connect to a health device using {@link #connectChannelToSource}. Some
- * devices will connect the channel automatically. The {@link BluetoothHealth}
- * callback will inform the application of channel state change. </li>
- * <li> Use the file descriptor provided with a connected channel to read and
- * write data to the health channel. </li>
- * <li> The received data needs to be interpreted using a health manager which
- * implements the IEEE 11073-xxxxx specifications.
- * <li> When done, close the health channel by calling {@link #disconnectChannel}
- * and unregister the application configuration calling
- * {@link #unregisterAppConfiguration}
- *
+ * <li> Use {@link BluetoothAdapter#getProfileProxy} to get
+ * the BluetoothHealth proxy object. </li>
+ * <li> Create an {@link BluetoothHealth} callback and call
+ * {@link #registerSinkAppConfiguration} to register an application
+ * configuration </li>
+ * <li> Pair with the remote device. This currently needs to be done manually
+ * from Bluetooth Settings </li>
+ * <li> Connect to a health device using {@link #connectChannelToSource}. Some
+ * devices will connect the channel automatically. The {@link BluetoothHealth}
+ * callback will inform the application of channel state change. </li>
+ * <li> Use the file descriptor provided with a connected channel to read and
+ * write data to the health channel. </li>
+ * <li> The received data needs to be interpreted using a health manager which
+ * implements the IEEE 11073-xxxxx specifications.
+ * <li> When done, close the health channel by calling {@link #disconnectChannel}
+ * and unregister the application configuration calling
+ * {@link #unregisterAppConfiguration}
*/
public final class BluetoothHealth implements BluetoothProfile {
private static final String TAG = "BluetoothHealth";
@@ -98,34 +97,34 @@ public final class BluetoothHealth implements BluetoothProfile {
/** @hide */
public static final int HEALTH_OPERATION_NOT_ALLOWED = 6005;
- final private IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
+ private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
new IBluetoothStateChangeCallback.Stub() {
public void onBluetoothStateChange(boolean up) {
if (DBG) Log.d(TAG, "onBluetoothStateChange: up=" + up);
if (!up) {
- if (VDBG) Log.d(TAG,"Unbinding service...");
+ if (VDBG) Log.d(TAG, "Unbinding service...");
synchronized (mConnection) {
try {
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
} else {
synchronized (mConnection) {
try {
if (mService == null) {
- if (VDBG) Log.d(TAG,"Binding service...");
+ if (VDBG) Log.d(TAG, "Binding service...");
doBind();
}
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
}
- };
+ };
/**
@@ -137,10 +136,10 @@ public final class BluetoothHealth implements BluetoothProfile {
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param name The friendly name associated with the application or configuration.
- * @param dataType The dataType of the Source role of Health Profile to which
- * the sink wants to connect to.
- * @param callback A callback to indicate success or failure of the registration and
- * all operations done on this application configuration.
+ * @param dataType The dataType of the Source role of Health Profile to which the sink wants to
+ * connect to.
+ * @param callback A callback to indicate success or failure of the registration and all
+ * operations done on this application configuration.
* @return If true, callback will be called.
*/
public boolean registerSinkAppConfiguration(String name, int dataType,
@@ -161,9 +160,8 @@ public final class BluetoothHealth implements BluetoothProfile {
*
* @param name The friendly name associated with the application or configuration.
* @param dataType The dataType of the Source role of Health Profile.
- * @param channelType The channel type. Will be one of
- * {@link #CHANNEL_TYPE_RELIABLE} or
- * {@link #CHANNEL_TYPE_STREAMING}
+ * @param channelType The channel type. Will be one of {@link #CHANNEL_TYPE_RELIABLE} or {@link
+ * #CHANNEL_TYPE_STREAMING}
* @param callback - A callback to indicate success or failure.
* @return If true, callback will be called.
* @hide
@@ -197,7 +195,7 @@ public final class BluetoothHealth implements BluetoothProfile {
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
- * @param config The health app configuration
+ * @param config The health app configuration
* @return Success or failure.
*/
public boolean unregisterAppConfiguration(BluetoothHealthAppConfiguration config) {
@@ -224,14 +222,13 @@ public final class BluetoothHealth implements BluetoothProfile {
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device The remote Bluetooth device.
- * @param config The application configuration which has been registered using
- * {@link #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
+ * @param config The application configuration which has been registered using {@link
+ * #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
* @return If true, the callback associated with the application config will be called.
*/
public boolean connectChannelToSource(BluetoothDevice device,
BluetoothHealthAppConfiguration config) {
- if (mService != null && isEnabled() && isValidDevice(device) &&
- config != null) {
+ if (mService != null && isEnabled() && isValidDevice(device) && config != null) {
try {
return mService.connectChannelToSource(device, config);
} catch (RemoteException e) {
@@ -249,18 +246,17 @@ public final class BluetoothHealth implements BluetoothProfile {
* This is an asynchronous call. If this function returns true, the callback
* associated with the application configuration will be called.
*
- *<p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device The remote Bluetooth device.
- * @param config The application configuration which has been registered using
- * {@link #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
+ * @param config The application configuration which has been registered using {@link
+ * #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
* @return If true, the callback associated with the application config will be called.
* @hide
*/
public boolean connectChannelToSink(BluetoothDevice device,
BluetoothHealthAppConfiguration config, int channelType) {
- if (mService != null && isEnabled() && isValidDevice(device) &&
- config != null) {
+ if (mService != null && isEnabled() && isValidDevice(device) && config != null) {
try {
return mService.connectChannelToSink(device, config, channelType);
} catch (RemoteException e) {
@@ -278,18 +274,17 @@ public final class BluetoothHealth implements BluetoothProfile {
* This is an asynchronous call. If this function returns true, the callback
* associated with the application configuration will be called.
*
- *<p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
*
* @param device The remote Bluetooth device.
- * @param config The application configuration which has been registered using
- * {@link #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
+ * @param config The application configuration which has been registered using {@link
+ * #registerSinkAppConfiguration(String, int, BluetoothHealthCallback) }
* @param channelId The channel id associated with the channel
* @return If true, the callback associated with the application config will be called.
*/
public boolean disconnectChannel(BluetoothDevice device,
BluetoothHealthAppConfiguration config, int channelId) {
- if (mService != null && isEnabled() && isValidDevice(device) &&
- config != null) {
+ if (mService != null && isEnabled() && isValidDevice(device) && config != null) {
try {
return mService.disconnectChannel(device, config, channelId);
} catch (RemoteException e) {
@@ -317,8 +312,7 @@ public final class BluetoothHealth implements BluetoothProfile {
*/
public ParcelFileDescriptor getMainChannelFd(BluetoothDevice device,
BluetoothHealthAppConfiguration config) {
- if (mService != null && isEnabled() && isValidDevice(device) &&
- config != null) {
+ if (mService != null && isEnabled() && isValidDevice(device) && config != null) {
try {
return mService.getMainChannelFd(device, config);
} catch (RemoteException e) {
@@ -342,9 +336,8 @@ public final class BluetoothHealth implements BluetoothProfile {
* local adapter.
*
* @param device Remote bluetooth device.
- * @return State of the profile connection. One of
- * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
- * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
+ * @return State of the profile connection. One of {@link #STATE_CONNECTED}, {@link
+ * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
*/
@Override
public int getConnectionState(BluetoothDevice device) {
@@ -372,6 +365,7 @@ public final class BluetoothHealth implements BluetoothProfile {
* state of the local Bluetooth adapter for this profile. This can be used
* by applications like status bar which would just like to know the state of the
* local adapter.
+ *
* @return List of devices. The list will be empty on error.
*/
@Override
@@ -401,9 +395,8 @@ public final class BluetoothHealth implements BluetoothProfile {
* by applications like status bar which would just like to know the state of the
* local adapter.
*
- * @param states Array of states. States can be one of
- * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
- * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
+ * @param states Array of states. States can be one of {@link #STATE_CONNECTED}, {@link
+ * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
* @return List of devices. The list will be empty on error.
*/
@Override
@@ -429,25 +422,25 @@ public final class BluetoothHealth implements BluetoothProfile {
@Override
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
- int status) {
- mCallback.onHealthAppConfigurationStatusChange(config, status);
+ int status) {
+ mCallback.onHealthAppConfigurationStatusChange(config, status);
}
@Override
public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
- BluetoothDevice device, int prevState, int newState,
- ParcelFileDescriptor fd, int channelId) {
+ BluetoothDevice device, int prevState, int newState,
+ ParcelFileDescriptor fd, int channelId) {
mCallback.onHealthChannelStateChange(config, device, prevState, newState, fd,
- channelId);
+ channelId);
}
}
- /** Health Channel Connection State - Disconnected */
- public static final int STATE_CHANNEL_DISCONNECTED = 0;
+ /** Health Channel Connection State - Disconnected */
+ public static final int STATE_CHANNEL_DISCONNECTED = 0;
/** Health Channel Connection State - Connecting */
- public static final int STATE_CHANNEL_CONNECTING = 1;
+ public static final int STATE_CHANNEL_CONNECTING = 1;
/** Health Channel Connection State - Connected */
- public static final int STATE_CHANNEL_CONNECTED = 2;
+ public static final int STATE_CHANNEL_CONNECTED = 2;
/** Health Channel Connection State - Disconnecting */
public static final int STATE_CHANNEL_DISCONNECTING = 3;
@@ -477,7 +470,7 @@ public final class BluetoothHealth implements BluetoothProfile {
try {
mgr.registerStateChangeCallback(mBluetoothStateChangeCallback);
} catch (RemoteException e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -503,7 +496,7 @@ public final class BluetoothHealth implements BluetoothProfile {
try {
mgr.unregisterStateChangeCallback(mBluetoothStateChangeCallback);
} catch (Exception e) {
- Log.e(TAG,"",e);
+ Log.e(TAG, "", e);
}
}
@@ -513,7 +506,7 @@ public final class BluetoothHealth implements BluetoothProfile {
mService = null;
mContext.unbindService(mConnection);
} catch (Exception re) {
- Log.e(TAG,"",re);
+ Log.e(TAG, "", re);
}
}
}
@@ -529,6 +522,7 @@ public final class BluetoothHealth implements BluetoothProfile {
mServiceListener.onServiceConnected(BluetoothProfile.HEALTH, BluetoothHealth.this);
}
}
+
public void onServiceDisconnected(ComponentName className) {
if (DBG) Log.d(TAG, "Proxy object disconnected");
mService = null;
@@ -555,10 +549,10 @@ public final class BluetoothHealth implements BluetoothProfile {
private boolean checkAppParam(String name, int role, int channelType,
BluetoothHealthCallback callback) {
- if (name == null || (role != SOURCE_ROLE && role != SINK_ROLE) ||
- (channelType != CHANNEL_TYPE_RELIABLE &&
- channelType != CHANNEL_TYPE_STREAMING &&
- channelType != CHANNEL_TYPE_ANY) || callback == null) {
+ if (name == null || (role != SOURCE_ROLE && role != SINK_ROLE)
+ || (channelType != CHANNEL_TYPE_RELIABLE && channelType != CHANNEL_TYPE_STREAMING
+ && channelType != CHANNEL_TYPE_ANY)
+ || callback == null) {
return false;
}
if (role == SOURCE_ROLE && channelType == CHANNEL_TYPE_ANY) return false;