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