From bf981ca2e9d1d75ef726fa6d17a0b5450cf17cdf Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Fri, 1 Apr 2011 16:33:09 -0700 Subject: Implement APIs for Bluetooth Health profile. This first patch implements all the APIs. The APIs wil be made public soon. The data specification API will be submited in another patchset. Change-Id: I2462683b7e07380e2c42474b0036b34d03b4bed1 --- .../bluetooth/BluetoothHealthAppConfiguration.java | 180 +++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java new file mode 100644 index 0000000000..b87aea5913 --- /dev/null +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package android.bluetooth; + +import android.os.IBinder; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * The Bluetooth Health Application Configuration that is used in conjunction with + * the {@link BluetoothHealth} class. This class represents an application configuration + * that the Bluetooth Health third party application will register to communicate with the + * remote Bluetooth health device. + * + * @hide + */ +public final class BluetoothHealthAppConfiguration implements Parcelable { + private final String mName; + private final int mDataType; + private final int mRole; + private final int mChannelType; + private final IBluetoothHealthCallback mCallback; + + /** + * Constructor to register the SINK role + * + * @param name Friendly name associated with the application configuration + * @param dataType Data Type of the remote Bluetooth Health device + * @param callback Callback associated with the application configuration. + */ + BluetoothHealthAppConfiguration(String name, int dataType, IBluetoothHealthCallback callback) { + mName = name; + mDataType = dataType; + mRole = BluetoothHealth.SINK_ROLE; + mChannelType = BluetoothHealth.CHANNEL_TYPE_ANY; + mCallback = callback; + } + + /** + * Constructor to register the application configuration. + * + * @param name Friendly name associated with the application configuration + * @param dataType Data Type of the remote Bluetooth Health device + * @param role {@link BluetoothHealth.SOURCE_ROLE} or + * {@link BluetoothHealth.SINK_ROLE} + * @param callback Callback associated with the application configuration. + */ + BluetoothHealthAppConfiguration(String name, int dataType, int role, int channelType, + IBluetoothHealthCallback callback) { + mName = name; + mDataType = dataType; + mRole = role; + mChannelType = channelType; + mCallback = callback; + } + + @Override + public boolean equals(Object o) { + if (o instanceof BluetoothHealthAppConfiguration) { + BluetoothHealthAppConfiguration config = (BluetoothHealthAppConfiguration) o; + // config.getName() can never be NULL + return mName.equals(config.getName()) && + mDataType == config.getDataType() && + mRole == config.getRole() && + mChannelType == config.getChannelType() && + mCallback.equals(config.getCallback()); + } + return false; + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + (mName != null ? mName.hashCode() : 0); + result = 31 * result + mDataType; + result = 31 * result + mRole; + result = 31 * result + mChannelType; + result = 31 * result + (mCallback != null ? mCallback.hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "BluetoothHealthAppConfiguration [mName = " + mName + + ",mDataType = " + mDataType + ", mRole = " + mRole + ",mChannelType = " + + mChannelType + ",callback=" + mCallback +"]"; + } + + public int describeContents() { + return 0; + } + + /** + * Return the data type associated with this application configuration. + * + * @return dataType + */ + public int getDataType() { + return mDataType; + } + + /** + * Return the name of the application configuration. + * + * @return String name + */ + public String getName() { + return mName; + } + + /** + * Return the role associated with this application configuration. + * + * @return One of {@link BluetoothHealth#SOURCE_ROLE} or + * {@link BluetoothHealth#SINK_ROLE} + */ + public int getRole() { + return mRole; + } + + /** + * Return the channel type associated with this application configuration. + * + * @return One of {@link BluetoothHealth#CHANNEL_TYPE_RELIABLE} or + * {@link BluetoothHealth#CHANNEL_TYPE_STREAMING} or + * {@link BluetoothHealth#CHANNEL_TYPE_ANY}. + */ + public int getChannelType() { + return mChannelType; + } + + /** + * Return the callback associated with this application configuration. + * + * @return IBluetoothHealthCallback + */ + public IBluetoothHealthCallback getCallback() { + return mCallback; + } + + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { + public BluetoothHealthAppConfiguration createFromParcel(Parcel in) { + String name = in.readString(); + int type = in.readInt(); + int role = in.readInt(); + int channelType = in.readInt(); + IBluetoothHealthCallback callback = + IBluetoothHealthCallback.Stub.asInterface(in.readStrongBinder()); + return new BluetoothHealthAppConfiguration(name, type, role, channelType, + callback); + } + public BluetoothHealthAppConfiguration[] newArray(int size) { + return new BluetoothHealthAppConfiguration[size]; + } + }; + + public void writeToParcel(Parcel out, int flags) { + out.writeString(mName); + out.writeInt(mDataType); + out.writeInt(mRole); + out.writeInt(mChannelType); + out.writeStrongInterface(mCallback); + } +} -- cgit v1.2.3 From d3b7d1d78d8a2a71d2e825bf74b04cb9e9baa52f Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Wed, 6 Jul 2011 17:37:02 -0700 Subject: Bluetooth Health APIs 1. Remove the check of configs in BluetoothHealth. This check is useless since BluetoothHealth is a proxy. 2. Add a wrapper and a callback class. We shouldn't expose Binder interfaces as public APIs. Change-Id: If62620b4251cf93f3f97d2fe63099e40fae7da4d --- .../bluetooth/BluetoothHealthAppConfiguration.java | 45 ++++++++-------------- 1 file changed, 16 insertions(+), 29 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index b87aea5913..7020249c4c 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -17,7 +17,6 @@ package android.bluetooth; -import android.os.IBinder; import android.os.Parcel; import android.os.Parcelable; @@ -34,21 +33,18 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { private final int mDataType; private final int mRole; private final int mChannelType; - private final IBluetoothHealthCallback mCallback; /** * Constructor to register the SINK role * * @param name Friendly name associated with the application configuration * @param dataType Data Type of the remote Bluetooth Health device - * @param callback Callback associated with the application configuration. */ - BluetoothHealthAppConfiguration(String name, int dataType, IBluetoothHealthCallback callback) { + BluetoothHealthAppConfiguration(String name, int dataType) { mName = name; mDataType = dataType; mRole = BluetoothHealth.SINK_ROLE; mChannelType = BluetoothHealth.CHANNEL_TYPE_ANY; - mCallback = callback; } /** @@ -56,17 +52,15 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { * * @param name Friendly name associated with the application configuration * @param dataType Data Type of the remote Bluetooth Health device - * @param role {@link BluetoothHealth.SOURCE_ROLE} or - * {@link BluetoothHealth.SINK_ROLE} - * @param callback Callback associated with the application configuration. + * @param role {@link BluetoothHealth#SOURCE_ROLE} or + * {@link BluetoothHealth#SINK_ROLE} */ - BluetoothHealthAppConfiguration(String name, int dataType, int role, int channelType, - IBluetoothHealthCallback callback) { + BluetoothHealthAppConfiguration(String name, int dataType, int role, int + channelType) { mName = name; mDataType = dataType; mRole = role; mChannelType = channelType; - mCallback = callback; } @Override @@ -77,8 +71,7 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { return mName.equals(config.getName()) && mDataType == config.getDataType() && mRole == config.getRole() && - mChannelType == config.getChannelType() && - mCallback.equals(config.getCallback()); + mChannelType == config.getChannelType(); } return false; } @@ -90,7 +83,6 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { result = 31 * result + mDataType; result = 31 * result + mRole; result = 31 * result + mChannelType; - result = 31 * result + (mCallback != null ? mCallback.hashCode() : 0); return result; } @@ -98,9 +90,10 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { public String toString() { return "BluetoothHealthAppConfiguration [mName = " + mName + ",mDataType = " + mDataType + ", mRole = " + mRole + ",mChannelType = " + - mChannelType + ",callback=" + mCallback +"]"; + mChannelType + "]"; } + @Override public int describeContents() { return 0; } @@ -144,37 +137,31 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { return mChannelType; } - /** - * Return the callback associated with this application configuration. - * - * @return IBluetoothHealthCallback - */ - public IBluetoothHealthCallback getCallback() { - return mCallback; - } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + @Override public BluetoothHealthAppConfiguration createFromParcel(Parcel in) { String name = in.readString(); int type = in.readInt(); int role = in.readInt(); int channelType = in.readInt(); - IBluetoothHealthCallback callback = - IBluetoothHealthCallback.Stub.asInterface(in.readStrongBinder()); - return new BluetoothHealthAppConfiguration(name, type, role, channelType, - callback); + return new BluetoothHealthAppConfiguration(name, type, role, + channelType); } + + @Override public BluetoothHealthAppConfiguration[] newArray(int size) { return new BluetoothHealthAppConfiguration[size]; } }; + @Override public void writeToParcel(Parcel out, int flags) { out.writeString(mName); out.writeInt(mDataType); out.writeInt(mRole); out.writeInt(mChannelType); - out.writeStrongInterface(mCallback); } + + } -- cgit v1.2.3 From 090847e4abeee69744aaf1a75d6d8b30ff20bd21 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Wed, 31 Aug 2011 15:36:05 -0700 Subject: Make Bluetooth Health APIs public. Fix a few bugs: a) Pass a integer token to identify the channel. b) Close fds in case of errors. Change-Id: I2046787be5008769435f2f72a5bd67c19b749da0 --- .../java/android/bluetooth/BluetoothHealthAppConfiguration.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index 7020249c4c..15a9101452 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -26,7 +26,6 @@ import android.os.Parcelable; * that the Bluetooth Health third party application will register to communicate with the * remote Bluetooth health device. * - * @hide */ public final class BluetoothHealthAppConfiguration implements Parcelable { private final String mName; @@ -39,6 +38,7 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { * * @param name Friendly name associated with the application configuration * @param dataType Data Type of the remote Bluetooth Health device + * @hide */ BluetoothHealthAppConfiguration(String name, int dataType) { mName = name; @@ -54,6 +54,7 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { * @param dataType Data Type of the remote Bluetooth Health device * @param role {@link BluetoothHealth#SOURCE_ROLE} or * {@link BluetoothHealth#SINK_ROLE} + * @hide */ BluetoothHealthAppConfiguration(String name, int dataType, int role, int channelType) { @@ -93,7 +94,6 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { mChannelType + "]"; } - @Override public int describeContents() { return 0; } @@ -132,6 +132,7 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { * @return One of {@link BluetoothHealth#CHANNEL_TYPE_RELIABLE} or * {@link BluetoothHealth#CHANNEL_TYPE_STREAMING} or * {@link BluetoothHealth#CHANNEL_TYPE_ANY}. + * @hide */ public int getChannelType() { return mChannelType; @@ -155,13 +156,10 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { } }; - @Override public void writeToParcel(Parcel out, int flags) { out.writeString(mName); out.writeInt(mDataType); out.writeInt(mRole); out.writeInt(mChannelType); } - - } -- cgit v1.2.3 From 2e8a0aff66e8501eb5a425b8bfea92ef0dbdc80c Mon Sep 17 00:00:00 2001 From: Ajay Panicker Date: Fri, 23 Sep 2016 12:39:43 -0700 Subject: Prevent NPE if someone creates a bad BluetoothHealthAppConfig object Bug: 28271086 Change-Id: Ic8ebe3152e2b06c070316acc7e6a1f89763cd2a3 --- framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index 15a9101452..1717a1e36e 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -68,7 +68,9 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { public boolean equals(Object o) { if (o instanceof BluetoothHealthAppConfiguration) { BluetoothHealthAppConfiguration config = (BluetoothHealthAppConfiguration) o; - // config.getName() can never be NULL + + if (mName == null) return false; + return mName.equals(config.getName()) && mDataType == config.getDataType() && mRole == config.getRole() && -- cgit v1.2.3 From 910201beb0bde1dcf6b33e4ec5d1eb60042419d8 Mon Sep 17 00:00:00 2001 From: Jack He Date: Tue, 22 Aug 2017 16:06:54 -0700 Subject: Fix checkstyle errors (1/2) * Automatic style corrections through IDE Bug: 63596319 Test: make checkbuild, no manual changes, no functional changes Change-Id: I2397d55abc34c9b7a9b748bec6137778df3421a7 --- .../bluetooth/BluetoothHealthAppConfiguration.java | 50 ++++++++++------------ 1 file changed, 23 insertions(+), 27 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index 1717a1e36e..d406ac2b1e 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -25,7 +25,6 @@ import android.os.Parcelable; * the {@link BluetoothHealth} class. This class represents an application configuration * that the Bluetooth Health third party application will register to communicate with the * remote Bluetooth health device. - * */ public final class BluetoothHealthAppConfiguration implements Parcelable { private final String mName; @@ -52,12 +51,11 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { * * @param name Friendly name associated with the application configuration * @param dataType Data Type of the remote Bluetooth Health device - * @param role {@link BluetoothHealth#SOURCE_ROLE} or - * {@link BluetoothHealth#SINK_ROLE} + * @param role {@link BluetoothHealth#SOURCE_ROLE} or {@link BluetoothHealth#SINK_ROLE} * @hide */ BluetoothHealthAppConfiguration(String name, int dataType, int role, int - channelType) { + channelType) { mName = name; mDataType = dataType; mRole = role; @@ -92,8 +90,8 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { @Override public String toString() { return "BluetoothHealthAppConfiguration [mName = " + mName + - ",mDataType = " + mDataType + ", mRole = " + mRole + ",mChannelType = " + - mChannelType + "]"; + ",mDataType = " + mDataType + ", mRole = " + mRole + ",mChannelType = " + + mChannelType + "]"; } public int describeContents() { @@ -121,8 +119,7 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { /** * Return the role associated with this application configuration. * - * @return One of {@link BluetoothHealth#SOURCE_ROLE} or - * {@link BluetoothHealth#SINK_ROLE} + * @return One of {@link BluetoothHealth#SOURCE_ROLE} or {@link BluetoothHealth#SINK_ROLE} */ public int getRole() { return mRole; @@ -131,9 +128,8 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { /** * Return the channel type associated with this application configuration. * - * @return One of {@link BluetoothHealth#CHANNEL_TYPE_RELIABLE} or - * {@link BluetoothHealth#CHANNEL_TYPE_STREAMING} or - * {@link BluetoothHealth#CHANNEL_TYPE_ANY}. + * @return One of {@link BluetoothHealth#CHANNEL_TYPE_RELIABLE} or {@link + * BluetoothHealth#CHANNEL_TYPE_STREAMING} or {@link BluetoothHealth#CHANNEL_TYPE_ANY}. * @hide */ public int getChannelType() { @@ -141,22 +137,22 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { } public static final Parcelable.Creator CREATOR = - new Parcelable.Creator() { - @Override - public BluetoothHealthAppConfiguration createFromParcel(Parcel in) { - String name = in.readString(); - int type = in.readInt(); - int role = in.readInt(); - int channelType = in.readInt(); - return new BluetoothHealthAppConfiguration(name, type, role, - channelType); - } - - @Override - public BluetoothHealthAppConfiguration[] newArray(int size) { - return new BluetoothHealthAppConfiguration[size]; - } - }; + new Parcelable.Creator() { + @Override + public BluetoothHealthAppConfiguration createFromParcel(Parcel in) { + String name = in.readString(); + int type = in.readInt(); + int role = in.readInt(); + int channelType = in.readInt(); + return new BluetoothHealthAppConfiguration(name, type, role, + channelType); + } + + @Override + public BluetoothHealthAppConfiguration[] newArray(int size) { + return new BluetoothHealthAppConfiguration[size]; + } + }; public void writeToParcel(Parcel out, int flags) { out.writeString(mName); -- cgit v1.2.3 From 9e045d26d0128826b40520f523307d8d16473779 Mon Sep 17 00:00:00 2001 From: Jack He Date: Tue, 22 Aug 2017 21:21:23 -0700 Subject: Fix checkstyle errors (2/2) * Manual style corrections with IDE assistance * Variable name refactors are done through IDE * Corrected general style errors such as: - "final private var" -> "private final var" - "&&", "+", "||" should not be at the end of line - Non-static private variable should be like "mVar" - Private static variable should be like "sVar" - Code file should always end with newline - Inherited methods should be annotated with @Override and no @hide tags - Public methods should always have a JavaDoc entry - "int[] array" is preferred over "int array[]" - private methods should be accessed without "this." when there is no name collisions. - "boolean ? true : false" -> boolean - "boolean ? false : true" -> !boolean - "boolean == true" OR "boolean != false" -> boolean - "boolean != true" OR "boolean == false" -> !boolean Bug: 63596319 Test: make checkbuild, no functional changes Change-Id: Iabdc2be912a32dd63a53213d175cf1bfef268ccd --- .../android/bluetooth/BluetoothHealthAppConfiguration.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index d406ac2b1e..7c9db6f721 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -69,10 +69,8 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { if (mName == null) return false; - return mName.equals(config.getName()) && - mDataType == config.getDataType() && - mRole == config.getRole() && - mChannelType == config.getChannelType(); + return mName.equals(config.getName()) && mDataType == config.getDataType() + && mRole == config.getRole() && mChannelType == config.getChannelType(); } return false; } @@ -89,11 +87,11 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { @Override public String toString() { - return "BluetoothHealthAppConfiguration [mName = " + mName + - ",mDataType = " + mDataType + ", mRole = " + mRole + ",mChannelType = " + - mChannelType + "]"; + return "BluetoothHealthAppConfiguration [mName = " + mName + ",mDataType = " + mDataType + + ", mRole = " + mRole + ",mChannelType = " + mChannelType + "]"; } + @Override public int describeContents() { return 0; } @@ -154,6 +152,7 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { } }; + @Override public void writeToParcel(Parcel out, int flags) { out.writeString(mName); out.writeInt(mDataType); -- cgit v1.2.3 From 07ffaa447fdd967689901cca38eba386a8d97b23 Mon Sep 17 00:00:00 2001 From: Jack He Date: Thu, 3 Jan 2019 16:23:41 -0800 Subject: Deprecate BluetoothHealth APIs * Mark all BluetoothHealth related APIs as deprecated * Make BluetoothAdapter#getProfileProxy(context, BluetoothProfile.HEALTH) always return false * Remove all logic behind BluetoothHealth APIs and add deprecation error log * Health Device Profile (HDP) and MCAP protocol has been largely replaced by BLE. New applications should use Bluetooth Low Energy instead of legacy Bluetooth Health Device Profile Bug: 111562841 Test: make, unit test, use Bluetooth Change-Id: If99a9d79e9e1b89b75b9b74bd3b1c965247a1892 --- .../bluetooth/BluetoothHealthAppConfiguration.java | 122 ++++++--------------- 1 file changed, 34 insertions(+), 88 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index 7c9db6f721..9788bbf74e 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -25,72 +25,14 @@ import android.os.Parcelable; * the {@link BluetoothHealth} class. This class represents an application configuration * that the Bluetooth Health third party application will register to communicate with the * remote Bluetooth health device. + * + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ +@Deprecated public final class BluetoothHealthAppConfiguration implements Parcelable { - private final String mName; - private final int mDataType; - private final int mRole; - private final int mChannelType; - - /** - * Constructor to register the SINK role - * - * @param name Friendly name associated with the application configuration - * @param dataType Data Type of the remote Bluetooth Health device - * @hide - */ - BluetoothHealthAppConfiguration(String name, int dataType) { - mName = name; - mDataType = dataType; - mRole = BluetoothHealth.SINK_ROLE; - mChannelType = BluetoothHealth.CHANNEL_TYPE_ANY; - } - - /** - * Constructor to register the application configuration. - * - * @param name Friendly name associated with the application configuration - * @param dataType Data Type of the remote Bluetooth Health device - * @param role {@link BluetoothHealth#SOURCE_ROLE} or {@link BluetoothHealth#SINK_ROLE} - * @hide - */ - BluetoothHealthAppConfiguration(String name, int dataType, int role, int - channelType) { - mName = name; - mDataType = dataType; - mRole = role; - mChannelType = channelType; - } - - @Override - public boolean equals(Object o) { - if (o instanceof BluetoothHealthAppConfiguration) { - BluetoothHealthAppConfiguration config = (BluetoothHealthAppConfiguration) o; - - if (mName == null) return false; - - return mName.equals(config.getName()) && mDataType == config.getDataType() - && mRole == config.getRole() && mChannelType == config.getChannelType(); - } - return false; - } - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + (mName != null ? mName.hashCode() : 0); - result = 31 * result + mDataType; - result = 31 * result + mRole; - result = 31 * result + mChannelType; - return result; - } - - @Override - public String toString() { - return "BluetoothHealthAppConfiguration [mName = " + mName + ",mDataType = " + mDataType - + ", mRole = " + mRole + ",mChannelType = " + mChannelType + "]"; - } - @Override public int describeContents() { return 0; @@ -100,50 +42,59 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { * Return the data type associated with this application configuration. * * @return dataType + * + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ + @Deprecated public int getDataType() { - return mDataType; + return 0; } /** * Return the name of the application configuration. * * @return String name + * + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ + @Deprecated public String getName() { - return mName; + return null; } /** * Return the role associated with this application configuration. * * @return One of {@link BluetoothHealth#SOURCE_ROLE} or {@link BluetoothHealth#SINK_ROLE} + * + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ + @Deprecated public int getRole() { - return mRole; + return 0; } /** - * Return the channel type associated with this application configuration. - * - * @return One of {@link BluetoothHealth#CHANNEL_TYPE_RELIABLE} or {@link - * BluetoothHealth#CHANNEL_TYPE_STREAMING} or {@link BluetoothHealth#CHANNEL_TYPE_ANY}. - * @hide + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ - public int getChannelType() { - return mChannelType; - } - + @Deprecated public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override public BluetoothHealthAppConfiguration createFromParcel(Parcel in) { - String name = in.readString(); - int type = in.readInt(); - int role = in.readInt(); - int channelType = in.readInt(); - return new BluetoothHealthAppConfiguration(name, type, role, - channelType); + return new BluetoothHealthAppConfiguration(); } @Override @@ -153,10 +104,5 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { }; @Override - public void writeToParcel(Parcel out, int flags) { - out.writeString(mName); - out.writeInt(mDataType); - out.writeInt(mRole); - out.writeInt(mChannelType); - } + public void writeToParcel(Parcel out, int flags) {} } -- cgit v1.2.3 From 8bb9c7d4acc24f45fad0b1b964f4973e71fab3e3 Mon Sep 17 00:00:00 2001 From: Jack He Date: Thu, 3 Jan 2019 16:23:41 -0800 Subject: Deprecate BluetoothHealth APIs * Mark all BluetoothHealth related APIs as deprecated * Make BluetoothAdapter#getProfileProxy(context, BluetoothProfile.HEALTH) always return false * Remove all logic behind BluetoothHealth APIs and add deprecation error log * Health Device Profile (HDP) and MCAP protocol has been largely replaced by BLE. New applications should use Bluetooth Low Energy instead of legacy Bluetooth Health Device Profile Bug: 111562841 Test: make, unit test, use Bluetooth Change-Id: If99a9d79e9e1b89b75b9b74bd3b1c965247a1892 Merged-In: If99a9d79e9e1b89b75b9b74bd3b1c965247a1892 (cherry picked from commit 07ffaa447fdd967689901cca38eba386a8d97b23) --- .../bluetooth/BluetoothHealthAppConfiguration.java | 122 ++++++--------------- 1 file changed, 34 insertions(+), 88 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index 7c9db6f721..9788bbf74e 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -25,72 +25,14 @@ import android.os.Parcelable; * the {@link BluetoothHealth} class. This class represents an application configuration * that the Bluetooth Health third party application will register to communicate with the * remote Bluetooth health device. + * + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ +@Deprecated public final class BluetoothHealthAppConfiguration implements Parcelable { - private final String mName; - private final int mDataType; - private final int mRole; - private final int mChannelType; - - /** - * Constructor to register the SINK role - * - * @param name Friendly name associated with the application configuration - * @param dataType Data Type of the remote Bluetooth Health device - * @hide - */ - BluetoothHealthAppConfiguration(String name, int dataType) { - mName = name; - mDataType = dataType; - mRole = BluetoothHealth.SINK_ROLE; - mChannelType = BluetoothHealth.CHANNEL_TYPE_ANY; - } - - /** - * Constructor to register the application configuration. - * - * @param name Friendly name associated with the application configuration - * @param dataType Data Type of the remote Bluetooth Health device - * @param role {@link BluetoothHealth#SOURCE_ROLE} or {@link BluetoothHealth#SINK_ROLE} - * @hide - */ - BluetoothHealthAppConfiguration(String name, int dataType, int role, int - channelType) { - mName = name; - mDataType = dataType; - mRole = role; - mChannelType = channelType; - } - - @Override - public boolean equals(Object o) { - if (o instanceof BluetoothHealthAppConfiguration) { - BluetoothHealthAppConfiguration config = (BluetoothHealthAppConfiguration) o; - - if (mName == null) return false; - - return mName.equals(config.getName()) && mDataType == config.getDataType() - && mRole == config.getRole() && mChannelType == config.getChannelType(); - } - return false; - } - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + (mName != null ? mName.hashCode() : 0); - result = 31 * result + mDataType; - result = 31 * result + mRole; - result = 31 * result + mChannelType; - return result; - } - - @Override - public String toString() { - return "BluetoothHealthAppConfiguration [mName = " + mName + ",mDataType = " + mDataType - + ", mRole = " + mRole + ",mChannelType = " + mChannelType + "]"; - } - @Override public int describeContents() { return 0; @@ -100,50 +42,59 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { * Return the data type associated with this application configuration. * * @return dataType + * + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ + @Deprecated public int getDataType() { - return mDataType; + return 0; } /** * Return the name of the application configuration. * * @return String name + * + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ + @Deprecated public String getName() { - return mName; + return null; } /** * Return the role associated with this application configuration. * * @return One of {@link BluetoothHealth#SOURCE_ROLE} or {@link BluetoothHealth#SINK_ROLE} + * + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ + @Deprecated public int getRole() { - return mRole; + return 0; } /** - * Return the channel type associated with this application configuration. - * - * @return One of {@link BluetoothHealth#CHANNEL_TYPE_RELIABLE} or {@link - * BluetoothHealth#CHANNEL_TYPE_STREAMING} or {@link BluetoothHealth#CHANNEL_TYPE_ANY}. - * @hide + * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New + * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, + * {@link BluetoothAdapter#listenUsingL2capChannel()(int)}, or + * {@link BluetoothDevice#createL2capChannel(int)} */ - public int getChannelType() { - return mChannelType; - } - + @Deprecated public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override public BluetoothHealthAppConfiguration createFromParcel(Parcel in) { - String name = in.readString(); - int type = in.readInt(); - int role = in.readInt(); - int channelType = in.readInt(); - return new BluetoothHealthAppConfiguration(name, type, role, - channelType); + return new BluetoothHealthAppConfiguration(); } @Override @@ -153,10 +104,5 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { }; @Override - public void writeToParcel(Parcel out, int flags) { - out.writeString(mName); - out.writeInt(mDataType); - out.writeInt(mRole); - out.writeInt(mChannelType); - } + public void writeToParcel(Parcel out, int flags) {} } -- cgit v1.2.3 From 13613a3f176ab3e10367685367443dddeee77db5 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 28 Feb 2019 12:06:45 -0700 Subject: All Parcelable CREATOR fields are @NonNull. If they were null, then the Parcelable would fail to work. Bug: 126726802 Test: manual Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014 Exempt-From-Owner-Approval: Trivial API annotations --- framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index 9788bbf74e..88e06e58f9 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -90,7 +90,7 @@ public final class BluetoothHealthAppConfiguration implements Parcelable { * {@link BluetoothDevice#createL2capChannel(int)} */ @Deprecated - public static final Parcelable.Creator CREATOR = + public static final @android.annotation.NonNull Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override public BluetoothHealthAppConfiguration createFromParcel(Parcel in) { -- cgit v1.2.3 From f2d49bda6a69f74226c6e364a3eed5707f2cfd20 Mon Sep 17 00:00:00 2001 From: Jack He Date: Thu, 28 Mar 2019 17:42:26 -0700 Subject: BluetoothHealth: hide auto-created default constructors Fixes: 123926561 Test: make Change-Id: I388472c82eaca245285b5ecf2959c415508d7e69 --- .../java/android/bluetooth/BluetoothHealthAppConfiguration.java | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java') diff --git a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java index 9788bbf74e..e960ed64dc 100644 --- a/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java +++ b/framework/java/android/bluetooth/BluetoothHealthAppConfiguration.java @@ -33,6 +33,13 @@ import android.os.Parcelable; */ @Deprecated public final class BluetoothHealthAppConfiguration implements Parcelable { + + /** + * Hide auto-created default constructor + * @hide + */ + BluetoothHealthAppConfiguration() {} + @Override public int describeContents() { return 0; -- cgit v1.2.3