Casper Bonde | da177bb | 2015-04-16 15:28:21 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.bluetooth; |
| 18 | |
| 19 | import android.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
| 22 | /** @hide */ |
| 23 | public class SdpSapsRecord implements Parcelable { |
| 24 | private final int mRfcommChannelNumber; |
| 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 SdpSapsRecord(int rfcommChannelNumber, int profileVersion, String serviceName) { |
| 29 | mRfcommChannelNumber = rfcommChannelNumber; |
| 30 | mProfileVersion = profileVersion; |
| 31 | mServiceName = serviceName; |
Casper Bonde | da177bb | 2015-04-16 15:28:21 +0200 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | public SdpSapsRecord(Parcel in) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 35 | mRfcommChannelNumber = in.readInt(); |
| 36 | mProfileVersion = in.readInt(); |
| 37 | mServiceName = in.readString(); |
Casper Bonde | da177bb | 2015-04-16 15:28:21 +0200 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public int describeContents() { |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 42 | return 0; |
Casper Bonde | da177bb | 2015-04-16 15:28:21 +0200 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | public int getRfcommCannelNumber() { |
| 46 | return mRfcommChannelNumber; |
| 47 | } |
| 48 | |
| 49 | public int getProfileVersion() { |
| 50 | return mProfileVersion; |
| 51 | } |
| 52 | |
| 53 | public String getServiceName() { |
| 54 | return mServiceName; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public void writeToParcel(Parcel dest, int flags) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 59 | dest.writeInt(mRfcommChannelNumber); |
| 60 | dest.writeInt(mProfileVersion); |
| 61 | dest.writeString(mServiceName); |
Casper Bonde | da177bb | 2015-04-16 15:28:21 +0200 | [diff] [blame] | 62 | |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public String toString() { |
| 67 | String ret = "Bluetooth MAS SDP Record:\n"; |
| 68 | |
| 69 | if (mRfcommChannelNumber != -1) { |
| 70 | ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n"; |
| 71 | } |
| 72 | if (mServiceName != null) { |
| 73 | ret += "Service Name: " + mServiceName + "\n"; |
| 74 | } |
| 75 | if (mProfileVersion != -1) { |
| 76 | ret += "Profile version: " + mProfileVersion + "\n"; |
| 77 | } |
| 78 | return ret; |
| 79 | } |
| 80 | |
| 81 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { |
| 82 | public SdpSapsRecord createFromParcel(Parcel in) { |
| 83 | return new SdpSapsRecord(in); |
| 84 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 85 | |
Casper Bonde | da177bb | 2015-04-16 15:28:21 +0200 | [diff] [blame] | 86 | public SdpRecord[] newArray(int size) { |
| 87 | return new SdpRecord[size]; |
| 88 | } |
| 89 | }; |
| 90 | } |