Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 22 | /** |
Jakub Pawlowski | c0e8ff3 | 2016-04-14 06:06:00 -0700 | [diff] [blame] | 23 | * Out Of Band Data for Bluetooth device pairing. |
| 24 | * |
| 25 | * <p>This object represents optional data obtained from a remote device through |
| 26 | * an out-of-band channel (eg. NFC). |
| 27 | * |
Jeff Sharkey | fa6a1bc | 2016-03-01 17:36:23 -0700 | [diff] [blame] | 28 | * @hide |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 29 | */ |
Jeff Sharkey | 9ad443f | 2016-03-01 17:28:36 -0700 | [diff] [blame] | 30 | public class OobData implements Parcelable { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 31 | private byte[] mLeBluetoothDeviceAddress; |
| 32 | private byte[] mSecurityManagerTk; |
| 33 | private byte[] mLeSecureConnectionsConfirmation; |
| 34 | private byte[] mLeSecureConnectionsRandom; |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 35 | |
Jakub Pawlowski | f465823 | 2016-11-09 16:51:09 -0800 | [diff] [blame] | 36 | public byte[] getLeBluetoothDeviceAddress() { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 37 | return mLeBluetoothDeviceAddress; |
Jakub Pawlowski | f465823 | 2016-11-09 16:51:09 -0800 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Sets the LE Bluetooth Device Address value to be used during LE pairing. |
| 42 | * The value shall be 7 bytes. Please see Bluetooth CSSv6, Part A 1.16 for |
| 43 | * a detailed description. |
| 44 | */ |
| 45 | public void setLeBluetoothDeviceAddress(byte[] leBluetoothDeviceAddress) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 46 | mLeBluetoothDeviceAddress = leBluetoothDeviceAddress; |
Jakub Pawlowski | f465823 | 2016-11-09 16:51:09 -0800 | [diff] [blame] | 47 | } |
| 48 | |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 49 | public byte[] getSecurityManagerTk() { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 50 | return mSecurityManagerTk; |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 51 | } |
| 52 | |
Jakub Pawlowski | c0e8ff3 | 2016-04-14 06:06:00 -0700 | [diff] [blame] | 53 | /** |
| 54 | * Sets the Temporary Key value to be used by the LE Security Manager during |
| 55 | * LE pairing. The value shall be 16 bytes. Please see Bluetooth CSSv6, |
| 56 | * Part A 1.8 for a detailed description. |
| 57 | */ |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 58 | public void setSecurityManagerTk(byte[] securityManagerTk) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 59 | mSecurityManagerTk = securityManagerTk; |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 60 | } |
| 61 | |
Jakub Pawlowski | 747711c | 2016-07-28 05:21:36 -0700 | [diff] [blame] | 62 | public byte[] getLeSecureConnectionsConfirmation() { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 63 | return mLeSecureConnectionsConfirmation; |
Jakub Pawlowski | 747711c | 2016-07-28 05:21:36 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | public void setLeSecureConnectionsConfirmation(byte[] leSecureConnectionsConfirmation) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 67 | mLeSecureConnectionsConfirmation = leSecureConnectionsConfirmation; |
Jakub Pawlowski | 747711c | 2016-07-28 05:21:36 -0700 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | public byte[] getLeSecureConnectionsRandom() { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 71 | return mLeSecureConnectionsRandom; |
Jakub Pawlowski | 747711c | 2016-07-28 05:21:36 -0700 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | public void setLeSecureConnectionsRandom(byte[] leSecureConnectionsRandom) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 75 | mLeSecureConnectionsRandom = leSecureConnectionsRandom; |
Jakub Pawlowski | 747711c | 2016-07-28 05:21:36 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 78 | public OobData() { |
| 79 | } |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 80 | |
| 81 | private OobData(Parcel in) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 82 | mLeBluetoothDeviceAddress = in.createByteArray(); |
| 83 | mSecurityManagerTk = in.createByteArray(); |
| 84 | mLeSecureConnectionsConfirmation = in.createByteArray(); |
| 85 | mLeSecureConnectionsRandom = in.createByteArray(); |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 86 | } |
| 87 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 88 | @Override |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 89 | public int describeContents() { |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public void writeToParcel(Parcel out, int flags) { |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 95 | out.writeByteArray(mLeBluetoothDeviceAddress); |
| 96 | out.writeByteArray(mSecurityManagerTk); |
| 97 | out.writeByteArray(mLeSecureConnectionsConfirmation); |
| 98 | out.writeByteArray(mLeSecureConnectionsRandom); |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 99 | } |
| 100 | |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 101 | public static final Parcelable.Creator<OobData> CREATOR = |
| 102 | new Parcelable.Creator<OobData>() { |
Jakub Pawlowski | 2fc6e6b | 2015-12-29 13:19:21 -0800 | [diff] [blame] | 103 | public OobData createFromParcel(Parcel in) { |
| 104 | return new OobData(in); |
| 105 | } |
| 106 | |
| 107 | public OobData[] newArray(int size) { |
| 108 | return new OobData[size]; |
| 109 | } |
| 110 | }; |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 111 | } |