BluetoothAdapter的getRemoteDevice方法用于获取给定蓝牙硬件地址的 BluetoothDevice对象,代码如下:
//packages/modules/Bluetooth/framework/java/android/bluetooth/BluetoothAdapter.java
public final class BluetoothAdapter {
public BluetoothDevice getRemoteDevice(String address) {
final BluetoothDevice res = new BluetoothDevice(address); //创建BluetoothDevice对象
res.setAttributionSource(mAttributionSource); //调用BluetoothDevice的setAttributionSource方法
return res;
}
}
上面方法主要处理如下:
1、创建BluetoothDevice对象
2、调用BluetoothDevice的setAttributionSource方法
下面分别进行分析:
new BluetoothDevice
Android13 BluetoothDevice 创建流程分析-CSDN博客
BluetoothDevice setAttributionSource
调用BluetoothDevice的setAttributionSource方法,设置归因来源:
//packages/modules/Bluetooth/framework/java/android/bluetooth/BluetoothDevice.java
public final class BluetoothDevice implements Parcelable, Attributable {
public void setAttributionSource(@NonNull AttributionSource attributionSource) {
mAttributionSource = attributionSource; //对mAttributionSource进行赋值
}
}