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

前端 未结 3 1670
故里飘歌
故里飘歌 2020-12-13 15:56

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:

3条回答
  •  被撕碎了的回忆
    2020-12-13 16:12

    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:

    
    false
    

提交回复
热议问题