2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.bluetooth;
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 import android.util.EventLog;
23 import java.util.Random;
26 public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
28 private static final int MAX_DESCRIPTOR_SIZE = 2048;
30 final public String name;
31 final public String description;
32 final public String provider;
33 final public byte subclass;
34 final public byte[] descriptors;
36 public BluetoothHidDeviceAppSdpSettings(String name, String description, String provider,
37 byte subclass, byte[] descriptors) {
39 this.description = description;
40 this.provider = provider;
41 this.subclass = subclass;
43 if (descriptors == null || descriptors.length > MAX_DESCRIPTOR_SIZE) {
44 EventLog.writeEvent(0x534e4554, "119819889", -1, "");
45 throw new IllegalArgumentException("descriptors must be not null and shorter than "
46 + MAX_DESCRIPTOR_SIZE);
48 this.descriptors = descriptors.clone();
52 public boolean equals(Object o) {
53 if (o instanceof BluetoothHidDeviceAppSdpSettings) {
54 BluetoothHidDeviceAppSdpSettings sdp = (BluetoothHidDeviceAppSdpSettings) o;
61 public int describeContents() {
65 public static final Parcelable.Creator<BluetoothHidDeviceAppSdpSettings> CREATOR =
66 new Parcelable.Creator<BluetoothHidDeviceAppSdpSettings>() {
69 public BluetoothHidDeviceAppSdpSettings createFromParcel(Parcel in) {
71 return new BluetoothHidDeviceAppSdpSettings(in.readString(), in.readString(),
72 in.readString(), in.readByte(), in.createByteArray());
76 public BluetoothHidDeviceAppSdpSettings[] newArray(int size) {
77 return new BluetoothHidDeviceAppSdpSettings[size];
82 public void writeToParcel(Parcel out, int flags) {
83 out.writeString(name);
84 out.writeString(description);
85 out.writeString(provider);
86 out.writeByte(subclass);
87 out.writeByteArray(descriptors);