Merge "gatt: Allow to set eatt support" am: f04d2d58c2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1372157 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I96ee22c3e7f6d36e88c374eb95219a21ad558cba
This commit is contained in:
@@ -824,6 +824,25 @@ public final class BluetoothGatt implements BluetoothProfile {
|
||||
* error
|
||||
*/
|
||||
private boolean registerApp(BluetoothGattCallback callback, Handler handler) {
|
||||
return registerApp(callback, handler, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an application callback to start using GATT.
|
||||
*
|
||||
* <p>This is an asynchronous call. The callback {@link BluetoothGattCallback#onAppRegistered}
|
||||
* is used to notify success or failure if the function returns true.
|
||||
*
|
||||
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
|
||||
*
|
||||
* @param callback GATT callback handler that will receive asynchronous callbacks.
|
||||
* @param eatt_support indicate to allow for eatt support
|
||||
* @return If true, the callback will be called to notify success or failure, false on immediate
|
||||
* error
|
||||
* @hide
|
||||
*/
|
||||
private boolean registerApp(BluetoothGattCallback callback, Handler handler,
|
||||
boolean eatt_support) {
|
||||
if (DBG) Log.d(TAG, "registerApp()");
|
||||
if (mService == null) return false;
|
||||
|
||||
@@ -833,7 +852,7 @@ public final class BluetoothGatt implements BluetoothProfile {
|
||||
if (DBG) Log.d(TAG, "registerApp() - UUID=" + uuid);
|
||||
|
||||
try {
|
||||
mService.registerClient(new ParcelUuid(uuid), mBluetoothGattCallback);
|
||||
mService.registerClient(new ParcelUuid(uuid), mBluetoothGattCallback, eatt_support);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "", e);
|
||||
return false;
|
||||
|
||||
@@ -443,6 +443,25 @@ public final class BluetoothGattServer implements BluetoothProfile {
|
||||
* error
|
||||
*/
|
||||
/*package*/ boolean registerCallback(BluetoothGattServerCallback callback) {
|
||||
return registerCallback(callback, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an application callback to start using GattServer.
|
||||
*
|
||||
* <p>This is an asynchronous call. The callback is used to notify
|
||||
* success or failure if the function returns true.
|
||||
*
|
||||
* <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
|
||||
*
|
||||
* @param callback GATT callback handler that will receive asynchronous callbacks.
|
||||
* @param eatt_support indicates if server can use eatt
|
||||
* @return true, the callback will be called to notify success or failure, false on immediate
|
||||
* error
|
||||
* @hide
|
||||
*/
|
||||
/*package*/ boolean registerCallback(BluetoothGattServerCallback callback,
|
||||
boolean eatt_support) {
|
||||
if (DBG) Log.d(TAG, "registerCallback()");
|
||||
if (mService == null) {
|
||||
Log.e(TAG, "GATT service not available");
|
||||
@@ -459,7 +478,7 @@ public final class BluetoothGattServer implements BluetoothProfile {
|
||||
|
||||
mCallback = callback;
|
||||
try {
|
||||
mService.registerServer(new ParcelUuid(uuid), mBluetoothGattServerCallback);
|
||||
mService.registerServer(new ParcelUuid(uuid), mBluetoothGattServerCallback, eatt_support);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "", e);
|
||||
mCallback = null;
|
||||
|
||||
@@ -216,6 +216,24 @@ public final class BluetoothManager {
|
||||
return (openGattServer(context, callback, BluetoothDevice.TRANSPORT_AUTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a GATT Server
|
||||
* The callback is used to deliver results to Caller, such as connection status as well
|
||||
* as the results of any other GATT server operations.
|
||||
* The method returns a BluetoothGattServer instance. You can use BluetoothGattServer
|
||||
* to conduct GATT server operations.
|
||||
*
|
||||
* @param context App context
|
||||
* @param callback GATT server callback handler that will receive asynchronous callbacks.
|
||||
* @param eatt_support idicates if server should use eatt channel for notifications.
|
||||
* @return BluetoothGattServer instance
|
||||
* @hide
|
||||
*/
|
||||
public BluetoothGattServer openGattServer(Context context,
|
||||
BluetoothGattServerCallback callback, boolean eatt_support) {
|
||||
return (openGattServer(context, callback, BluetoothDevice.TRANSPORT_AUTO, eatt_support));
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a GATT Server
|
||||
* The callback is used to deliver results to Caller, such as connection status as well
|
||||
@@ -233,6 +251,27 @@ public final class BluetoothManager {
|
||||
*/
|
||||
public BluetoothGattServer openGattServer(Context context,
|
||||
BluetoothGattServerCallback callback, int transport) {
|
||||
return (openGattServer(context, callback, transport, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a GATT Server
|
||||
* The callback is used to deliver results to Caller, such as connection status as well
|
||||
* as the results of any other GATT server operations.
|
||||
* The method returns a BluetoothGattServer instance. You can use BluetoothGattServer
|
||||
* to conduct GATT server operations.
|
||||
*
|
||||
* @param context App context
|
||||
* @param callback GATT server callback handler that will receive asynchronous callbacks.
|
||||
* @param transport preferred transport for GATT connections to remote dual-mode devices {@link
|
||||
* BluetoothDevice#TRANSPORT_AUTO} or {@link BluetoothDevice#TRANSPORT_BREDR} or {@link
|
||||
* BluetoothDevice#TRANSPORT_LE}
|
||||
* @param eatt_support idicates if server should use eatt channel for notifications.
|
||||
* @return BluetoothGattServer instance
|
||||
* @hide
|
||||
*/
|
||||
public BluetoothGattServer openGattServer(Context context,
|
||||
BluetoothGattServerCallback callback, int transport, boolean eatt_support) {
|
||||
if (context == null || callback == null) {
|
||||
throw new IllegalArgumentException("null parameter: " + context + " " + callback);
|
||||
}
|
||||
@@ -248,7 +287,7 @@ public final class BluetoothManager {
|
||||
return null;
|
||||
}
|
||||
BluetoothGattServer mGattServer = new BluetoothGattServer(iGatt, transport);
|
||||
Boolean regStatus = mGattServer.registerCallback(callback);
|
||||
Boolean regStatus = mGattServer.registerCallback(callback, eatt_support);
|
||||
return regStatus ? mGattServer : null;
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "", e);
|
||||
|
||||
Reference in New Issue
Block a user