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 | |
| 28 | public SdpSapsRecord(int rfcomm_channel_number, |
| 29 | int profile_version, |
| 30 | String service_name) { |
| 31 | this.mRfcommChannelNumber = rfcomm_channel_number; |
| 32 | this.mProfileVersion = profile_version; |
| 33 | this.mServiceName = service_name; |
| 34 | } |
| 35 | |
| 36 | public SdpSapsRecord(Parcel in) { |
| 37 | this.mRfcommChannelNumber = in.readInt(); |
| 38 | this.mProfileVersion = in.readInt(); |
| 39 | this.mServiceName = in.readString(); |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public int describeContents() { |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 44 | return 0; |
Casper Bonde | da177bb | 2015-04-16 15:28:21 +0200 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | public int getRfcommCannelNumber() { |
| 48 | return mRfcommChannelNumber; |
| 49 | } |
| 50 | |
| 51 | public int getProfileVersion() { |
| 52 | return mProfileVersion; |
| 53 | } |
| 54 | |
| 55 | public String getServiceName() { |
| 56 | return mServiceName; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public void writeToParcel(Parcel dest, int flags) { |
| 61 | dest.writeInt(this.mRfcommChannelNumber); |
| 62 | dest.writeInt(this.mProfileVersion); |
| 63 | dest.writeString(this.mServiceName); |
| 64 | |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public String toString() { |
| 69 | String ret = "Bluetooth MAS SDP Record:\n"; |
| 70 | |
| 71 | if (mRfcommChannelNumber != -1) { |
| 72 | ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n"; |
| 73 | } |
| 74 | if (mServiceName != null) { |
| 75 | ret += "Service Name: " + mServiceName + "\n"; |
| 76 | } |
| 77 | if (mProfileVersion != -1) { |
| 78 | ret += "Profile version: " + mProfileVersion + "\n"; |
| 79 | } |
| 80 | return ret; |
| 81 | } |
| 82 | |
| 83 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { |
| 84 | public SdpSapsRecord createFromParcel(Parcel in) { |
| 85 | return new SdpSapsRecord(in); |
| 86 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 87 | |
Casper Bonde | da177bb | 2015-04-16 15:28:21 +0200 | [diff] [blame] | 88 | public SdpRecord[] newArray(int size) { |
| 89 | return new SdpRecord[size]; |
| 90 | } |
| 91 | }; |
| 92 | } |