From 74f5202dc0628470d7260e988c58a00b672f7bbb Mon Sep 17 00:00:00 2001 From: William Escande Date: Wed, 5 Mar 2025 15:52:49 -0800 Subject: 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 --- framework/java/android/bluetooth/BluetoothUtils.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'framework/java') 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 { -- cgit v1.2.3-59-g8ed1b