blob: d6325728697557959ee708dcafd0dd5c2446d00e [file] [log] [blame]
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -08001/*
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
17package android.bluetooth;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080022/**
Jakub Pawlowskic0e8ff32016-04-14 06:06:00 -070023 * 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 Sharkeyfa6a1bc2016-03-01 17:36:23 -070028 * @hide
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080029 */
Jeff Sharkey9ad443f2016-03-01 17:28:36 -070030public class OobData implements Parcelable {
Jack He2992cd02017-08-22 21:21:23 -070031 private byte[] mLeBluetoothDeviceAddress;
32 private byte[] mSecurityManagerTk;
33 private byte[] mLeSecureConnectionsConfirmation;
34 private byte[] mLeSecureConnectionsRandom;
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080035
Jakub Pawlowskif4658232016-11-09 16:51:09 -080036 public byte[] getLeBluetoothDeviceAddress() {
Jack He2992cd02017-08-22 21:21:23 -070037 return mLeBluetoothDeviceAddress;
Jakub Pawlowskif4658232016-11-09 16:51:09 -080038 }
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 He2992cd02017-08-22 21:21:23 -070046 mLeBluetoothDeviceAddress = leBluetoothDeviceAddress;
Jakub Pawlowskif4658232016-11-09 16:51:09 -080047 }
48
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080049 public byte[] getSecurityManagerTk() {
Jack He2992cd02017-08-22 21:21:23 -070050 return mSecurityManagerTk;
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080051 }
52
Jakub Pawlowskic0e8ff32016-04-14 06:06:00 -070053 /**
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 Pawlowski2fc6e6b2015-12-29 13:19:21 -080058 public void setSecurityManagerTk(byte[] securityManagerTk) {
Jack He2992cd02017-08-22 21:21:23 -070059 mSecurityManagerTk = securityManagerTk;
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080060 }
61
Jakub Pawlowski747711c2016-07-28 05:21:36 -070062 public byte[] getLeSecureConnectionsConfirmation() {
Jack He2992cd02017-08-22 21:21:23 -070063 return mLeSecureConnectionsConfirmation;
Jakub Pawlowski747711c2016-07-28 05:21:36 -070064 }
65
66 public void setLeSecureConnectionsConfirmation(byte[] leSecureConnectionsConfirmation) {
Jack He2992cd02017-08-22 21:21:23 -070067 mLeSecureConnectionsConfirmation = leSecureConnectionsConfirmation;
Jakub Pawlowski747711c2016-07-28 05:21:36 -070068 }
69
70 public byte[] getLeSecureConnectionsRandom() {
Jack He2992cd02017-08-22 21:21:23 -070071 return mLeSecureConnectionsRandom;
Jakub Pawlowski747711c2016-07-28 05:21:36 -070072 }
73
74 public void setLeSecureConnectionsRandom(byte[] leSecureConnectionsRandom) {
Jack He2992cd02017-08-22 21:21:23 -070075 mLeSecureConnectionsRandom = leSecureConnectionsRandom;
Jakub Pawlowski747711c2016-07-28 05:21:36 -070076 }
77
Jack Hea355e5e2017-08-22 16:06:54 -070078 public OobData() {
79 }
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080080
81 private OobData(Parcel in) {
Jack He2992cd02017-08-22 21:21:23 -070082 mLeBluetoothDeviceAddress = in.createByteArray();
83 mSecurityManagerTk = in.createByteArray();
84 mLeSecureConnectionsConfirmation = in.createByteArray();
85 mLeSecureConnectionsRandom = in.createByteArray();
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080086 }
87
Jack He2992cd02017-08-22 21:21:23 -070088 @Override
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080089 public int describeContents() {
90 return 0;
91 }
92
93 @Override
94 public void writeToParcel(Parcel out, int flags) {
Jack He2992cd02017-08-22 21:21:23 -070095 out.writeByteArray(mLeBluetoothDeviceAddress);
96 out.writeByteArray(mSecurityManagerTk);
97 out.writeByteArray(mLeSecureConnectionsConfirmation);
98 out.writeByteArray(mLeSecureConnectionsRandom);
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080099 }
100
Jack He2992cd02017-08-22 21:21:23 -0700101 public static final Parcelable.Creator<OobData> CREATOR =
102 new Parcelable.Creator<OobData>() {
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -0800103 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 He2992cd02017-08-22 21:21:23 -0700111}