mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-26 13:44:23 +08:00
android: Start Android Bluetooth daemon
Start Android Bluetooth daemon from HAL init(). Make sure that daemon is in "running" state.
This commit is contained in:
parent
7999518d3f
commit
e6ad61d3b4
@ -23,11 +23,16 @@
|
||||
#include <hardware/bluetooth.h>
|
||||
#include <hardware/bt_sock.h>
|
||||
|
||||
#include <cutils/sockets.h>
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#define LOG_TAG "BlueZ"
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
#define SERVICE_NAME "bluetoothd"
|
||||
|
||||
bt_callbacks_t *bt_hal_cbacks = NULL;
|
||||
|
||||
static bool interface_ready(void)
|
||||
@ -35,6 +40,33 @@ static bool interface_ready(void)
|
||||
return bt_hal_cbacks != NULL;
|
||||
}
|
||||
|
||||
static bool start_bt_daemon(void)
|
||||
{
|
||||
int tries = 40; /* wait 4 seconds for completion */
|
||||
|
||||
ALOGD(__func__);
|
||||
|
||||
/* Start Android Bluetooth daemon service */
|
||||
property_set("ctl.start", SERVICE_NAME);
|
||||
|
||||
while (tries-- > 0) {
|
||||
char val[PROPERTY_VALUE_MAX];
|
||||
|
||||
if (property_get("init.svc." SERVICE_NAME, val, NULL)) {
|
||||
if (!strcmp(val, "running")) {
|
||||
ALOGI("Android BlueZ daemon started");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int init(bt_callbacks_t *callbacks)
|
||||
{
|
||||
ALOGD(__func__);
|
||||
@ -42,10 +74,13 @@ static int init(bt_callbacks_t *callbacks)
|
||||
if (interface_ready())
|
||||
return BT_STATUS_SUCCESS;
|
||||
|
||||
/* store reference to user callbacks */
|
||||
if (start_bt_daemon()) {
|
||||
/* TODO: open channel */
|
||||
|
||||
bt_hal_cbacks = callbacks;
|
||||
|
||||
/* TODO: Init here bluezd task */
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return BT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user