diff options
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothDevice.java | 70 |
1 files changed, 43 insertions, 27 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java index 5646efb50b..58895ef1f7 100644 --- a/framework/java/android/bluetooth/BluetoothDevice.java +++ b/framework/java/android/bluetooth/BluetoothDevice.java @@ -3248,14 +3248,14 @@ public final class BluetoothDevice implements Parcelable, Attributable { /** @hide */ @Retention(RetentionPolicy.SOURCE) @IntDef( - prefix = { "REMOTE_STATUS_" }, + prefix = { "FEATURE_" }, value = { /** Remote support status of audio policy feature is unknown/unconfigured **/ - BluetoothAudioPolicy.FEATURE_UNCONFIGURED_BY_REMOTE, + BluetoothStatusCodes.FEATURE_NOT_CONFIGURED, /** Remote support status of audio policy feature is supported **/ - BluetoothAudioPolicy.FEATURE_SUPPORTED_BY_REMOTE, + BluetoothStatusCodes.FEATURE_SUPPORTED, /** Remote support status of audio policy feature is not supported **/ - BluetoothAudioPolicy.FEATURE_NOT_SUPPORTED_BY_REMOTE, + BluetoothStatusCodes.FEATURE_NOT_SUPPORTED, } ) @@ -3269,24 +3269,29 @@ public final class BluetoothDevice implements Parcelable, Attributable { BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ALLOWED, BluetoothStatusCodes.ERROR_DEVICE_NOT_BONDED, BluetoothStatusCodes.ERROR_MISSING_BLUETOOTH_CONNECT_PERMISSION, - BluetoothStatusCodes.FEATURE_NOT_SUPPORTED, BluetoothStatusCodes.ERROR_PROFILE_NOT_CONNECTED, }) public @interface AudioPolicyReturnValues{} /** - * Returns whether the audio policy feature is supported by the remote. - * This requires a vendor specific command, so the API returns - * {@link BluetoothAudioPolicy#FEATURE_UNCONFIGURED_BY_REMOTE} to indicate the remote + * Returns whether the audio policy feature is supported by + * both the local and the remote device. + * This is configured during initiating the connection between the devices through + * one of the transport protocols (e.g. HFP Vendor specific protocol). So if the API + * is invoked before this initial configuration is completed, it returns + * {@link BluetoothStatusCodes#FEATURE_NOT_CONFIGURED} to indicate the remote * device has not yet relayed this information. After the internal configuration, * the support status will be set to either - * {@link BluetoothAudioPolicy#FEATURE_NOT_SUPPORTED_BY_REMOTE} or - * {@link BluetoothAudioPolicy#FEATURE_SUPPORTED_BY_REMOTE}. + * {@link BluetoothStatusCodes#FEATURE_NOT_SUPPORTED} or + * {@link BluetoothStatusCodes#FEATURE_SUPPORTED}. * The rest of the APIs related to this feature in both {@link BluetoothDevice} - * and {@link BluetoothAudioPolicy} should be invoked only after getting a - * {@link BluetoothAudioPolicy#FEATURE_SUPPORTED_BY_REMOTE} response from this API. + * and {@link BluetoothSinkAudioPolicy} should be invoked only after getting a + * {@link BluetoothStatusCodes#FEATURE_SUPPORTED} response from this API. + * <p>Note that this API is intended to be used by a client device to send these requests + * to the server represented by this BluetoothDevice object. * - * @return if call audio policy feature is supported or not + * @return if call audio policy feature is supported by both local and remote + * device or not * * @hide */ @@ -3295,17 +3300,17 @@ public final class BluetoothDevice implements Parcelable, Attributable { android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED, }) - public @AudioPolicyRemoteSupport int getAudioPolicyRemoteSupported() { - if (DBG) log("getAudioPolicyRemoteSupported()"); + public @AudioPolicyRemoteSupport int isRequestAudioPolicyAsSinkSupported() { + if (DBG) log("isRequestAudioPolicyAsSinkSupported()"); final IBluetooth service = getService(); - final int defaultValue = BluetoothAudioPolicy.FEATURE_UNCONFIGURED_BY_REMOTE; + final int defaultValue = BluetoothStatusCodes.FEATURE_NOT_CONFIGURED; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot retrieve audio policy support status."); if (DBG) log(Log.getStackTraceString(new Throwable())); } else { try { final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get(); - service.getAudioPolicyRemoteSupported(this, mAttributionSource, recv); + service.isRequestAudioPolicyAsSinkSupported(this, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); @@ -3319,9 +3324,15 @@ public final class BluetoothDevice implements Parcelable, Attributable { /** * Sets call audio preferences and sends them to the remote device. + * <p>Note that the caller should check if the feature is supported by + * invoking {@link BluetoothDevice#isRequestAudioPolicyAsSinkSupported} first. + * <p>This API will throw an exception if the feature is not supported but still + * invoked. + * <p>Note that this API is intended to be used by a client device to send these requests + * to the server represented by this BluetoothDevice object. * * @param policies call audio policy preferences - * @return whether audio policy was set successfully or not + * @return whether audio policy was requested successfully or not * * @hide */ @@ -3330,8 +3341,9 @@ public final class BluetoothDevice implements Parcelable, Attributable { android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED, }) - public @AudioPolicyReturnValues int setAudioPolicy(@NonNull BluetoothAudioPolicy policies) { - if (DBG) log("setAudioPolicy"); + public @AudioPolicyReturnValues int requestAudioPolicyAsSink( + @NonNull BluetoothSinkAudioPolicy policies) { + if (DBG) log("requestAudioPolicyAsSink"); final IBluetooth service = getService(); final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; if (service == null || !isBluetoothEnabled()) { @@ -3340,7 +3352,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { } else { try { final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get(); - service.setAudioPolicy(this, policies, mAttributionSource, recv); + service.requestAudioPolicyAsSink(this, policies, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue); } catch (RemoteException | TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); @@ -3352,14 +3364,18 @@ public final class BluetoothDevice implements Parcelable, Attributable { /** * Gets the call audio preferences for the remote device. * <p>Note that the caller should check if the feature is supported by - * invoking {@link BluetoothDevice#getAudioPolicyRemoteSupported} first. + * invoking {@link BluetoothDevice#isRequestAudioPolicyAsSinkSupported} first. + * <p>This API will throw an exception if the feature is not supported but still + * invoked. * <p>This API will return null if * 1. The bleutooth service is not started yet, * 2. It is invoked for a device which is not bonded, or * 3. The used transport, for example, HFP Client profile is not enabled or * connected yet. + * <p>Note that this API is intended to be used by a client device to send these requests + * to the server represented by this BluetoothDevice object. * - * @return call audio policy as {@link BluetoothAudioPolicy} object + * @return call audio policy as {@link BluetoothSinkAudioPolicy} object * * @hide */ @@ -3368,17 +3384,17 @@ public final class BluetoothDevice implements Parcelable, Attributable { android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED, }) - public @Nullable BluetoothAudioPolicy getAudioPolicy() { - if (DBG) log("getAudioPolicy"); + public @Nullable BluetoothSinkAudioPolicy getRequestedAudioPolicyAsSink() { + if (DBG) log("getRequestedAudioPolicyAsSink"); final IBluetooth service = getService(); if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth is not enabled. Cannot get Audio Policy."); if (DBG) log(Log.getStackTraceString(new Throwable())); } else { try { - final SynchronousResultReceiver<BluetoothAudioPolicy> + final SynchronousResultReceiver<BluetoothSinkAudioPolicy> recv = SynchronousResultReceiver.get(); - service.getAudioPolicy(this, mAttributionSource, recv); + service.getRequestedAudioPolicyAsSink(this, mAttributionSource, recv); return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); } catch (RemoteException | TimeoutException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); |
