Android可以通过蓝牙设备的macAdress或者蓝牙设备名称,通过修改系统Setting部分源码实现在蓝牙设备列表中显示的蓝牙设备的自动配对和自动连接,具体源码修改如下
自动配对部分源码修改参照之前博文提到的修改方法Android蓝牙自动配对授权连接的实现方法,具体修改如下 /packages/apps/Settings/src/com/android/settings/bluetooth/BluetoothDevicePreference.java
public void onDeviceAttributesChanged() {
/*
* The preference framework takes care of making sure the value has
* changed before proceeding. It will also call notifyChanged() if
* any preference info has changed from the previous value.
*/
setTitle(mCachedDevice.getName());
int summaryResId = mCachedDevice.getConnectionSummary();
if (summaryResId != 0) {
setSummary(summaryResId);
} else {
setSummary(null); // empty summary for unpaired devices
}
// feathure add