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

Commit 467c8848 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

LE: Add connection parameter update request API (4/4)

Change-Id: Ifb531a1b7ab05888817b96fcc89f85e17df7ffe2
parent 1ceb0121
Loading
Loading
Loading
Loading
+52 −1
Original line number Diff line number Diff line
@@ -92,6 +92,25 @@ public final class BluetoothGatt implements BluetoothProfile {
    /** A GATT operation failed, errors other than the above */
    public static final int GATT_FAILURE = 0x101;

    /**
     * Connection paramter update - Use the connection paramters recommended by the
     * Bluetooth SIG. This is the default value if no connection parameter update
     * is requested.
     */
    public static final int GATT_CONNECTION_BALANCED = 0;

    /**
     * Connection paramter update - Request a high priority, low latency connection.
     * An application should only request high priority connection paramters to transfer
     * large amounts of data over LE quickly. Once the transfer is complete, the application
     * should request {@link BluetoothGatt#GATT_CONNECTION_BALANCED} connectoin parameters
     * to reduce energy use.
     */
    public static final int GATT_CONNECTION_HIGH_PRIORITY = 1;

    /** Connection paramter update - Request low power, reduced data rate connection parameters. */
    public static final int GATT_CONNECTION_LOW_POWER = 2;

    /**
     * No authentication required.
     * @hide
@@ -738,7 +757,7 @@ public final class BluetoothGatt implements BluetoothProfile {
     * {@link BluetoothGattCallback#onConnectionStateChange} callback will be
     * invoked when the connection state changes as a result of this function.
     *
     * <p>The autoConnect paramter determines whether to actively connect to
     * <p>The autoConnect parameter determines whether to actively connect to
     * the remote device, or rather passively scan and finalize the connection
     * when the remote device is in range/available. Generally, the first ever
     * connection to a device should be direct (autoConnect set to false) and
@@ -1286,6 +1305,38 @@ public final class BluetoothGatt implements BluetoothProfile {
        return true;
    }

    /**
     * Request a connection parameter update.
     *
     * <p>This function will send a connection parameter update request to the
     * remote device.
     *
     * @param connectionPriority Request a specific connection priority. Must be one of
     *          {@link BluetoothGatt#GATT_CONNECTION_BALANCED},
     *          {@link BluetoothGatt#GATT_CONNECTION_HIGH_PRIORITY}
     *          or {@link BluetoothGatt#GATT_CONNECTION_LOW_POWER}.
     * @throws IllegalArgumentException If the parameters are outside of their
     *                                  specified range.
     */
    public boolean requestConnectionParameterUpdate(int connectionPriority) {
        if (connectionPriority < GATT_CONNECTION_BALANCED ||
            connectionPriority > GATT_CONNECTION_LOW_POWER) {
            throw new IllegalArgumentException("connectionPriority not within valid range");
        }

        if (DBG) Log.d(TAG, "requestConnectionParameterUpdate() - params: " + connectionPriority);
        if (mService == null || mClientIf == 0) return false;

        try {
            mService.connectionParameterUpdate(mClientIf, mDevice.getAddress(), connectionPriority);
        } catch (RemoteException e) {
            Log.e(TAG,"",e);
            return false;
        }

        return true;
    }

    /**
     * Not supported - please use {@link BluetoothManager#getConnectedDevices(int)}
     * with {@link BluetoothProfile#GATT} as argument
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ interface IBluetoothGatt {
    void endReliableWrite(in int clientIf, in String address, in boolean execute);
    void readRemoteRssi(in int clientIf, in String address);
    void configureMTU(in int clientIf, in String address, in int mtu);
    void connectionParameterUpdate(in int clientIf, in String address, in int connectionPriority);

    void registerServer(in ParcelUuid appId, in IBluetoothGattServerCallback callback);
    void unregisterServer(in int serverIf);