summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/app/src/com/android/bluetooth/tbs/TbsGatt.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/android/app/src/com/android/bluetooth/tbs/TbsGatt.java b/android/app/src/com/android/bluetooth/tbs/TbsGatt.java
index e3845c8c3e..f78d8c0c30 100644
--- a/android/app/src/com/android/bluetooth/tbs/TbsGatt.java
+++ b/android/app/src/com/android/bluetooth/tbs/TbsGatt.java
@@ -24,6 +24,8 @@ import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattServerCallback;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothLeCall;
+import android.os.Handler;
+import android.os.Looper;
import android.content.Context;
import android.util.Log;
@@ -133,6 +135,7 @@ public class TbsGatt {
private final GattCharacteristic mIncomingCallCharacteristic;
private final GattCharacteristic mCallFriendlyNameCharacteristic;
private BluetoothGattServerProxy mBluetoothGattServer;
+ private Handler mHandler;
private Callback mCallback;
public static abstract class Callback {
@@ -210,6 +213,7 @@ public class TbsGatt {
setCallControlPointOptionalOpcodes(isLocalHoldOpcodeSupported, isJoinOpcodeSupported);
mStatusFlagsCharacteristic.setValue(0, BluetoothGattCharacteristic.FORMAT_UINT16, 0);
mCallback = callback;
+ mHandler = new Handler(Looper.getMainLooper());
if (mBluetoothGattServer == null) {
mBluetoothGattServer = new BluetoothGattServerProxy(mContext);
@@ -412,7 +416,7 @@ public class TbsGatt {
super.setValue(value);
// to avoid sending control point notification before write response
- mContext.getMainThreadHandler().post(() -> mNotifier.notify(device, this));
+ mHandler.post(() -> mNotifier.notify(device, this));
}
}