Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

frameworks-base: Commit

frameworks/base


Commit MetaInfo

Revisionc0b2dd0f42771c10fc2a97f36054ff0b3fa37118 (tree)
Time2015-12-22 16:22:07
AuthorGrzegorz Kolodziejczyk <grzegorz.kolodziejczyk@tiet...>
CommiterChih-Wei Huang

Log Message

Add support for setting passkey as pairing variant

This is needed if pairing variant is passkey entry.

Change-Id: I8f3efbc90757ac77414a9e86d7c29326c25c12ad

Change Summary

Incremental Difference

--- a/api/current.txt
+++ b/api/current.txt
@@ -6202,6 +6202,7 @@ package android.bluetooth {
62026202 method public int getType();
62036203 method public android.os.ParcelUuid[] getUuids();
62046204 method public boolean setPairingConfirmation(boolean);
6205+ method public boolean setPasskey(int);
62056206 method public boolean setPin(byte[]);
62066207 method public void writeToParcel(android.os.Parcel, int);
62076208 field public static final java.lang.String ACTION_ACL_CONNECTED = "android.bluetooth.device.action.ACL_CONNECTED";
@@ -6231,6 +6232,7 @@ package android.bluetooth {
62316232 field public static final java.lang.String EXTRA_PREVIOUS_BOND_STATE = "android.bluetooth.device.extra.PREVIOUS_BOND_STATE";
62326233 field public static final java.lang.String EXTRA_RSSI = "android.bluetooth.device.extra.RSSI";
62336234 field public static final java.lang.String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
6235+ field public static final int PAIRING_VARIANT_PASSKEY = 1; // 0x1
62346236 field public static final int PAIRING_VARIANT_PASSKEY_CONFIRMATION = 2; // 0x2
62356237 field public static final int PAIRING_VARIANT_PIN = 0; // 0x0
62366238 }
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -6416,6 +6416,7 @@ package android.bluetooth {
64166416 method public boolean isConnected();
64176417 method public boolean isEncrypted();
64186418 method public boolean setPairingConfirmation(boolean);
6419+ method public boolean setPasskey(int);
64196420 method public boolean setPin(byte[]);
64206421 method public void writeToParcel(android.os.Parcel, int);
64216422 field public static final java.lang.String ACTION_ACL_CONNECTED = "android.bluetooth.device.action.ACL_CONNECTED";
@@ -6445,6 +6446,7 @@ package android.bluetooth {
64456446 field public static final java.lang.String EXTRA_PREVIOUS_BOND_STATE = "android.bluetooth.device.extra.PREVIOUS_BOND_STATE";
64466447 field public static final java.lang.String EXTRA_RSSI = "android.bluetooth.device.extra.RSSI";
64476448 field public static final java.lang.String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
6449+ field public static final int PAIRING_VARIANT_PASSKEY = 1; // 0x1
64486450 field public static final int PAIRING_VARIANT_PASSKEY_CONFIRMATION = 2; // 0x2
64496451 field public static final int PAIRING_VARIANT_PIN = 0; // 0x0
64506452 }
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -29,6 +29,8 @@ import android.util.Log;
2929 import java.io.IOException;
3030 import java.io.UnsupportedEncodingException;
3131 import java.util.UUID;
32+import java.nio.ByteBuffer;
33+import java.nio.ByteOrder;
3234
3335 /**
3436 * Represents a remote Bluetooth device. A {@link BluetoothDevice} lets you
@@ -272,6 +274,7 @@ public final class BluetoothDevice implements Parcelable {
272274 * intents to indicate pairing method used. Possible values are:
273275 * {@link #PAIRING_VARIANT_PIN},
274276 * {@link #PAIRING_VARIANT_PASSKEY_CONFIRMATION},
277+ * {@link #PAIRING_VARIANT_PASSKEY},
275278 */
276279 public static final String EXTRA_PAIRING_VARIANT =
277280 "android.bluetooth.device.extra.PAIRING_VARIANT";
@@ -483,7 +486,6 @@ public final class BluetoothDevice implements Parcelable {
483486
484487 /**
485488 * The user will be prompted to enter a passkey
486- * @hide
487489 */
488490 public static final int PAIRING_VARIANT_PASSKEY = 1;
489491
@@ -1094,13 +1096,27 @@ public final class BluetoothDevice implements Parcelable {
10941096 return false;
10951097 }
10961098
1097- /** @hide */
1099+ /**
1100+ * Set the passkey during pairing when the pairing method is
1101+ * {@link #PAIRING_VARIANT_PASSKEY}
1102+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
1103+ *
1104+ * @return true if passkey has been set
1105+ * flase for error
1106+ */
10981107 public boolean setPasskey(int passkey) {
1099- //TODO(BT)
1100- /*
1108+ if (sService == null) {
1109+ Log.e(TAG, "BT not enabled. Cannot set Remote Device passkey");
1110+ return false;
1111+ }
1112+ ByteBuffer buff = ByteBuffer.allocate(5);
1113+ buff.order(ByteOrder.nativeOrder());
1114+ buff.putInt(passkey);
1115+ byte[] passkeyByte = buff.array();
1116+
11011117 try {
1102- return sService.setPasskey(this, true, 4, passkey);
1103- } catch (RemoteException e) {Log.e(TAG, "", e);}*/
1118+ return sService.setPasskey(this, true, passkeyByte.length, passkeyByte);
1119+ } catch (RemoteException e) {Log.e(TAG, "", e);}
11041120 return false;
11051121 }
11061122
Show on old repository browser