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