Home | History | Annotate | Download | only in bluetooth
      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 
     22 
     23 /**
     24  * Represents the Service Discovery Protocol (SDP) settings for a Bluetooth HID Device application.
     25  *
     26  * <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.
     28  *
     29  * <p>{@see BluetoothHidDevice}
     30  */
     31 public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
     32 
     33     private final String mName;
     34     private final String mDescription;
     35     private final String mProvider;
     36     private final byte mSubclass;
     37     private final byte[] mDescriptors;
     38 
     39     /**
     40      * Create a BluetoothHidDeviceAppSdpSettings object for the Bluetooth SDP record.
     41      *
     42      * @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.
     45      * @param subclass Subclass of this Bluetooth HID device. See <a
     46      *     href="www.usb.org/developers/hidpage/HID1_11.pdf">
     47      *     www.usb.org/developers/hidpage/HID1_11.pdf Section 4.2</a>
     48      * @param descriptors Descriptors of this Bluetooth HID device. See <a
     49      *     href="www.usb.org/developers/hidpage/HID1_11.pdf">
     50      *     www.usb.org/developers/hidpage/HID1_11.pdf Chapter 6</a> Maximum length is 2048 bytes.
     51      */
     52     public BluetoothHidDeviceAppSdpSettings(
     53             String name, String description, String provider, byte subclass, byte[] descriptors) {
     54         mName = name;
     55         mDescription = description;
     56         mProvider = provider;
     57         mSubclass = subclass;
     58         mDescriptors = descriptors.clone();
     59     }
     60 
     61     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;
     79     }
     80 
     81     @Override
     82     public int describeContents() {
     83         return 0;
     84     }
     85 
     86     public static final Parcelable.Creator<BluetoothHidDeviceAppSdpSettings> CREATOR =
     87             new Parcelable.Creator<BluetoothHidDeviceAppSdpSettings>() {
     88 
     89                 @Override
     90                 public BluetoothHidDeviceAppSdpSettings createFromParcel(Parcel in) {
     91 
     92                     return new BluetoothHidDeviceAppSdpSettings(
     93                             in.readString(),
     94                             in.readString(),
     95                             in.readString(),
     96                             in.readByte(),
     97                             in.createByteArray());
     98                 }
     99 
    100                 @Override
    101                 public BluetoothHidDeviceAppSdpSettings[] newArray(int size) {
    102                     return new BluetoothHidDeviceAppSdpSettings[size];
    103                 }
    104             };
    105 
    106     @Override
    107     public void writeToParcel(Parcel out, int flags) {
    108         out.writeString(mName);
    109         out.writeString(mDescription);
    110         out.writeString(mProvider);
    111         out.writeByte(mSubclass);
    112         out.writeByteArray(mDescriptors);
    113     }
    114 }
    115