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 | |
| 16 | package android.bluetooth; |
| 17 | |
| 18 | import android.os.Parcel; |
| 19 | import android.os.Parcelable; |
| 20 | |
| 21 | /** @hide */ |
| 22 | public class SdpPseRecord implements Parcelable { |
| 23 | private final int mL2capPsm; |
| 24 | private final int mRfcommChannelNumber; |
| 25 | private final int mProfileVersion; |
| 26 | private final int mSupportedFeatures; |
| 27 | private final int mSupportedRepositories; |
| 28 | private final String mServiceName; |
| 29 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 30 | public SdpPseRecord(int l2capPsm, |
| 31 | int rfcommChannelNumber, |
| 32 | int profileVersion, |
| 33 | int supportedFeatures, |
| 34 | int supportedRepositories, |
| 35 | String serviceName) { |
| 36 | mL2capPsm = l2capPsm; |
| 37 | mRfcommChannelNumber = rfcommChannelNumber; |
| 38 | mProfileVersion = profileVersion; |
| 39 | mSupportedFeatures = supportedFeatures; |
| 40 | mSupportedRepositories = supportedRepositories; |
| 41 | mServiceName = serviceName; |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 42 | } |
| 43 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 44 | public SdpPseRecord(Parcel in) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 45 | mRfcommChannelNumber = in.readInt(); |
| 46 | mL2capPsm = in.readInt(); |
| 47 | mProfileVersion = in.readInt(); |
| 48 | mSupportedFeatures = in.readInt(); |
| 49 | mSupportedRepositories = in.readInt(); |
| 50 | mServiceName = in.readString(); |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 51 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 52 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 53 | @Override |
| 54 | public int describeContents() { |
| 55 | // TODO Auto-generated method stub |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | public int getL2capPsm() { |
| 60 | return mL2capPsm; |
| 61 | } |
| 62 | |
| 63 | public int getRfcommChannelNumber() { |
| 64 | return mRfcommChannelNumber; |
| 65 | } |
| 66 | |
| 67 | public int getSupportedFeatures() { |
| 68 | return mSupportedFeatures; |
| 69 | } |
| 70 | |
| 71 | public String getServiceName() { |
| 72 | return mServiceName; |
| 73 | } |
| 74 | |
| 75 | public int getProfileVersion() { |
| 76 | return mProfileVersion; |
| 77 | } |
| 78 | |
| 79 | public int getSupportedRepositories() { |
| 80 | return mSupportedRepositories; |
| 81 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 82 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 83 | @Override |
| 84 | public void writeToParcel(Parcel dest, int flags) { |
| 85 | dest.writeInt(mRfcommChannelNumber); |
| 86 | dest.writeInt(mL2capPsm); |
| 87 | dest.writeInt(mProfileVersion); |
| 88 | dest.writeInt(mSupportedFeatures); |
| 89 | dest.writeInt(mSupportedRepositories); |
| 90 | dest.writeString(mServiceName); |
| 91 | |
| 92 | } |
| 93 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 94 | @Override |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 95 | public String toString() { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 96 | String ret = "Bluetooth MNS SDP Record:\n"; |
| 97 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 98 | if (mRfcommChannelNumber != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 99 | ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n"; |
| 100 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 101 | if (mL2capPsm != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 102 | ret += "L2CAP PSM: " + mL2capPsm + "\n"; |
| 103 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 104 | if (mProfileVersion != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 105 | ret += "profile version: " + mProfileVersion + "\n"; |
| 106 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 107 | if (mServiceName != null) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 108 | ret += "Service Name: " + mServiceName + "\n"; |
| 109 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 110 | if (mSupportedFeatures != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 111 | ret += "Supported features: " + mSupportedFeatures + "\n"; |
| 112 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 113 | if (mSupportedRepositories != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 114 | ret += "Supported repositories: " + mSupportedRepositories + "\n"; |
| 115 | } |
| 116 | |
| 117 | return ret; |
| 118 | } |
| 119 | |
| 120 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { |
| 121 | public SdpPseRecord createFromParcel(Parcel in) { |
| 122 | return new SdpPseRecord(in); |
| 123 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 124 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 125 | public SdpPseRecord[] newArray(int size) { |
| 126 | return new SdpPseRecord[size]; |
| 127 | } |
| 128 | }; |
| 129 | } |