blob: a781d5df7dd0f2c798ecda1c4fae008f8921edd4 [file] [log] [blame]
Casper Bonde238e0f92015-04-09 09:24:48 +02001/*
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
Jack He2992cd02017-08-22 21:21:23 -070028 public SdpMnsRecord(int l2capPsm,
29 int rfcommChannelNumber,
30 int profileVersion,
31 int supportedFeatures,
32 String serviceName) {
33 mL2capPsm = l2capPsm;
34 mRfcommChannelNumber = rfcommChannelNumber;
35 mSupportedFeatures = supportedFeatures;
36 mServiceName = serviceName;
37 mProfileVersion = profileVersion;
Casper Bonde238e0f92015-04-09 09:24:48 +020038 }
39
Jack Hea355e5e2017-08-22 16:06:54 -070040 public SdpMnsRecord(Parcel in) {
Jack He2992cd02017-08-22 21:21:23 -070041 mRfcommChannelNumber = in.readInt();
42 mL2capPsm = in.readInt();
43 mServiceName = in.readString();
44 mSupportedFeatures = in.readInt();
45 mProfileVersion = in.readInt();
Casper Bonde238e0f92015-04-09 09:24:48 +020046 }
Jack Hea355e5e2017-08-22 16:06:54 -070047
Casper Bonde238e0f92015-04-09 09:24:48 +020048 @Override
49 public int describeContents() {
50 // TODO Auto-generated method stub
51 return 0;
52 }
53
54
55 public int getL2capPsm() {
56 return mL2capPsm;
57 }
58
59 public int getRfcommChannelNumber() {
60 return mRfcommChannelNumber;
61 }
62
63 public int getSupportedFeatures() {
64 return mSupportedFeatures;
65 }
66
67 public String getServiceName() {
68 return mServiceName;
69 }
70
71 public int getProfileVersion() {
72 return mProfileVersion;
73 }
74
75 @Override
76 public void writeToParcel(Parcel dest, int flags) {
77 dest.writeInt(mRfcommChannelNumber);
78 dest.writeInt(mL2capPsm);
79 dest.writeString(mServiceName);
80 dest.writeInt(mSupportedFeatures);
81 dest.writeInt(mProfileVersion);
82 }
83
Jack Hea355e5e2017-08-22 16:06:54 -070084 public String toString() {
Casper Bonde238e0f92015-04-09 09:24:48 +020085 String ret = "Bluetooth MNS SDP Record:\n";
86
Jack Hea355e5e2017-08-22 16:06:54 -070087 if (mRfcommChannelNumber != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +020088 ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
89 }
Jack Hea355e5e2017-08-22 16:06:54 -070090 if (mL2capPsm != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +020091 ret += "L2CAP PSM: " + mL2capPsm + "\n";
92 }
Jack Hea355e5e2017-08-22 16:06:54 -070093 if (mServiceName != null) {
Casper Bonde238e0f92015-04-09 09:24:48 +020094 ret += "Service Name: " + mServiceName + "\n";
95 }
Jack Hea355e5e2017-08-22 16:06:54 -070096 if (mSupportedFeatures != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +020097 ret += "Supported features: " + mSupportedFeatures + "\n";
98 }
Jack Hea355e5e2017-08-22 16:06:54 -070099 if (mProfileVersion != -1) {
100 ret += "Profile_version: " + mProfileVersion + "\n";
Casper Bonde238e0f92015-04-09 09:24:48 +0200101 }
102 return ret;
103 }
104
105 public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
106 public SdpMnsRecord createFromParcel(Parcel in) {
107 return new SdpMnsRecord(in);
108 }
Jack Hea355e5e2017-08-22 16:06:54 -0700109
Casper Bonde238e0f92015-04-09 09:24:48 +0200110 public SdpMnsRecord[] newArray(int size) {
111 return new SdpMnsRecord[size];
112 }
113 };
114}