Merge "Add Android APIs for Hearing Aids Profile"

This commit is contained in:
Treehugger Robot
2019-01-24 01:37:05 +00:00
committed by Gerrit Code Review
4 changed files with 44 additions and 59 deletions

View File

@@ -8385,6 +8385,13 @@ package android.bluetooth {
method @Deprecated @BinderThread public void onHealthChannelStateChange(android.bluetooth.BluetoothHealthAppConfiguration, android.bluetooth.BluetoothDevice, int, int, android.os.ParcelFileDescriptor, int); method @Deprecated @BinderThread public void onHealthChannelStateChange(android.bluetooth.BluetoothHealthAppConfiguration, android.bluetooth.BluetoothDevice, int, int, android.os.ParcelFileDescriptor, int);
} }
public final class BluetoothHearingAid implements android.bluetooth.BluetoothProfile {
method public java.util.List<android.bluetooth.BluetoothDevice> getConnectedDevices();
method public int getConnectionState(android.bluetooth.BluetoothDevice);
method public java.util.List<android.bluetooth.BluetoothDevice> getDevicesMatchingConnectionStates(int[]);
field public static final String ACTION_CONNECTION_STATE_CHANGED = "android.bluetooth.hearingaid.profile.action.CONNECTION_STATE_CHANGED";
}
public final class BluetoothHidDevice implements android.bluetooth.BluetoothProfile { public final class BluetoothHidDevice implements android.bluetooth.BluetoothProfile {
method public boolean connect(android.bluetooth.BluetoothDevice); method public boolean connect(android.bluetooth.BluetoothDevice);
method public boolean disconnect(android.bluetooth.BluetoothDevice); method public boolean disconnect(android.bluetooth.BluetoothDevice);
@@ -8480,6 +8487,7 @@ package android.bluetooth {
field public static final int GATT_SERVER = 8; // 0x8 field public static final int GATT_SERVER = 8; // 0x8
field public static final int HEADSET = 1; // 0x1 field public static final int HEADSET = 1; // 0x1
field @Deprecated public static final int HEALTH = 3; // 0x3 field @Deprecated public static final int HEALTH = 3; // 0x3
field public static final int HEARING_AID = 21; // 0x15
field public static final int HID_DEVICE = 19; // 0x13 field public static final int HID_DEVICE = 19; // 0x13
field public static final int SAP = 10; // 0xa field public static final int SAP = 10; // 0xa
field public static final int STATE_CONNECTED = 2; // 0x2 field public static final int STATE_CONNECTED = 2; // 0x2

View File

@@ -2487,15 +2487,16 @@ public final class BluetoothAdapter {
* Get the profile proxy object associated with the profile. * Get the profile proxy object associated with the profile.
* *
* <p>Profile can be one of {@link BluetoothProfile#HEADSET}, {@link BluetoothProfile#A2DP}, * <p>Profile can be one of {@link BluetoothProfile#HEADSET}, {@link BluetoothProfile#A2DP},
* {@link BluetoothProfile#GATT}, or {@link BluetoothProfile#GATT_SERVER}. Clients must * {@link BluetoothProfile#GATT}, {@link BluetoothProfile#HEARING_AID}, or {@link
* implement {@link BluetoothProfile.ServiceListener} to get notified of the connection status * BluetoothProfile#GATT_SERVER}. Clients must implement {@link
* and to get the proxy object. * BluetoothProfile.ServiceListener} to get notified of the connection status and to get the
* proxy object.
* *
* @param context Context of the application * @param context Context of the application
* @param listener The service Listener for connection callbacks. * @param listener The service Listener for connection callbacks.
* @param profile The Bluetooth profile; either {@link BluetoothProfile#HEADSET}, * @param profile The Bluetooth profile; either {@link BluetoothProfile#HEADSET},
* {@link BluetoothProfile#A2DP}. {@link BluetoothProfile#GATT} or * {@link BluetoothProfile#A2DP}, {@link BluetoothProfile#GATT}, {@link
* {@link BluetoothProfile#GATT_SERVER}. * BluetoothProfile#HEARING_AID} or {@link BluetoothProfile#GATT_SERVER}.
* @return true on success, false on error * @return true on success, false on error
*/ */
public boolean getProfileProxy(Context context, BluetoothProfile.ServiceListener listener, public boolean getProfileProxy(Context context, BluetoothProfile.ServiceListener listener,

View File

@@ -38,15 +38,14 @@ import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
/** /**
* This class provides the public APIs to control the Bluetooth Hearing Aid * This class provides the public APIs to control the Hearing Aid profile.
* profile.
* *
* <p>BluetoothHearingAid is a proxy object for controlling the Bluetooth Hearing Aid * <p>BluetoothHearingAid is a proxy object for controlling the Bluetooth Hearing Aid
* Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get * Service via IPC. Use {@link BluetoothAdapter#getProfileProxy} to get
* the BluetoothHearingAid proxy object. * the BluetoothHearingAid proxy object.
* *
* <p> Each method is protected with its appropriate permission. * <p> Android only supports one set of connected Bluetooth Hearing Aid device at a time. Each
* @hide * method is protected with its appropriate permission.
*/ */
public final class BluetoothHearingAid implements BluetoothProfile { public final class BluetoothHearingAid implements BluetoothProfile {
private static final String TAG = "BluetoothHearingAid"; private static final String TAG = "BluetoothHearingAid";
@@ -55,7 +54,8 @@ public final class BluetoothHearingAid implements BluetoothProfile {
/** /**
* Intent used to broadcast the change in connection state of the Hearing Aid * Intent used to broadcast the change in connection state of the Hearing Aid
* profile. * profile. Please note that in the binaural case, there will be two different LE devices for
* the left and right side and each device will have their own connection state changes.S
* *
* <p>This intent will have 3 extras: * <p>This intent will have 3 extras:
* <ul> * <ul>
@@ -75,27 +75,6 @@ public final class BluetoothHearingAid implements BluetoothProfile {
public static final String ACTION_CONNECTION_STATE_CHANGED = public static final String ACTION_CONNECTION_STATE_CHANGED =
"android.bluetooth.hearingaid.profile.action.CONNECTION_STATE_CHANGED"; "android.bluetooth.hearingaid.profile.action.CONNECTION_STATE_CHANGED";
/**
* Intent used to broadcast the change in the Playing state of the Hearing Aid
* profile.
*
* <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>
* </ul>
*
* <p>{@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} can be any of
* {@link #STATE_PLAYING}, {@link #STATE_NOT_PLAYING},
*
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
* receive.
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_PLAYING_STATE_CHANGED =
"android.bluetooth.hearingaid.profile.action.PLAYING_STATE_CHANGED";
/** /**
* Intent used to broadcast the selection of a connected device as active. * Intent used to broadcast the selection of a connected device as active.
* *
@@ -107,6 +86,8 @@ public final class BluetoothHearingAid implements BluetoothProfile {
* *
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission to
* receive. * receive.
*
* @hide
*/ */
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
@UnsupportedAppUsage @UnsupportedAppUsage
@@ -114,32 +95,38 @@ public final class BluetoothHearingAid implements BluetoothProfile {
"android.bluetooth.hearingaid.profile.action.ACTIVE_DEVICE_CHANGED"; "android.bluetooth.hearingaid.profile.action.ACTIVE_DEVICE_CHANGED";
/** /**
* Hearing Aid device is streaming music. This state can be one of * This device represents Left Hearing Aid.
* {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of *
* {@link #ACTION_PLAYING_STATE_CHANGED} intent. * @hide
*/ */
public static final int STATE_PLAYING = 10;
/**
* Hearing Aid device is NOT streaming music. This state can be one of
* {@link #EXTRA_STATE} or {@link #EXTRA_PREVIOUS_STATE} of
* {@link #ACTION_PLAYING_STATE_CHANGED} intent.
*/
public static final int STATE_NOT_PLAYING = 11;
/** This device represents Left Hearing Aid. */
public static final int SIDE_LEFT = IBluetoothHearingAid.SIDE_LEFT; public static final int SIDE_LEFT = IBluetoothHearingAid.SIDE_LEFT;
/** This device represents Right Hearing Aid. */ /**
* This device represents Right Hearing Aid.
*
* @hide
*/
public static final int SIDE_RIGHT = IBluetoothHearingAid.SIDE_RIGHT; public static final int SIDE_RIGHT = IBluetoothHearingAid.SIDE_RIGHT;
/** This device is Monaural. */ /**
* This device is Monaural.
*
* @hide
*/
public static final int MODE_MONAURAL = IBluetoothHearingAid.MODE_MONAURAL; public static final int MODE_MONAURAL = IBluetoothHearingAid.MODE_MONAURAL;
/** This device is Binaural (should receive only left or right audio). */ /**
* This device is Binaural (should receive only left or right audio).
*
* @hide
*/
public static final int MODE_BINAURAL = IBluetoothHearingAid.MODE_BINAURAL; public static final int MODE_BINAURAL = IBluetoothHearingAid.MODE_BINAURAL;
/** Can't read ClientID for this device */ /**
* Indicates the HiSyncID could not be read and is unavailable.
*
* @hide
*/
public static final long HI_SYNC_ID_INVALID = IBluetoothHearingAid.HI_SYNC_ID_INVALID; public static final long HI_SYNC_ID_INVALID = IBluetoothHearingAid.HI_SYNC_ID_INVALID;
private Context mContext; private Context mContext;
@@ -235,12 +222,6 @@ public final class BluetoothHearingAid implements BluetoothProfile {
} }
} }
@Override
public void finalize() {
// The empty finalize needs to be kept or the
// cts signature tests would fail.
}
/** /**
* Initiate connection to a profile of the remote bluetooth device. * Initiate connection to a profile of the remote bluetooth device.
* *
@@ -537,10 +518,6 @@ public final class BluetoothHearingAid implements BluetoothProfile {
return "connected"; return "connected";
case STATE_DISCONNECTING: case STATE_DISCONNECTING:
return "disconnecting"; return "disconnecting";
case STATE_PLAYING:
return "playing";
case STATE_NOT_PLAYING:
return "not playing";
default: default:
return "<unknown state " + state + ">"; return "<unknown state " + state + ">";
} }

View File

@@ -185,7 +185,6 @@ public interface BluetoothProfile {
/** /**
* Hearing Aid Device * Hearing Aid Device
* *
* @hide
*/ */
int HEARING_AID = 21; int HEARING_AID = 21;