1/*
2 * Copyright (C) 2015 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
17package android.bluetooth;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
22/** @hide */
23public class SdpSapsRecord implements Parcelable {
24    private final int mRfcommChannelNumber;
25    private final int mProfileVersion;
26    private final String mServiceName;
27
28    public SdpSapsRecord(int rfcommChannelNumber, int profileVersion, String serviceName) {
29        mRfcommChannelNumber = rfcommChannelNumber;
30        mProfileVersion = profileVersion;
31        mServiceName = serviceName;
32    }
33
34    public SdpSapsRecord(Parcel in) {
35        mRfcommChannelNumber = in.readInt();
36        mProfileVersion = in.readInt();
37        mServiceName = in.readString();
38    }
39
40    @Override
41    public int describeContents() {
42        return 0;
43    }
44
45    public int getRfcommCannelNumber() {
46        return mRfcommChannelNumber;
47    }
48
49    public int getProfileVersion() {
50        return mProfileVersion;
51    }
52
53    public String getServiceName() {
54        return mServiceName;
55    }
56
57    @Override
58    public void writeToParcel(Parcel dest, int flags) {
59        dest.writeInt(mRfcommChannelNumber);
60        dest.writeInt(mProfileVersion);
61        dest.writeString(mServiceName);
62
63    }
64
65    @Override
66    public String toString() {
67        String ret = "Bluetooth MAS SDP Record:\n";
68
69        if (mRfcommChannelNumber != -1) {
70            ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
71        }
72        if (mServiceName != null) {
73            ret += "Service Name: " + mServiceName + "\n";
74        }
75        if (mProfileVersion != -1) {
76            ret += "Profile version: " + mProfileVersion + "\n";
77        }
78        return ret;
79    }
80
81    public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
82        public SdpSapsRecord createFromParcel(Parcel in) {
83            return new SdpSapsRecord(in);
84        }
85
86        public SdpRecord[] newArray(int size) {
87            return new SdpRecord[size];
88        }
89    };
90}
91