From 55e3b74babe7cfc1a6aac573f6935972594cc3d7 Mon Sep 17 00:00:00 2001
From: William Escande <wescande@google.com>
Date: Wed, 6 Sep 2023 22:03:02 -0700
Subject: [PATCH] LeBroadcast: App exception aren't from SystemServer

Calling into IBluetoothLeAudio will call the LeAudioService from
Bluetooth app that does not live in the systemServer.
Therefore, exception should be rethrown as runtimeException

Bug: 298264617
Test: atest CtsBluetoothTestCases | Cts does not handled failure in the
      binder nor any of the Test framework we currently have
Change-Id: I6adb47ceb1d075f001ff972dded6e44716368363
---
 .../bluetooth/BluetoothLeBroadcast.java       | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/framework/java/android/bluetooth/BluetoothLeBroadcast.java b/framework/java/android/bluetooth/BluetoothLeBroadcast.java
index d724335d3b6..6fae30750bd 100644
--- a/framework/java/android/bluetooth/BluetoothLeBroadcast.java
+++ b/framework/java/android/bluetooth/BluetoothLeBroadcast.java
@@ -449,7 +449,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
                 } catch (TimeoutException e) {
                     Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
                 } catch (RemoteException e) {
-                    throw e.rethrowFromSystemServer();
+                    throw e.rethrowAsRuntimeException();
                 }
             }
 
@@ -502,7 +502,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException | IllegalStateException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
     }
@@ -574,7 +574,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             } catch (SecurityException e) {
                 throw e;
             }
@@ -614,7 +614,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             } catch (SecurityException e) {
                 throw e;
             }
@@ -663,7 +663,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             } catch (SecurityException e) {
                 throw e;
             }
@@ -709,7 +709,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             } catch (SecurityException e) {
                 throw e;
             }
@@ -751,7 +751,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             } catch (SecurityException e) {
                 throw e;
             }
@@ -786,7 +786,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
@@ -820,7 +820,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
@@ -848,7 +848,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
@@ -877,7 +877,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
@@ -909,7 +909,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
             } catch (TimeoutException e) {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
-- 
GitLab