diff options
-rw-r--r-- | api/current.txt | 4 | ||||
-rw-r--r-- | core/java/android/bluetooth/BluetoothGatt.java | 53 | ||||
-rw-r--r-- | core/java/android/bluetooth/IBluetoothGatt.aidl | 1 |
3 files changed, 57 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt index faeddf1..6f7f9ee 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6185,10 +6185,14 @@ package android.bluetooth { method public boolean readCharacteristic(android.bluetooth.BluetoothGattCharacteristic); method public boolean readDescriptor(android.bluetooth.BluetoothGattDescriptor); method public boolean readRemoteRssi(); + method public boolean requestConnectionParameterUpdate(int); method public boolean setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic, boolean); method public boolean writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic); method public boolean writeDescriptor(android.bluetooth.BluetoothGattDescriptor); + field public static final int GATT_CONNECTION_BALANCED = 0; // 0x0 field public static final int GATT_CONNECTION_CONGESTED = 143; // 0x8f + field public static final int GATT_CONNECTION_HIGH_PRIORITY = 1; // 0x1 + field public static final int GATT_CONNECTION_LOW_POWER = 2; // 0x2 field public static final int GATT_FAILURE = 257; // 0x101 field public static final int GATT_INSUFFICIENT_AUTHENTICATION = 5; // 0x5 field public static final int GATT_INSUFFICIENT_ENCRYPTION = 15; // 0xf diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index a287b3c..f8684e1 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java @@ -93,6 +93,25 @@ public final class BluetoothGatt implements BluetoothProfile { 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 @@ -1287,6 +1306,38 @@ public final class BluetoothGatt implements BluetoothProfile { } /** + * 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 * diff --git a/core/java/android/bluetooth/IBluetoothGatt.aidl b/core/java/android/bluetooth/IBluetoothGatt.aidl index 6d4b9cd..533be13 100644 --- a/core/java/android/bluetooth/IBluetoothGatt.aidl +++ b/core/java/android/bluetooth/IBluetoothGatt.aidl @@ -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); |