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 /** 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 * 28 * @hide 29 */ 30 public class OobData implements Parcelable { 31 private byte[] mLeBluetoothDeviceAddress; 32 private byte[] mSecurityManagerTk; 33 private byte[] mLeSecureConnectionsConfirmation; 34 private byte[] mLeSecureConnectionsRandom; 35 getLeBluetoothDeviceAddress()36 public byte[] getLeBluetoothDeviceAddress() { 37 return mLeBluetoothDeviceAddress; 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 */ setLeBluetoothDeviceAddress(byte[] leBluetoothDeviceAddress)45 public void setLeBluetoothDeviceAddress(byte[] leBluetoothDeviceAddress) { 46 mLeBluetoothDeviceAddress = leBluetoothDeviceAddress; 47 } 48 getSecurityManagerTk()49 public byte[] getSecurityManagerTk() { 50 return mSecurityManagerTk; 51 } 52 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 */ setSecurityManagerTk(byte[] securityManagerTk)58 public void setSecurityManagerTk(byte[] securityManagerTk) { 59 mSecurityManagerTk = securityManagerTk; 60 } 61 getLeSecureConnectionsConfirmation()62 public byte[] getLeSecureConnectionsConfirmation() { 63 return mLeSecureConnectionsConfirmation; 64 } 65 setLeSecureConnectionsConfirmation(byte[] leSecureConnectionsConfirmation)66 public void setLeSecureConnectionsConfirmation(byte[] leSecureConnectionsConfirmation) { 67 mLeSecureConnectionsConfirmation = leSecureConnectionsConfirmation; 68 } 69 getLeSecureConnectionsRandom()70 public byte[] getLeSecureConnectionsRandom() { 71 return mLeSecureConnectionsRandom; 72 } 73 setLeSecureConnectionsRandom(byte[] leSecureConnectionsRandom)74 public void setLeSecureConnectionsRandom(byte[] leSecureConnectionsRandom) { 75 mLeSecureConnectionsRandom = leSecureConnectionsRandom; 76 } 77 OobData()78 public OobData() { 79 } 80 OobData(Parcel in)81 private OobData(Parcel in) { 82 mLeBluetoothDeviceAddress = in.createByteArray(); 83 mSecurityManagerTk = in.createByteArray(); 84 mLeSecureConnectionsConfirmation = in.createByteArray(); 85 mLeSecureConnectionsRandom = in.createByteArray(); 86 } 87 88 @Override describeContents()89 public int describeContents() { 90 return 0; 91 } 92 93 @Override writeToParcel(Parcel out, int flags)94 public void writeToParcel(Parcel out, int flags) { 95 out.writeByteArray(mLeBluetoothDeviceAddress); 96 out.writeByteArray(mSecurityManagerTk); 97 out.writeByteArray(mLeSecureConnectionsConfirmation); 98 out.writeByteArray(mLeSecureConnectionsRandom); 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 } 112