I'm new to BLE and thus BLE on Android and I'm trying to understand how BLE addresses are managed by Android. Looking at different posts and android documentation, I understood that Android is enforcing LE privacy by using private resolvable addresses when advertising and scanning.
I have a use case with challenging timing constraints and ideally I'd like to perform a direct BLE connection between 2 Android devices by using their MAC addresses instead of doing the usual scanning/advertising discovery.
Unfortunately, Android is now blocking access to the current device address using BluetoothAdapter.getAddress() for privacy reasons which prevents any out-of-band flow to share BLE addresses.
I was wondering if there is any way for an Android central device to use the Bluetooth public address (the one displayed in the device settings i.e. Settings/ About Phone / Bluetooth address) of an Android device set in peripheral mode?
I tried to use the following flow without success so my guess is that it's not possible:
On Peripheral device:
On Central device:
BluetoothDevice bleDevice = mbtAdapter.getRemoteDevice(peripheralStaticPublicAddress);
connectGATT(bleDevice, context);
Thanks for your help!
EDIT 1: I tried to use the system permission android.permission.LOCAL_MAC_ADDRESS since my device is rooted. I can get the peripheral's own public address using the BluetoothAdapter.getAddress() method but opening a GATT connection to this address on the central device does not seem to work (with or without advertising on the peripheral device).
Only if the central supports "resolving list" (i.e. in practice is not too old) and the devices are bonded, you should be able to use the peripheral's public address (which is stored in the bonding entry as Identity Address together with the Identity Resolving Key) to connect to it. The remote device must advertise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With