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*/ 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; 29 public static final class MessageType { 30 public static final int EMAIL = 0x01; 31 public static final int SMS_GSM = 0x02; 32 public static final int SMS_CDMA = 0x04; 33 public static final int MMS = 0x08; 34 } 35 36 public SdpMasRecord(int mas_instance_id, 37 int l2cap_psm, 38 int rfcomm_channel_number, 39 int profile_version, 40 int supported_features, 41 int supported_message_types, 42 String service_name){ 43 this.mMasInstanceId = mas_instance_id; 44 this.mL2capPsm = l2cap_psm; 45 this.mRfcommChannelNumber = rfcomm_channel_number; 46 this.mProfileVersion = profile_version; 47 this.mSupportedFeatures = supported_features; 48 this.mSupportedMessageTypes = supported_message_types; 49 this.mServiceName = service_name; 50 } 51 52 public SdpMasRecord(Parcel in){ 53 this.mMasInstanceId = in.readInt(); 54 this.mL2capPsm = in.readInt(); 55 this.mRfcommChannelNumber = in.readInt(); 56 this.mProfileVersion = in.readInt(); 57 this.mSupportedFeatures = in.readInt(); 58 this.mSupportedMessageTypes = in.readInt(); 59 this.mServiceName = in.readString(); 60 } 61 @Override 62 public int describeContents() { 63 // TODO Auto-generated method stub 64 return 0; 65 } 66 67 public int getMasInstanceId() { 68 return mMasInstanceId; 69 } 70 71 public int getL2capPsm() { 72 return mL2capPsm; 73 } 74 75 public int getRfcommCannelNumber() { 76 return mRfcommChannelNumber; 77 } 78 79 public int getProfileVersion() { 80 return mProfileVersion; 81 } 82 83 public int getSupportedFeatures() { 84 return mSupportedFeatures; 85 } 86 87 public int getSupportedMessageTypes() { 88 return mSupportedMessageTypes; 89 } 90 91 public boolean msgSupported(int msg) { 92 return (mSupportedMessageTypes & msg) != 0; 93 } 94 95 public String getServiceName() { 96 return mServiceName; 97 } 98 99 @Override 100 public void writeToParcel(Parcel dest, int flags) { 101 102 dest.writeInt(this.mMasInstanceId); 103 dest.writeInt(this.mL2capPsm); 104 dest.writeInt(this.mRfcommChannelNumber); 105 dest.writeInt(this.mProfileVersion); 106 dest.writeInt(this.mSupportedFeatures); 107 dest.writeInt(this.mSupportedMessageTypes); 108 dest.writeString(this.mServiceName); 109 110 } 111 @Override 112 public String toString(){ 113 String ret = "Bluetooth MAS SDP Record:\n"; 114 115 if(mMasInstanceId != -1){ 116 ret += "Mas Instance Id: " + mMasInstanceId + "\n"; 117 } 118 if(mRfcommChannelNumber != -1){ 119 ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n"; 120 } 121 if(mL2capPsm != -1){ 122 ret += "L2CAP PSM: " + mL2capPsm + "\n"; 123 } 124 if(mServiceName != null){ 125 ret += "Service Name: " + mServiceName + "\n"; 126 } 127 if(mProfileVersion != -1){ 128 ret += "Profile version: " + mProfileVersion + "\n"; 129 } 130 if(mSupportedMessageTypes != -1){ 131 ret += "Supported msg types: " + mSupportedMessageTypes + "\n"; 132 } 133 if(mSupportedFeatures != -1){ 134 ret += "Supported features: " + mSupportedFeatures + "\n"; 135 } 136 return ret; 137 } 138 139 public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 140 public SdpMasRecord createFromParcel(Parcel in) { 141 return new SdpMasRecord(in); 142 } 143 public SdpRecord[] newArray(int size) { 144 return new SdpRecord[size]; 145 } 146 }; 147} 148