blob: b202e536ba02270f2395e903a5c2d3daf954417d [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
Casper Bonde238e0f92015-04-09 09:24:48 +020030 public static final class MessageType {
Jack Hea355e5e2017-08-22 16:06:54 -070031 public static final int EMAIL = 0x01;
32 public static final int SMS_GSM = 0x02;
Casper Bonde238e0f92015-04-09 09:24:48 +020033 public static final int SMS_CDMA = 0x04;
Jack Hea355e5e2017-08-22 16:06:54 -070034 public static final int MMS = 0x08;
Casper Bonde238e0f92015-04-09 09:24:48 +020035 }
36
37 public SdpMasRecord(int mas_instance_id,
Jack Hea355e5e2017-08-22 16:06:54 -070038 int l2cap_psm,
39 int rfcomm_channel_number,
40 int profile_version,
41 int supported_features,
42 int supported_message_types,
43 String service_name) {
Casper Bonde238e0f92015-04-09 09:24:48 +020044 this.mMasInstanceId = mas_instance_id;
45 this.mL2capPsm = l2cap_psm;
46 this.mRfcommChannelNumber = rfcomm_channel_number;
47 this.mProfileVersion = profile_version;
48 this.mSupportedFeatures = supported_features;
49 this.mSupportedMessageTypes = supported_message_types;
50 this.mServiceName = service_name;
51 }
52
Jack Hea355e5e2017-08-22 16:06:54 -070053 public SdpMasRecord(Parcel in) {
Casper Bonde238e0f92015-04-09 09:24:48 +020054 this.mMasInstanceId = in.readInt();
55 this.mL2capPsm = in.readInt();
56 this.mRfcommChannelNumber = in.readInt();
57 this.mProfileVersion = in.readInt();
58 this.mSupportedFeatures = in.readInt();
59 this.mSupportedMessageTypes = in.readInt();
60 this.mServiceName = in.readString();
61 }
Jack Hea355e5e2017-08-22 16:06:54 -070062
Casper Bonde238e0f92015-04-09 09:24:48 +020063 @Override
64 public int describeContents() {
65 // TODO Auto-generated method stub
66 return 0;
67 }
68
69 public int getMasInstanceId() {
70 return mMasInstanceId;
71 }
72
73 public int getL2capPsm() {
74 return mL2capPsm;
75 }
76
77 public int getRfcommCannelNumber() {
78 return mRfcommChannelNumber;
79 }
80
81 public int getProfileVersion() {
82 return mProfileVersion;
83 }
84
85 public int getSupportedFeatures() {
86 return mSupportedFeatures;
87 }
88
89 public int getSupportedMessageTypes() {
90 return mSupportedMessageTypes;
91 }
Jack Hea355e5e2017-08-22 16:06:54 -070092
Casper Bonde238e0f92015-04-09 09:24:48 +020093 public boolean msgSupported(int msg) {
94 return (mSupportedMessageTypes & msg) != 0;
95 }
Jack Hea355e5e2017-08-22 16:06:54 -070096
Casper Bonde238e0f92015-04-09 09:24:48 +020097 public String getServiceName() {
98 return mServiceName;
99 }
100
101 @Override
102 public void writeToParcel(Parcel dest, int flags) {
103
104 dest.writeInt(this.mMasInstanceId);
105 dest.writeInt(this.mL2capPsm);
106 dest.writeInt(this.mRfcommChannelNumber);
107 dest.writeInt(this.mProfileVersion);
108 dest.writeInt(this.mSupportedFeatures);
109 dest.writeInt(this.mSupportedMessageTypes);
110 dest.writeString(this.mServiceName);
111
112 }
Jack Hea355e5e2017-08-22 16:06:54 -0700113
Casper Bonde238e0f92015-04-09 09:24:48 +0200114 @Override
Jack Hea355e5e2017-08-22 16:06:54 -0700115 public String toString() {
Casper Bonde238e0f92015-04-09 09:24:48 +0200116 String ret = "Bluetooth MAS SDP Record:\n";
117
Jack Hea355e5e2017-08-22 16:06:54 -0700118 if (mMasInstanceId != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200119 ret += "Mas Instance Id: " + mMasInstanceId + "\n";
120 }
Jack Hea355e5e2017-08-22 16:06:54 -0700121 if (mRfcommChannelNumber != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200122 ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
123 }
Jack Hea355e5e2017-08-22 16:06:54 -0700124 if (mL2capPsm != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200125 ret += "L2CAP PSM: " + mL2capPsm + "\n";
126 }
Jack Hea355e5e2017-08-22 16:06:54 -0700127 if (mServiceName != null) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200128 ret += "Service Name: " + mServiceName + "\n";
129 }
Jack Hea355e5e2017-08-22 16:06:54 -0700130 if (mProfileVersion != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200131 ret += "Profile version: " + mProfileVersion + "\n";
132 }
Jack Hea355e5e2017-08-22 16:06:54 -0700133 if (mSupportedMessageTypes != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200134 ret += "Supported msg types: " + mSupportedMessageTypes + "\n";
135 }
Jack Hea355e5e2017-08-22 16:06:54 -0700136 if (mSupportedFeatures != -1) {
Casper Bonde238e0f92015-04-09 09:24:48 +0200137 ret += "Supported features: " + mSupportedFeatures + "\n";
138 }
139 return ret;
140 }
141
142 public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
143 public SdpMasRecord createFromParcel(Parcel in) {
144 return new SdpMasRecord(in);
145 }
Jack Hea355e5e2017-08-22 16:06:54 -0700146
Casper Bonde238e0f92015-04-09 09:24:48 +0200147 public SdpRecord[] newArray(int size) {
148 return new SdpRecord[size];
149 }
150 };
151}