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