• 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 
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(
31             int l2capPsm,
32             int rfcommChannelNumber,
33             int profileVersion,
34             int supportedFeatures,
35             int supportedRepositories,
36             String serviceName) {
37         mL2capPsm = l2capPsm;
38         mRfcommChannelNumber = rfcommChannelNumber;
39         mProfileVersion = profileVersion;
40         mSupportedFeatures = supportedFeatures;
41         mSupportedRepositories = supportedRepositories;
42         mServiceName = serviceName;
43     }
44 
SdpPseRecord(Parcel in)45     public SdpPseRecord(Parcel in) {
46         mRfcommChannelNumber = in.readInt();
47         mL2capPsm = in.readInt();
48         mProfileVersion = in.readInt();
49         mSupportedFeatures = in.readInt();
50         mSupportedRepositories = in.readInt();
51         mServiceName = in.readString();
52     }
53 
54     @Override
describeContents()55     public int describeContents() {
56         // TODO Auto-generated method stub
57         return 0;
58     }
59 
getL2capPsm()60     public int getL2capPsm() {
61         return mL2capPsm;
62     }
63 
getRfcommChannelNumber()64     public int getRfcommChannelNumber() {
65         return mRfcommChannelNumber;
66     }
67 
getSupportedFeatures()68     public int getSupportedFeatures() {
69         return mSupportedFeatures;
70     }
71 
getServiceName()72     public String getServiceName() {
73         return mServiceName;
74     }
75 
getProfileVersion()76     public int getProfileVersion() {
77         return mProfileVersion;
78     }
79 
getSupportedRepositories()80     public int getSupportedRepositories() {
81         return mSupportedRepositories;
82     }
83 
84     @Override
writeToParcel(Parcel dest, int flags)85     public void writeToParcel(Parcel dest, int flags) {
86         dest.writeInt(mRfcommChannelNumber);
87         dest.writeInt(mL2capPsm);
88         dest.writeInt(mProfileVersion);
89         dest.writeInt(mSupportedFeatures);
90         dest.writeInt(mSupportedRepositories);
91         dest.writeString(mServiceName);
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 =
121             new Parcelable.Creator() {
122                 public SdpPseRecord createFromParcel(Parcel in) {
123                     return new SdpPseRecord(in);
124                 }
125 
126                 public SdpPseRecord[] newArray(int size) {
127                     return new SdpPseRecord[size];
128                 }
129             };
130 }
131