summaryrefslogtreecommitdiff
path: root/framework/java
diff options
context:
space:
mode:
author William Escande <wescande@google.com> 2025-03-05 15:52:49 -0800
committer William Escande <wescande@google.com> 2025-03-05 17:52:42 -0800
commit74f5202dc0628470d7260e988c58a00b672f7bbb (patch)
tree9f3af7835591c6695fdb7039a4f504bc8d2bb0fd /framework/java
parent8ac4b03c38058ddd88f5b7b75d8312991fdb9672 (diff)
Gatt: do not kill Bluetooth on app callback
Also minor fix to do early return and uniformize the code Bug: 311772251 Flag: Exempt no-op Test: m . Change-Id: I08d2c8c2464412f54610487e8064fa8a8eb7396f
Diffstat (limited to 'framework/java')
-rw-r--r--framework/java/android/bluetooth/BluetoothUtils.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothUtils.java b/framework/java/android/bluetooth/BluetoothUtils.java
index 2665af1bac..c7aff6aa44 100644
--- a/framework/java/android/bluetooth/BluetoothUtils.java
+++ b/framework/java/android/bluetooth/BluetoothUtils.java
@@ -346,6 +346,22 @@ public final class BluetoothUtils {
}
}
+ /** A {@link Runnable} that automatically logs {@link RemoteException} @hide */
+ @FunctionalInterface
+ public interface RemoteExceptionIgnoringRunnable {
+ /** Called by {@code accept}. */
+ void runOrThrow() throws RemoteException;
+
+ @RequiresNoPermission
+ default void run() {
+ try {
+ runOrThrow();
+ } catch (RemoteException ex) {
+ logRemoteException(TAG, ex);
+ }
+ }
+ }
+
/** A {@link Consumer} that automatically logs {@link RemoteException} @hide */
@FunctionalInterface
public interface RemoteExceptionIgnoringConsumer<T> {