summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/bluetooth/BluetoothGatt.java53
-rw-r--r--core/java/android/bluetooth/IBluetoothGatt.aidl1
2 files changed, 53 insertions, 1 deletions
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);