Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9827ffe authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Deprecate BluetoothHealth APIs"

parents 84995ea1 8bb9c7d4
Loading
Loading
Loading
Loading
+10 −17
Original line number Diff line number Diff line
@@ -2066,8 +2066,7 @@ public final class BluetoothAdapter {
     * Get the current connection state of a profile.
     * This function can be used to check whether the local Bluetooth adapter
     * is connected to any remote device for a specific profile.
     * Profile can be one of {@link BluetoothProfile#HEALTH}, {@link BluetoothProfile#HEADSET},
     * {@link BluetoothProfile#A2DP}.
     * Profile can be one of {@link BluetoothProfile#HEADSET}, {@link BluetoothProfile#A2DP}.
     *
     * <p> Return value can be one of
     * {@link BluetoothProfile#STATE_DISCONNECTED},
@@ -2441,16 +2440,15 @@ public final class BluetoothAdapter {
    /**
     * Get the profile proxy object associated with the profile.
     *
     * <p>Profile can be one of {@link BluetoothProfile#HEALTH}, {@link BluetoothProfile#HEADSET},
     * {@link BluetoothProfile#A2DP}, {@link BluetoothProfile#GATT}, or
     * {@link BluetoothProfile#GATT_SERVER}. Clients must implement
     * {@link BluetoothProfile.ServiceListener} to get notified of
     * the connection status and to get the proxy object.
     * <p>Profile can be one of {@link BluetoothProfile#HEADSET}, {@link BluetoothProfile#A2DP},
     * {@link BluetoothProfile#GATT}, or {@link BluetoothProfile#GATT_SERVER}. Clients must
     * implement {@link BluetoothProfile.ServiceListener} to get notified of the connection status
     * and to get the proxy object.
     *
     * @param context Context of the application
     * @param listener The service Listener for connection callbacks.
     * @param profile The Bluetooth profile; either {@link BluetoothProfile#HEALTH}, {@link
     * BluetoothProfile#HEADSET}, {@link BluetoothProfile#A2DP}. {@link BluetoothProfile#GATT} or
     * @param profile The Bluetooth profile; either {@link BluetoothProfile#HEADSET},
     * {@link BluetoothProfile#A2DP}. {@link BluetoothProfile#GATT} or
     * {@link BluetoothProfile#GATT_SERVER}.
     * @return true on success, false on error
     */
@@ -2479,8 +2477,8 @@ public final class BluetoothAdapter {
            BluetoothPan pan = new BluetoothPan(context, listener);
            return true;
        } else if (profile == BluetoothProfile.HEALTH) {
            BluetoothHealth health = new BluetoothHealth(context, listener);
            return true;
            Log.e(TAG, "getProfileProxy(): BluetoothHealth is deprecated");
            return false;
        } else if (profile == BluetoothProfile.MAP) {
            BluetoothMap map = new BluetoothMap(context, listener);
            return true;
@@ -2512,8 +2510,7 @@ public final class BluetoothAdapter {
     *
     * <p> Clients should call this when they are no longer using
     * the proxy obtained from {@link #getProfileProxy}.
     * Profile can be one of  {@link BluetoothProfile#HEALTH}, {@link BluetoothProfile#HEADSET} or
     * {@link BluetoothProfile#A2DP}
     * Profile can be one of  {@link BluetoothProfile#HEADSET} or {@link BluetoothProfile#A2DP}
     *
     * @param profile
     * @param proxy Profile proxy object
@@ -2548,10 +2545,6 @@ public final class BluetoothAdapter {
                BluetoothPan pan = (BluetoothPan) proxy;
                pan.close();
                break;
            case BluetoothProfile.HEALTH:
                BluetoothHealth health = (BluetoothHealth) proxy;
                health.close();
                break;
            case BluetoothProfile.GATT:
                BluetoothGatt gatt = (BluetoothGatt) proxy;
                gatt.close();
+136 −347

File changed.

Preview size limit exceeded, changes collapsed.

+34 −88
Original line number Diff line number Diff line
@@ -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.
 */
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
 * @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)}
 */
    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 + "]";
    }

@Deprecated
public final class BluetoothHealthAppConfiguration implements Parcelable {
    @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<BluetoothHealthAppConfiguration> CREATOR =
            new Parcelable.Creator<BluetoothHealthAppConfiguration>() {
                @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) {}
}
+18 −0
Original line number Diff line number Diff line
@@ -23,7 +23,13 @@ import android.util.Log;

/**
 * This abstract class is used to implement {@link BluetoothHealth} callbacks.
 *
 * @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 abstract class BluetoothHealthCallback {
    private static final String TAG = "BluetoothHealthCallback";

@@ -38,8 +44,14 @@ public abstract class BluetoothHealthCallback {
     * BluetoothHealth#APP_CONFIG_REGISTRATION_FAILURE} or
     * {@link BluetoothHealth#APP_CONFIG_UNREGISTRATION_SUCCESS}
     * or {@link BluetoothHealth#APP_CONFIG_UNREGISTRATION_FAILURE}
     *
     * @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)}
     */
    @BinderThread
    @Deprecated
    public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
            int status) {
        Log.d(TAG, "onHealthAppConfigurationStatusChange: " + config + "Status: " + status);
@@ -58,8 +70,14 @@ public abstract class BluetoothHealthCallback {
     * @param fd The Parcel File Descriptor when the channel state is connected.
     * @param channelId The id associated with the channel. This id will be used in future calls
     * like when disconnecting the channel.
     *
     * @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)}
     */
    @BinderThread
    @Deprecated
    public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
            BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
            int channelId) {
+9 −4
Original line number Diff line number Diff line
@@ -72,7 +72,13 @@ public interface BluetoothProfile {

    /**
     * Health Profile
     *
     * @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()}, or
     * {@link BluetoothDevice#createL2capChannel(int)}
     */
    @Deprecated
    int HEALTH = 3;

    /**
@@ -269,9 +275,8 @@ public interface BluetoothProfile {
         * Called to notify the client when the proxy object has been
         * connected to the service.
         *
         * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or {@link #A2DP}
         * @param proxy - One of {@link BluetoothHealth}, {@link BluetoothHeadset} or {@link
         * BluetoothA2dp}
         * @param profile - One of {@link #HEADSET} or {@link #A2DP}
         * @param proxy - One of {@link BluetoothHeadset} or {@link BluetoothA2dp}
         */
        public void onServiceConnected(int profile, BluetoothProfile proxy);

@@ -279,7 +284,7 @@ public interface BluetoothProfile {
         * Called to notify the client that this proxy object has been
         * disconnected from the service.
         *
         * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or {@link #A2DP}
         * @param profile - One of {@link #HEADSET} or {@link #A2DP}
         */
        public void onServiceDisconnected(int profile);
    }