summaryrefslogtreecommitdiffstats
path: root/src/com/android/bluetooth/gatt/GattService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/bluetooth/gatt/GattService.java')
-rw-r--r--src/com/android/bluetooth/gatt/GattService.java30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/com/android/bluetooth/gatt/GattService.java b/src/com/android/bluetooth/gatt/GattService.java
index 0595ae510..f8bef759d 100644
--- a/src/com/android/bluetooth/gatt/GattService.java
+++ b/src/com/android/bluetooth/gatt/GattService.java
@@ -237,6 +237,7 @@ public class GattService extends ProfileService {
boolean permissionCheck(int connId, int handle) {
List<BluetoothGattService> db = gattClientDatabases.get(connId);
+ if (db == null) return true;
for (BluetoothGattService service : db) {
for (BluetoothGattCharacteristic characteristic: service.getCharacteristics()) {
@@ -759,7 +760,15 @@ public class GattService extends ProfileService {
void onSearchCompleted(int connId, int status) throws RemoteException {
if (DBG) Log.d(TAG, "onSearchCompleted() - connId=" + connId+ ", status=" + status);
// Gatt DB is ready!
- gattClientGetGattDbNative(connId);
+
+ // This callback was called from the jni_workqueue thread. If we make request to the stack
+ // on the same thread, it might cause deadlock. Schedule request on a new thread instead.
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ gattClientGetGattDbNative(connId);
+ }
+ });
+ t.start();
}
GattDbElement GetSampleGattDbElement() {
@@ -1638,12 +1647,11 @@ public class GattService extends ProfileService {
void connectionParameterUpdate(int clientIf, String address, int connectionPriority) {
enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
- // Default spec recommended interval is 30->50 ms
- int minInterval = 24; // 24 * 1.25ms = 30ms
- int maxInterval = 40; // 40 * 1.25ms = 50ms
+ int minInterval;
+ int maxInterval;
// Slave latency
- int latency = 0;
+ int latency;
// Link supervision timeout is measured in N * 10ms
int timeout = 2000; // 20s
@@ -1653,12 +1661,22 @@ public class GattService extends ProfileService {
case BluetoothGatt.CONNECTION_PRIORITY_HIGH:
minInterval = getResources().getInteger(R.integer.gatt_high_priority_min_interval);
maxInterval = getResources().getInteger(R.integer.gatt_high_priority_max_interval);
+ latency = getResources().getInteger(R.integer.gatt_high_priority_latency);
break;
case BluetoothGatt.CONNECTION_PRIORITY_LOW_POWER:
minInterval = getResources().getInteger(R.integer.gatt_low_power_min_interval);
maxInterval = getResources().getInteger(R.integer.gatt_low_power_max_interval);
- latency = 2;
+ latency = getResources().getInteger(R.integer.gatt_low_power_latency);
+ break;
+
+ default:
+ // Using the values for CONNECTION_PRIORITY_BALANCED.
+ minInterval =
+ getResources().getInteger(R.integer.gatt_balanced_priority_min_interval);
+ maxInterval =
+ getResources().getInteger(R.integer.gatt_balanced_priority_max_interval);
+ latency = getResources().getInteger(R.integer.gatt_balanced_priority_latency);
break;
}