Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 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 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 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 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; |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 38 | } |
| 39 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 40 | public SdpMnsRecord(Parcel in) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 41 | mRfcommChannelNumber = in.readInt(); |
| 42 | mL2capPsm = in.readInt(); |
| 43 | mServiceName = in.readString(); |
| 44 | mSupportedFeatures = in.readInt(); |
| 45 | mProfileVersion = in.readInt(); |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 46 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 47 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 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 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 84 | public String toString() { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 85 | String ret = "Bluetooth MNS SDP Record:\n"; |
| 86 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 87 | if (mRfcommChannelNumber != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 88 | ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n"; |
| 89 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 90 | if (mL2capPsm != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 91 | ret += "L2CAP PSM: " + mL2capPsm + "\n"; |
| 92 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 93 | if (mServiceName != null) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 94 | ret += "Service Name: " + mServiceName + "\n"; |
| 95 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 96 | if (mSupportedFeatures != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 97 | ret += "Supported features: " + mSupportedFeatures + "\n"; |
| 98 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 99 | if (mProfileVersion != -1) { |
| 100 | ret += "Profile_version: " + mProfileVersion + "\n"; |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 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 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 109 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 110 | public SdpMnsRecord[] newArray(int size) { |
| 111 | return new SdpMnsRecord[size]; |
| 112 | } |
| 113 | }; |
| 114 | } |