Unhide setPin, setPin, setPairingConfirmation, and relevant intent fields
bug 9987787
Change-Id: Id1c149964137e35703310e2f2893c8830aacddea
diff --git a/api/current.txt b/api/current.txt
index 77df600..4084fbd 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -33,6 +33,7 @@
field public static final java.lang.String BIND_WALLPAPER = "android.permission.BIND_WALLPAPER";
field public static final java.lang.String BLUETOOTH = "android.permission.BLUETOOTH";
field public static final java.lang.String BLUETOOTH_ADMIN = "android.permission.BLUETOOTH_ADMIN";
+ field public static final java.lang.String BLUETOOTH_PRIVILEGED = "android.permission.BLUETOOTH_PRIVILEGED";
field public static final java.lang.String BRICK = "android.permission.BRICK";
field public static final java.lang.String BROADCAST_PACKAGE_REMOVED = "android.permission.BROADCAST_PACKAGE_REMOVED";
field public static final java.lang.String BROADCAST_SMS = "android.permission.BROADCAST_SMS";
@@ -5103,6 +5104,7 @@
public final class BluetoothDevice implements android.os.Parcelable {
method public android.bluetooth.BluetoothGatt connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback);
+ method public boolean createBond();
method public android.bluetooth.BluetoothSocket createInsecureRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
method public android.bluetooth.BluetoothSocket createRfcommSocketToServiceRecord(java.util.UUID) throws java.io.IOException;
method public int describeContents();
@@ -5113,6 +5115,8 @@
method public java.lang.String getName();
method public int getType();
method public android.os.ParcelUuid[] getUuids();
+ method public boolean setPairingConfirmation(boolean);
+ method public boolean setPin(byte[]);
method public void writeToParcel(android.os.Parcel, int);
field public static final java.lang.String ACTION_ACL_CONNECTED = "android.bluetooth.device.action.ACL_CONNECTED";
field public static final java.lang.String ACTION_ACL_DISCONNECTED = "android.bluetooth.device.action.ACL_DISCONNECTED";
@@ -5121,6 +5125,7 @@
field public static final java.lang.String ACTION_CLASS_CHANGED = "android.bluetooth.device.action.CLASS_CHANGED";
field public static final java.lang.String ACTION_FOUND = "android.bluetooth.device.action.FOUND";
field public static final java.lang.String ACTION_NAME_CHANGED = "android.bluetooth.device.action.NAME_CHANGED";
+ field public static final java.lang.String ACTION_PAIRING_REQUEST = "android.bluetooth.device.action.PAIRING_REQUEST";
field public static final java.lang.String ACTION_UUID = "android.bluetooth.device.action.UUID";
field public static final int BOND_BONDED = 12; // 0xc
field public static final int BOND_BONDING = 11; // 0xb
@@ -5135,9 +5140,13 @@
field public static final java.lang.String EXTRA_CLASS = "android.bluetooth.device.extra.CLASS";
field public static final java.lang.String EXTRA_DEVICE = "android.bluetooth.device.extra.DEVICE";
field public static final java.lang.String EXTRA_NAME = "android.bluetooth.device.extra.NAME";
+ field public static final java.lang.String EXTRA_PAIRING_KEY = "android.bluetooth.device.extra.PAIRING_KEY";
+ field public static final java.lang.String EXTRA_PAIRING_VARIANT = "android.bluetooth.device.extra.PAIRING_VARIANT";
field public static final java.lang.String EXTRA_PREVIOUS_BOND_STATE = "android.bluetooth.device.extra.PREVIOUS_BOND_STATE";
field public static final java.lang.String EXTRA_RSSI = "android.bluetooth.device.extra.RSSI";
field public static final java.lang.String EXTRA_UUID = "android.bluetooth.device.extra.UUID";
+ field public static final int PAIRING_VARIANT_PASSKEY_CONFIRMATION = 2; // 0x2
+ field public static final int PAIRING_VARIANT_PIN = 0; // 0x0
}
public final class BluetoothGatt implements android.bluetooth.BluetoothProfile {
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java
index 2c85382..1efdc81 100644
--- a/core/java/android/bluetooth/BluetoothDevice.java
+++ b/core/java/android/bluetooth/BluetoothDevice.java
@@ -219,7 +219,7 @@
* {@link #BOND_NONE},
* {@link #BOND_BONDING},
* {@link #BOND_BONDED}.
- */
+ */
public static final String EXTRA_BOND_STATE = "android.bluetooth.device.extra.BOND_STATE";
/**
* Used as an int extra field in {@link #ACTION_BOND_STATE_CHANGED} intents.
@@ -228,7 +228,7 @@
* {@link #BOND_NONE},
* {@link #BOND_BONDING},
* {@link #BOND_BONDED}.
- */
+ */
public static final String EXTRA_PREVIOUS_BOND_STATE =
"android.bluetooth.device.extra.PREVIOUS_BOND_STATE";
/**
@@ -253,12 +253,26 @@
*/
public static final int BOND_BONDED = 12;
- /** @hide */
+ /**
+ * Used as an int extra field in {@link #ACTION_PAIRING_REQUEST}
+ * intents for unbond reason.
+ * @hide
+ */
public static final String EXTRA_REASON = "android.bluetooth.device.extra.REASON";
- /** @hide */
+
+ /**
+ * Used as an int extra field in {@link #ACTION_PAIRING_REQUEST}
+ * intents to indicate pairing method used. Possible values are:
+ * {@link #PAIRING_VARIANT_PIN},
+ * {@link #PAIRING_VARIANT_PASSKEY_CONFIRMATION},
+ */
public static final String EXTRA_PAIRING_VARIANT =
"android.bluetooth.device.extra.PAIRING_VARIANT";
- /** @hide */
+
+ /**
+ * Used as an int extra field in {@link #ACTION_PAIRING_REQUEST}
+ * intents as the value of passkey.
+ */
public static final String EXTRA_PAIRING_KEY = "android.bluetooth.device.extra.PAIRING_KEY";
/**
@@ -306,7 +320,10 @@
public static final String ACTION_NAME_FAILED =
"android.bluetooth.device.action.NAME_FAILED";
- /** @hide */
+ /**
+ * Broadcast Action: This intent is used to broadcast PAIRING REQUEST
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH} to receive.
+ */
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_PAIRING_REQUEST =
"android.bluetooth.device.action.PAIRING_REQUEST";
@@ -446,8 +463,8 @@
public static final int UNBOND_REASON_REMOVED = 9;
/**
- * The user will be prompted to enter a pin
- * @hide
+ * The user will be prompted to enter a pin or
+ * a privileged app will enter a pin for user.
*/
public static final int PAIRING_VARIANT_PIN = 0;
@@ -458,8 +475,8 @@
public static final int PAIRING_VARIANT_PASSKEY = 1;
/**
- * The user will be prompted to confirm the passkey displayed on the screen
- * @hide
+ * The user will be prompted to confirm the passkey displayed on the screen or
+ * a privileged app will confirm the passkey for the user.
*/
public static final int PAIRING_VARIANT_PASSKEY_CONFIRMATION = 2;
@@ -707,10 +724,9 @@
* the bonding process completes, and its result.
* <p>Android system services will handle the necessary user interactions
* to confirm and complete the bonding process.
- * <p>Requires {@link android.Manifest.permission#BLUETOOTH_ADMIN}.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
*
* @return false on immediate error, true if bonding will begin
- * @hide
*/
public boolean createBond() {
if (sService == null) {
@@ -946,7 +962,13 @@
return BluetoothDevice.ERROR;
}
- /** @hide */
+ /**
+ * Set the pin during pairing when the pairing method is {@link #PAIRING_VARIANT_PIN}
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
+ *
+ * @return true pin has been set
+ * false for error
+ */
public boolean setPin(byte[] pin) {
if (sService == null) {
Log.e(TAG, "BT not enabled. Cannot set Remote Device pin");
@@ -968,7 +990,13 @@
return false;
}
- /** @hide */
+ /**
+ * Confirm passkey for {@link #PAIRING_VARIANT_PASSKEY_CONFIRMATION} pairing.
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED}.
+ *
+ * @return true confirmation has been sent out
+ * false for error
+ */
public boolean setPairingConfirmation(boolean confirm) {
if (sService == null) {
Log.e(TAG, "BT not enabled. Cannot set pairing confirmation");
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index b41b5b5..4c73cd7 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -773,6 +773,13 @@
android:description="@string/permdesc_bluetoothAdmin"
android:label="@string/permlab_bluetoothAdmin" />
+ <!-- Allows applications to pair bluetooth devices without user interaction -->
+ <permission android:name="android.permission.BLUETOOTH_PRIVILEGED"
+ android:permissionGroup="android.permission-group.BLUETOOTH_NETWORK"
+ android:protectionLevel="system|signature"
+ android:description="@string/permdesc_bluetoothPriv"
+ android:label="@string/permlab_bluetoothPriv" />
+
<!-- Allows bluetooth stack to access files
@hide This should only be used by Bluetooth apk.
-->
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index d0c24e2..6c334e2 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1801,6 +1801,15 @@
<string name="permdesc_bluetoothAdmin" product="default">Allows the app to configure
the local Bluetooth phone, and to discover and pair with remote devices.</string>
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_bluetoothPriv">allow Bluetooth pairing by Application</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_bluetoothPriv" product="tablet">Allows the app to
+ pair with remote devices without user interaction.</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_bluetoothPriv" product="default">Allows the app to
+ pair with remote devices without user interaction.</string>
+
<string name="permlab_accessWimaxState">connect and disconnect from WiMAX</string>
<string name="permdesc_accessWimaxState">Allows the app to determine whether
WiMAX is enabled and information about any WiMAX networks that are