Skip to content
Snippets Groups Projects
Commit 7ccc74f3 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "VolumeControl: Early return in unregisterCallback" into main

parents bb5f78f8 1d5d4bae
No related branches found
No related tags found
No related merge requests found
......@@ -604,21 +604,23 @@ public final class BluetoothVolumeControl implements BluetoothProfile, AutoClose
}
}
if (!mCallbackExecutorMap.isEmpty()) {
return;
}
// If the callback map is empty, we unregister the service-to-app callback
if (mCallbackExecutorMap.isEmpty()) {
try {
final IBluetoothVolumeControl service = getService();
if (service != null) {
final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get();
service.unregisterCallback(mCallback, mAttributionSource, recv);
recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null);
}
} catch (RemoteException e) {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
throw e.rethrowAsRuntimeException();
} catch (IllegalStateException | TimeoutException e) {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
try {
final IBluetoothVolumeControl service = getService();
if (service != null) {
final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get();
service.unregisterCallback(mCallback, mAttributionSource, recv);
recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null);
}
} catch (RemoteException e) {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
throw e.rethrowAsRuntimeException();
} catch (IllegalStateException | TimeoutException e) {
Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment