本文需要结合《Android BLE蓝牙——服务端实现》这篇文章一起看,因为本文是根据服务端实现的流程进行对应的源码进行分析的。
1、设置广播
这部分主要是对广播属性和广播数据进行设置和初始化。
源码路径:
/frameworks/base/core/java/android/bluetooth/le/AdvertiseSettings.java
/frameworks/base/core/java/android/bluetooth/le/AdvertiseData.java
2、开始广播
BluetoothAdapter.getBluetoothLeAdvertiser()
public BluetoothLeAdvertiser getBluetoothLeAdvertiser() {
if (!getLeAccess()) {
return null;
}
synchronized (mLock) {
if (mBluetoothLeAdvertiser == null) {
mBluetoothLeAdvertiser = new BluetoothLeAdvertiser(this);
}