Revert "Require user pass in a non-null BluetoothDevice to all B..."
Revert "Pass in active device to all BluetoothA2dp APIs in packa..." Revert "Pass in active device to all BluetoothA2dp APIs in packa..." Revert submission 10253996-bt-a2dp-no-null Reason for revert: b/149361880 Reverted Changes: If43934374: Pass in active device to all BluetoothA2dp APIs in... I22dd1ca36: Make sure calls to BluetoothA2dp APIs pass non-nul... If6475af6f: Require user pass in a non-null BluetoothDevice to... I9d0e2c89c: Pass in active device to all BluetoothA2dp APIs in... I1faa6174d: Need to now pass in active device instead of null ... I69a941a7e: Pass in active device to all BluetoothA2dp APIs in... Change-Id: I297bda68da5023fd832201c485554d6bff05fa78
This commit is contained in:
@@ -643,9 +643,8 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
@SystemApi
|
||||
@Nullable
|
||||
@RequiresPermission(Manifest.permission.BLUETOOTH)
|
||||
public BluetoothCodecStatus getCodecStatus(@NonNull BluetoothDevice device) {
|
||||
public BluetoothCodecStatus getCodecStatus(@Nullable BluetoothDevice device) {
|
||||
if (DBG) Log.d(TAG, "getCodecStatus(" + device + ")");
|
||||
verifyDeviceNotNull(device, "getCodecStatus");
|
||||
try {
|
||||
final IBluetoothA2dp service = getService();
|
||||
if (service != null && isEnabled()) {
|
||||
@@ -671,14 +670,9 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
|
||||
public void setCodecConfigPreference(@NonNull BluetoothDevice device,
|
||||
@NonNull BluetoothCodecConfig codecConfig) {
|
||||
public void setCodecConfigPreference(@Nullable BluetoothDevice device,
|
||||
@Nullable BluetoothCodecConfig codecConfig) {
|
||||
if (DBG) Log.d(TAG, "setCodecConfigPreference(" + device + ")");
|
||||
verifyDeviceNotNull(device, "setCodecConfigPreference");
|
||||
if (codecConfig == null) {
|
||||
Log.e(TAG, "setCodecConfigPreference: Codec config can't be null");
|
||||
throw new IllegalArgumentException("codecConfig cannot be null");
|
||||
}
|
||||
try {
|
||||
final IBluetoothA2dp service = getService();
|
||||
if (service != null && isEnabled()) {
|
||||
@@ -701,9 +695,8 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
|
||||
public void enableOptionalCodecs(@NonNull BluetoothDevice device) {
|
||||
public void enableOptionalCodecs(@Nullable BluetoothDevice device) {
|
||||
if (DBG) Log.d(TAG, "enableOptionalCodecs(" + device + ")");
|
||||
verifyDeviceNotNull(device, "enableOptionalCodecs");
|
||||
enableDisableOptionalCodecs(device, true);
|
||||
}
|
||||
|
||||
@@ -716,9 +709,8 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
|
||||
public void disableOptionalCodecs(@NonNull BluetoothDevice device) {
|
||||
public void disableOptionalCodecs(@Nullable BluetoothDevice device) {
|
||||
if (DBG) Log.d(TAG, "disableOptionalCodecs(" + device + ")");
|
||||
verifyDeviceNotNull(device, "disableOptionalCodecs");
|
||||
enableDisableOptionalCodecs(device, false);
|
||||
}
|
||||
|
||||
@@ -758,8 +750,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
@SystemApi
|
||||
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
|
||||
@OptionalCodecsSupportStatus
|
||||
public int isOptionalCodecsSupported(@NonNull BluetoothDevice device) {
|
||||
verifyDeviceNotNull(device, "isOptionalCodecsSupported");
|
||||
public int supportsOptionalCodecs(@Nullable BluetoothDevice device) {
|
||||
try {
|
||||
final IBluetoothA2dp service = getService();
|
||||
if (service != null && isEnabled() && isValidDevice(device)) {
|
||||
@@ -784,8 +775,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
@SystemApi
|
||||
@RequiresPermission(Manifest.permission.BLUETOOTH_ADMIN)
|
||||
@OptionalCodecsPreferenceStatus
|
||||
public int isOptionalCodecsEnabled(@NonNull BluetoothDevice device) {
|
||||
verifyDeviceNotNull(device, "isOptionalCodecsEnabled");
|
||||
public int getOptionalCodecsEnabled(@Nullable BluetoothDevice device) {
|
||||
try {
|
||||
final IBluetoothA2dp service = getService();
|
||||
if (service != null && isEnabled() && isValidDevice(device)) {
|
||||
@@ -810,9 +800,8 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
|
||||
public void setOptionalCodecsEnabled(@NonNull BluetoothDevice device,
|
||||
public void setOptionalCodecsEnabled(@Nullable BluetoothDevice device,
|
||||
@OptionalCodecsPreferenceStatus int value) {
|
||||
verifyDeviceNotNull(device, "setOptionalCodecsEnabled");
|
||||
try {
|
||||
if (value != BluetoothA2dp.OPTIONAL_CODECS_PREF_UNKNOWN
|
||||
&& value != BluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED
|
||||
@@ -865,13 +854,6 @@ public final class BluetoothA2dp implements BluetoothProfile {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void verifyDeviceNotNull(BluetoothDevice device, String methodName) {
|
||||
if (device == null) {
|
||||
Log.e(TAG, methodName + ": device param is null");
|
||||
throw new IllegalArgumentException("Device cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidDevice(BluetoothDevice device) {
|
||||
if (device == null) return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user