Home | History | Annotate | Download | only in bluetooth
      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 /**
     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  *
     30  * @hide
     31  */
     32 public class OobData implements Parcelable {
     33     private byte[] leBluetoothDeviceAddress;
     34     private byte[] securityManagerTk;
     35     private byte[] leSecureConnectionsConfirmation;
     36     private byte[] leSecureConnectionsRandom;
     37 
     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 
     51     public byte[] getSecurityManagerTk() {
     52         return securityManagerTk;
     53     }
     54 
     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      */
     60     public void setSecurityManagerTk(byte[] securityManagerTk) {
     61         this.securityManagerTk = securityManagerTk;
     62     }
     63 
     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 
     80     public OobData() { }
     81 
     82     private OobData(Parcel in) {
     83         leBluetoothDeviceAddress = in.createByteArray();
     84         securityManagerTk = in.createByteArray();
     85         leSecureConnectionsConfirmation = in.createByteArray();
     86         leSecureConnectionsRandom = in.createByteArray();
     87     }
     88 
     89     public int describeContents() {
     90         return 0;
     91     }
     92 
     93     @Override
     94     public void writeToParcel(Parcel out, int flags) {
     95         out.writeByteArray(leBluetoothDeviceAddress);
     96         out.writeByteArray(securityManagerTk);
     97         out.writeByteArray(leSecureConnectionsConfirmation);
     98         out.writeByteArray(leSecureConnectionsRandom);
     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 }