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 
16 package android.bluetooth;
17 
18 import android.os.Parcel;
19 import android.os.Parcelable;
20 
21 /** @hide */
22 public class SdpPseRecord implements Parcelable {
23     private final int mL2capPsm;
24     private final int mRfcommChannelNumber;
25     private final int mProfileVersion;
26     private final int mSupportedFeatures;
27     private final int mSupportedRepositories;
28     private final String mServiceName;
29 
SdpPseRecord(int l2capPsm, int rfcommChannelNumber, int profileVersion, int supportedFeatures, int supportedRepositories, String serviceName)30     public SdpPseRecord(int l2capPsm,
31             int rfcommChannelNumber,
32             int profileVersion,
33             int supportedFeatures,
34             int supportedRepositories,
35             String serviceName) {
36         mL2capPsm = l2capPsm;
37         mRfcommChannelNumber = rfcommChannelNumber;
38         mProfileVersion = profileVersion;
39         mSupportedFeatures = supportedFeatures;
40         mSupportedRepositories = supportedRepositories;
41         mServiceName = serviceName;
42     }
43 
SdpPseRecord(Parcel in)44     public SdpPseRecord(Parcel in) {
45         mRfcommChannelNumber = in.readInt();
46         mL2capPsm = in.readInt();
47         mProfileVersion = in.readInt();
48         mSupportedFeatures = in.readInt();
49         mSupportedRepositories = in.readInt();
50         mServiceName = in.readString();
51     }
52 
53     @Override
describeContents()54     public int describeContents() {
55         // TODO Auto-generated method stub
56         return 0;
57     }
58 
getL2capPsm()59     public int getL2capPsm() {
60         return mL2capPsm;
61     }
62 
getRfcommChannelNumber()63     public int getRfcommChannelNumber() {
64         return mRfcommChannelNumber;
65     }
66 
getSupportedFeatures()67     public int getSupportedFeatures() {
68         return mSupportedFeatures;
69     }
70 
getServiceName()71     public String getServiceName() {
72         return mServiceName;
73     }
74 
getProfileVersion()75     public int getProfileVersion() {
76         return mProfileVersion;
77     }
78 
getSupportedRepositories()79     public int getSupportedRepositories() {
80         return mSupportedRepositories;
81     }
82 
83     @Override
writeToParcel(Parcel dest, int flags)84     public void writeToParcel(Parcel dest, int flags) {
85         dest.writeInt(mRfcommChannelNumber);
86         dest.writeInt(mL2capPsm);
87         dest.writeInt(mProfileVersion);
88         dest.writeInt(mSupportedFeatures);
89         dest.writeInt(mSupportedRepositories);
90         dest.writeString(mServiceName);
91 
92     }
93 
94     @Override
toString()95     public String toString() {
96         String ret = "Bluetooth MNS SDP Record:\n";
97 
98         if (mRfcommChannelNumber != -1) {
99             ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
100         }
101         if (mL2capPsm != -1) {
102             ret += "L2CAP PSM: " + mL2capPsm + "\n";
103         }
104         if (mProfileVersion != -1) {
105             ret += "profile version: " + mProfileVersion + "\n";
106         }
107         if (mServiceName != null) {
108             ret += "Service Name: " + mServiceName + "\n";
109         }
110         if (mSupportedFeatures != -1) {
111             ret += "Supported features: " + mSupportedFeatures + "\n";
112         }
113         if (mSupportedRepositories != -1) {
114             ret += "Supported repositories: " + mSupportedRepositories + "\n";
115         }
116 
117         return ret;
118     }
119 
120     public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
121         public SdpPseRecord createFromParcel(Parcel in) {
122             return new SdpPseRecord(in);
123         }
124 
125         public SdpPseRecord[] newArray(int size) {
126             return new SdpPseRecord[size];
127         }
128     };
129 }
130