blob: 237082e4cb664780769a2556173299c7d32cffcf [file] [log] [blame]
Hemant Guptae88fd4b2014-04-18 11:22:45 +05301/*
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
17package android.bluetooth;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
Hansong Zhangceb84db2017-11-08 09:57:12 -080022
Hansong Zhangfa377b42017-09-27 14:17:20 -070023/**
Hansong Zhang53f54122017-12-04 10:31:30 -080024 * Represents the Service Discovery Protocol (SDP) settings for a Bluetooth HID Device application.
Hansong Zhangfa377b42017-09-27 14:17:20 -070025 *
Hansong Zhang53f54122017-12-04 10:31:30 -080026 * <p>The BluetoothHidDevice framework adds the SDP record during app registration, so that the
27 * Android device can be discovered as a Bluetooth HID Device.
Hansong Zhangfa377b42017-09-27 14:17:20 -070028 *
Hansong Zhang53f54122017-12-04 10:31:30 -080029 * <p>{@see BluetoothHidDevice}
Hansong Zhangfa377b42017-09-27 14:17:20 -070030 */
Hemant Guptae88fd4b2014-04-18 11:22:45 +053031public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
32
Ivan Podogovf2f5dc32018-02-27 17:58:16 +000033 private final String mName;
34 private final String mDescription;
35 private final String mProvider;
36 private final byte mSubclass;
37 private final byte[] mDescriptors;
Hemant Guptae88fd4b2014-04-18 11:22:45 +053038
Hansong Zhangceb84db2017-11-08 09:57:12 -080039 /**
40 * Create a BluetoothHidDeviceAppSdpSettings object for the Bluetooth SDP record.
Hansong Zhang53f54122017-12-04 10:31:30 -080041 *
Hansong Zhangceb84db2017-11-08 09:57:12 -080042 * @param name Name of this Bluetooth HID device. Maximum length is 50 bytes.
43 * @param description Description for this Bluetooth HID device. Maximum length is 50 bytes.
44 * @param provider Provider of this Bluetooth HID device. Maximum length is 50 bytes.
Hansong Zhang53f54122017-12-04 10:31:30 -080045 * @param subclass Subclass of this Bluetooth HID device. See <a
46 * href="www.usb.org/developers/hidpage/HID1_11.pdf">
Hansong Zhangceb84db2017-11-08 09:57:12 -080047 * www.usb.org/developers/hidpage/HID1_11.pdf Section 4.2</a>
Hansong Zhang53f54122017-12-04 10:31:30 -080048 * @param descriptors Descriptors of this Bluetooth HID device. See <a
49 * href="www.usb.org/developers/hidpage/HID1_11.pdf">
Hansong Zhangceb84db2017-11-08 09:57:12 -080050 * www.usb.org/developers/hidpage/HID1_11.pdf Chapter 6</a> Maximum length is 2048 bytes.
51 */
Hansong Zhang53f54122017-12-04 10:31:30 -080052 public BluetoothHidDeviceAppSdpSettings(
53 String name, String description, String provider, byte subclass, byte[] descriptors) {
Ivan Podogovf2f5dc32018-02-27 17:58:16 +000054 mName = name;
55 mDescription = description;
56 mProvider = provider;
57 mSubclass = subclass;
58 mDescriptors = descriptors.clone();
Hemant Guptae88fd4b2014-04-18 11:22:45 +053059 }
60
Ivan Podogovf2f5dc32018-02-27 17:58:16 +000061 public String getName() {
62 return mName;
63 }
64
65 public String getDescription() {
66 return mDescription;
67 }
68
69 public String getProvider() {
70 return mProvider;
71 }
72
73 public byte getSubclass() {
74 return mSubclass;
75 }
76
77 public byte[] getDescriptors() {
78 return mDescriptors;
Hemant Guptae88fd4b2014-04-18 11:22:45 +053079 }
80
81 @Override
82 public int describeContents() {
83 return 0;
84 }
85
86 public static final Parcelable.Creator<BluetoothHidDeviceAppSdpSettings> CREATOR =
Jack Hea355e5e2017-08-22 16:06:54 -070087 new Parcelable.Creator<BluetoothHidDeviceAppSdpSettings>() {
Hemant Guptae88fd4b2014-04-18 11:22:45 +053088
Jack Hea355e5e2017-08-22 16:06:54 -070089 @Override
90 public BluetoothHidDeviceAppSdpSettings createFromParcel(Parcel in) {
Hemant Guptae88fd4b2014-04-18 11:22:45 +053091
Hansong Zhangfa377b42017-09-27 14:17:20 -070092 return new BluetoothHidDeviceAppSdpSettings(
93 in.readString(),
94 in.readString(),
95 in.readString(),
96 in.readByte(),
97 in.createByteArray());
Jack Hea355e5e2017-08-22 16:06:54 -070098 }
Hemant Guptae88fd4b2014-04-18 11:22:45 +053099
Jack Hea355e5e2017-08-22 16:06:54 -0700100 @Override
101 public BluetoothHidDeviceAppSdpSettings[] newArray(int size) {
102 return new BluetoothHidDeviceAppSdpSettings[size];
103 }
104 };
Hemant Guptae88fd4b2014-04-18 11:22:45 +0530105
106 @Override
107 public void writeToParcel(Parcel out, int flags) {
Ivan Podogovf2f5dc32018-02-27 17:58:16 +0000108 out.writeString(mName);
109 out.writeString(mDescription);
110 out.writeString(mProvider);
111 out.writeByte(mSubclass);
112 out.writeByteArray(mDescriptors);
Hemant Guptae88fd4b2014-04-18 11:22:45 +0530113 }
114}