summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothHeadset.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothHeadset.java72
1 files changed, 36 insertions, 36 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java
index 9cbfe2971a..693b86608c 100644
--- a/framework/java/android/bluetooth/BluetoothHeadset.java
+++ b/framework/java/android/bluetooth/BluetoothHeadset.java
@@ -1001,7 +1001,6 @@ public final class BluetoothHeadset implements BluetoothProfile {
@Retention(RetentionPolicy.SOURCE)
@IntDef(value = {
BluetoothStatusCodes.SUCCESS,
- BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED,
BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND,
BluetoothStatusCodes.ERROR_TIMEOUT,
BluetoothStatusCodes.ERROR_UNKNOWN,
@@ -1013,7 +1012,6 @@ public final class BluetoothHeadset implements BluetoothProfile {
@IntDef(value = {
BluetoothStatusCodes.ALLOWED,
BluetoothStatusCodes.NOT_ALLOWED,
- BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED,
BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND,
BluetoothStatusCodes.ERROR_TIMEOUT,
BluetoothStatusCodes.ERROR_UNKNOWN,
@@ -1046,21 +1044,22 @@ public final class BluetoothHeadset implements BluetoothProfile {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND;
- } else if (!isEnabled()) {
- return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
- }
- try {
- final SynchronousResultReceiver recv = new SynchronousResultReceiver();
- service.setAudioRouteAllowed(allowed, mAttributionSource, recv);
- recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null);
- return BluetoothStatusCodes.SUCCESS;
- } catch (TimeoutException e) {
- Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
- return BluetoothStatusCodes.ERROR_TIMEOUT;
- } catch (RemoteException e) {
- Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
- e.rethrowFromSystemServer();
+ } else if (isEnabled()) {
+ try {
+ final SynchronousResultReceiver recv = new SynchronousResultReceiver();
+ service.setAudioRouteAllowed(allowed, mAttributionSource, recv);
+ recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null);
+ return BluetoothStatusCodes.SUCCESS;
+ } catch (TimeoutException e) {
+ Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ return BluetoothStatusCodes.ERROR_TIMEOUT;
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ e.rethrowFromSystemServer();
+ }
}
+
+ Log.e(TAG, "setAudioRouteAllowed: Bluetooth disabled, but profile service still bound");
return BluetoothStatusCodes.ERROR_UNKNOWN;
}
@@ -1085,21 +1084,22 @@ public final class BluetoothHeadset implements BluetoothProfile {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
return BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND;
- } else if (!isEnabled()) {
- return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
- }
- try {
- final SynchronousResultReceiver<Boolean> recv = new SynchronousResultReceiver();
- service.getAudioRouteAllowed(mAttributionSource, recv);
- return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(false)
- ? BluetoothStatusCodes.ALLOWED : BluetoothStatusCodes.NOT_ALLOWED;
- } catch (TimeoutException e) {
- Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
- return BluetoothStatusCodes.ERROR_TIMEOUT;
- } catch (RemoteException e) {
- Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
- e.rethrowFromSystemServer();
+ } else if (isEnabled()) {
+ try {
+ final SynchronousResultReceiver<Boolean> recv = new SynchronousResultReceiver();
+ service.getAudioRouteAllowed(mAttributionSource, recv);
+ return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(false)
+ ? BluetoothStatusCodes.ALLOWED : BluetoothStatusCodes.NOT_ALLOWED;
+ } catch (TimeoutException e) {
+ Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ return BluetoothStatusCodes.ERROR_TIMEOUT;
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ e.rethrowFromSystemServer();
+ }
}
+
+ Log.e(TAG, "getAudioRouteAllowed: Bluetooth disabled, but profile service still bound");
return BluetoothStatusCodes.ERROR_UNKNOWN;
}
@@ -1136,7 +1136,6 @@ public final class BluetoothHeadset implements BluetoothProfile {
BluetoothStatusCodes.ERROR_UNKNOWN,
BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND,
BluetoothStatusCodes.ERROR_TIMEOUT,
- BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED,
BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_CONNECTED,
BluetoothStatusCodes.ERROR_NO_ACTIVE_DEVICES,
BluetoothStatusCodes.ERROR_NOT_ACTIVE_DEVICE,
@@ -1186,9 +1185,10 @@ public final class BluetoothHeadset implements BluetoothProfile {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
return BluetoothStatusCodes.ERROR_TIMEOUT;
}
- } else {
- return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
}
+
+ Log.e(TAG, "connectAudio: Bluetooth disabled, but profile service still bound");
+ return defaultValue;
}
/** @hide */
@@ -1198,7 +1198,6 @@ public final class BluetoothHeadset implements BluetoothProfile {
BluetoothStatusCodes.ERROR_UNKNOWN,
BluetoothStatusCodes.ERROR_PROFILE_SERVICE_NOT_BOUND,
BluetoothStatusCodes.ERROR_TIMEOUT,
- BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED,
BluetoothStatusCodes.ERROR_PROFILE_NOT_CONNECTED,
BluetoothStatusCodes.ERROR_AUDIO_DEVICE_ALREADY_DISCONNECTED
})
@@ -1241,9 +1240,10 @@ public final class BluetoothHeadset implements BluetoothProfile {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
return BluetoothStatusCodes.ERROR_TIMEOUT;
}
- } else {
- return BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
}
+
+ Log.e(TAG, "disconnectAudio: Bluetooth disabled, but profile service still bound");
+ return defaultValue;
}
/**