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