blob: 72249d0585c63f8fd08774bd9ae4de5f1b288bcd [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*/
15
16package android.bluetooth;
17
18import android.os.Parcel;
19import android.os.Parcelable;
20
21/** @hide */
22public 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
Jack He2992cd02017-08-22 21:21:23 -070030 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;
Casper Bonde238e0f92015-04-09 09:24:48 +020042 }
43
Jack Hea355e5e2017-08-22 16:06:54 -070044 public SdpPseRecord(Parcel in) {
Jack He2992cd02017-08-22 21:21:23 -070045 mRfcommChannelNumber = in.readInt();
46 mL2capPsm = in.readInt();
47 mProfileVersion = in.readInt();
48 mSupportedFeatures = in.readInt();
49 mSupportedRepositories = in.readInt();
50 mServiceName = in.readString();
Casper Bonde238e0f92015-04-09 09:24:48 +020051 }
Jack Hea355e5e2017-08-22 16:06:54 -070052
Casper Bonde238e0f92015-04-09 09:24:48 +020053 @Override
54 public int describeContents() {
55 // TODO Auto-generated method stub
56 return 0;
57 }
58
59 public int getL2capPsm() {
60 return mL2capPsm;
61 }
62
63 public int getRfcommChannelNumber() {
64 return mRfcommChannelNumber;
65 }
66
67 public int getSupportedFeatures() {
68 return mSupportedFeatures;
69 }
70
71 public String getServiceName() {
72 return mServiceName;
73 }
74
75 public int getProfileVersion() {
76 return mProfileVersion;
77 }
78
79 public int getSupportedRepositories() {
80 return mSupportedRepositories;
81 }
Jack Hea355e5e2017-08-22 16:06:54 -070082
Casper Bonde238e0f92015-04-09 09:24:48 +020083 @Override
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
Jack He2992cd02017-08-22 21:21:23 -070094 @Override
Jack Hea355e5e2017-08-22 16:06:54 -070095 public String toString() {
Casper Bonde238e0f92015-04-09 09:24:48 +020096 String ret = "Bluetooth MNS SDP Record:\n";
97
Jack Hea355e5e2017-08-22 16:06:54 -070098 if (mRfcommChannelNumber != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +020099 ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
100 }
Jack Hea355e5e2017-08-22 16:06:54 -0700101 if (mL2capPsm != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200102 ret += "L2CAP PSM: " + mL2capPsm + "\n";
103 }
Jack Hea355e5e2017-08-22 16:06:54 -0700104 if (mProfileVersion != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200105 ret += "profile version: " + mProfileVersion + "\n";
106 }
Jack Hea355e5e2017-08-22 16:06:54 -0700107 if (mServiceName != null) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200108 ret += "Service Name: " + mServiceName + "\n";
109 }
Jack Hea355e5e2017-08-22 16:06:54 -0700110 if (mSupportedFeatures != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200111 ret += "Supported features: " + mSupportedFeatures + "\n";
112 }
Jack Hea355e5e2017-08-22 16:06:54 -0700113 if (mSupportedRepositories != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200114 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 }
Jack Hea355e5e2017-08-22 16:06:54 -0700124
Casper Bonde238e0f92015-04-09 09:24:48 +0200125 public SdpPseRecord[] newArray(int size) {
126 return new SdpPseRecord[size];
127 }
128 };
129}