Does Android KitKat allows devices that support Bluetooth LE to act as a peripheral device?

Shobhit Puri picture Shobhit Puri · Oct 31, 2013 · Viewed 14.1k times · Source

Till Android 4.3, an Android device with Bluetooth Low Energy support could only act as a central device. As is given in the Android 4.3 Bluetooth LE docs:

Android 4.3 (API Level 18) introduces built-in platform support for Bluetooth Low Energy in the central role and provides APIs that apps can use to discover devices, query for services, and read/write characteristics.

With the introduction of Android 4.4 KitKat, can it also behave as a peripheral device now? I couldn't find any documentation of that. If not, then do we have to wait for Android 4.5 for getting the BTLE peripheral mode on Android device? Or is there any alternative way in which an Android device can be made to act as a peripheral device?

Answer

madeyes picture madeyes · Dec 13, 2013

Not in this version but there is evidence that it is coming soon.
If you look in BluetoothGatt.java in the android-19 sources there are new methods listen and setAdvData that weren't there in android-18.
However these are not documented as I don't think native support is complete yet. The last check in on AOSP for peripheral mode was titled "LE: Add peripheral role support (2/4)". Also, setAdvData and listen have this code:

if (mContext == null || !mContext.getResources().getBoolean(com.android.internal.R.bool.config_bluetooth_le_peripheral_mode_supported))
{
    throw new UnsupportedOperationException("BluetoothGatt#listen is blocked");
}

Looking in android/platform_frameworks_base/blob/master/core/res/res/values/config.xml from the Android sources you can see this is currently disabled:

<!-- Boolean indicating if current platform supports BLE peripheral mode -->
<bool name="config_bluetooth_le_peripheral_mode_supported">false</bool>