diff options
author | Hansong Zhang <hsz@google.com> | 2017-11-16 18:59:36 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-11-16 18:59:36 +0000 |
commit | 2364431ec81e88ca139498efa1e277567fd3888c (patch) | |
tree | 1980183231b8e604a57107ed838c69dcedd9d605 /framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java | |
parent | 359a4a8441b4aa1c6e93a2ce6b6779cf444fc656 (diff) | |
parent | a9b2b0496ca86e28010ba541bb01431804541dd3 (diff) |
Merge "Bluetooth HID Device API docs and helper" am: a89f6150dc
am: a9b2b0496c
Change-Id: Ic95f83d9884aea8d75ca33fed1ddf69d6c0e33e3
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java | 103 |
1 files changed, 102 insertions, 1 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java b/framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java index ccc3ef4008..881ae98d98 100644 --- a/framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java +++ b/framework/java/android/bluetooth/BluetoothHidDeviceAppQosSettings.java @@ -45,6 +45,21 @@ public final class BluetoothHidDeviceAppQosSettings implements Parcelable { public static final int MAX = (int) 0xffffffff; + /** + * Create a BluetoothHidDeviceAppQosSettings object for the Bluetooth L2CAP channel. + * The QoS Settings is optional. + * Recommended to use BluetoothHidDeviceAppQosSettings.Builder. + * {@see <a href="https://www.bluetooth.com/specifications/profiles-overview"> + * https://www.bluetooth.com/specifications/profiles-overview + * </a> + * Bluetooth HID Specfication v1.1.1 Section 5.2 and Appendix D } + * @param serviceType L2CAP service type + * @param tokenRate L2CAP token rate + * @param tokenBucketSize L2CAP token bucket size + * @param peakBandwidth L2CAP peak bandwidth + * @param latency L2CAP latency + * @param delayVariation L2CAP delay variation + */ public BluetoothHidDeviceAppQosSettings(int serviceType, int tokenRate, int tokenBucketSize, int peakBandwidth, int latency, int delayVariation) { this.serviceType = serviceType; @@ -59,7 +74,12 @@ public final class BluetoothHidDeviceAppQosSettings implements Parcelable { public boolean equals(Object o) { if (o instanceof BluetoothHidDeviceAppQosSettings) { BluetoothHidDeviceAppQosSettings qos = (BluetoothHidDeviceAppQosSettings) o; - return false; + return this.serviceType == qos.serviceType + && this.tokenRate == qos.tokenRate + && this.tokenBucketSize == qos.tokenBucketSize + && this.peakBandwidth == qos.peakBandwidth + && this.latency == qos.latency + && this.delayVariation == qos.delayVariation; } return false; } @@ -106,4 +126,85 @@ public final class BluetoothHidDeviceAppQosSettings implements Parcelable { serviceType, tokenRate, tokenBucketSize, peakBandwidth, latency, delayVariation }; } + + /** + * A helper to build the BluetoothHidDeviceAppQosSettings object. + */ + public static class Builder { + // Optional parameters - initialized to default values + private int mServiceType = SERVICE_BEST_EFFORT; + private int mTokenRate = 0; + private int mTokenBucketSize = 0; + private int mPeakBandwidth = 0; + private int mLatency = MAX; + private int mDelayVariation = MAX; + + /** + * Set the service type. + * @param val service type. Should be one of {SERVICE_NO_TRAFFIC, SERVICE_BEST_EFFORT, + * SERVICE_GUARANTEED}, with SERVICE_BEST_EFFORT being the default one. + * @return BluetoothHidDeviceAppQosSettings Builder with specified service type. + */ + public Builder serviceType(int val) { + mServiceType = val; + return this; + } + /** + * Set the token rate. + * @param val token rate + * @return BluetoothHidDeviceAppQosSettings Builder with specified token rate. + */ + public Builder tokenRate(int val) { + mTokenRate = val; + return this; + } + + /** + * Set the bucket size. + * @param val bucket size + * @return BluetoothHidDeviceAppQosSettings Builder with specified bucket size. + */ + public Builder tokenBucketSize(int val) { + mTokenBucketSize = val; + return this; + } + + /** + * Set the peak bandwidth. + * @param val peak bandwidth + * @return BluetoothHidDeviceAppQosSettings Builder with specified peak bandwidth. + */ + public Builder peakBandwidth(int val) { + mPeakBandwidth = val; + return this; + } + /** + * Set the latency. + * @param val latency + * @return BluetoothHidDeviceAppQosSettings Builder with specified latency. + */ + public Builder latency(int val) { + mLatency = val; + return this; + } + + /** + * Set the delay variation. + * @param val delay variation + * @return BluetoothHidDeviceAppQosSettings Builder with specified delay variation. + */ + public Builder delayVariation(int val) { + mDelayVariation = val; + return this; + } + + /** + * Build the BluetoothHidDeviceAppQosSettings object. + * @return BluetoothHidDeviceAppQosSettings object with current settings. + */ + public BluetoothHidDeviceAppQosSettings build() { + return new BluetoothHidDeviceAppQosSettings(mServiceType, mTokenRate, mTokenBucketSize, + mPeakBandwidth, mLatency, mDelayVariation); + } + } } |