summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothManager.java
diff options
context:
space:
mode:
authorWilliam Escande <wescande@google.com>2022-01-10 19:13:28 +0100
committerWilliam Escande <wescande@google.com>2022-01-28 02:44:28 +0100
commit335de95b1764401962bce6f0d9ae237078cf25b1 (patch)
treec62e223ca86d044b5d5278fe6efe68050781b9ab /framework/java/android/bluetooth/BluetoothManager.java
parentaa63bd2617a90f4d83724802b024a97e3a623709 (diff)
Remove allowBlocking from BluetoothManagerService
Since Bluetooth is becoming a mainline module, it can no longer call the allowBlocking hidden api. Instead, corresponding aidl are moved to be oneway and use a synchronous data to handle the return value. also: aosp/1927380 for similar work on all bluetooth profiles BluetoothGatt will be done next Bug: 211851706 Test: build + start bt Tag: #refactor Ignore-AOSP-First: merge conflict resolution Change-Id: I715cc2d8f2ae42be6d1099cd73095d37fa9e30f4
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothManager.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothManager.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/framework/java/android/bluetooth/BluetoothManager.java b/framework/java/android/bluetooth/BluetoothManager.java
index fef6f225dd..7ab32f3dfb 100644
--- a/framework/java/android/bluetooth/BluetoothManager.java
+++ b/framework/java/android/bluetooth/BluetoothManager.java
@@ -16,6 +16,8 @@
package android.bluetooth;
+import static android.bluetooth.BluetoothUtils.getSyncTimeout;
+
import android.annotation.RequiresFeature;
import android.annotation.RequiresNoPermission;
import android.annotation.RequiresPermission;
@@ -28,8 +30,11 @@ import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.util.Log;
+import com.android.modules.utils.SynchronousResultReceiver;
+
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeoutException;
/**
* High level manager used to obtain an instance of an {@link BluetoothAdapter}
@@ -166,10 +171,13 @@ public final class BluetoothManager {
IBluetoothManager managerService = mAdapter.getBluetoothManager();
IBluetoothGatt iGatt = managerService.getBluetoothGatt();
if (iGatt == null) return devices;
+ final SynchronousResultReceiver<List<BluetoothDevice>> recv =
+ new SynchronousResultReceiver();
+ iGatt.getDevicesMatchingConnectionStates(states, mAttributionSource, recv);
devices = Attributable.setAttributionSource(
- iGatt.getDevicesMatchingConnectionStates(states, mAttributionSource),
+ recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(devices),
mAttributionSource);
- } catch (RemoteException e) {
+ } catch (RemoteException | TimeoutException e) {
Log.e(TAG, "", e);
}