blob: 9e87230c686e4d6f2e15a60b648ae387d23aee8d [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
22import android.util.Log;
23
24/**
Jakub Pawlowskic0e8ff32016-04-14 06:06:00 -070025 * 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 Sharkeyfa6a1bc2016-03-01 17:36:23 -070030 * @hide
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080031 */
Jeff Sharkey9ad443f2016-03-01 17:28:36 -070032public class OobData implements Parcelable {
Jakub Pawlowskif4658232016-11-09 16:51:09 -080033 private byte[] leBluetoothDeviceAddress;
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080034 private byte[] securityManagerTk;
Jakub Pawlowski747711c2016-07-28 05:21:36 -070035 private byte[] leSecureConnectionsConfirmation;
36 private byte[] leSecureConnectionsRandom;
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080037
Jakub Pawlowskif4658232016-11-09 16:51:09 -080038 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 Pawlowski2fc6e6b2015-12-29 13:19:21 -080051 public byte[] getSecurityManagerTk() {
52 return securityManagerTk;
53 }
54
Jakub Pawlowskic0e8ff32016-04-14 06:06:00 -070055 /**
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 Pawlowski2fc6e6b2015-12-29 13:19:21 -080060 public void setSecurityManagerTk(byte[] securityManagerTk) {
61 this.securityManagerTk = securityManagerTk;
62 }
63
Jakub Pawlowski747711c2016-07-28 05:21:36 -070064 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 Pawlowski2fc6e6b2015-12-29 13:19:21 -080080 public OobData() { }
81
82 private OobData(Parcel in) {
Jakub Pawlowskif4658232016-11-09 16:51:09 -080083 leBluetoothDeviceAddress = in.createByteArray();
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080084 securityManagerTk = in.createByteArray();
Jakub Pawlowski747711c2016-07-28 05:21:36 -070085 leSecureConnectionsConfirmation = in.createByteArray();
86 leSecureConnectionsRandom = in.createByteArray();
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080087 }
88
89 public int describeContents() {
90 return 0;
91 }
92
93 @Override
94 public void writeToParcel(Parcel out, int flags) {
Jakub Pawlowskif4658232016-11-09 16:51:09 -080095 out.writeByteArray(leBluetoothDeviceAddress);
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080096 out.writeByteArray(securityManagerTk);
Jakub Pawlowski747711c2016-07-28 05:21:36 -070097 out.writeByteArray(leSecureConnectionsConfirmation);
98 out.writeByteArray(leSecureConnectionsRandom);
Jakub Pawlowski2fc6e6b2015-12-29 13:19:21 -080099 }
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}