summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothDevice.java
diff options
context:
space:
mode:
authorChienyuan <chienyuanhuang@google.com>2022-01-17 21:05:14 +0800
committerJack He <siyuanh@google.com>2022-02-02 15:17:34 -0800
commit14c9fcd9e9047314c8ea7d95fe9cf8cc087c1447 (patch)
treeb8e1fde624cac7f8df1b5965fff79975ebd2b5bd /framework/java/android/bluetooth/BluetoothDevice.java
parent36011ac6d4d2e1c64e449d6f7714cb92a0c7b7a0 (diff)
Add API to get identity address
Bug: 197044261 Bug: 216305555 Test: build pass Tag: #feature Change-Id: Ia62e9e3ee8934b3afc5e98d41caf40ddb5e47fc5 Merged-In: Ia62e9e3ee8934b3afc5e98d41caf40ddb5e47fc5 (cherry picked from commit 139b970aa9e9c91e52524b2354895e58467d3554)
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothDevice.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index d9ab7ecc0e..f0a6c4a48a 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/java/android/bluetooth/BluetoothDevice.java
@@ -1323,6 +1323,33 @@ public final class BluetoothDevice implements Parcelable, Attributable {
}
/**
+ * Returns the identity address of this BluetoothDevice.
+ * <p> For example, "00:11:22:AA:BB:CC".
+ *
+ * @return Bluetooth identity address as a string
+ * @hide
+ */
+ @SystemApi
+ @RequiresBluetoothConnectPermission
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.BLUETOOTH_CONNECT,
+ android.Manifest.permission.BLUETOOTH_PRIVILEGED,
+ })
+ public @Nullable String getIdentityAddress() {
+ final IBluetooth service = sService;
+ if (service == null) {
+ Log.e(TAG, "BT not enabled. Cannot get identity address");
+ return null;
+ }
+ try {
+ return service.getIdentityAddress(mAddress);
+ } catch (RemoteException e) {
+ Log.e(TAG, "", e);
+ }
+ return null;
+ }
+
+ /**
* Get the friendly Bluetooth name of the remote device.
*
* <p>The local adapter will automatically retrieve remote names when