1 /*
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 package android.bluetooth;
16 
17 import android.os.Parcel;
18 import android.os.Parcelable;
19 
20 /** @hide */
21 public 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;
29 
30     /** Message type */
31     public static final class MessageType {
32         public static final int EMAIL = 0x01;
33         public static final int SMS_GSM = 0x02;
34         public static final int SMS_CDMA = 0x04;
35         public static final int MMS = 0x08;
36     }
37 
SdpMasRecord(int masInstanceId, int l2capPsm, int rfcommChannelNumber, int profileVersion, int supportedFeatures, int supportedMessageTypes, String serviceName)38     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;
52     }
53 
SdpMasRecord(Parcel in)54     public SdpMasRecord(Parcel in) {
55         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();
62     }
63 
64     @Override
describeContents()65     public int describeContents() {
66         // TODO Auto-generated method stub
67         return 0;
68     }
69 
getMasInstanceId()70     public int getMasInstanceId() {
71         return mMasInstanceId;
72     }
73 
getL2capPsm()74     public int getL2capPsm() {
75         return mL2capPsm;
76     }
77 
getRfcommCannelNumber()78     public int getRfcommCannelNumber() {
79         return mRfcommChannelNumber;
80     }
81 
getProfileVersion()82     public int getProfileVersion() {
83         return mProfileVersion;
84     }
85 
getSupportedFeatures()86     public int getSupportedFeatures() {
87         return mSupportedFeatures;
88     }
89 
getSupportedMessageTypes()90     public int getSupportedMessageTypes() {
91         return mSupportedMessageTypes;
92     }
93 
msgSupported(int msg)94     public boolean msgSupported(int msg) {
95         return (mSupportedMessageTypes & msg) != 0;
96     }
97 
getServiceName()98     public String getServiceName() {
99         return mServiceName;
100     }
101 
102     @Override
writeToParcel(Parcel dest, int flags)103     public void writeToParcel(Parcel dest, int flags) {
104         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);
111     }
112 
113     @Override
toString()114     public String toString() {
115         String ret = "Bluetooth MAS SDP Record:\n";
116 
117         if (mMasInstanceId != -1) {
118             ret += "Mas Instance Id: " + mMasInstanceId + "\n";
119         }
120         if (mRfcommChannelNumber != -1) {
121             ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
122         }
123         if (mL2capPsm != -1) {
124             ret += "L2CAP PSM: " + mL2capPsm + "\n";
125         }
126         if (mServiceName != null) {
127             ret += "Service Name: " + mServiceName + "\n";
128         }
129         if (mProfileVersion != -1) {
130             ret += "Profile version: " + mProfileVersion + "\n";
131         }
132         if (mSupportedMessageTypes != -1) {
133             ret += "Supported msg types: " + mSupportedMessageTypes + "\n";
134         }
135         if (mSupportedFeatures != -1) {
136             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         }
145 
146         public SdpRecord[] newArray(int size) {
147             return new SdpRecord[size];
148         }
149     };
150 }
151