From 120139341b5df38e016a817de83a946dac229d3c Mon Sep 17 00:00:00 2001
From: William Escande <wescande@google.com>
Date: Wed, 6 Sep 2023 22:16:28 -0700
Subject: [PATCH] BluetoothDevice: App exception aren't from SystemServer

Calling into (IBluetooth) will call the AdapterService 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: I1b5df5c4f7d59e8dc01a20ac805ff04e840c6b19
---
 framework/java/android/bluetooth/BluetoothDevice.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index 4bcd959c6e8..514d510047c 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/java/android/bluetooth/BluetoothDevice.java
@@ -1765,7 +1765,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
                 Log.e(TAG, "", e);
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
@@ -2202,7 +2202,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
                 Log.e(TAG, "", e);
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
@@ -2249,7 +2249,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
                 Log.e(TAG, "", e);
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
@@ -3497,7 +3497,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
                 Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
             } catch (RemoteException e) {
                 Log.e(TAG, "", e);
-                throw e.rethrowFromSystemServer();
+                throw e.rethrowAsRuntimeException();
             }
         }
         return defaultValue;
-- 
GitLab