Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5376b16 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Automerger Merge Worker
Browse files

Merge "gatt: Allow to set eatt support" am: f04d2d58 am: 4fcde6c1 am: 2c4cbf33

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1372157

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Iaba23fca7fc2deb64835f77153db07204d4c63f8
parents 80c2d285 2c4cbf33
Loading
Loading
Loading
Loading
+20 −1
Original line number Original line Diff line number Diff line
@@ -824,6 +824,25 @@ public final class BluetoothGatt implements BluetoothProfile {
     * error
     * error
     */
     */
    private boolean registerApp(BluetoothGattCallback callback, Handler handler) {
    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 (DBG) Log.d(TAG, "registerApp()");
        if (mService == null) return false;
        if (mService == null) return false;


@@ -833,7 +852,7 @@ public final class BluetoothGatt implements BluetoothProfile {
        if (DBG) Log.d(TAG, "registerApp() - UUID=" + uuid);
        if (DBG) Log.d(TAG, "registerApp() - UUID=" + uuid);


        try {
        try {
            mService.registerClient(new ParcelUuid(uuid), mBluetoothGattCallback);
            mService.registerClient(new ParcelUuid(uuid), mBluetoothGattCallback, eatt_support);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
            Log.e(TAG, "", e);
            return false;
            return false;
+20 −1
Original line number Original line Diff line number Diff line
@@ -443,6 +443,25 @@ public final class BluetoothGattServer implements BluetoothProfile {
     * error
     * error
     */
     */
    /*package*/ boolean registerCallback(BluetoothGattServerCallback callback) {
    /*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 (DBG) Log.d(TAG, "registerCallback()");
        if (mService == null) {
        if (mService == null) {
            Log.e(TAG, "GATT service not available");
            Log.e(TAG, "GATT service not available");
@@ -459,7 +478,7 @@ public final class BluetoothGattServer implements BluetoothProfile {


            mCallback = callback;
            mCallback = callback;
            try {
            try {
                mService.registerServer(new ParcelUuid(uuid), mBluetoothGattServerCallback);
                mService.registerServer(new ParcelUuid(uuid), mBluetoothGattServerCallback, eatt_support);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG, "", e);
                Log.e(TAG, "", e);
                mCallback = null;
                mCallback = null;
+40 −1
Original line number Original line Diff line number Diff line
@@ -216,6 +216,24 @@ public final class BluetoothManager {
        return (openGattServer(context, callback, BluetoothDevice.TRANSPORT_AUTO));
        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
     * Open a GATT Server
     * The callback is used to deliver results to Caller, such as connection status as well
     * 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,
    public BluetoothGattServer openGattServer(Context context,
            BluetoothGattServerCallback callback, int transport) {
            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) {
        if (context == null || callback == null) {
            throw new IllegalArgumentException("null parameter: " + context + " " + callback);
            throw new IllegalArgumentException("null parameter: " + context + " " + callback);
        }
        }
@@ -248,7 +287,7 @@ public final class BluetoothManager {
                return null;
                return null;
            }
            }
            BluetoothGattServer mGattServer = new BluetoothGattServer(iGatt, transport);
            BluetoothGattServer mGattServer = new BluetoothGattServer(iGatt, transport);
            Boolean regStatus = mGattServer.registerCallback(callback);
            Boolean regStatus = mGattServer.registerCallback(callback, eatt_support);
            return regStatus ? mGattServer : null;
            return regStatus ? mGattServer : null;
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
            Log.e(TAG, "", e);