• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.annotation.NonNull;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 /**
24  * Represents the Quality of Service (QoS) settings for a Bluetooth HID Device application.
25  *
26  * <p>The BluetoothHidDevice framework will update the L2CAP QoS settings for the app during
27  * registration.
28  *
29  * @see BluetoothHidDevice
30  */
31 public final class BluetoothHidDeviceAppQosSettings implements Parcelable {
32 
33     private final int mServiceType;
34     private final int mTokenRate;
35     private final int mTokenBucketSize;
36     private final int mPeakBandwidth;
37     private final int mLatency;
38     private final int mDelayVariation;
39 
40     public static final int SERVICE_NO_TRAFFIC = 0x00;
41     public static final int SERVICE_BEST_EFFORT = 0x01;
42     public static final int SERVICE_GUARANTEED = 0x02;
43 
44     public static final int MAX = (int) 0xffffffff;
45 
46     /**
47      * Create a BluetoothHidDeviceAppQosSettings object for the Bluetooth L2CAP channel. The QoS
48      * Settings is optional. Please refer to Bluetooth HID Specification v1.1.1 Section 5.2 and
49      * Appendix D for parameters.
50      *
51      * @param serviceType L2CAP service type, default = SERVICE_BEST_EFFORT
52      * @param tokenRate L2CAP token rate, default = 0
53      * @param tokenBucketSize L2CAP token bucket size, default = 0
54      * @param peakBandwidth L2CAP peak bandwidth, default = 0
55      * @param latency L2CAP latency, default = MAX
56      * @param delayVariation L2CAP delay variation, default = MAX
57      */
BluetoothHidDeviceAppQosSettings( int serviceType, int tokenRate, int tokenBucketSize, int peakBandwidth, int latency, int delayVariation)58     public BluetoothHidDeviceAppQosSettings(
59             int serviceType,
60             int tokenRate,
61             int tokenBucketSize,
62             int peakBandwidth,
63             int latency,
64             int delayVariation) {
65         mServiceType = serviceType;
66         mTokenRate = tokenRate;
67         mTokenBucketSize = tokenBucketSize;
68         mPeakBandwidth = peakBandwidth;
69         mLatency = latency;
70         mDelayVariation = delayVariation;
71     }
72 
getServiceType()73     public int getServiceType() {
74         return mServiceType;
75     }
76 
getTokenRate()77     public int getTokenRate() {
78         return mTokenRate;
79     }
80 
getTokenBucketSize()81     public int getTokenBucketSize() {
82         return mTokenBucketSize;
83     }
84 
getPeakBandwidth()85     public int getPeakBandwidth() {
86         return mPeakBandwidth;
87     }
88 
getLatency()89     public int getLatency() {
90         return mLatency;
91     }
92 
getDelayVariation()93     public int getDelayVariation() {
94         return mDelayVariation;
95     }
96 
97     @Override
describeContents()98     public int describeContents() {
99         return 0;
100     }
101 
102     @NonNull
103     public static final Creator<BluetoothHidDeviceAppQosSettings> CREATOR =
104             new Creator<>() {
105                 @Override
106                 public BluetoothHidDeviceAppQosSettings createFromParcel(Parcel in) {
107                     return new BluetoothHidDeviceAppQosSettings(
108                             in.readInt(),
109                             in.readInt(),
110                             in.readInt(),
111                             in.readInt(),
112                             in.readInt(),
113                             in.readInt());
114                 }
115 
116                 @Override
117                 public BluetoothHidDeviceAppQosSettings[] newArray(int size) {
118                     return new BluetoothHidDeviceAppQosSettings[size];
119                 }
120             };
121 
122     @Override
writeToParcel(Parcel out, int flags)123     public void writeToParcel(Parcel out, int flags) {
124         out.writeInt(mServiceType);
125         out.writeInt(mTokenRate);
126         out.writeInt(mTokenBucketSize);
127         out.writeInt(mPeakBandwidth);
128         out.writeInt(mLatency);
129         out.writeInt(mDelayVariation);
130     }
131 }
132