diff options
author | Łukasz Rymanowski <rlukasz@google.com> | 2022-01-14 12:51:21 +0000 |
---|---|---|
committer | Łukasz Rymanowski <rlukasz@google.com> | 2022-01-19 11:11:34 +0000 |
commit | 5f2365f9adf0c9dc27f9636f5890496142f4eb43 (patch) | |
tree | 6d0c11ae9f21dec0fcc919a51f2d24149ebdf62e | |
parent | d796637eca324871f2777e60d5b160006d9c1639 (diff) |
gtbs: Remove usage of mContext.getMainThreadHandler
This is hidden API and shall not be used.
Bug: 150670922
Sponsor: @jpawlowski
Test: phone call over BT
Change-Id: Idb81d93d8df45b40a68fdd2529ec77d3cfa2d866
-rw-r--r-- | android/app/src/com/android/bluetooth/tbs/TbsGatt.java | 6 |
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)); } } |