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 SdpMnsRecord implements Parcelable { 22 private final int mL2capPsm; 23 private final int mRfcommChannelNumber; 24 private final int mSupportedFeatures; 25 private final int mProfileVersion; 26 private final String mServiceName; 27 28 public SdpMnsRecord(int l2capPsm, 29 int rfcommChannelNumber, 30 int profileVersion, 31 int supportedFeatures, 32 String serviceName) { 33 mL2capPsm = l2capPsm; 34 mRfcommChannelNumber = rfcommChannelNumber; 35 mSupportedFeatures = supportedFeatures; 36 mServiceName = serviceName; 37 mProfileVersion = profileVersion; 38 } 39 40 public SdpMnsRecord(Parcel in) { 41 mRfcommChannelNumber = in.readInt(); 42 mL2capPsm = in.readInt(); 43 mServiceName = in.readString(); 44 mSupportedFeatures = in.readInt(); 45 mProfileVersion = in.readInt(); 46 } 47 48 @Override 49 public int describeContents() { 50 // TODO Auto-generated method stub 51 return 0; 52 } 53 54 55 public int getL2capPsm() { 56 return mL2capPsm; 57 } 58 59 public int getRfcommChannelNumber() { 60 return mRfcommChannelNumber; 61 } 62 63 public int getSupportedFeatures() { 64 return mSupportedFeatures; 65 } 66 67 public String getServiceName() { 68 return mServiceName; 69 } 70 71 public int getProfileVersion() { 72 return mProfileVersion; 73 } 74 75 @Override 76 public void writeToParcel(Parcel dest, int flags) { 77 dest.writeInt(mRfcommChannelNumber); 78 dest.writeInt(mL2capPsm); 79 dest.writeString(mServiceName); 80 dest.writeInt(mSupportedFeatures); 81 dest.writeInt(mProfileVersion); 82 } 83 84 public String toString() { 85 String ret = "Bluetooth MNS SDP Record:\n"; 86 87 if (mRfcommChannelNumber != -1) { 88 ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n"; 89 } 90 if (mL2capPsm != -1) { 91 ret += "L2CAP PSM: " + mL2capPsm + "\n"; 92 } 93 if (mServiceName != null) { 94 ret += "Service Name: " + mServiceName + "\n"; 95 } 96 if (mSupportedFeatures != -1) { 97 ret += "Supported features: " + mSupportedFeatures + "\n"; 98 } 99 if (mProfileVersion != -1) { 100 ret += "Profile_version: " + mProfileVersion + "\n"; 101 } 102 return ret; 103 } 104 105 public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { 106 public SdpMnsRecord createFromParcel(Parcel in) { 107 return new SdpMnsRecord(in); 108 } 109 110 public SdpMnsRecord[] newArray(int size) { 111 return new SdpMnsRecord[size]; 112 } 113 }; 114} 115