public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
int channelId) {
if (Log.isLoggable(TAG, Log.DEBUG))
Log.d(TAG, String.format("prevState\t%d ----------> newState\t%d",
prevState, newState));
if (prevState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
newState == BluetoothHealth.STATE_CHANNEL_CONNECTED) {
if (config.equals(mHealthAppConfig)) {
mChannelId = channelId;
sendMessage(STATUS_CREATE_CHANNEL, RESULT_OK);
(new ReadThread(fd)).start();
} else {
sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
}
} else if (prevState == BluetoothHealth.STATE_CHANNEL_CONNECTING &&
newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
} else if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
if (config.equals(mHealthAppConfig)) {
sendMessage(STATUS_DESTROY_CHANNEL, RESULT_OK);
} else {
sendMessage(STATUS_DESTROY_CHANNEL, RESULT_FAIL);
}
}
}
java类android.bluetooth.BluetoothHealthAppConfiguration的实例源码
BluetoothHDPService.java 文件源码
项目:buildAPKsSamples
阅读 36
收藏 0
点赞 0
评论 0
BluetoothHDPService.java 文件源码
项目:AndroidthingsStudy
阅读 45
收藏 0
点赞 0
评论 0
public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
int channelId) {
if (Log.isLoggable(TAG, Log.DEBUG))
Log.d(TAG, String.format("prevState\t%d ----------> newState\t%d",
prevState, newState));
if (prevState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
newState == BluetoothHealth.STATE_CHANNEL_CONNECTED) {
if (config.equals(mHealthAppConfig)) {
mChannelId = channelId;
sendMessage(STATUS_CREATE_CHANNEL, RESULT_OK);
(new ReadThread(fd)).start();
} else {
sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
}
} else if (prevState == BluetoothHealth.STATE_CHANNEL_CONNECTING &&
newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL);
} else if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
if (config.equals(mHealthAppConfig)) {
sendMessage(STATUS_DESTROY_CHANNEL, RESULT_OK);
} else {
sendMessage(STATUS_DESTROY_CHANNEL, RESULT_FAIL);
}
}
}
BluetoothHDPService.java 文件源码
项目:buildAPKsSamples
阅读 25
收藏 0
点赞 0
评论 0
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
int status) {
if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_FAILURE) {
mHealthAppConfig = null;
sendMessage(STATUS_HEALTH_APP_REG, RESULT_FAIL);
} else if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_SUCCESS) {
mHealthAppConfig = config;
sendMessage(STATUS_HEALTH_APP_REG, RESULT_OK);
} else if (status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_FAILURE ||
status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) {
sendMessage(STATUS_HEALTH_APP_UNREG,
status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS ?
RESULT_OK : RESULT_FAIL);
}
}
BluetoothHDPService.java 文件源码
项目:AndroidthingsStudy
阅读 28
收藏 0
点赞 0
评论 0
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
int status) {
if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_FAILURE) {
mHealthAppConfig = null;
sendMessage(STATUS_HEALTH_APP_REG, RESULT_FAIL);
} else if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_SUCCESS) {
mHealthAppConfig = config;
sendMessage(STATUS_HEALTH_APP_REG, RESULT_OK);
} else if (status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_FAILURE ||
status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) {
sendMessage(STATUS_HEALTH_APP_UNREG,
status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS ?
RESULT_OK : RESULT_FAIL);
}
}
HDPDriverService.java 文件源码
项目:HDPDeviceAdapter
阅读 29
收藏 0
点赞 0
评论 0
private BluetoothHealthAppConfiguration getDeviceConfiguration(BluetoothDevice dev)
{
if (! deviceconfigs.containsKey(dev)) {
if (configs.size() > 0) {
return configs.get(0);
} else {
return null;
}
}
return deviceconfigs.get(dev);
}
HDPDriverService.java 文件源码
项目:HDPDeviceAdapter
阅读 24
收藏 0
点赞 0
评论 0
public void onHealthAppConfigurationStatusChange(BluetoothHealthAppConfiguration config,
int status) {
if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_FAILURE) {
sendMessage(STATUS_HEALTH_APP_REG, RESULT_FAIL, null);
} else if (status == BluetoothHealth.APP_CONFIG_REGISTRATION_SUCCESS) {
configs.add(config);
sendMessage(STATUS_HEALTH_APP_REG, RESULT_OK, null);
} else if (status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_FAILURE ||
status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS) {
sendMessage(STATUS_HEALTH_APP_UNREG,
status == BluetoothHealth.APP_CONFIG_UNREGISTRATION_SUCCESS ?
RESULT_OK : RESULT_FAIL,
null);
}
}
HDPDriverService.java 文件源码
项目:HDPDeviceAdapter
阅读 28
收藏 0
点赞 0
评论 0
public void onHealthChannelStateChange(BluetoothHealthAppConfiguration config,
BluetoothDevice device, int prevState, int newState, ParcelFileDescriptor fd,
int channelId) {
Log.w(TAG, String.format("prevState\t%d ----------> newState\t%d",
prevState, newState));
if (prevState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED &&
newState == BluetoothHealth.STATE_CHANNEL_CONNECTED) {
if (acceptsConfiguration(config)) {
insertDeviceConfiguration(device, config);
insertChannelId(device, channelId);
sendMessage(STATUS_CREATE_CHANNEL, RESULT_OK, device);
FileOutputStream wr = new FileOutputStream(fd.getFileDescriptor());
insertWriter(device, wr);
(new ReadThread(device, fd)).start();
} else {
sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL, device);
}
} else if (prevState == BluetoothHealth.STATE_CHANNEL_CONNECTING &&
newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
sendMessage(STATUS_CREATE_CHANNEL, RESULT_FAIL, device);
removeWriter(device);
} else if (newState == BluetoothHealth.STATE_CHANNEL_DISCONNECTED) {
if (acceptsConfiguration(config)) {
sendMessage(STATUS_DESTROY_CHANNEL, RESULT_OK, device);
removeWriter(device);
} else {
sendMessage(STATUS_DESTROY_CHANNEL, RESULT_FAIL, device);
removeWriter(device);
}
}
}
HDPDriverService.java 文件源码
项目:HDPDeviceAdapter
阅读 34
收藏 0
点赞 0
评论 0
private boolean acceptsConfiguration(BluetoothHealthAppConfiguration config)
{
return configs.contains(config);
}
HDPDriverService.java 文件源码
项目:HDPDeviceAdapter
阅读 30
收藏 0
点赞 0
评论 0
private synchronized void insertDeviceConfiguration(BluetoothDevice dev,
BluetoothHealthAppConfiguration config)
{
deviceconfigs.put(dev, config);
}
HDPDriverService.java 文件源码
项目:HDPDeviceAdapter
阅读 27
收藏 0
点赞 0
评论 0
private void unregisterApp() {
for (BluetoothHealthAppConfiguration app: configs) {
mBluetoothHealth.unregisterAppConfiguration(app);
}
}
HDPDriverService.java 文件源码
项目:HDPDeviceAdapter
阅读 35
收藏 0
点赞 0
评论 0
private void connectChannel(BluetoothDevice dev) {
Log.w(TAG, "connectChannel()");
BluetoothHealthAppConfiguration app = getDeviceConfiguration(dev);
if (app != null)
mBluetoothHealth.connectChannelToSource(dev, app);
}
HDPDriverService.java 文件源码
项目:HDPDeviceAdapter
阅读 33
收藏 0
点赞 0
评论 0
private void disconnectChannel(BluetoothDevice dev) {
Log.w(TAG, "disconnectChannel()");
BluetoothHealthAppConfiguration app = getDeviceConfiguration(dev);
if (app != null)
mBluetoothHealth.disconnectChannel(dev, app, getChannelId(dev));
}