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 SdpMasRecord implements Parcelable { |
| 22 | private final int mMasInstanceId; |
| 23 | private final int mL2capPsm; |
| 24 | private final int mRfcommChannelNumber; |
| 25 | private final int mProfileVersion; |
| 26 | private final int mSupportedFeatures; |
| 27 | private final int mSupportedMessageTypes; |
| 28 | private final String mServiceName; |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 29 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 30 | public static final class MessageType { |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 31 | public static final int EMAIL = 0x01; |
| 32 | public static final int SMS_GSM = 0x02; |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 33 | public static final int SMS_CDMA = 0x04; |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 34 | public static final int MMS = 0x08; |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | public SdpMasRecord(int mas_instance_id, |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 38 | int l2cap_psm, |
| 39 | int rfcomm_channel_number, |
| 40 | int profile_version, |
| 41 | int supported_features, |
| 42 | int supported_message_types, |
| 43 | String service_name) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 44 | this.mMasInstanceId = mas_instance_id; |
| 45 | this.mL2capPsm = l2cap_psm; |
| 46 | this.mRfcommChannelNumber = rfcomm_channel_number; |
| 47 | this.mProfileVersion = profile_version; |
| 48 | this.mSupportedFeatures = supported_features; |
| 49 | this.mSupportedMessageTypes = supported_message_types; |
| 50 | this.mServiceName = service_name; |
| 51 | } |
| 52 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 53 | public SdpMasRecord(Parcel in) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 54 | this.mMasInstanceId = in.readInt(); |
| 55 | this.mL2capPsm = in.readInt(); |
| 56 | this.mRfcommChannelNumber = in.readInt(); |
| 57 | this.mProfileVersion = in.readInt(); |
| 58 | this.mSupportedFeatures = in.readInt(); |
| 59 | this.mSupportedMessageTypes = in.readInt(); |
| 60 | this.mServiceName = in.readString(); |
| 61 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 62 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 63 | @Override |
| 64 | public int describeContents() { |
| 65 | // TODO Auto-generated method stub |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | public int getMasInstanceId() { |
| 70 | return mMasInstanceId; |
| 71 | } |
| 72 | |
| 73 | public int getL2capPsm() { |
| 74 | return mL2capPsm; |
| 75 | } |
| 76 | |
| 77 | public int getRfcommCannelNumber() { |
| 78 | return mRfcommChannelNumber; |
| 79 | } |
| 80 | |
| 81 | public int getProfileVersion() { |
| 82 | return mProfileVersion; |
| 83 | } |
| 84 | |
| 85 | public int getSupportedFeatures() { |
| 86 | return mSupportedFeatures; |
| 87 | } |
| 88 | |
| 89 | public int getSupportedMessageTypes() { |
| 90 | return mSupportedMessageTypes; |
| 91 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 92 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 93 | public boolean msgSupported(int msg) { |
| 94 | return (mSupportedMessageTypes & msg) != 0; |
| 95 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 96 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 97 | public String getServiceName() { |
| 98 | return mServiceName; |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public void writeToParcel(Parcel dest, int flags) { |
| 103 | |
| 104 | dest.writeInt(this.mMasInstanceId); |
| 105 | dest.writeInt(this.mL2capPsm); |
| 106 | dest.writeInt(this.mRfcommChannelNumber); |
| 107 | dest.writeInt(this.mProfileVersion); |
| 108 | dest.writeInt(this.mSupportedFeatures); |
| 109 | dest.writeInt(this.mSupportedMessageTypes); |
| 110 | dest.writeString(this.mServiceName); |
| 111 | |
| 112 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 113 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 114 | @Override |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 115 | public String toString() { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 116 | String ret = "Bluetooth MAS SDP Record:\n"; |
| 117 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 118 | if (mMasInstanceId != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 119 | ret += "Mas Instance Id: " + mMasInstanceId + "\n"; |
| 120 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 121 | if (mRfcommChannelNumber != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 122 | ret += "RFCOMM Chan Number: " + mRfcommChannelNumber + "\n"; |
| 123 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 124 | if (mL2capPsm != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 125 | ret += "L2CAP PSM: " + mL2capPsm + "\n"; |
| 126 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 127 | if (mServiceName != null) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 128 | ret += "Service Name: " + mServiceName + "\n"; |
| 129 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 130 | if (mProfileVersion != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 131 | ret += "Profile version: " + mProfileVersion + "\n"; |
| 132 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 133 | if (mSupportedMessageTypes != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 134 | ret += "Supported msg types: " + mSupportedMessageTypes + "\n"; |
| 135 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 136 | if (mSupportedFeatures != -1) { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 137 | ret += "Supported features: " + mSupportedFeatures + "\n"; |
| 138 | } |
| 139 | return ret; |
| 140 | } |
| 141 | |
| 142 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { |
| 143 | public SdpMasRecord createFromParcel(Parcel in) { |
| 144 | return new SdpMasRecord(in); |
| 145 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame^] | 146 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 147 | public SdpRecord[] newArray(int size) { |
| 148 | return new SdpRecord[size]; |
| 149 | } |
| 150 | }; |
| 151 | } |