blob: 72d49380b713aa2472ce830f5712d7946db0fd94 [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 SdpMasRecord implements Parcelable {
22 private final int mMasInstanceId;
23 private final int mL2capPsm;
24 private final int mRfcommChannelNumber;
25 private final int mProfileVersion;
26 private final int mSupportedFeatures;
27 private final int mSupportedMessageTypes;
28 private final String mServiceName;
Jack Hea355e5e2017-08-22 16:06:54 -070029
Jack He2992cd02017-08-22 21:21:23 -070030 /** Message type */
Casper Bonde238e0f92015-04-09 09:24:48 +020031 public static final class MessageType {
Jack Hea355e5e2017-08-22 16:06:54 -070032 public static final int EMAIL = 0x01;
33 public static final int SMS_GSM = 0x02;
Casper Bonde238e0f92015-04-09 09:24:48 +020034 public static final int SMS_CDMA = 0x04;
Jack Hea355e5e2017-08-22 16:06:54 -070035 public static final int MMS = 0x08;
Casper Bonde238e0f92015-04-09 09:24:48 +020036 }
37
Jack He2992cd02017-08-22 21:21:23 -070038 public SdpMasRecord(int masInstanceId,
39 int l2capPsm,
40 int rfcommChannelNumber,
41 int profileVersion,
42 int supportedFeatures,
43 int supportedMessageTypes,
44 String serviceName) {
45 mMasInstanceId = masInstanceId;
46 mL2capPsm = l2capPsm;
47 mRfcommChannelNumber = rfcommChannelNumber;
48 mProfileVersion = profileVersion;
49 mSupportedFeatures = supportedFeatures;
50 mSupportedMessageTypes = supportedMessageTypes;
51 mServiceName = serviceName;
Casper Bonde238e0f92015-04-09 09:24:48 +020052 }
53
Jack Hea355e5e2017-08-22 16:06:54 -070054 public SdpMasRecord(Parcel in) {
Jack He2992cd02017-08-22 21:21:23 -070055 mMasInstanceId = in.readInt();
56 mL2capPsm = in.readInt();
57 mRfcommChannelNumber = in.readInt();
58 mProfileVersion = in.readInt();
59 mSupportedFeatures = in.readInt();
60 mSupportedMessageTypes = in.readInt();
61 mServiceName = in.readString();
Casper Bonde238e0f92015-04-09 09:24:48 +020062 }
Jack Hea355e5e2017-08-22 16:06:54 -070063
Casper Bonde238e0f92015-04-09 09:24:48 +020064 @Override
65 public int describeContents() {
66 // TODO Auto-generated method stub
67 return 0;
68 }
69
70 public int getMasInstanceId() {
71 return mMasInstanceId;
72 }
73
74 public int getL2capPsm() {
75 return mL2capPsm;
76 }
77
78 public int getRfcommCannelNumber() {
79 return mRfcommChannelNumber;
80 }
81
82 public int getProfileVersion() {
83 return mProfileVersion;
84 }
85
86 public int getSupportedFeatures() {
87 return mSupportedFeatures;
88 }
89
90 public int getSupportedMessageTypes() {
91 return mSupportedMessageTypes;
92 }
Jack Hea355e5e2017-08-22 16:06:54 -070093
Casper Bonde238e0f92015-04-09 09:24:48 +020094 public boolean msgSupported(int msg) {
95 return (mSupportedMessageTypes & msg) != 0;
96 }
Jack Hea355e5e2017-08-22 16:06:54 -070097
Casper Bonde238e0f92015-04-09 09:24:48 +020098 public String getServiceName() {
99 return mServiceName;
100 }
101
102 @Override
103 public void writeToParcel(Parcel dest, int flags) {
Jack He2992cd02017-08-22 21:21:23 -0700104 dest.writeInt(mMasInstanceId);
105 dest.writeInt(mL2capPsm);
106 dest.writeInt(mRfcommChannelNumber);
107 dest.writeInt(mProfileVersion);
108 dest.writeInt(mSupportedFeatures);
109 dest.writeInt(mSupportedMessageTypes);
110 dest.writeString(mServiceName);
Casper Bonde238e0f92015-04-09 09:24:48 +0200111 }
Jack Hea355e5e2017-08-22 16:06:54 -0700112
Casper Bonde238e0f92015-04-09 09:24:48 +0200113 @Override
Jack Hea355e5e2017-08-22 16:06:54 -0700114 public String toString() {
Casper Bonde238e0f92015-04-09 09:24:48 +0200115 String ret = "Bluetooth MAS SDP Record:\n";
116
Jack Hea355e5e2017-08-22 16:06:54 -0700117 if (mMasInstanceId != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200118 ret += "Mas Instance Id: " + mMasInstanceId + "\n";
119 }
Jack Hea355e5e2017-08-22 16:06:54 -0700120 if (mRfcommChannelNumber != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200121 ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
122 }
Jack Hea355e5e2017-08-22 16:06:54 -0700123 if (mL2capPsm != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200124 ret += "L2CAP PSM: " + mL2capPsm + "\n";
125 }
Jack Hea355e5e2017-08-22 16:06:54 -0700126 if (mServiceName != null) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200127 ret += "Service Name: " + mServiceName + "\n";
128 }
Jack Hea355e5e2017-08-22 16:06:54 -0700129 if (mProfileVersion != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200130 ret += "Profile version: " + mProfileVersion + "\n";
131 }
Jack Hea355e5e2017-08-22 16:06:54 -0700132 if (mSupportedMessageTypes != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200133 ret += "Supported msg types: " + mSupportedMessageTypes + "\n";
134 }
Jack Hea355e5e2017-08-22 16:06:54 -0700135 if (mSupportedFeatures != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200136 ret += "Supported features: " + mSupportedFeatures + "\n";
137 }
138 return ret;
139 }
140
141 public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
142 public SdpMasRecord createFromParcel(Parcel in) {
143 return new SdpMasRecord(in);
144 }
Jack Hea355e5e2017-08-22 16:06:54 -0700145
Casper Bonde238e0f92015-04-09 09:24:48 +0200146 public SdpRecord[] newArray(int size) {
147 return new SdpRecord[size];
148 }
149 };
150}