• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2015 Samsung System LSI
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *      http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package android.bluetooth;
16 
17 import java.util.Arrays;
18 
19 import android.os.Parcel;
20 import android.os.Parcelable;
21 
22 /**
23  * Data representation of a Object Push Profile Server side SDP record.
24  */
25 /** @hide */
26 public class SdpOppOpsRecord implements Parcelable {
27 
28     private final String mServiceName;
29     private final int mRfcommChannel;
30     private final int mL2capPsm;
31     private final int mProfileVersion;
32     private final byte[] mFormatsList;
33 
SdpOppOpsRecord(String serviceName, int rfcommChannel, int l2capPsm, int version, byte[] formatsList)34     public SdpOppOpsRecord(String serviceName, int rfcommChannel,
35             int l2capPsm, int version, byte[] formatsList) {
36         super();
37         this.mServiceName = serviceName;
38         this.mRfcommChannel = rfcommChannel;
39         this.mL2capPsm = l2capPsm;
40         this.mProfileVersion = version;
41         this.mFormatsList = formatsList;
42     }
43 
getServiceName()44     public String getServiceName() {
45         return mServiceName;
46     }
47 
getRfcommChannel()48     public int getRfcommChannel() {
49         return mRfcommChannel;
50     }
51 
getL2capPsm()52     public int getL2capPsm() {
53         return mL2capPsm;
54     }
55 
getProfileVersion()56     public int getProfileVersion() {
57         return mProfileVersion;
58     }
59 
getFormatsList()60     public byte[] getFormatsList() {
61         return mFormatsList;
62     }
63 
64     @Override
describeContents()65     public int describeContents() {
66         /* No special objects */
67         return 0;
68     }
69 
SdpOppOpsRecord(Parcel in)70     public SdpOppOpsRecord(Parcel in){
71         this.mRfcommChannel = in.readInt();
72         this.mL2capPsm = in.readInt();
73         this.mProfileVersion = in.readInt();
74         this.mServiceName = in.readString();
75         int arrayLength = in.readInt();
76         if(arrayLength > 0) {
77             byte[] bytes = new byte[arrayLength];
78             in.readByteArray(bytes);
79             this.mFormatsList = bytes;
80         } else {
81             this.mFormatsList = null;
82         }
83     }
84 
85     @Override
writeToParcel(Parcel dest, int flags)86     public void writeToParcel(Parcel dest, int flags) {
87         dest.writeInt(mRfcommChannel);
88         dest.writeInt(mL2capPsm);
89         dest.writeInt(mProfileVersion);
90         dest.writeString(mServiceName);
91         if(mFormatsList!= null && mFormatsList.length > 0) {
92             dest.writeInt(mFormatsList.length);
93             dest.writeByteArray(mFormatsList);
94         } else {
95             dest.writeInt(0);
96         }
97     }
98 
toString()99     public String toString(){
100         StringBuilder sb = new StringBuilder("Bluetooth OPP Server SDP Record:\n");
101         sb.append("  RFCOMM Chan Number: ").append(mRfcommChannel);
102         sb.append("\n  L2CAP PSM: ").append(mL2capPsm);
103         sb.append("\n  Profile version: ").append(mProfileVersion);
104         sb.append("\n  Service Name: ").append(mServiceName);
105         sb.append("\n  Formats List: ").append(Arrays.toString(mFormatsList));
106         return sb.toString();
107     }
108 
109     public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
110         public SdpOppOpsRecord createFromParcel(Parcel in) {
111             return new SdpOppOpsRecord(in);
112         }
113         public SdpOppOpsRecord[] newArray(int size) {
114             return new SdpOppOpsRecord[size];
115         }
116     };
117 
118 }
119