summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothLeAudio.java
diff options
context:
space:
mode:
authorPatty <plhuang@google.com>2022-03-08 10:46:21 +0800
committerPatty <plhuang@google.com>2022-03-08 13:28:27 +0800
commit581d90a6325f27cb113395a7491256454b8535df (patch)
tree91980893b80ec3b7543f2b88eecdd9ee87832c43 /framework/java/android/bluetooth/BluetoothLeAudio.java
parent33d07faedee7bf1a696459fe489432798f04bb82 (diff)
Rethrow the exception when there is a RemoteException or service is null
Tag: #refactor Bug: 219875113 Test: atest BluetoothInstrumentationTests Change-Id: Ia29cbd6252c0b652c324b23e1fd9c0332cf45e06
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothLeAudio.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothLeAudio.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeAudio.java b/framework/java/android/bluetooth/BluetoothLeAudio.java
index 23e9a039f4..a15746edb7 100644
--- a/framework/java/android/bluetooth/BluetoothLeAudio.java
+++ b/framework/java/android/bluetooth/BluetoothLeAudio.java
@@ -978,8 +978,11 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
new SynchronousResultReceiver();
service.getCodecStatus(device, mAttributionSource, recv);
return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue);
- } catch (RemoteException | TimeoutException e) {
+ } catch (TimeoutException e) {
+ Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ } catch (RemoteException e) {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ e.rethrowFromSystemServer();
}
}
return defaultValue;
@@ -990,6 +993,7 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
*
* @param device the remote Bluetooth device.
* @param codecConfig the codec configuration preference
+ * @throws IllegalStateException if LE Audio Service is null
* @hide
*/
@SystemApi
@@ -1012,11 +1016,13 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
if (service == null) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
+ throw new IllegalStateException("Service is unavailable");
} else if (mAdapter.isEnabled() && isValidDevice(device)) {
try {
service.setCodecConfigPreference(device, codecConfig, mAttributionSource);
} catch (RemoteException e) {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ e.rethrowFromSystemServer();
}
}
}