Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.bluetooth; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
Hansong Zhang | fa377b4 | 2017-09-27 14:17:20 -0700 | [diff] [blame] | 22 | /** |
Hansong Zhang | 53f5412 | 2017-12-04 10:31:30 -0800 | [diff] [blame] | 23 | * Represents the Quality of Service (QoS) settings for a Bluetooth HID Device application. |
Hansong Zhang | fa377b4 | 2017-09-27 14:17:20 -0700 | [diff] [blame] | 24 | * |
Hansong Zhang | 53f5412 | 2017-12-04 10:31:30 -0800 | [diff] [blame] | 25 | * <p>The BluetoothHidDevice framework will update the L2CAP QoS settings for the app during |
| 26 | * registration. |
Hansong Zhang | fa377b4 | 2017-09-27 14:17:20 -0700 | [diff] [blame] | 27 | * |
Hansong Zhang | 53f5412 | 2017-12-04 10:31:30 -0800 | [diff] [blame] | 28 | * <p>{@see BluetoothHidDevice} |
Hansong Zhang | fa377b4 | 2017-09-27 14:17:20 -0700 | [diff] [blame] | 29 | */ |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 30 | public final class BluetoothHidDeviceAppQosSettings implements Parcelable { |
| 31 | |
Ivan Podogov | f2f5dc3 | 2018-02-27 17:58:16 +0000 | [diff] [blame] | 32 | private final int mServiceType; |
| 33 | private final int mTokenRate; |
| 34 | private final int mTokenBucketSize; |
| 35 | private final int mPeakBandwidth; |
| 36 | private final int mLatency; |
| 37 | private final int mDelayVariation; |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 38 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 39 | public static final int SERVICE_NO_TRAFFIC = 0x00; |
| 40 | public static final int SERVICE_BEST_EFFORT = 0x01; |
| 41 | public static final int SERVICE_GUARANTEED = 0x02; |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 42 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 43 | public static final int MAX = (int) 0xffffffff; |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 44 | |
Hansong Zhang | ceb84db | 2017-11-08 09:57:12 -0800 | [diff] [blame] | 45 | /** |
Hansong Zhang | 53f5412 | 2017-12-04 10:31:30 -0800 | [diff] [blame] | 46 | * Create a BluetoothHidDeviceAppQosSettings object for the Bluetooth L2CAP channel. The QoS |
Ivan Podogov | f2f5dc3 | 2018-02-27 17:58:16 +0000 | [diff] [blame] | 47 | * Settings is optional. Please refer to Bluetooth HID Specfication v1.1.1 Section 5.2 and |
| 48 | * Appendix D for parameters. |
Hansong Zhang | 53f5412 | 2017-12-04 10:31:30 -0800 | [diff] [blame] | 49 | * |
Ivan Podogov | f2f5dc3 | 2018-02-27 17:58:16 +0000 | [diff] [blame] | 50 | * @param serviceType L2CAP service type, default = SERVICE_BEST_EFFORT |
| 51 | * @param tokenRate L2CAP token rate, default = 0 |
| 52 | * @param tokenBucketSize L2CAP token bucket size, default = 0 |
| 53 | * @param peakBandwidth L2CAP peak bandwidth, default = 0 |
| 54 | * @param latency L2CAP latency, default = MAX |
| 55 | * @param delayVariation L2CAP delay variation, default = MAX |
Hansong Zhang | ceb84db | 2017-11-08 09:57:12 -0800 | [diff] [blame] | 56 | */ |
Ivan Podogov | f2f5dc3 | 2018-02-27 17:58:16 +0000 | [diff] [blame] | 57 | public BluetoothHidDeviceAppQosSettings( |
| 58 | int serviceType, |
| 59 | int tokenRate, |
| 60 | int tokenBucketSize, |
| 61 | int peakBandwidth, |
| 62 | int latency, |
| 63 | int delayVariation) { |
| 64 | mServiceType = serviceType; |
| 65 | mTokenRate = tokenRate; |
| 66 | mTokenBucketSize = tokenBucketSize; |
| 67 | mPeakBandwidth = peakBandwidth; |
| 68 | mLatency = latency; |
| 69 | mDelayVariation = delayVariation; |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 70 | } |
| 71 | |
Ivan Podogov | f2f5dc3 | 2018-02-27 17:58:16 +0000 | [diff] [blame] | 72 | public int getServiceType() { |
| 73 | return mServiceType; |
| 74 | } |
| 75 | |
| 76 | public int getTokenRate() { |
| 77 | return mTokenRate; |
| 78 | } |
| 79 | |
| 80 | public int getTokenBucketSize() { |
| 81 | return mTokenBucketSize; |
| 82 | } |
| 83 | |
| 84 | public int getPeakBandwidth() { |
| 85 | return mPeakBandwidth; |
| 86 | } |
| 87 | |
| 88 | public int getLatency() { |
| 89 | return mLatency; |
| 90 | } |
| 91 | |
| 92 | public int getDelayVariation() { |
| 93 | return mDelayVariation; |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public int describeContents() { |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | public static final Parcelable.Creator<BluetoothHidDeviceAppQosSettings> CREATOR = |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 102 | new Parcelable.Creator<BluetoothHidDeviceAppQosSettings>() { |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 103 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 104 | @Override |
| 105 | public BluetoothHidDeviceAppQosSettings createFromParcel(Parcel in) { |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 106 | |
Hansong Zhang | fa377b4 | 2017-09-27 14:17:20 -0700 | [diff] [blame] | 107 | return new BluetoothHidDeviceAppQosSettings( |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 108 | in.readInt(), |
| 109 | in.readInt(), |
Hansong Zhang | fa377b4 | 2017-09-27 14:17:20 -0700 | [diff] [blame] | 110 | in.readInt(), |
| 111 | in.readInt(), |
| 112 | in.readInt(), |
| 113 | in.readInt()); |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 114 | } |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 115 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 116 | @Override |
| 117 | public BluetoothHidDeviceAppQosSettings[] newArray(int size) { |
| 118 | return new BluetoothHidDeviceAppQosSettings[size]; |
| 119 | } |
| 120 | }; |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 121 | |
| 122 | @Override |
| 123 | public void writeToParcel(Parcel out, int flags) { |
Ivan Podogov | f2f5dc3 | 2018-02-27 17:58:16 +0000 | [diff] [blame] | 124 | out.writeInt(mServiceType); |
| 125 | out.writeInt(mTokenRate); |
| 126 | out.writeInt(mTokenBucketSize); |
| 127 | out.writeInt(mPeakBandwidth); |
| 128 | out.writeInt(mLatency); |
| 129 | out.writeInt(mDelayVariation); |
Hansong Zhang | ceb84db | 2017-11-08 09:57:12 -0800 | [diff] [blame] | 130 | } |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 131 | } |