Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 581d90a6 authored by Patty's avatar Patty
Browse files

Rethrow the exception when there is a RemoteException or service is null

Tag: #refactor
Bug: 219875113
Test: atest BluetoothInstrumentationTests
Change-Id: Ia29cbd6252c0b652c324b23e1fd9c0332cf45e06
parent 33d07fae
Loading
Loading
Loading
Loading
+7 −1
Original line number Original line Diff line number Diff line
@@ -978,8 +978,11 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
                        new SynchronousResultReceiver();
                        new SynchronousResultReceiver();
                service.getCodecStatus(device, mAttributionSource, recv);
                service.getCodecStatus(device, mAttributionSource, recv);
                return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue);
                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()));
                Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
                e.rethrowFromSystemServer();
            }
            }
        }
        }
        return defaultValue;
        return defaultValue;
@@ -990,6 +993,7 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
     *
     *
     * @param device the remote Bluetooth device.
     * @param device the remote Bluetooth device.
     * @param codecConfig the codec configuration preference
     * @param codecConfig the codec configuration preference
     * @throws IllegalStateException if LE Audio Service is null
     * @hide
     * @hide
     */
     */
    @SystemApi
    @SystemApi
@@ -1012,11 +1016,13 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
        if (service == null) {
        if (service == null) {
            Log.w(TAG, "Proxy not attached to service");
            Log.w(TAG, "Proxy not attached to service");
            if (DBG) log(Log.getStackTraceString(new Throwable()));
            if (DBG) log(Log.getStackTraceString(new Throwable()));
            throw new IllegalStateException("Service is unavailable");
        } else if (mAdapter.isEnabled() && isValidDevice(device)) {
        } else if (mAdapter.isEnabled() && isValidDevice(device)) {
            try {
            try {
                service.setCodecConfigPreference(device, codecConfig, mAttributionSource);
                service.setCodecConfigPreference(device, codecConfig, mAttributionSource);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
                Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
                e.rethrowFromSystemServer();
            }
            }
        }
        }
    }
    }