• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
94     /** @hide */
msgSupported(int msg)95     public boolean msgSupported(int msg) {
96         return (mSupportedMessageTypes & msg) != 0;
97     }
98 
getServiceName()99     public String getServiceName() {
100         return mServiceName;
101     }
102 
103     @Override
writeToParcel(Parcel dest, int flags)104     public void writeToParcel(Parcel dest, int flags) {
105         dest.writeInt(mMasInstanceId);
106         dest.writeInt(mL2capPsm);
107         dest.writeInt(mRfcommChannelNumber);
108         dest.writeInt(mProfileVersion);
109         dest.writeInt(mSupportedFeatures);
110         dest.writeInt(mSupportedMessageTypes);
111         dest.writeString(mServiceName);
112     }
113 
114     @Override
toString()115     public String toString() {
116         String ret = "Bluetooth MAS SDP Record:\n";
117 
118         if (mMasInstanceId != -1) {
119             ret += "Mas Instance Id: " + mMasInstanceId + "\n";
120         }
121         if (mRfcommChannelNumber != -1) {
122             ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n";
123         }
124         if (mL2capPsm != -1) {
125             ret += "L2CAP PSM: " + mL2capPsm + "\n";
126         }
127         if (mServiceName != null) {
128             ret += "Service Name: " + mServiceName + "\n";
129         }
130         if (mProfileVersion != -1) {
131             ret += "Profile version: " + mProfileVersion + "\n";
132         }
133         if (mSupportedMessageTypes != -1) {
134             ret += "Supported msg types: " + mSupportedMessageTypes + "\n";
135         }
136         if (mSupportedFeatures != -1) {
137             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         }
146 
147         public SdpRecord[] newArray(int size) {
148             return new SdpRecord[size];
149         }
150     };
151 }
152