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 | import java.util.Arrays; |
| 22 | |
| 23 | /** @hide */ |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 24 | public class SdpRecord implements Parcelable { |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 25 | |
| 26 | private final byte[] mRawData; |
| 27 | private final int mRawSize; |
| 28 | |
| 29 | @Override |
| 30 | public String toString() { |
| 31 | return "BluetoothSdpRecord [rawData=" + Arrays.toString(mRawData) |
| 32 | + ", rawSize=" + mRawSize + "]"; |
| 33 | } |
| 34 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 35 | public SdpRecord(int sizeRecord, byte[] record) { |
| 36 | mRawData = record; |
| 37 | mRawSize = sizeRecord; |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 38 | } |
| 39 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 40 | public SdpRecord(Parcel in) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 41 | mRawSize = in.readInt(); |
| 42 | mRawData = new byte[mRawSize]; |
| 43 | in.readByteArray(mRawData); |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 44 | |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public int describeContents() { |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public void writeToParcel(Parcel dest, int flags) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 54 | dest.writeInt(mRawSize); |
| 55 | dest.writeByteArray(mRawData); |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 56 | |
| 57 | |
| 58 | } |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 59 | |
Casper Bonde | 238e0f9 | 2015-04-09 09:24:48 +0200 | [diff] [blame] | 60 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { |
| 61 | public SdpRecord createFromParcel(Parcel in) { |
| 62 | return new SdpRecord(in); |
| 63 | } |
| 64 | |
| 65 | public SdpRecord[] newArray(int size) { |
| 66 | return new SdpRecord[size]; |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | public byte[] getRawData() { |
| 71 | return mRawData; |
| 72 | } |
| 73 | |
| 74 | public int getRawSize() { |
| 75 | return mRawSize; |
| 76 | } |
| 77 | } |